@@ -18,12 +18,12 @@ @implementation ANClientKiller
18
18
19
19
- (id )initWithFrame : (NSRect )frame sniffer : (ANWiFiSniffer *)theSniffer networks : (NSArray *)networks clients : (NSArray *)theClients {
20
20
if ((self = [super initWithFrame: frame])) {
21
- clients = [ theClients mutableCopy ] ;
21
+ clients = theClients. mutableCopy ;
22
22
sniffer = theSniffer;
23
- [ sniffer setDelegate: self ] ;
23
+ sniffer. delegate = self;
24
24
[sniffer start ];
25
25
26
- NSMutableArray * mChannels = [[ NSMutableArray alloc ] init ] ;
26
+ NSMutableArray * mChannels = NSMutableArray . new ;
27
27
for (CWNetwork * net in networks) {
28
28
if (![mChannels containsObject: net.wlanChannel]) {
29
29
[mChannels addObject: net.wlanChannel];
@@ -32,17 +32,17 @@ - (id)initWithFrame:(NSRect)frame sniffer:(ANWiFiSniffer *)theSniffer networks:(
32
32
channels = [mChannels copy ];
33
33
channelIndex = -1 ;
34
34
35
- NSMutableDictionary * mNetworksPerChannel = [[ NSMutableDictionary alloc ] init ] ;
35
+ NSMutableDictionary * mNetworksPerChannel = NSMutableDictionary . new ;
36
36
for (CWChannel * channel in channels) {
37
- NSMutableArray * mNetworks = [[ NSMutableArray alloc ] init ] ;
37
+ NSMutableArray * mNetworks = NSMutableArray . new ;
38
38
for (CWNetwork * network in networks) {
39
39
if ([[network wlanChannel ] isEqualToChannel: channel]) {
40
40
[mNetworks addObject: network];
41
41
}
42
42
}
43
- [mNetworksPerChannel setObject: [ mNetworks copy ] forKey: channel];
43
+ [mNetworksPerChannel setObject: mNetworks. copy forKey: channel];
44
44
}
45
- networksForChannel = [ mNetworksPerChannel copy ] ;
45
+ networksForChannel = mNetworksPerChannel. copy ;
46
46
47
47
jamTimer = [NSTimer scheduledTimerWithTimeInterval: 0.02 target: self selector: @selector (performNextRound ) userInfo: nil repeats: YES ];
48
48
[self performNextRound ];
@@ -54,56 +54,56 @@ - (id)initWithFrame:(NSRect)frame sniffer:(ANWiFiSniffer *)theSniffer networks:(
54
54
55
55
- (void )configureUI {
56
56
NSRect frame = self.bounds ;
57
- infoScrollView = [[ NSScrollView alloc ] initWithFrame: NSMakeRect (10 , 52 , frame.size.width - 20 , frame.size.height - 62 )];
58
- infoTable = [[ NSTableView alloc ] initWithFrame: [[ infoScrollView contentView ] bounds ] ];
59
- doneButton = [[ NSButton alloc ] initWithFrame: NSMakeRect (frame.size.width - 110 , 10 , 100 , 24 )];
60
- backButton = [[ NSButton alloc ] initWithFrame: NSMakeRect (frame.size.width - 210 , 10 , 100 , 24 )];
61
- newClientsCheck = [[ NSButton alloc ] initWithFrame: NSMakeRect (10 , 10 , 200 , 24 )];
57
+ infoScrollView = [NSScrollView . alloc initWithFrame: NSMakeRect (10 , 52 , frame.size.width - 20 , frame.size.height - 62 )];
58
+ infoTable = [NSTableView . alloc initWithFrame: infoScrollView. contentView. bounds];
59
+ doneButton = [NSButton . alloc initWithFrame: NSMakeRect (frame.size.width - 110 , 10 , 100 , 24 )];
60
+ backButton = [NSButton . alloc initWithFrame: NSMakeRect (frame.size.width - 210 , 10 , 100 , 24 )];
61
+ newClientsCheck = [NSButton . alloc initWithFrame: NSMakeRect (10 , 10 , 200 , 24 )];
62
62
63
- [ newClientsCheck setButtonType: NSSwitchButton ] ;
64
- [ newClientsCheck setBezelStyle: NSRoundedBezelStyle ] ;
65
- [ newClientsCheck setTitle: @" Actively scan for clients" ] ;
66
- [ newClientsCheck setState: 1 ] ;
63
+ newClientsCheck. buttonType = NSSwitchButton ;
64
+ newClientsCheck. bezelStyle = NSRoundedBezelStyle ;
65
+ newClientsCheck. title = @" Actively scan for clients" ;
66
+ newClientsCheck. state = 1 ;
67
67
68
- [ backButton setBezelStyle: NSRoundedBezelStyle ] ;
69
- [ backButton setTitle: @" Back" ] ;
70
- [ backButton setFont: [NSFont systemFontOfSize: 13 ] ];
71
- [ backButton setTarget: self ] ;
72
- [ backButton setAction: @selector (backButton: )] ;
68
+ backButton. bezelStyle = NSRoundedBezelStyle ;
69
+ backButton. title = @" Back" ;
70
+ backButton. font = [NSFont systemFontOfSize: 13 ];
71
+ backButton. target = self;
72
+ backButton. action = @selector (backButton: );
73
73
74
- [ doneButton setBezelStyle: NSRoundedBezelStyle ] ;
75
- [ doneButton setTitle: @" Done" ] ;
76
- [ doneButton setFont: [NSFont systemFontOfSize: 13 ] ];
77
- [ doneButton setTarget: self ] ;
78
- [ doneButton setAction: @selector (doneButton: )] ;
74
+ doneButton. bezelStyle = NSRoundedBezelStyle ;
75
+ doneButton. title = @" Done" ;
76
+ doneButton. font = [NSFont systemFontOfSize: 13 ];
77
+ doneButton. target = self;
78
+ doneButton. action = @selector (doneButton: );
79
79
80
- NSTableColumn * enabledColumn = [[ NSTableColumn alloc ] initWithIdentifier: @" enabled" ];
81
- [[ enabledColumn headerCell ] setStringValue: @" Jam" ] ;
82
- [ enabledColumn setWidth: 30 ] ;
83
- [ enabledColumn setEditable: YES ] ;
80
+ NSTableColumn * enabledColumn = [NSTableColumn . alloc initWithIdentifier: @" enabled" ];
81
+ enabledColumn. headerCell . stringValue = @" Jam" ;
82
+ enabledColumn. width = 30 ;
83
+ enabledColumn. editable = YES ;
84
84
[infoTable addTableColumn: enabledColumn];
85
85
86
- NSTableColumn * stationColumn = [[ NSTableColumn alloc ] initWithIdentifier: @" station " ];
87
- [[stationColumn headerCell ] setStringValue: @" Station " ] ;
88
- [stationColumn setWidth: 120 ] ;
89
- [stationColumn setEditable: NO ] ;
90
- [infoTable addTableColumn: stationColumn ];
86
+ NSTableColumn * deviceColumn = [NSTableColumn . alloc initWithIdentifier: @" device " ];
87
+ deviceColumn. headerCell . stringValue = @" Device " ;
88
+ deviceColumn. width = 120 ;
89
+ deviceColumn. editable = NO ;
90
+ [infoTable addTableColumn: deviceColumn ];
91
91
92
- NSTableColumn * deauthsColumn = [[ NSTableColumn alloc ] initWithIdentifier: @" count" ];
93
- [[ deauthsColumn headerCell ] setStringValue: @" Deauths" ] ;
94
- [ deauthsColumn setWidth: 120 ] ;
95
- [ deauthsColumn setEditable: NO ] ;
92
+ NSTableColumn * deauthsColumn = [NSTableColumn . alloc initWithIdentifier: @" count" ];
93
+ deauthsColumn. headerCell . stringValue = @" Deauths" ;
94
+ deauthsColumn. width = 120 ;
95
+ deauthsColumn. editable = NO ;
96
96
[infoTable addTableColumn: deauthsColumn];
97
97
98
- [ infoScrollView setDocumentView: infoTable] ;
99
- [ infoScrollView setBorderType: NSBezelBorder] ;
100
- [ infoScrollView setHasVerticalScroller: YES ] ;
101
- [ infoScrollView setHasHorizontalScroller: YES ] ;
102
- [ infoScrollView setAutohidesScrollers: NO ] ;
98
+ infoScrollView. documentView = infoTable;
99
+ infoScrollView. borderType = NSBezelBorder;
100
+ infoScrollView. hasVerticalScroller = YES ;
101
+ infoScrollView. hasHorizontalScroller = YES ;
102
+ infoScrollView. autohidesScrollers = NO ;
103
103
104
- [ infoTable setDataSource: self ] ;
105
- [ infoTable setDelegate: self ] ;
106
- [ infoTable setAllowsMultipleSelection: YES ] ;
104
+ infoTable. dataSource = self;
105
+ infoTable. delegate = self;
106
+ infoTable. allowsMultipleSelection = YES ;
107
107
108
108
[self addSubview: infoScrollView];
109
109
[self addSubview: backButton];
@@ -122,28 +122,28 @@ - (void)configureUI {
122
122
- (void )backButton : (id )sender {
123
123
[jamTimer invalidate ];
124
124
jamTimer = nil ;
125
- [ sniffer setDelegate: nil ] ;
126
- NSMutableArray * networks = [ NSMutableArray array ] ;
125
+ sniffer. delegate = nil ;
126
+ NSMutableArray * networks = NSMutableArray . array ;
127
127
for (id key in networksForChannel) {
128
128
[networks addObjectsFromArray: [networksForChannel objectForKey: key]];
129
129
}
130
- ANTrafficGatherer * gatherer = [[ ANTrafficGatherer alloc ] initWithFrame: self .bounds sniffer: sniffer networks: networks];
131
- [(ANAppDelegate *)[ NSApp delegate ] pushView: gatherer direction: ANViewSlideDirectionBackward];
130
+ ANTrafficGatherer * gatherer = [ANTrafficGatherer. alloc initWithFrame: self .bounds sniffer: sniffer networks: networks];
131
+ [(ANAppDelegate *)NSApp . delegate pushView: gatherer direction: ANViewSlideDirectionBackward];
132
132
}
133
133
134
134
- (void )doneButton : (id )sender {
135
135
[jamTimer invalidate ];
136
136
jamTimer = nil ;
137
137
[sniffer stop ];
138
- [ sniffer setDelegate: nil ] ;
138
+ sniffer. delegate = nil ;
139
139
sniffer = nil ;
140
- [(ANAppDelegate *)[ NSApp delegate ] showNetworkList ];
140
+ [(ANAppDelegate *)NSApp . delegate showNetworkList ];
141
141
}
142
142
143
143
#pragma mark - Table View -
144
144
145
145
- (NSInteger )numberOfRowsInTableView : (NSTableView *)tableView {
146
- return [ clients count ] ;
146
+ return clients. count ;
147
147
}
148
148
149
149
- (id )tableView : (NSTableView *)tableView objectValueForTableColumn : (NSTableColumn *)tableColumn row : (NSInteger )row {
@@ -160,9 +160,9 @@ - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum
160
160
161
161
- (NSCell *)tableView : (NSTableView *)tableView dataCellForTableColumn : (NSTableColumn *)tableColumn row : (NSInteger )row {
162
162
if ([[tableColumn identifier ] isEqualToString: @" enabled" ]) {
163
- NSButtonCell * cell = [[ NSButtonCell alloc ] init ] ;
164
- [ cell setButtonType: NSSwitchButton ] ;
165
- [ cell setTitle: @" " ] ;
163
+ NSButtonCell * cell = NSButtonCell . new ;
164
+ cell. buttonType = NSSwitchButton ;
165
+ cell. title = @" " ;
166
166
return cell;
167
167
}
168
168
return nil ;
@@ -205,7 +205,7 @@ - (AN80211Packet *)deauthPacketForBSSID:(const unsigned char *)bssid client:(con
205
205
memcpy (&deauth[4 ], client, 6 );
206
206
memcpy (&deauth[10 ], bssid, 6 );
207
207
memcpy (&deauth[16 ], bssid, 6 );
208
- AN80211Packet * packet = [[ AN80211Packet alloc ] initWithData: [NSData dataWithBytes: deauth length: 26 ]];
208
+ AN80211Packet * packet = [AN80211Packet. alloc initWithData: [NSData dataWithBytes: deauth length: 26 ]];
209
209
return packet;
210
210
}
211
211
@@ -251,7 +251,7 @@ - (void)wifiSniffer:(ANWiFiSniffer *)sniffer gotPacket:(AN80211Packet *)packet {
251
251
if (client[0 ] == 0xFF && client[1 ] == 0xFF ) hasClient = NO ;
252
252
if (client[0 ] == 0x03 && client[5 ] == 0x01 ) hasClient = NO ;
253
253
if (hasClient) {
254
- ANClient * clientObj = [[ ANClient alloc ] initWithMac: client bssid: bssid];
254
+ ANClient * clientObj = [ANClient. alloc initWithMac: client bssid: bssid];
255
255
BOOL containsClient = NO ;
256
256
for (ANClient * aClient in clients) {
257
257
if (memcmp (aClient.macAddress , clientObj.macAddress , 6 ) == 0 ) {
0 commit comments