Skip to content

Commit

Permalink
Merge pull request #100 from bmorcelli/main
Browse files Browse the repository at this point in the history
Wardrive and LittleFS space check
  • Loading branch information
pr3y authored Aug 1, 2024
2 parents 1b42cad + 694188a commit d26109c
Show file tree
Hide file tree
Showing 14 changed files with 594 additions and 292 deletions.
474 changes: 238 additions & 236 deletions platformio.ini

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ void drawMainBorder(bool clear) {
// if(wifiConnected) {tft.print(timeStr);} else {tft.print("BRUCE 1.0b");}

int i=0;
if(sdcardMounted) { tft.setTextColor(FGCOLOR, BGCOLOR); tft.setTextSize(FP); tft.drawString("SD", WIDTH - (90 + 21*i),12); i++; } // Indication for SD card on screen
if(wifiConnected) { drawWifiSmall(WIDTH - (90 + 20*i), 7); i++;} //Draw Wifi Symbol beside battery
if(BLEConnected) { drawBLESmall(WIDTH - (90 + 20*i), 7); i++; } //Draw BLE beside Wifi
if(isConnectedWireguard) { drawWireguardStatus(WIDTH - (90 + 21*i), 7); i++; }//Draw Wg bedide BLE, if the others exist, if not, beside battery
if(sdcardMounted) { tft.setTextColor(FGCOLOR, BGCOLOR); tft.setTextSize(FP); tft.drawString("SD", WIDTH - (85 + 20*i),12); i++; } // Indication for SD card on screen
if(gpsConnected) { drawGpsSmall(WIDTH - (85 + 20*i), 7); i++; }
if(wifiConnected) { drawWifiSmall(WIDTH - (85 + 20*i), 7); i++;} //Draw Wifi Symbol beside battery
if(BLEConnected) { drawBLESmall(WIDTH - (85 + 20*i), 7); i++; } //Draw BLE beside Wifi
if(isConnectedWireguard) { drawWireguardStatus(WIDTH - (85 + 21*i), 7); i++; }//Draw Wg bedide BLE, if the others exist, if not, beside battery


tft.drawRoundRect(5, 5, WIDTH - 10, HEIGHT - 10, 5, FGCOLOR);
Expand Down Expand Up @@ -477,3 +478,16 @@ void drawOther(int x, int y) {
tft.drawArc(40+x,40+y,32,29,240,360,FGCOLOR,BGCOLOR);
}

void drawGPS(int x, int y) {
tft.fillRect(x,y,80,80,BGCOLOR);
tft.drawEllipse(40+x,70+y,15,8,FGCOLOR);
tft.drawArc(40+x,25+y,23,7,0,340,FGCOLOR,BGCOLOR);
tft.fillTriangle(40+x,70+y,20+x,64+y,60+x,64+y,FGCOLOR);
}

void drawGpsSmall(int x, int y) {
tft.fillRect(x,y,17,17,BGCOLOR);
tft.drawEllipse(9+x,14+y,4,3,FGCOLOR);
tft.drawArc(9+x,6+y,5,2,0,340,FGCOLOR,BGCOLOR);
tft.fillTriangle(9+x,15+y,5+x,9+y,13+x,9+y,FGCOLOR);
}
2 changes: 2 additions & 0 deletions src/core/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ void drawOther(int x, int y);

void drawCfg(int x, int y);

void drawGPS(int x, int y);

void drawGpsSmall(int x, int y);

#define bruce_small_width 60
#define bruce_small_height 34
Expand Down
10 changes: 6 additions & 4 deletions src/core/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ extern Timezone myTZ;

extern int prog_handler; // 0 - Flash, 1 - LittleFS, 2 - Download

extern bool sdcardMounted; // informa se o cartão está montado ou não, sem precisar chamar a função setupSdCard
extern bool sdcardMounted; // inform if SD Cardis active or not

extern bool wifiConnected; // informa se o wifi está ativo ou não
extern bool wifiConnected; // inform if wifi is active or not

extern bool BLEConnected; // informa se o BLE está ativo ou não
extern bool BLEConnected; // inform if BLE is active or not

extern bool gpsConnected; // inform if GPS is active or not

extern std::vector<std::pair<std::string, std::function<void()>>> options;

Expand All @@ -63,7 +65,7 @@ extern uint8_t buff[4096];

extern const int bufSize;

extern bool returnToMenu; // variável para verificação e quebrar os loops
extern bool returnToMenu; // variable to check and break loops to return to main menu

extern int IrTx;

Expand Down
3 changes: 3 additions & 0 deletions src/core/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "modules/wifi/scan_hosts.h"
#include "modules/wifi/sniffer.h"
#include "modules/wifi/wifi_atks.h"
#include "modules/wifi/wardriving.h"

#ifdef CARDPUTER
#include "modules/others/bad_usb.h"
Expand All @@ -42,6 +43,7 @@ void wifiOptions() {
};
}
options.push_back({"Wifi Atks", [=]() { wifi_atk_menu(); }});
options.push_back({"Wardriving", [=]() { wardriving_setup(); }});
#ifndef STICK_C_PLUS
options.push_back({"TelNET", [=]() { telnet_setup(); }});
options.push_back({"SSH", [=]() { ssh_setup(); }});
Expand Down Expand Up @@ -140,6 +142,7 @@ void otherOptions(){
{"Megalodon", [=]() { shark_setup(); }},
#ifdef CARDPUTER
{"BadUSB", [=]() { usb_setup(); }},
{"USB Keyborard",[=]() { usb_keyboard(); }},
{"LED Control", [=]() { ledrgb_setup(); }}, //IncursioHack
{"LED FLash", [=]() { ledrgb_flash(); }}, // IncursioHack
#endif
Expand Down
12 changes: 11 additions & 1 deletion src/core/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,4 +614,14 @@ void viewFile(FS fs, String filepath) {

return;
}

/*********************************************************************
** Function: checkLittleFsSize
** Check if there are more then 4096 bytes available for storage
**********************************************************************/
bool checkLittleFsSize() {
if((LittleFS.totalBytes() - LittleFS.usedBytes()) < 4096) {
displayError("LittleFS is Full");
delay(2000);
return false;
} else return true;
}
2 changes: 2 additions & 0 deletions src/core/sd_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ String loopSD(FS &fs, bool filePicker = false, String allowed_ext = "*");
void viewFile(FS fs, String filepath);

int createFilePages(String fileContent);

bool checkLittleFsSize();
7 changes: 4 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ int RfRx;
int dimmerSet;
int bright=100;
int tmz=3;
bool sdcardMounted;
bool wifiConnected;
bool BLEConnected;
bool sdcardMounted = false;
bool gpsConnected = false;
bool wifiConnected = false;
bool BLEConnected = false;
bool returnToMenu;
bool isSleeping = false;
bool isScreenOff = false;
Expand Down
103 changes: 59 additions & 44 deletions src/modules/others/bad_usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,68 +270,83 @@ void usb_setup() {

}

/*

Now cardputer works as a USB Keyboard!

Keyboard functions
Created by: edulk2, thankss

//Now cardputer works as a USB Keyboard!

//Keyboard functions
//Created by: edulk2, thankss

void keyboard_setup() {
tft.fillScreen(BGCOLOR);
tft.setRotation(1);
tft.setTextColor(FGCOLOR);
tft.setTextDatum(MC_DATUM);
void usb_keyboard() {
drawMainBorder();
tft.setTextSize(2);
tft.setTextColor(FGCOLOR);
tft.drawString("Keyboard Started",
tft.width() / 2,
tft.height() / 2);
Kb.begin();
options = {
{"US Inter", [=]() { chooseKb(KeyboardLayout_en_US); }},
{"PT-BR ABNT2", [=]() { chooseKb(KeyboardLayout_pt_BR); }},
{"PT-Portugal", [=]() { chooseKb(KeyboardLayout_pt_PT); }},
{"AZERTY FR", [=]() { chooseKb(KeyboardLayout_fr_FR); }},
{"es-Espanol", [=]() { chooseKb(KeyboardLayout_es_ES); }},
{"it-Italiano", [=]() { chooseKb(KeyboardLayout_it_IT); }},
{"en-UK", [=]() { chooseKb(KeyboardLayout_en_UK); }},
{"de-DE", [=]() { chooseKb(KeyboardLayout_de_DE); }},
{"sv-SE", [=]() { chooseKb(KeyboardLayout_sv_SE); }},
{"da-DK", [=]() { chooseKb(KeyboardLayout_da_DK); }},
{"hu-HU", [=]() { chooseKb(KeyboardLayout_hu_HU); }},
};
delay(200);
loopOptions(options,false,true,"Keyboard Layout");
USB.begin();
tft.setTextColor(FGCOLOR, BGCOLOR);
}

void keyboard_loop() {
M5Cardputer.update();
if (M5Cardputer.Keyboard.isChange()) {
if (M5Cardputer.Keyboard.isPressed()) {
Keyboard_Class::KeysState status = M5Cardputer.Keyboard.keysState();
KeyReport report = { 0 };
report.modifiers = status.modifiers;
uint8_t index = 0;
for (auto i : status.hid_keys) {
report.keys[index] = i;
index++;
if (index > 5) {
index = 5;
tft.setTextColor(FGCOLOR, BGCOLOR);
tft.setTextSize(FP);
drawMainBorder();
tft.setCursor(10,28);
tft.println("Usb Keyboard:");
tft.setTextSize(FM);

while(1) {
Keyboard.update();
if (Keyboard.isChange()) {
if (Keyboard.isPressed()) {
Keyboard_Class::KeysState status = Keyboard.keysState();

KeyReport report = { 0 };
report.modifiers = status.modifiers;
uint8_t index = 0;
for (auto i : status.hid_keys) {
report.keys[index] = i;
index++;
if (index > 5) {
index = 5;
}
}
}
Kb.sendReport(&report);
Kb.releaseAll();
// only text for tftlay
String keyStr = "";
for (auto i : status.word) {
if (keyStr != "") {
keyStr = keyStr + "+" + i;
} else {
keyStr += i;
Kb.sendReport(&report);
Kb.releaseAll();

// only text for tftlay
String keyStr = "";
for (auto i : status.word) {
if (keyStr != "") {
keyStr = keyStr + "+" + i;
} else {
keyStr += i;
}
}
}

if (keyStr.length() > 0) {
tft.clear();
tft.drawString("Pressed: " + keyStr,
tft.width() / 2,
tft.height() / 2);
if (keyStr.length() > 0) {
drawMainBorder(false);
tft.drawCentreString("Pressed: " + keyStr, WIDTH / 2, HEIGHT / 2,1);
delay(100);
}
}
}
}
}
*/


#endif
1 change: 1 addition & 0 deletions src/modules/others/bad_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void key_input(FS fs, String bad_script = "/badpayload.txt");

void usb_setup();

void usb_keyboard();


#endif
3 changes: 3 additions & 0 deletions src/modules/rf/rf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ void RCSwitch_Read_Raw() {
file = SD.open("/BruceRF/bruce_"+ String(i) +".sub", FILE_WRITE);
FS="SD";
} else if(LittleFS.begin()) {
if(!checkLittleFsSize()) goto Exit;
if (!LittleFS.exists("/BruceRF")) LittleFS.mkdir("/BruceRF");
while(LittleFS.exists("/BruceRF/bruce_" + String(i) + ".sub")) i++;
file = LittleFS.open("/BruceRF/bruce_"+ String(i) +".sub", FILE_WRITE);
Expand Down Expand Up @@ -434,6 +435,8 @@ void RCSwitch_Read_Raw() {
}
}
}
Exit:
delay(1);
}


Expand Down
4 changes: 4 additions & 0 deletions src/modules/wifi/sniffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ void sniffer_loop(FS &Fs) {
String FileSys="LittleFS";
if(&Fs == &SD) FileSys="SD";

if(FileSys=="LittleFS" && !checkLittleFsSize()) goto Exit;

for(;;) {
// if ((checkSelPress())) {
unsigned long currentTime = millis();
Expand Down Expand Up @@ -223,4 +225,6 @@ void sniffer_loop(FS &Fs) {
//goto Exit;
}
}
Exit:
delay(1); // just to Exit Work
}
Loading

0 comments on commit d26109c

Please sign in to comment.