Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge recent changes #49

Merged
merged 16 commits into from
Jul 8, 2024
15 changes: 4 additions & 11 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,17 @@ std::string Config::screen = "";
There are multiple different screen types available:

- `SSD1306`

- `SSD1305`

- `IDEASPARK_SSD1306`

- `WEMOS_OLED_SHIELD`

- `CYD`

- `T_DISPLAY_S3`

- `M5StickCP`

- `M5StickCP2`

- `M5Cardputer`
- `M5STICKCP`
- `M5STICKCP2`
- `M5CARDPUTER`

Set `bool Config::display = false;` to true, and `std::string Config::screen = "<YOUR_SCREEN_TYPE>";` to one of those screen types if your screen is supported.

Expand Down Expand Up @@ -130,9 +125,7 @@ Make sure you install the correct library, they aren't the same library and if y

2. For `compiler.c.elf.libs.esp32`, `compiler.c.elf.libs.esp32s2`, `compiler.c.elf.libs.esp32s3`, `compiler.c.elf.libs.esp32c3`, add `-zmuldefs` to their compile settings

3. For `compiler.c.elf.libs.esp32`, `compiler.c.elf.libs.esp32s2`, `compiler.c.elf.libs.esp32s3`, `compiler.c.elf.libs.esp32c3`, add `-zmuldefs` to their compile settings

4. More may be added [here](https://github.com/justcallmekoko/ESP32Marauder/wiki/arduino-ide-setup#if-you-are-following-these-instructions-you-do-not-need-to-do-this)
3. More may be added [here](https://github.com/justcallmekoko/ESP32Marauder/wiki/arduino-ide-setup#if-you-are-following-these-instructions-you-do-not-need-to-do-this)

- Select your COM port/Serial port through `Tools` > `Port` where the ESP32 is plugged in

Expand Down
78 changes: 12 additions & 66 deletions minigotchi-ESP32/deauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,16 @@ bool Deauth::broadcast(uint8_t *mac) {
}

void Deauth::printMac(uint8_t *mac) {
for (int i = 0; i < 6; i++) {
Serial.print(mac[i], HEX);
if (i < 5) {
Serial.print(":");
}
}

Serial.println();
String macStr = printMacStr(mac);
Serial.println(macStr);
Display::updateDisplay("('-')", "AP BSSID: " + macStr);
}

String Deauth::printMacStr(uint8_t *mac) {
String macStr = "";
for (int i = 0; i < 6; i++) {
if (mac[i] < 16) {
macStr += "0";
}
macStr += String(mac[i], HEX);
if (i < 5) {
macStr += ":";
}
}
return macStr;
char buf[18]; // 17 for MAC, 1 for null terminator
snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1],
mac[2], mac[3], mac[4], mac[5]);
return String(buf);
}

bool Deauth::select() {
Expand Down Expand Up @@ -200,7 +188,7 @@ bool Deauth::select() {
Display::updateDisplay("('-')", "Selected random AP: " + randomAP);
delay(Config::shortDelay);

if (encType == -1) {
if (encType == WIFI_AUTH_OPEN || encType == -1) {
Serial.println(
"('-') Selected AP is not encrypted. Skipping deauthentication...");
Display::updateDisplay(
Expand Down Expand Up @@ -259,10 +247,6 @@ bool Deauth::select() {
// bssid
uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex);

// set our mac address
uint8_t mac[6];
WiFi.macAddress(mac);

/** developer note:
*
* addr1: reciever addr
Expand All @@ -275,50 +259,14 @@ bool Deauth::select() {
std::copy(Deauth::broadcastAddr,
Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr),
Deauth::deauthFrame + 4);
std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 10);
std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 16);
std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10);
std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16);

std::copy(Deauth::broadcastAddr,
Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr),
Deauth::disassociateFrame + 4);
std::copy(apBssid, apBssid + sizeof(apBssid),
Deauth::disassociateFrame + 10);
std::copy(apBssid, apBssid + sizeof(apBssid),
Deauth::disassociateFrame + 16);

if (!broadcast(Deauth::broadcastAddr)) {
// build deauth
Deauth::deauthFrame[0] = 0xC0; // type
Deauth::deauthFrame[1] = 0x00; // subtype
Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that)
Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that)

// reason
Deauth::deauthFrame[24] = 0x01; // reason: unspecified

std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4);
std::copy(Deauth::broadcastAddr,
Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr),
Deauth::deauthFrame + 10);
std::copy(Deauth::broadcastAddr,
Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr),
Deauth::deauthFrame + 16);

// build disassocaition
Deauth::disassociateFrame[0] = 0xA0; // type
Deauth::disassociateFrame[1] = 0x00; // subtype
Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that)
Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that)

std::copy(apBssid, apBssid + sizeof(apBssid),
Deauth::disassociateFrame + 4);
std::copy(Deauth::broadcastAddr,
Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr),
Deauth::disassociateFrame + 10);
std::copy(Deauth::broadcastAddr,
Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr),
Deauth::disassociateFrame + 16);
}
std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10);
std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16);

Serial.print("('-') Full AP SSID: ");
Serial.println(WiFi.SSID(Deauth::randomIndex));
Expand All @@ -338,8 +286,6 @@ bool Deauth::select() {

Serial.print("('-') AP BSSID: ");
printMac(apBssid);
Display::updateDisplay("('-')",
"AP BSSID: " + Deauth::printMacStr(apBssid));

Serial.print("('-') AP Channel: ");
Serial.println(WiFi.channel(Deauth::randomIndex));
Expand Down
12 changes: 6 additions & 6 deletions minigotchi-ESP32/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ void Display::startScreen() {
ssd1306_ideaspark_display != nullptr) {
ssd1306_ideaspark_display->clearBuffer();
delay(100);
} else if (Config::screen == "M5StickCP" ||
Config::screen == "M5StickCP2" ||
} else if (Config::screen == "M5STICKCP" ||
Config::screen == "M5STICKCP2" ||
Config::screen ==
"M5Cardputer") { // New condition for M5StickC Plus
"M5CARDPUTER") { // New condition for M5StickC Plus
tft.setRotation(1); // Set display rotation if needed
tft.begin(); // Initialize TFT_eSPI library
delay(100);
Expand Down Expand Up @@ -213,10 +213,10 @@ void Display::updateDisplay(String face, String text) {
delay(5);
ssd1306_ideaspark_display->sendBuffer();
delay(5);
} else if (Config::screen == "M5StickCP" ||
Config::screen == "M5StickCP2" ||
} else if (Config::screen == "M5STICKCP" ||
Config::screen == "M5STICKCP2" ||
Config::screen ==
"M5Cardputer") { // New condition for M5 devices
"M5CARDPUTER") { // New condition for M5 devices
bool faceChanged = (face != Display::storedFace);
bool textChanged = (text != Display::storedText);

Expand Down
121 changes: 56 additions & 65 deletions minigotchi-ESP32/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ size_t Frame::payloadSize = 255; // by default
const size_t Frame::chunkSize = 0xFF;

// beacon stuff
uint8_t *Frame::Frame::beaconFrame = nullptr;
size_t Frame::essidLength = 0;
uint8_t Frame::headerLength = 0;

Expand Down Expand Up @@ -73,14 +72,14 @@ const uint8_t Frame::header[]{
0xef,
0xde,
0xad, // source address
/* 16 - 21 */ 0xa1,
0x00,
0x64,
0xe6,
0x0b,
0x8b, // bssid
/* 22 - 23 */ 0x40,
0x43, // fragment and sequence number
/* 16 - 21 */ 0xde,
0xad,
0xbe,
0xef,
0xde,
0xad, // bssid
/* 22 - 23 */ 0x00,
0x00, // fragment and sequence number
/* 24 - 32 */ 0x00,
0x00,
0x00,
Expand Down Expand Up @@ -126,30 +125,24 @@ uint8_t *Frame::pack() {
doc["identity"] = Config::identity;
doc["name"] = Config::name;

JsonObject policy = doc.createNestedObject("policy");
policy["advertise"] = Config::advertise;
policy["ap_ttl"] = Config::ap_ttl;
policy["associate"] = Config::associate;
policy["bored_num_epochs"] = Config::bored_num_epochs;

JsonArray channels = policy.createNestedArray("channels");
for (size_t i = 0; i < sizeof(Config::channels) / sizeof(Config::channels[0]);
++i) {
channels.add(Config::channels[i]);
}

policy["deauth"] = Config::deauth;
policy["excited_num_epochs"] = Config::excited_num_epochs;
policy["hop_recon_time"] = Config::hop_recon_time;
policy["max_inactive_scale"] = Config::max_inactive_scale;
policy["max_interactions"] = Config::max_interactions;
policy["max_misses_for_recon"] = Config::max_misses_for_recon;
policy["min_recon_time"] = Config::min_rssi;
policy["min_rssi"] = Config::min_rssi;
policy["recon_inactive_multiplier"] = Config::recon_inactive_multiplier;
policy["recon_time"] = Config::recon_time;
policy["sad_num_epochs"] = Config::sad_num_epochs;
policy["sta_ttl"] = Config::sta_ttl;
doc["policy"]["advertise"] = Config::advertise;
doc["policy"]["ap_ttl"] = Config::ap_ttl;
doc["policy"]["associate"] = Config::associate;
doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs;

doc["policy"]["deauth"] = Config::deauth;
doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs;
doc["policy"]["hop_recon_time"] = Config::hop_recon_time;
doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale;
doc["policy"]["max_interactions"] = Config::max_interactions;
doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon;
doc["policy"]["min_recon_time"] = Config::min_rssi;
doc["policy"]["min_rssi"] = Config::min_rssi;
doc["policy"]["recon_inactive_multiplier"] =
Config::recon_inactive_multiplier;
doc["policy"]["recon_time"] = Config::recon_time;
doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs;
doc["policy"]["sta_ttl"] = Config::sta_ttl;

doc["pwnd_run"] = Config::pwnd_run;
doc["pwnd_tot"] = Config::pwnd_tot;
Expand All @@ -161,9 +154,9 @@ uint8_t *Frame::pack() {
serializeJson(doc, jsonString);
Frame::essidLength = measureJson(doc);
Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2);
Frame::beaconFrame = new uint8_t[Frame::pwngridHeaderLength +
Frame::essidLength + Frame::headerLength];
memcpy(Frame::beaconFrame, Frame::header, Frame::pwngridHeaderLength);
uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength +
Frame::essidLength + Frame::headerLength];
memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength);
Dismissed Show dismissed Hide dismissed

/** developer note:
*
Expand All @@ -173,49 +166,47 @@ uint8_t *Frame::pack() {
* Serial.println(jsonString);
*/

int currentByte = pwngridHeaderLength;

for (int i = 0; i < Frame::essidLength; i++) {
int frameByte = pwngridHeaderLength;
for (int i = 0; i < essidLength; i++) {
if (i == 0 || i % 255 == 0) {
Frame::beaconFrame[currentByte++] = Frame::IDWhisperPayload;
if (Frame::essidLength - i < Frame::chunkSize) {
Frame::payloadSize = Frame::essidLength - i;
beaconFrame[frameByte++] = Frame::IDWhisperPayload;
uint8_t newPayloadLength = 255;
if (essidLength - i < Frame::chunkSize) {
newPayloadLength = essidLength - i;
}
Frame::beaconFrame[currentByte++] = Frame::payloadSize;
beaconFrame[frameByte++] = newPayloadLength;
}
beaconFrame[frameByte++] = (uint8_t)jsonString[i];
}

uint8_t nextByte = (uint8_t)'?';
if (isAscii(jsonString[i])) {
nextByte = (uint8_t)jsonString[i];
}
/* developer note: we can print the beacon frame like so...

Frame::beaconFrame[currentByte++] = nextByte;
Serial.println("('-') Full Beacon Frame:");
for (size_t i = 0; i < frameSize; ++i) {
Serial.print(beaconFrame[i], HEX);
Serial.print(" ");
}

return Frame::beaconFrame;
/** developer note:
*
* we can print the beacon frame like so...
*
* Serial.println("('-') Full Beacon Frame:");
* for (size_t i = 0; i < Frame::beaconFrame.size(); ++i) {
* Serial.print(Frame::beaconFrame[i], HEX);
* Serial.print(" ");
* }
* Serial.println(" ");
*
*/
Serial.println(" ");

*/

return beaconFrame;
}

bool Frame::send() {
// build frame
// convert to a pointer because esp-idf is a pain in the ass
WiFi.mode(WIFI_AP);
uint8_t *frame = Frame::pack();
size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength +
Frame::headerLength; // actually disgusting but it works

// send full frame
// we dont use raw80211 since it sends a header(which we don't need), although
// we do use it for monitoring, etc.
// we don't use raw80211 since it sends a header (which we don't need),
// although we do use it for monitoring, etc.
delay(102);
esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, frame, sizeof(frame), false);
// Channel::switchChannel(1 + rand() % (13 - 1 + 1));
esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false);

delete[] frame;
return (err == ESP_OK);
Expand Down
2 changes: 1 addition & 1 deletion minigotchi-ESP32/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "display.h"
#include "parasite.h"
#include <ArduinoJson.h>
#include <Wifi.h>
#include <esp_wifi.h>
#include <sstream>
#include <string>
Expand All @@ -47,7 +48,6 @@ class Frame {
static const uint8_t BroadcastAddr[];
static const uint16_t wpaFlags;

static uint8_t *beaconFrame;
static const int pwngridHeaderLength;
static size_t essidLength;
static uint8_t headerLength;
Expand Down
5 changes: 5 additions & 0 deletions minigotchi-ESP32/minigotchi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ void Minigotchi::boot() {
Serial.println("# BOOTUP PROCESS #");
Serial.println("################################################");
Serial.println(" ");
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_start());
Deauth::list();
Channel::init(Config::channel);
Minigotchi::info();
Expand Down
Loading