Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/modules/pwnagotchi/mood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
#include "mood.h"

// ASCII equivalent
Expand Down Expand Up @@ -75,6 +74,7 @@ String getCurrentMoodPhrase() { return current_phrase; }
bool isCurrentMoodBroken() { return current_broken; }

void setMood(uint8_t mood, String face, String phrase, bool broken) {
if (mood >= number_of_moods) mood = 2; // clamp to safe index (awake)
current_mood = mood;
current_broken = broken;

Expand All @@ -90,4 +90,3 @@ void setMood(uint8_t mood, String face, String phrase, bool broken) {
current_phrase = palnagotchi_moods_desc[current_mood];
}
}
#endif
2 changes: 0 additions & 2 deletions src/modules/pwnagotchi/mood.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
#include <Arduino.h>

#define MOOD_BROKEN 19
Expand All @@ -17,4 +16,3 @@ int getNumberOfMoods();
String getCurrentMoodFace();
String getCurrentMoodPhrase();
bool isCurrentMoodBroken();
#endif
118 changes: 55 additions & 63 deletions src/modules/pwnagotchi/pwnagotchi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
#include "../wifi/sniffer.h"
#include "../wifi/wifi_atks.h"
#include "core/mykeyboard.h"
Expand Down Expand Up @@ -80,10 +79,10 @@ void brucegotchi_update() {
}

void wakeUp() {
for (uint8_t i = 0; i < active_channels_size; i++) {
for (uint8_t i = 0; i < 4; i++) {
setMood(i % getNumberOfMoods());
updateUi(false);
vTaskDelay(1250 / portTICK_RATE_MS);
vTaskDelay(300 / portTICK_RATE_MS);
}
}

Expand Down Expand Up @@ -114,11 +113,6 @@ void advertise(uint8_t channel) {
void set_pwnagotchi_exit(bool new_value) { pwnagotchi_exit = new_value; }

void brucegotchi_start() {
int tmp = 0; // Control workflow
bool shot = false; // Control deauth faces
bool pwgrid_done = false; // Control to start advertising
bool Deauth_done = false; // Control to start deauth
uint8_t _times = 0; // control delays without impacting control btns
set_pwnagotchi_exit(false);

tft.fillScreen(bruceConfig.bgColor);
Expand Down Expand Up @@ -158,79 +152,78 @@ void brucegotchi_start() {
#endif
brucegotchi_update();

tmp = millis();
// LET'S GOOOOO!!!
uint32_t lastAdv = 0;
uint32_t lastUi = 0;
uint32_t lastDeauth = 0;
uint32_t lastMoodCheck = 0;
bool deauthFaces = false;

while (true) {
if (millis() - tmp < 2000 && !Deauth_done) {
Deauth_done = true;
drawMood("(-@_@)", "Preparing Deauth Sniper");
uint32_t now = millis();

if (registeredBeacons.size() > 30) {
registeredBeacons.clear();
}
if (millis() - tmp > (2000 + 1000 * _times) && Deauth_done && !pwgrid_done) {

if (registeredBeacons.size() > 30)
registeredBeacons.clear(); // Clear registered beacons to restart search and avoid restarts
// Serial.println("<<---- Starting Deauthentication Process ---->>");
for (auto registeredBeacon : registeredBeacons) {
char _MAC[20];
sprintf(
_MAC,
"%02X:%02X:%02X:%02X:%02X:%02X",
registeredBeacon.MAC[0],
registeredBeacon.MAC[1],
registeredBeacon.MAC[2],
registeredBeacon.MAC[3],
registeredBeacon.MAC[4],
registeredBeacon.MAC[5]
);
// Serial.println(
// String(_MAC) + " on ch" + String(registeredBeacon.channel) + " -> we are now on ch " +
// String(ch)
// );
if (registeredBeacon.channel == ch) {
memcpy(&ap_record.bssid, registeredBeacon.MAC, 6);
wsl_bypasser_send_raw_frame(
&ap_record, registeredBeacon.channel
); // writes the buffer with the information

if (now - lastAdv > 2500) {
current_channel++;
if (current_channel >= active_channels_size) current_channel = 0;
ch = active_channels[current_channel];
advertise(ch);
lastAdv = now;
}

if (now - lastDeauth > 800 && !registeredBeacons.empty()) {
for (const auto &beacon : registeredBeacons) {
if (beacon.channel == ch) {
memcpy(&ap_record.bssid, beacon.MAC, 6);
wsl_bypasser_send_raw_frame(&ap_record, beacon.channel);
send_raw_frame(deauth_frame, 26);
}
if (SelPress) break; // stops deauthing if select button is pressed
}
// Serial.println("<<---- Stopping Deauthentication Process ---->>");
drawMood(shot ? "(<<_<<)" : "(>>_>>)", shot ? "Lasers Activated! Deauthing" : "pew! pew! pew!");
_times++;
shot = !shot;
lastDeauth = now;
deauthFaces = true;
}
if (millis() - tmp > 12000 && pwgrid_done == false) {
drawMood("(^__^)", "Lets Make Friends!");
_times = 0;
pwgrid_done = true;

if (now - lastMoodCheck > 4000) {
if (!registeredBeacons.empty()) {
// Active pwnage: cycle through intense/cool/motivated/debugging moods
static const uint8_t activeMoods[] = {7, 8, 12, 14, 20};
static uint8_t activeIdx = 0;
setMood(activeMoods[activeIdx % 5], "", "Pwning " + String(registeredBeacons.size()) + " friends!", false);
activeIdx++;
} else if (deauthFaces) {
// Just finished deauthing but no active friends: happy/excited
static const uint8_t happyMoods[] = {9, 10, 11, 13};
static uint8_t happyIdx = 0;
setMood(happyMoods[happyIdx % 4], "", "", false);
happyIdx++;
deauthFaces = false;
} else {
// No friends around: mood varies by loneliness
static const uint8_t lonelyMoods[] = {5, 15, 16, 17, 18};
static uint8_t lonelyIdx = 0;
setMood(lonelyMoods[lonelyIdx % 5], "", "", false);
lonelyIdx++;
}
lastMoodCheck = now;
}
if (pwgrid_done && millis() - tmp > (12000 + 3000 * _times)) {
_times++;
advertise(ch);

if (now - lastUi > 1000) {
updateUi(true);
lastUi = now;
}
if (millis() - tmp > 29500) {
_times = 0;
tmp = millis();
pwgrid_done = false;
Deauth_done = false;
brucegotchi_update();
}

if (check(SelPress)) {
// Build options menu with channel toggle status
String channel_status = use_all_channels ? "All Ch: ON" : "All Ch: OFF";

// moved down here to reset the options, due to use in other parts in pwngrid spam
options = {
{"Find friends", yield},
{"Pwngrid spam", send_pwnagotchi_beacon_main},
{channel_status.c_str(), toggle_all_channels},
{"Main Menu", lambdaHelper(set_pwnagotchi_exit, true)},
};
// Display menu
loopOptions(options);
// Redraw footer & header
tft.fillScreen(bruceConfig.bgColor);
drawTopCanvas();
drawBottomCanvas();
Expand All @@ -245,4 +238,3 @@ void brucegotchi_start() {
esp_wifi_set_promiscuous_rx_cb(nullptr);
wifiDisconnect();
}
#endif
2 changes: 0 additions & 2 deletions src/modules/pwnagotchi/pwnagotchi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
void brucegotchi_start();
void brucegotchi_setup();
void brucegotchi_update();
#endif
17 changes: 5 additions & 12 deletions src/modules/pwnagotchi/pwngrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Thanks to @bmorcelli (Pirata) for his help doing a better code.
20/09 - Changed from DynamicJsonDocument json[2048] to JsonDocument json, to avoid stack smashing errors
(firgers crossed)
*/
#if !defined(LITE_VERSION)
#include "pwngrid.h"
#include "../wifi/sniffer.h"
#include "core/wifi/wifi_common.h"
Expand All @@ -25,18 +24,15 @@ std::vector<pwngrid_peer> getPwngridPeers() { return pwngrid_peers; }
// Add pwngrid peers
void add_new_peer(JsonDocument &json, signed int rssi) {
// Check if it exists in the list
bool exists = false;
for (auto peer_list : pwngrid_peers) {
for (auto &peer_list : pwngrid_peers) {
if (peer_list.identity == json["identity"].as<String>()) {
exists = true;
peer_list.last_ping = millis();
peer_list.gone = false;
peer_list.rssi = rssi;
return;
}
}
// Check if doesn't exists AND there are room in RAM memory to save
if (!exists && pwngrid_peers.size() < 50) {
if (pwngrid_peers.size() < 50) {
pwngrid_peers.push_back((pwngrid_peer){
json["epoch"].as<int>(),
json["face"].as<String>(),
Expand Down Expand Up @@ -105,7 +101,7 @@ esp_err_t pwngridAdvertise(uint8_t channel, String face) {
String pal_json_str = "";

pal_json["pal"] = true; // Also detect other Palnagotchis
pal_json["name"] = "Bruce";
pal_json["name"] = "HeavyButter";
pal_json["face"] = face;
pal_json["epoch"] = 1;
pal_json["grid_version"] = "1.10.3";
Expand Down Expand Up @@ -179,10 +175,8 @@ esp_err_t pwngridAdvertise(uint8_t channel, String face) {
const int away_threshold = 120000;

void checkPwngridGoneFriends() {
for (auto peer_list : pwngrid_peers) {
// Check if peer is away
int away_secs = peer_list.last_ping - millis();
if (away_secs > away_threshold) {
for (auto &peer_list : pwngrid_peers) {
if (millis() - peer_list.last_ping > away_threshold) {
peer_list.gone = true;
delete_peer_gone();
return;
Expand Down Expand Up @@ -325,4 +319,3 @@ void initPwngrid() {
esp_wifi_set_channel(random(0, 14), WIFI_SECOND_CHAN_NONE);
vTaskDelay(1 / portTICK_RATE_MS);
}
#endif
2 changes: 0 additions & 2 deletions src/modules/pwnagotchi/pwngrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
#include "ArduinoJson.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
Expand Down Expand Up @@ -38,4 +37,3 @@ uint8_t getPwngridTotalPeers();
String getPwngridLastFriendName();
signed int getPwngridClosestRssi();
void checkPwngridGoneFriends();
#endif
2 changes: 0 additions & 2 deletions src/modules/pwnagotchi/spam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
#include "esp_wifi.h"
#include "nvs_flash.h"
#include <ArduinoJson.h>
Expand Down Expand Up @@ -403,4 +402,3 @@ void send_pwnagotchi_beacon_main() {
// Display the spam status and wait for user input
displaySpamStatus();
}
#endif
2 changes: 0 additions & 2 deletions src/modules/pwnagotchi/spam.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
void send_pwnagotchi_beacon_main();
#endif
44 changes: 37 additions & 7 deletions src/modules/pwnagotchi/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
#include "ui.h"
#include "../wifi/sniffer.h"

Expand Down Expand Up @@ -107,9 +106,10 @@ void updateUi(bool show_toolbars) {
);
}

// Draw mood
drawMood(mood_face, mood_phrase, mood_broken);

drawFriendPanel();

#if defined(HAS_TOUCH)
TouchFooter();
#endif
Expand Down Expand Up @@ -142,19 +142,49 @@ void drawBottomCanvas() {
}

void drawMood(String face, String phrase, bool broken) {
// prepare canvas
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
tft.setTextSize(FG + 1);
tft.setTextDatum(MC_DATUM);
// draw screen
tft.drawPixel(0, 0, 0);
tft.fillRect(0, canvas_top_h + 10, display_w, canvas_bot_h - 40, bruceConfig.bgColor);
tft.drawCentreString(face, canvas_center_x, canvas_h / 3, SMOOTH_FONT);
// prepare canvas
tft.setTextDatum(BC_DATUM);
tft.setTextSize(1);
// draw screen
tft.drawPixel(0, 0, 0);
tft.drawCentreString(phrase, canvas_center_x, canvas_h - 30, SMOOTH_FONT);
}
#endif

void drawFriendPanel() {
auto peers = getPwngridPeers();
int y = canvas_h - 22;
int lineH = 10;

tft.setTextSize(1);
tft.setTextDatum(TL_DATUM);

int count = 0;
for (auto &p : peers) {
if (p.gone) continue;
if (count >= 3) break;

tft.fillRect(4, y, display_w - 8, lineH, bruceConfig.bgColor);
tft.setTextColor(bruceConfig.secColor, bruceConfig.bgColor);

String name = p.name.substring(0, 12);
tft.drawString(name, 4, y);

String rssi;
if (p.rssi >= -67) rssi = "[####]";
else if (p.rssi >= -70) rssi = "[### ]";
else if (p.rssi >= -80) rssi = "[## ]";
else rssi = "[# ]";

tft.setTextDatum(TR_DATUM);
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
tft.drawString(rssi, display_w - 4, y);
tft.setTextDatum(TL_DATUM);

y += lineH;
count++;
}
}
3 changes: 1 addition & 2 deletions src/modules/pwnagotchi/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Thanks to thoses developers for their projects:

Thanks to @bmorcelli for his help doing a better code.
*/
#if !defined(LITE_VERSION)
#include "core/display.h"
#include "mood.h"
#include "pwngrid.h"
Expand All @@ -18,7 +17,7 @@ void drawTime();
void drawFooterData(
uint8_t friends_run = 0, uint8_t friends_tot = 0, String last_friend_name = "", signed int rssi = -1000
);
void drawFriendPanel();
void drawTopCanvas();
void drawBottomCanvas();
void updateUi(bool show_toolbars = false);
#endif