fix for invalid Json bug

JSON bug episode 2 - attack of the json bugs :D no? Ok.. :(
This commit is contained in:
Stefan Kremser
2017-02-20 15:24:40 +01:00
parent cf2789e235
commit 7be4d742ac
5 changed files with 11 additions and 19 deletions

View File

@@ -70,7 +70,7 @@ String APScan::getResults(){
json += "\"vendor\": \""+getAPVendor(i)+"\","; json += "\"vendor\": \""+getAPVendor(i)+"\",";
json += "\"selected\": "+getAPSelected(i); json += "\"selected\": "+getAPSelected(i);
json += "}"; json += "}";
if(i!=results-1) json += ","; if((i!=results-1) && (i!=maxResults-1)) json += ",";
} }
json += "] }"; json += "] }";
return json; return json;

View File

@@ -131,7 +131,7 @@ String Attack::getResults(){
void Attack::run(){ void Attack::run(){
currentMillis = millis(); currentMillis = millis();
if(running[0]){ if(running[0]){//deauth all
if((currentMillis - previousMillis[0]) >= 1000/deauthsPerSecond){ if((currentMillis - previousMillis[0]) >= 1000/deauthsPerSecond){
int clientsSelected = 0; int clientsSelected = 0;
@@ -171,7 +171,7 @@ void Attack::run(){
} }
} }
if(running[1]){ if(running[1]){//deauth selected
if((currentMillis - previousMillis[1]) >= 1000/deauthsPerSecond){ if((currentMillis - previousMillis[1]) >= 1000/deauthsPerSecond){
//send deauth //send deauth
@@ -207,7 +207,7 @@ void Attack::run(){
} }
if(running[2] || running[3]){ if(running[2] || running[3]){//beacon spam
if((currentMillis - previousMillis[3]) >= 1000/beaconPerSecond){ if((currentMillis - previousMillis[3]) >= 1000/beaconPerSecond){
previousMillis[3] = millis(); previousMillis[3] = millis();
@@ -216,7 +216,7 @@ void Attack::run(){
for(int i=0;i<randomBeacons;i++){ for(int i=0;i<randomBeacons;i++){
//unsigned long startTime = millis(); //unsigned long startTime = millis();
randomBeaconCounter++; randomBeaconCounter++;
generatePacket(); generateBeaconPacket();
if(wifi_send_pkt_freedom(packet, packetSize, 0) == -1){/* if(wifi_send_pkt_freedom(packet, packetSize, 0) == -1){/*
Serial.print(packetSize); Serial.print(packetSize);
@@ -238,14 +238,7 @@ void Attack::run(){
} }
} }
void Attack::generatePacket(){/* void Attack::generateBeaconPacket(){
if(running[0]){
}
if(running[1]){
}
else if(running[2] || running[3]){*/
if(currentMillis - previousRandomBeaconMillis >= randomBeaconChange*1000){ if(currentMillis - previousRandomBeaconMillis >= randomBeaconChange*1000){
generate(oldRandomBeacon); generate(oldRandomBeacon);
@@ -310,8 +303,6 @@ void Attack::generatePacket(){/*
//set MAC //set MAC
for(int i=0;i<6;i++) packet[10+i] = packet[16+i] = beaconMACs[randomBeaconCounter][i]; for(int i=0;i<6;i++) packet[10+i] = packet[16+i] = beaconMACs[randomBeaconCounter][i];
//}
} }
void Attack::stopAll(){ void Attack::stopAll(){

View File

@@ -17,7 +17,7 @@ extern "C" {
#define deauthsPerSecond 10 //number of deauthentication & disassociation frames sent per second per target. #define deauthsPerSecond 10 //number of deauthentication & disassociation frames sent per second per target.
#define beaconPerSecond 10 //number of beacon frames sent per second #define beaconPerSecond 10 //number of beacon frames sent per second
#define randomBeacons 50 //number of generated beacon frames #define randomBeacons 80 //number of generated beacon frames
#define SSIDLen 32 //SSID length of random generated APs (random beacon spam) #define SSIDLen 32 //SSID length of random generated APs (random beacon spam)
#define randomBeaconChange 3 //time in seconds after new beacon frames are generated #define randomBeaconChange 3 //time in seconds after new beacon frames are generated
#define beaconChannel 10 //channel to send beacon frames on (only for the packet bytes, it will actually sent on the current channel) #define beaconChannel 10 //channel to send beacon frames on (only for the packet bytes, it will actually sent on the current channel)
@@ -40,7 +40,7 @@ class Attack
void stopAll(); void stopAll();
void stop(int num); void stop(int num);
private: private:
void generatePacket(); void generateBeaconPacket();
bool send(uint8_t buf[], int len); bool send(uint8_t buf[], int len);
const String attackNames[attackNum] = {"deauth selected","deauth all","beacon spam","random beacon spam"}; const String attackNames[attackNum] = {"deauth selected","deauth all","beacon spam","random beacon spam"};
@@ -80,7 +80,7 @@ class Attack
uint8_t beaconPacket_header[36] = { uint8_t beaconPacket_header[36] = {
0x80, 0x00, 0x80, 0x00,
0x00, 0x00, //beacon 0x00, 0x00, //beacon
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //destination: broadcast 0x80, 0x7a, 0xbf, 0x3f, 0x8c, 0xac, //destination: broadcast
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //source 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //source
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //source 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //source
0xc0, 0x6c, 0xc0, 0x6c,

View File

@@ -98,7 +98,7 @@ String ClientScan::getResults(){
json += "\"vendor\": \""+(String)getClientVendor(i)+"\","; json += "\"vendor\": \""+(String)getClientVendor(i)+"\",";
json += "\"selected\": "+(String)getClientSelected(i); json += "\"selected\": "+(String)getClientSelected(i);
json += "}"; json += "}";
if(i!=results-1) json += ","; if((i!=results-1) && (i!=maxResults-1)) json += ",";
} }
json += "] }"; json += "] }";
return json; return json;

View File

@@ -45,6 +45,7 @@ void NameList::save(){
void NameList::add(Mac client, String name){ void NameList::add(Mac client, String name){
if(clients.add(client)) len++; if(clients.add(client)) len++;
else Serial.println("WARNING: name list is full!");
uint8_t _buf[nameLength]; uint8_t _buf[nameLength];
name.getBytes(_buf,nameLength); name.getBytes(_buf,nameLength);
for(int i=0;i<nameLength;i++){ for(int i=0;i<nameLength;i++){