1
1
#include " Attack.h"
2
2
3
3
Attack::Attack () {
4
- randomSeed (os_random ());
5
4
}
6
5
7
6
void Attack::generate () {
@@ -13,8 +12,7 @@ void Attack::generate() {
13
12
14
13
for (int i = 0 ; i < macListLen; i++) channels[i] = random (1 , maxChannel);
15
14
do {
16
- getRandomVendorMac (_randomMacBuffer);
17
- for (int i = 0 ; i < 6 ; i++) _randomBeaconMac.setAt (_randomMacBuffer[i], i);
15
+ _randomBeaconMac.randomize ();
18
16
} while (beaconAdrs.add (_randomBeaconMac) >= 0 );
19
17
if (debug) Serial.println (" done" );
20
18
@@ -162,7 +160,7 @@ void Attack::run() {
162
160
if (apScan.isSelected (a)) {
163
161
Mac _ap;
164
162
int _ch = apScan.getAPChannel (a);
165
- _ap.setMac (apScan.aps ._get (a));
163
+ _ap.set (apScan.aps ._get (a));
166
164
167
165
wifi_set_channel (_ch);
168
166
@@ -213,11 +211,7 @@ void Attack::run() {
213
211
prevTime[1 ] = millis ();
214
212
215
213
for (int a = 0 ; a < ssidList.len ; a++) {
216
- String _ssid = ssidList.get (a);
217
- int _ch = channels[a];
218
-
219
- buildBeacon (beaconAdrs._get (a), _ssid, _ch, settings.attackEncrypted );
220
-
214
+ buildBeacon (beaconAdrs._get (a), ssidList.get (a), channels[a], ssidList.isEncrypted (a));
221
215
if (send ()) packetsCounter[1 ]++;
222
216
}
223
217
@@ -287,7 +281,8 @@ void Attack::start(int num) {
287
281
attackTimeoutCounter[num] = 0 ;
288
282
refreshLed ();
289
283
if (debug) Serial.println (" starting " + (String)attackNames[num] + " attack..." );
290
- if (num == 0 ) attackMode = " STOP" ;
284
+ if (num == 0 ) attackMode_deauth = " STOP" ;
285
+ else if (num == 1 ) attackMode_beacon = " STOP" ;
291
286
if (!settings.multiAttacks ){
292
287
for (int i = 0 ; i < attacksNum; i++){
293
288
if (i != num) stop (i);
@@ -299,7 +294,8 @@ void Attack::start(int num) {
299
294
void Attack::stop (int num) {
300
295
if (isRunning[num]) {
301
296
if (debug) Serial.println (" stopping " + (String)attackNames[num] + " attack..." );
302
- if (num == 0 ) attackMode = " START" ;
297
+ if (num == 0 ) attackMode_deauth = " START" ;
298
+ else if (num == 1 ) attackMode_beacon = " START" ;
303
299
isRunning[num] = false ;
304
300
prevTime[num] = millis ();
305
301
refreshLed ();
@@ -317,7 +313,7 @@ void Attack::_log(int num){
317
313
for (int a=0 ;a<apScan.results ;a++){
318
314
if (apScan.isSelected (a)){
319
315
Mac _ap;
320
- _ap.setMac (apScan.aps ._get (a));
316
+ _ap.set (apScan.aps ._get (a));
321
317
addLog (_ap.toString ());
322
318
}
323
319
}
@@ -378,7 +374,11 @@ size_t Attack::getSize(){
378
374
json = " \" ssid\" :[" ;
379
375
jsonSize += json.length ();
380
376
for (int i = 0 ; i < ssidList.len ; i++) {
381
- json = " \" " + ssidList.get (i) + " \" " ;
377
+ json = " [" ;
378
+ json += " \" " + ssidList.get (i) + " \" ," ;
379
+ json += String ( ssidList.isEncrypted (i) ) + " " ;
380
+ Serial.print (ssidList.isEncrypted (i));
381
+ json += " ]" ;
382
382
if (i != ssidList.len - 1 ) json += " ," ;
383
383
jsonSize += json.length ();
384
384
}
@@ -439,7 +439,10 @@ void Attack::sendResults(){
439
439
json = " \" ssid\" :[" ;
440
440
sendToBuffer (json);
441
441
for (int i = 0 ; i < ssidList.len ; i++) {
442
- json = " \" " + ssidList.get (i) + " \" " ;
442
+ json = " [" ;
443
+ json += " \" " + ssidList.get (i) + " \" ," ;
444
+ json += (String)ssidList.isEncrypted (i) + " " ;
445
+ json += " ]" ;
443
446
if (i != ssidList.len - 1 ) json += " ," ;
444
447
sendToBuffer (json);
445
448
}
@@ -463,11 +466,11 @@ void Attack::refreshLed() {
463
466
}
464
467
if (numberRunning >= 1 && settings.useLed ) {
465
468
if (debug) Serial.println (" Attack LED : ON" );
466
- digitalWrite (settings.ledPin , LOW );
469
+ digitalWrite (settings.ledPin , !settings. pinStateOff );
467
470
}
468
471
else if (numberRunning == 0 || !settings.useLed ) {
469
472
if (debug) Serial.println (" Attack LED : OFF" );
470
- digitalWrite (settings.ledPin , HIGH );
473
+ digitalWrite (settings.ledPin , settings. pinStateOff );
471
474
}
472
475
}
473
476
0 commit comments