From 7e92f644d0735e7001bb30a61b6c54496b63b66e Mon Sep 17 00:00:00 2001 From: Stefan Kremser Date: Mon, 16 Apr 2018 21:33:38 +0200 Subject: [PATCH] Better packet counting and output --- esp8266_deauther/Attack.cpp | 38 +++++++++++++++++---------- esp8266_deauther/Attack.h | 5 ++++ esp8266_deauther/Names.cpp | 7 +++++ esp8266_deauther/Names.h | 1 + esp8266_deauther/esp8266_deauther.ino | 6 ++++- esp8266_deauther/language.h | 2 +- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/esp8266_deauther/Attack.cpp b/esp8266_deauther/Attack.cpp index 00c7107..c6c1634 100644 --- a/esp8266_deauther/Attack.cpp +++ b/esp8266_deauther/Attack.cpp @@ -81,8 +81,8 @@ void Attack::updateCounter() { // deauth packets per second if (deauth.active) { - if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() * (scan.countAll() - names.selected()); - else deauth.maxPkts = settings.getDeauthsPerTarget() * scan.countSelected(); + if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.count() + stations.count()*2 - names.selected()); + else deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.selected() + stations.selected()*2 + names.selected() + names.stations()); } else { deauth.maxPkts = 0; } @@ -107,17 +107,19 @@ void Attack::updateCounter() { deauthPkts = deauth.packetCounter; beaconPkts = beacon.packetCounter; probePkts = probe.packetCounter; + packetRate = tmpPacketRate; deauth.packetCounter = 0; beacon.packetCounter = 0; probe.packetCounter = 0; deauth.tc = 0; beacon.tc = 0; probe.tc = 0; + tmpPacketRate = 0; } void Attack::status() { - char s[80]; - sprintf(s, str(A_STATUS).c_str(), deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts, probe.maxPkts); + char s[120]; + sprintf(s, str(A_STATUS).c_str(), packetRate, deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts, probe.maxPkts); prnt(String(s)); } @@ -272,13 +274,17 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_ // send deauth frame deauthPacket[0] = 0xc0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ success = true; + deauth.packetCounter++; + } // send disassociate frame deauthPacket[0] = 0xa0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ success = true; + deauth.packetCounter++; + } // send another packet, this time from the station to the accesspoint if (!macBroadcast(stMac)) { // but only if the packet isn't a broadcast @@ -289,19 +295,21 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_ // send deauth frame deauthPacket[0] = 0xc0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ success = true; - + deauth.packetCounter++; + } + // send disassociate frame deauthPacket[0] = 0xa0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ success = true; + deauth.packetCounter++; + } } - if (success){ + if (success) deauth.time = currentTime; - deauth.packetCounter++; - } return success; } @@ -373,10 +381,12 @@ bool Attack::sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16 bool sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0; // try again until it's sent out - for (int i = 0; i < tries && !sent; i++) { + for (int i = 0; i < tries && !sent; i++) sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0; - } + if(sent) + tmpPacketRate ++; + return sent; } diff --git a/esp8266_deauther/Attack.h b/esp8266_deauther/Attack.h index b86a878..353dca3 100644 --- a/esp8266_deauther/Attack.h +++ b/esp8266_deauther/Attack.h @@ -30,6 +30,7 @@ extern String macToStr(uint8_t* mac); extern String bytesToStr(uint8_t* b, uint32_t size); extern void setWifiChannel(uint8_t ch); extern bool writeFile(String path, String &buf); +extern int8_t free80211_send(uint8_t *buffer, uint16_t len); class Attack { public: @@ -94,6 +95,9 @@ class Attack { uint32_t beaconPkts = 0; uint32_t probePkts = 0; + uint32_t tmpPacketRate = 0; + uint32_t packetRate = 0; + uint8_t apCount = 0; uint8_t stCount = 0; uint8_t nCount = 0; @@ -200,4 +204,5 @@ class Attack { #endif + diff --git a/esp8266_deauther/Names.cpp b/esp8266_deauther/Names.cpp index 3389da7..98a19bf 100644 --- a/esp8266_deauther/Names.cpp +++ b/esp8266_deauther/Names.cpp @@ -397,6 +397,13 @@ int Names::selected() { return num; } +int Names::stations() { + int num = 0; + for (int i = 0; i < count(); i++) + if (isStation(i)) num++; + return num; +} + bool Names::internal_check(int num) { return num >= 0 && num < count(); } diff --git a/esp8266_deauther/Names.h b/esp8266_deauther/Names.h index 4245db2..35151f3 100644 --- a/esp8266_deauther/Names.h +++ b/esp8266_deauther/Names.h @@ -73,6 +73,7 @@ class Names { int count(); int selected(); + int stations(); bool check(int num); private: diff --git a/esp8266_deauther/esp8266_deauther.ino b/esp8266_deauther/esp8266_deauther.ino index 37a6cd3..5d3d940 100644 --- a/esp8266_deauther/esp8266_deauther.ino +++ b/esp8266_deauther/esp8266_deauther.ino @@ -4,6 +4,9 @@ github.com/spacehuhn =========================================== */ +extern "C" { + #include "user_interface.h" +} #include #include "oui.h" #include "language.h" @@ -95,7 +98,7 @@ void setup() { wifi_set_promiscuous_rx_cb([](uint8_t* buf, uint16_t len) { scan.sniffer(buf, len); }); - + // set mac for station wifi_set_macaddr(STATION_IF, settings.getMacSt()); @@ -174,4 +177,5 @@ void loop() { + diff --git a/esp8266_deauther/language.h b/esp8266_deauther/language.h index 51970d8..1ea10fe 100644 --- a/esp8266_deauther/language.h +++ b/esp8266_deauther/language.h @@ -415,7 +415,7 @@ const char A_START[] PROGMEM = "Start attacking"; const char A_NO_MODE_ERROR[] PROGMEM = "WARNING: No valid attack mode set"; const char A_STOP[] PROGMEM = "Stopped attacking"; const char A_TIMEOUT[] PROGMEM = "Timeout - "; -const char A_STATUS[] PROGMEM = "[Pkt/s] deauths: %+3u/%-3u beacons: %+3u/%-3u probes: %+3u/%-3u\r\n"; +const char A_STATUS[] PROGMEM = "[Pkt/s] All: %+4u | Deauths: %+3u/%-3u | Beacons: %+3u/%-3u | Probes: %+3u/%-3u\r\n"; const char A_ENABLED_OUTPUT[] PROGMEM = "Enabled attack output"; const char A_DISABLED_OUTPUT[] PROGMEM = "Disabled attack output";