Skip to content

Commit

Permalink
Merge pull request #13 from Pwnagotchi-Unofficial/development
Browse files Browse the repository at this point in the history
merge screen changes
  • Loading branch information
dj1ch authored Jun 2, 2024
2 parents eb1d8e8 + a38f3b6 commit bb6fb8e
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.vscode

# builds
minigotchi/*.zip
minigotchi/build
minigotchi-*/*.zip
minigotchi-*/build
8 changes: 8 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ Make sure you install the correct library, they aren't the same library and if y

- Go to `Tools` > `Board` and use one of the boards in the `esp32` section. (Example: `Adafruit Feather ESP32-S3 TFT`)

- Open the following with your text editor `C:\Users\<YOUR USERNAME>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10\platform.txt` and add the following:

1. For `build.extra_flags.esp32`, `build.extra_flags.esp32s2`, `build.extra_flags.esp32s3`, `build.extra_flags.esp32c3`, add `-w` to their compile settings

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. 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

- Click on the upload button(arrow pointing to the left).
Expand Down
37 changes: 21 additions & 16 deletions minigotchi-ESP32/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ void Channel::init(int initChannel) {

// switch channel
Minigotchi::monStop();
esp_wifi_set_channel(initChannel, WIFI_SECOND_CHAN_NONE);
esp_err_t err = esp_wifi_set_channel(initChannel, WIFI_SECOND_CHAN_NONE);
Minigotchi::monStart();

if (initChannel == getChannel()) {
if (err == ESP_OK && initChannel == getChannel()) {
Serial.print("('-') Successfully initialized on channel ");
Serial.println(getChannel());
Display::cleanDisplayFace("('-')");
Display::attachSmallText("Successfully initialized on channel " + (String) getChannel());
delay(250);
} else {
Serial.print("(X-X) Channel initialization failed, try again?");
Serial.println("(X-X) Channel initialization failed, try again?");
Display::cleanDisplayFace("(X-X)");
Display::attachSmallText("Channel initialization failed, try again?");
delay(250);
Expand Down Expand Up @@ -74,18 +74,26 @@ void Channel::switchChannel(int newChannel) {

// monitor this one channel
Minigotchi::monStop();
esp_wifi_set_channel(newChannel, WIFI_SECOND_CHAN_NONE);
esp_err_t err = esp_wifi_set_channel(newChannel, WIFI_SECOND_CHAN_NONE);
Minigotchi::monStart();

// switched channel
checkChannel(newChannel);
// check if the channel switch was successful
if (err == ESP_OK) {
checkChannel(newChannel);
} else {
Serial.println("(X-X) Failed to switch channel.");
Display::cleanDisplayFace("(X-X)");
Display::attachSmallText("Failed to switch channel.");
delay(250);
}
}

// check if the channel switch was successful
void Channel::checkChannel(int channel) {
if (channel == getChannel()) {
int currentChannel = Channel::getChannel();
if (channel == currentChannel) {
Serial.print("('-') Currently on channel ");
Serial.println(getChannel());
Serial.println(currentChannel);
Display::cleanDisplayFace("('-')");
Display::attachSmallText("Currently on channel " + (String) getChannel());
Serial.println(" ");
Expand All @@ -95,7 +103,7 @@ void Channel::checkChannel(int channel) {
Serial.print(channel);
Serial.println(" has failed");
Serial.print("(X-X) Currently on channel ");
Serial.print(getChannel());
Serial.print(currentChannel);
Serial.println(" instead");
Serial.println(" ");
Display::cleanDisplayFace("(X-X)");
Expand All @@ -105,11 +113,8 @@ void Channel::checkChannel(int channel) {
}

int Channel::getChannel() {
wifi_ap_record_t ap_info;
esp_wifi_sta_get_ap_info(&ap_info);
return ap_info.primary;
uint8_t primary;
wifi_second_chan_t second;
esp_wifi_get_channel(&primary, &second);
return primary;
}

int Channel::list() {
return channelList[3];
}
1 change: 0 additions & 1 deletion minigotchi-ESP32/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Channel {
static void switchChannel(int newChannel);
static int getChannel();
static void checkChannel(int channel);
static int list();
static int channelList[13]; // 13 channels

private:
Expand Down
3 changes: 1 addition & 2 deletions minigotchi-ESP32/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ std::string Config::screen = "";
int Config::baud = 115200;

// define init channel
std::string Config::bssid = "fo:od:ba:be:fo:od";
int Config::channel = 1;

// define whitelist
Expand Down Expand Up @@ -61,7 +60,7 @@ std::string Config::session_id = "84:f3:eb:58:95:bd";
int Config::uptime = Config::time();

// define version(please do not change, this should not be changed)
std::string Config::version = "3.1.0-beta";
std::string Config::version = "3.2.2-beta";

/** developer note:
*
Expand Down
1 change: 0 additions & 1 deletion minigotchi-ESP32/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Config {
static bool display;
static std::string screen;
static int baud;
static std::string bssid;
static int channel;
static std::vector<std::string> whitelist;
static int epoch;
Expand Down
5 changes: 5 additions & 0 deletions minigotchi-ESP32/deauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
*
*/

// for some dumb reason espressif really doesn't like us sending deauth frames, so i'll need to make this fix
extern "C" int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, int32_t arg3){
return 0;
}

// default values before we start
bool Deauth::running = false;
std::vector<String> Deauth::whitelist = {};
Expand Down
11 changes: 5 additions & 6 deletions minigotchi-ESP32/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,15 @@ void Frame::pack() {
*/
}

void Frame::send() {
bool Frame::send() {
// build frame
Frame::pack();

// 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.
Frame::sent = esp_wifi_80211_tx(WIFI_IF_STA, Frame::beaconFrame.data(), Frame::frameSize, 0) == ESP_OK;
esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, Frame::beaconFrame.data(), Frame::frameSize, 0);
delay(102);
return(err == ESP_OK);
}


Expand All @@ -270,10 +272,7 @@ void Frame::advertise() {
Display::attachSmallText("Starting advertisment...");
delay(250);
for (int i = 0; i < 150; ++i) {
send();
delay(102);

if (Frame::sent) {
if (Frame::send()) {
packets++;

// calculate packets per second
Expand Down
2 changes: 1 addition & 1 deletion minigotchi-ESP32/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class Frame {
public:
static void pack();
static void send();
static bool send();
static void advertise();
static const uint8_t header[];
static const uint8_t IDWhisperPayload;
Expand Down
4 changes: 4 additions & 0 deletions minigotchi-ESP32/minigotchi-ESP32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ void loop() {
minigotchi.detect();
delay(250);

// advertise our presence with the help of pwngrid compatible beacon frames (probably the most confusing part lmao)
minigotchi.advertise();
delay(250);

// deauth random access point
minigotchi.deauth();
delay(250);
Expand Down

0 comments on commit bb6fb8e

Please sign in to comment.