[kismac] [binaervarianz] r196 - in trunk: KisMAC.xcodeproj Resources/Nibs/English.lproj/MainMenu.nib Sources/Controller Sources/Core

  • From: svn@xxxxxxxxxxxxxxxx
  • To: kismac@xxxxxxxxxxxxx
  • Date: Sat, 23 Sep 2006 11:21:17 +0200

Author: gkruse
Date: 2006-09-23 11:21:07 +0200 (Sat, 23 Sep 2006)
New Revision: 196

Added:
   trunk/Sources/Core/KismetXMLImporter.h
   trunk/Sources/Core/KismetXMLImporter.m
Modified:
   trunk/KisMAC.xcodeproj/project.pbxproj
   trunk/Resources/Nibs/English.lproj/MainMenu.nib/classes.nib
   trunk/Resources/Nibs/English.lproj/MainMenu.nib/data.dependency
   trunk/Resources/Nibs/English.lproj/MainMenu.nib/info.nib
   trunk/Resources/Nibs/English.lproj/MainMenu.nib/keyedobjects.nib
   trunk/Sources/Controller/ScanController.h
   trunk/Sources/Controller/ScanControllerMenus.m
   trunk/Sources/Core/WaveNet.mm
Log:
Kismet XML import.  Doesn't yet handle wireless clients

Modified: trunk/KisMAC.xcodeproj/project.pbxproj
===================================================================
--- trunk/KisMAC.xcodeproj/project.pbxproj      2006-09-22 14:34:31 UTC (rev 
195)
+++ trunk/KisMAC.xcodeproj/project.pbxproj      2006-09-23 09:21:07 UTC (rev 
196)
@@ -477,6 +477,8 @@
                6C541AAC0A72003000B58A95 /* growl-wpa-challenge.png in 
Resources */ = {isa = PBXBuildFile; fileRef = 6C541AA90A72002F00B58A95 /* 
growl-wpa-challenge.png */; };
                6C541AAD0A72003000B58A95 /* growl-wpa-response.png in Resources 
*/ = {isa = PBXBuildFile; fileRef = 6C541AAA0A72002F00B58A95 /* 
growl-wpa-response.png */; };
                6CA3BCCB09B2A58F00DCB407 /* Accelerate.framework in Frameworks 
*/ = {isa = PBXBuildFile; fileRef = 6CA3BCCA09B2A58F00DCB407 /* 
Accelerate.framework */; };
+               6CDAFD020AC4FA7D00A5D180 /* KismetXMLImporter.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 6CDAFD000AC4FA7D00A5D180 /* KismetXMLImporter.h 
*/; };
+               6CDAFD030AC4FA7D00A5D180 /* KismetXMLImporter.m in Sources */ = 
{isa = PBXBuildFile; fileRef = 6CDAFD010AC4FA7D00A5D180 /* KismetXMLImporter.m 
*/; };
                87CEBA8209AEF03700AEB0B8 /* GrowlController.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 87CEBA8009AEF03700AEB0B8 /* GrowlController.h 
*/; };
                87CEBA8309AEF03700AEB0B8 /* GrowlController.m in Sources */ = 
{isa = PBXBuildFile; fileRef = 87CEBA8109AEF03700AEB0B8 /* GrowlController.m 
*/; };
                8D1107280486CEB800E47090 /* KisMAC_Prefix.pch in Headers */ = 
{isa = PBXBuildFile; fileRef = 32CA4F630368D1EE00C91783 /* KisMAC_Prefix.pch 
*/; };
@@ -827,6 +829,8 @@
                6C541AA90A72002F00B58A95 /* growl-wpa-challenge.png */ = {isa = 
PBXFileReference; lastKnownFileType = image.png; path = 
"growl-wpa-challenge.png"; sourceTree = "<group>"; };
                6C541AAA0A72002F00B58A95 /* growl-wpa-response.png */ = {isa = 
PBXFileReference; lastKnownFileType = image.png; path = 
"growl-wpa-response.png"; sourceTree = "<group>"; };
                6CA3BCCA09B2A58F00DCB407 /* Accelerate.framework */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.framework; name = 
Accelerate.framework; path = /System/Library/Frameworks/Accelerate.framework; 
sourceTree = "<absolute>"; };
+               6CDAFD000AC4FA7D00A5D180 /* KismetXMLImporter.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
KismetXMLImporter.h; sourceTree = "<group>"; };
+               6CDAFD010AC4FA7D00A5D180 /* KismetXMLImporter.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= KismetXMLImporter.m; sourceTree = "<group>"; };
                87CEBA8009AEF03700AEB0B8 /* GrowlController.h */ = {isa = 
PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = 
GrowlController.h; sourceTree = "<group>"; };
                87CEBA8109AEF03700AEB0B8 /* GrowlController.m */ = {isa = 
PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; 
path = GrowlController.m; sourceTree = "<group>"; };
                8D1107320486CEB800E47090 /* KisMAC.app */ = {isa = 
PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; 
path = KisMAC.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1040,6 +1044,8 @@
                003533B206A5DD8500AB4577 /* Core */ = {
                        isa = PBXGroup;
                        children = (
+                               6CDAFD000AC4FA7D00A5D180 /* KismetXMLImporter.h 
*/,
+                               6CDAFD010AC4FA7D00A5D180 /* KismetXMLImporter.m 
*/,
                                003533B306A5DD8500AB4577 /* 80211b.h */,
                                003533B406A5DD8500AB4577 /* 
KisMACNotifications.h */,
                                003533B506A5DD8500AB4577 /* ScanHierarch.h */,
@@ -1645,6 +1651,7 @@
                                87CEBA8209AEF03700AEB0B8 /* GrowlController.h 
in Headers */,
                                6C1D31C009F37BC70005A9F8 /* PrefsAdvanced.h in 
Headers */,
                                6C41BAB00AA0B52900E0B411 /* GPSInfoController.h 
in Headers */,
+                               6CDAFD020AC4FA7D00A5D180 /* KismetXMLImporter.h 
in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -2037,6 +2044,7 @@
                                87CEBA8309AEF03700AEB0B8 /* GrowlController.m 
in Sources */,
                                6C1D31C109F37BC70005A9F8 /* PrefsAdvanced.m in 
Sources */,
                                6C41BAB10AA0B52900E0B411 /* GPSInfoController.m 
in Sources */,
+                               6CDAFD030AC4FA7D00A5D180 /* KismetXMLImporter.m 
in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };

Modified: trunk/Resources/Nibs/English.lproj/MainMenu.nib/classes.nib
===================================================================
--- trunk/Resources/Nibs/English.lproj/MainMenu.nib/classes.nib 2006-09-22 
14:34:31 UTC (rev 195)
+++ trunk/Resources/Nibs/English.lproj/MainMenu.nib/classes.nib 2006-09-23 
09:21:07 UTC (rev 196)
@@ -117,7 +117,6 @@
                 debugSaveStressTest = id; 
                 debugTestWPAHashingFunction = id; 
                 decryptPCAPFile = id; 
-                displayGPSInfo = id; 
                 exportJPEG = id; 
                 exportKMLFile = id; 
                 exportMacstumbler = id; 
@@ -126,6 +125,7 @@
                 exportToServer = id; 
                 exportWarD = id; 
                 gpsDebugToConsole = id; 
+                importKismetXML = id; 
                 importMapFromServer = id; 
                 importNetstumbler = id; 
                 injectPackets = id; 
@@ -141,7 +141,6 @@
                 showAllNetArea = id; 
                 showContextHelp = id; 
                 showCurNetArea = id; 
-                showGPS = id; 
                 showInfo = id; 
                 showNetHierarch = id; 
                 showPrefs = id; 

Modified: trunk/Resources/Nibs/English.lproj/MainMenu.nib/data.dependency
===================================================================
--- trunk/Resources/Nibs/English.lproj/MainMenu.nib/data.dependency     
2006-09-22 14:34:31 UTC (rev 195)
+++ trunk/Resources/Nibs/English.lproj/MainMenu.nib/data.dependency     
2006-09-23 09:21:07 UTC (rev 196)
@@ -4,8 +4,8 @@
 <dict>
        <key>IBPaletteDependency</key>
        <array>
+               <string>ASKPalette</string>
                <string>RollOverButtonPalette</string>
-               <string>ASKPalette</string>
        </array>
 </dict>
 </plist>

Modified: trunk/Resources/Nibs/English.lproj/MainMenu.nib/info.nib
===================================================================
--- trunk/Resources/Nibs/English.lproj/MainMenu.nib/info.nib    2006-09-22 
14:34:31 UTC (rev 195)
+++ trunk/Resources/Nibs/English.lproj/MainMenu.nib/info.nib    2006-09-23 
09:21:07 UTC (rev 196)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>7 -10 612 460 0 0 1024 746 </string>
+       <string>147 34 612 460 0 0 1280 832 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>1199</key>
@@ -17,9 +17,9 @@
                <key>1290</key>
                <string>352 338 576 461 0 0 1280 832 </string>
                <key>1446</key>
-               <string>502 483 185 263 0 0 1024 746 </string>
+               <string>655 569 185 263 0 0 1280 832 </string>
                <key>29</key>
-               <string>118 702 530 44 0 0 1024 746 </string>
+               <string>179 788 530 44 0 0 1280 832 </string>
                <key>501</key>
                <string>521 414 237 309 0 0 1280 832 </string>
                <key>719</key>

Modified: trunk/Resources/Nibs/English.lproj/MainMenu.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: trunk/Sources/Controller/ScanController.h
===================================================================
--- trunk/Sources/Controller/ScanController.h   2006-09-22 14:34:31 UTC (rev 
195)
+++ trunk/Sources/Controller/ScanController.h   2006-09-23 09:21:07 UTC (rev 
196)
@@ -170,6 +170,7 @@
 @interface ScanController(MenuExtension) 
 - (IBAction)showPrefs:(id)sender;
 
+- (IBAction)importKismetXML:(id)sender;
 - (IBAction)importNetstumbler:(id)sender;
 - (IBAction)importMapFromServer:(id)sender;
 

Modified: trunk/Sources/Controller/ScanControllerMenus.m
===================================================================
--- trunk/Sources/Controller/ScanControllerMenus.m      2006-09-22 14:34:31 UTC 
(rev 195)
+++ trunk/Sources/Controller/ScanControllerMenus.m      2006-09-23 09:21:07 UTC 
(rev 196)
@@ -32,6 +32,7 @@
 #import "DecryptController.h"
 #import "GPSInfoController.h"
 #import "HTTPStream.h"
+#import "../Core/KismetXMLImporter.h"
 #import "../Crypto/WPA.h"
 #import "TrafficController.h"
 #import "../WaveDrivers/WaveDriver.h"
@@ -65,6 +66,33 @@
 #pragma mark FILE MENU
 #pragma mark -
 
+- (IBAction)importKismetXML:(id)sender {
+    KismetXMLImporter * myImporter =  [[KismetXMLImporter alloc] init];
+    
+    aOP=[NSOpenPanel openPanel];
+    [aOP setAllowsMultipleSelection:NO];
+    [aOP setCanChooseFiles:YES];
+    [aOP setCanChooseDirectories:NO];
+    if ([aOP runModalForTypes:[NSArray arrayWithObjects:@"txt", @"xml", 
nil]]==NSOKButton) {
+        [self stopActiveAttacks];
+        [self stopScan];
+        
+        [self showBusyWithText: @"Importing Kismet XML"];
+         
+        _refreshGUI = NO;
+        [myImporter performKismetImport: [aOP filename] 
withContainer:_container];
+        _refreshGUI = YES;
+        
+        
+        [self busyDone];
+        
+        [self updateNetworkTable:self complete:YES];
+        [self refreshScanHierarch];
+        [_window setDocumentEdited:YES];
+        [[NSNotificationCenter defaultCenter] 
postNotificationName:KisMACViewItemChanged object:self];
+    }
+}
+
 - (IBAction)importMapFromServer:(id)sender {
     DownloadMapController* dmc = [[DownloadMapController alloc] 
initWithWindowNibName:@"DownloadMap"];
     
@@ -90,6 +118,7 @@
         [[NSNotificationCenter defaultCenter] 
postNotificationName:KisMACViewItemChanged object:self];
     }
 }
+
 - (void)performImportNetstumbler:(NSString*)filename {
     [_importController setTitle:[NSString 
stringWithFormat:NSLocalizedString(@"Importing %@...", "Status for busy 
dialog"), filename]];  
     

Added: trunk/Sources/Core/KismetXMLImporter.h
===================================================================
--- trunk/Sources/Core/KismetXMLImporter.h      2006-09-22 14:34:31 UTC (rev 
195)
+++ trunk/Sources/Core/KismetXMLImporter.h      2006-09-23 09:21:07 UTC (rev 
196)
@@ -0,0 +1,22 @@
+//
+//  KismetXMLImporter.h
+//  KisMAC
+//
+//  Created by Geoffrey Kruse on 9/22/06.
+//  Copyright 2006 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "WaveContainer.h"
+
+
+@interface KismetXMLImporter : NSObject {
+
+     NSMutableString * currentStringValue;
+     NSMutableArray * importedNets;
+     NSMutableDictionary * currentNet;
+}
+
+- (NSDictionary *)performKismetImport: (NSString *)filename 
withContainer:(WaveContainer*)container;
+
+@end

Added: trunk/Sources/Core/KismetXMLImporter.m
===================================================================
--- trunk/Sources/Core/KismetXMLImporter.m      2006-09-22 14:34:31 UTC (rev 
195)
+++ trunk/Sources/Core/KismetXMLImporter.m      2006-09-23 09:21:07 UTC (rev 
196)
@@ -0,0 +1,150 @@
+//
+//  KismetXMLImporter.m
+//  KisMAC
+//
+//  Created by Geoffrey Kruse on 9/22/06.
+//  Copyright 2006 __MyCompanyName__. All rights reserved.
+//
+
+#import "KismetXMLImporter.h"
+
+
+@implementation KismetXMLImporter
+
+-(id) init {
+    [super init];
+    importedNets = [[NSMutableArray alloc] init];
+    return self;
+}
+
+- (void)parser:(NSXMLParser *)parser 
+                didStartElement:(NSString *)elementName 
+  namespaceURI:(NSString *)namespaceURI
+ qualifiedName:(NSString *)qName
+    attributes:(NSDictionary *)attributeDict 
+{  
+    if (!currentNet) {
+        currentNet = [[NSMutableDictionary alloc] init];
+    }
+    
+    if([elementName isEqualToString:@"wireless-network"]){
+        if([[attributeDict objectForKey:@"type"] 
isEqualToString:@"infrastructure"])
+            [currentNet setValue: @"2" forKey:@"type"];
+        else if([[attributeDict objectForKey:@"type"] 
isEqualToString:@"ad-hoc"])
+            [currentNet setValue: @"1" forKey:@"type"];
+        else if([[attributeDict objectForKey:@"type"] 
isEqualToString:@"probe"])
+            [currentNet setValue: @"4" forKey:@"type"];
+        if([attributeDict objectForKey:@"first-time"]){
+            [currentNet setValue: [NSDate 
dateWithNaturalLanguageString:(NSString*)[attributeDict 
objectForKey:@"first-time"]]
+                                                          forKey:@"firstDate"];
+}
+        if([attributeDict objectForKey:@"first-time"])
+                [currentNet setValue: [NSDate 
dateWithNaturalLanguageString:[attributeDict objectForKey:@"last-time"]]
+                                                              forKey:@"date"];
+    }//first-time
+    
+}
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
+       //printf("current chars = %s\n", [string cString]);
+    if (!currentStringValue) {
+        currentStringValue = [[NSMutableString alloc] initWithCapacity:50];
+    }
+    if ([string characterAtIndex: 0] != '\n') {
+        [currentStringValue appendString:string];
+    }/*else {
+        printf("Found Newline!\n");
+    }*/
+    
+}
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
+    if (!currentNet) {
+        currentNet = [[NSMutableDictionary alloc] init];
+    }
+    
+    if([elementName isEqualToString:@"SSID"]){
+        //NSLog(@"Net Found SSID = %@", currentStringValue);
+        [currentNet setValue: currentStringValue forKey:@"SSID"];
+    }
+    else if([elementName isEqualToString:@"BSSID"]){
+        unsigned int ID[6];
+        sscanf([currentStringValue cString],
+               "%2X:%2X:%2X:%2X:%2X:%2X",
+               &ID[0], &ID[1], &ID[2], &ID[3], &ID[4], &ID[5]);
+        [currentNet setValue: [[NSString 
stringWithFormat:@"%2X%2X%2X%2X%2X%2X", ID[0], ID[1],ID[2], ID[3], ID[4], 
ID[5]] retain] forKey:@"ID"];
+        //NSLog(@"Net Found BSSID = %@", currentStringValue);
+        [currentNet setValue: currentStringValue forKey:@"BSSID"];
+    }
+    else if([elementName isEqualToString:@"channel"]){
+        [currentNet setValue: currentStringValue forKey:@"channel"];
+    }
+    else if([elementName isEqualToString:@"channel"]){
+        [currentNet setValue: currentStringValue forKey:@"channel"];
+    }
+    else if([elementName isEqualToString:@"total"]){
+        [currentNet setValue: currentStringValue forKey:@"packets"];
+    }
+    else if([elementName isEqualToString:@"data"]){
+        [currentNet setValue: currentStringValue forKey:@"dataPackets"];
+    }
+    else if([elementName isEqualToString:@"datasize"]){
+        [currentNet setValue: currentStringValue forKey:@"bytes"];
+    }
+    else if([elementName isEqualToString:@"encryption"]){
+        if([currentStringValue isEqualToString: @"WEP"])
+            [currentNet setValue: @"2" forKey:@"encryption"];
+        else if([currentStringValue isEqualToString: @"WPA"])
+            [currentNet setValue: @"4" forKey:@"encryption"];
+        else if([currentStringValue isEqualToString: @"None"])
+            [currentNet setValue: @"1" forKey:@"encryption"];
+        else
+            [currentNet setValue: @"0" forKey:@"encryption"];
+    }
+    else if([elementName isEqualToString:@"max-lat"]){
+        [currentNet setValue: currentStringValue forKey:@"lat"];
+    }
+    else if([elementName isEqualToString:@"max-lon"]){
+        [currentNet setValue: currentStringValue forKey:@"long"];
+    }
+    else if([elementName isEqualToString:@"max-alt"]){
+        [currentNet setValue: currentStringValue forKey:@"elev"];
+    }
+    else if([elementName isEqualToString:@"wireless-network"]){
+            //NSLog(@"End of Net Found");
+        
+            WaveNet* net = [[WaveNet alloc] initWithDataDictionary: 
currentNet];
+            currentNet = NULL;
+            if (net) {
+                [importedNets addObject:net];
+                [net release];
+            }else {
+                NSLog(@"Invalid Net!");
+            }
+
+    }
+
+    [currentStringValue release];
+    currentStringValue = nil;
+}
+
+
+- (NSDictionary*)performKismetImport: (NSString *)filename 
withContainer:(WaveContainer*)container
+{
+    NSData * theData = [[NSData alloc] initWithContentsOfFile: filename];
+       NSXMLParser * theParser = [[NSXMLParser alloc] initWithData: theData];
+       [theParser setDelegate: self];
+       if([theParser parse]){
+        NSLog(@"Parsing succeded:\n");
+        [container importData:importedNets];
+    }
+    
+    else {
+        NSLog(@"Parsing Failed!!!\n");
+        return nil;
+       // hasValidData = NO;
+    }
+    return currentNet;
+}
+
+@end

Modified: trunk/Sources/Core/WaveNet.mm
===================================================================
--- trunk/Sources/Core/WaveNet.mm       2006-09-22 14:34:31 UTC (rev 195)
+++ trunk/Sources/Core/WaveNet.mm       2006-09-23 09:21:07 UTC (rev 196)
@@ -332,6 +332,7 @@
 
 - (id)initWithDataDictionary:(NSDictionary*)dict {
     waypoint wp;
+    char ns_dir, ew_dir;
     int bssid[6];
     NSData *data;
     NSMutableDictionary *clients;
@@ -370,6 +371,9 @@
     wp._long = [[dict objectForKey:@"long"] doubleValue];
     wp._elevation = [[dict objectForKey:@"elev"] doubleValue];
     
+    (wp._lat < 0) ? ns_dir = 'S' :  ns_dir = 'N';
+    (wp._lat < 0) ? ew_dir = 'W' :  ew_dir = 'E';
+    
     _ID=[[dict objectForKey:@"ID"] retain];
     if (_ID!=Nil && sscanf([_ID cString], "%2X%2X%2X%2X%2X%2X", &bssid[0], 
&bssid[1], &bssid[2], &bssid[3], &bssid[4], &bssid[5])!=6) {
         NSLog(@"Error could not decode ID %@!", _ID);
@@ -431,12 +435,12 @@
        aComment = [[dict objectForKey:@"comment"] retain];
     if (!aComment) aComment = [[NSString stringWithString:@""] retain];
     aLat = [[dict objectForKey:@"latString"] retain];
-    if (!aLat) aLat = [[NSString stringWithString:@""] retain];
+    if (!aLat) aLat = [[NSString stringWithFormat:@"%f%c", wp._lat, ns_dir] 
retain];
     aLong = [[dict objectForKey:@"longString"] retain];
-    if (!aLong) aLong = [[NSString stringWithString:@""] retain];
+    if (!aLong) aLong = [[NSString stringWithFormat:@"%f%c", wp._long, ew_dir] 
retain];
     aElev = [[dict objectForKey:@"elevString"] retain];
-    if (!aElev) aElev = [[NSString stringWithString:@""] retain];
-
+    if (!aElev) aElev = [[NSString stringWithFormat:@"%.1f", (wp._elevation * 
3.2808399)] retain];
+    
        _coordinates = [[dict objectForKey:@"coordinates"] retain];
     if (!_coordinates) _coordinates = [[NSMutableDictionary dictionary] 
retain];
     else {


Other related posts:

  • » [kismac] [binaervarianz] r196 - in trunk: KisMAC.xcodeproj Resources/Nibs/English.lproj/MainMenu.nib Sources/Controller Sources/Core