Display things

This commit is contained in:
Just Call Me Koko
2023-07-20 11:51:24 -04:00
parent 81b04db462
commit 71266ae650
8 changed files with 81 additions and 75 deletions

View File

@@ -10,7 +10,7 @@ EvilPortal::EvilPortal() {
this->has_ap = false;
}
bool EvilPortal::begin() {
bool EvilPortal::begin(LinkedList<ssid>* ssids) {
// wait for init flipper input
if (!this->setAP())
return false;
@@ -63,11 +63,25 @@ bool EvilPortal::setHtml() {
#ifndef WRITE_PACKETS_SERIAL
File html_file = sd_obj.getFile("/index.html");
if (!html_file) {
Serial.println("Could not open index.html. Exiting...");
#ifdef HAS_SCREEN
display_obj.tft.setCursor(0, 100);
display_obj.tft.setFreeFont(NULL);
display_obj.tft.setTextSize(1);
display_obj.tft.println("Could not find /index.html. Touch to exit...");
#endif
Serial.println("Could not find /index.html. Exiting...");
return false;
}
else {
if (html_file.size() > MAX_HTML_SIZE) {
#ifdef HAS_SCREEN
display_obj.tft.setCursor(0, 100);
display_obj.tft.setFreeFont(NULL);
display_obj.tft.setTextSize(1);
display_obj.tft.println("The provided HTML is too large.");
display_obj.tft.println("The Byte limit is " + (String)MAX_HTML_SIZE);
display_obj.tft.println("Touch to exit...");
#endif
Serial.println("The provided HTML is too large. Byte limit is " + (String)MAX_HTML_SIZE);
return false;
}
@@ -93,11 +107,25 @@ bool EvilPortal::setAP() {
#ifndef WRITE_PACKETS_SERIAL
File ap_config_file = sd_obj.getFile("/ap.config.txt");
if (!ap_config_file) {
Serial.println("Could not open ap.config.txt. Exiting...");
#ifdef HAS_SCREEN
display_obj.tft.setCursor(0, 100);
display_obj.tft.setFreeFont(NULL);
display_obj.tft.setTextSize(1);
display_obj.tft.println("Could not find /ap.config.txt.\nTouch to exit...");
#endif
Serial.println("Could not find /ap.config.txt. Exiting...");
return false;
}
else {
if (ap_config_file.size() > MAX_AP_NAME_SIZE) {
#ifdef HAS_SCREEN
display_obj.tft.setCursor(0, 100);
display_obj.tft.setFreeFont(NULL);
display_obj.tft.setTextSize(1);
display_obj.tft.println("The provided AP name is too large.");
display_obj.tft.println("The Byte limit is " + (String)MAX_AP_NAME_SIZE);
display_obj.tft.println("Touch to exit...");
#endif
Serial.println("The provided AP name is too large. Byte limit is " + (String)MAX_AP_NAME_SIZE);
return false;
}
@@ -174,6 +202,24 @@ void EvilPortal::addLog(String log, int len) {
}
}
void EvilPortal::sendToDisplay(String msg) {
#ifdef HAS_SCREEN
String display_string = "";
display_string.concat(msg);
int temp_len = display_string.length();
for (int i = 0; i < 40 - temp_len; i++)
{
display_string.concat(" ");
}
if (display_obj.display_buffer->size() == 0)
{
display_obj.loading = true;
display_obj.display_buffer->add(display_string);
display_obj.loading = false;
}
#endif
}
void EvilPortal::main(uint8_t scan_mode) {
if (scan_mode == WIFI_SCAN_EVIL_PORTAL) {
this->dnsServer.processNextRequest();

View File

@@ -7,6 +7,10 @@
#include "configs.h"
#include "settings.h"
#ifdef HAS_SCREEN
#include "Display.h"
#include <LinkedList.h>
#endif
#ifndef WRITE_PACKETS_SERIAL
#include "SDInterface.h"
#else
@@ -18,6 +22,9 @@ extern Settings settings_obj;
#ifndef WRITE_PACKETS_SERIAL
extern SDInterface sd_obj;
#endif
#ifdef HAS_SCREEN
extern Display display_obj;
#endif
extern Buffer buffer_obj;
#define WAITING 0
@@ -44,6 +51,13 @@ public:
}
};
struct ssid {
String essid;
uint8_t channel;
int bssid[6];
bool selected;
};
class EvilPortal {
private:
@@ -71,13 +85,14 @@ class EvilPortal {
void startAP();
void addLog(String log, int len);
void convertStringToUint8Array(const String& str, uint8_t*& buf, uint32_t& len);
void sendToDisplay(String msg);
public:
EvilPortal();
String get_user_name();
String get_password();
bool begin();
bool begin(LinkedList<ssid>* ssids);
void main(uint8_t scan_mode);
};

View File

@@ -729,31 +729,6 @@ MenuFunctions::MenuFunctions()
}
}
/*void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) {
extern Display display_obj;
extern MenuFunctions menu_function_obj;
extern A32u4Interface a32u4_obj;
extern WiFiScan wifi_scan_obj;
lv_keyboard_def_event_cb(kb, event);
if(event == LV_EVENT_APPLY){
String display_string = "";
printf("LV_EVENT_APPLY\n");
String ta1_text = lv_textarea_get_text(ta1);
Serial.println(ta1_text);
a32u4_obj.runScript(ta1_text);
}
else if(event == LV_EVENT_CANCEL) {
printf("LV_EVENT_CANCEL\n");
menu_function_obj.deinitLVGL();
wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
display_obj.exit_draw = true; // set everything back to normal
}
}*/
// Keyboard callback dedicated to joining wifi
void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
extern Display display_obj;
@@ -822,12 +797,6 @@ MenuFunctions::MenuFunctions()
lv_keyboard_set_textarea(kb, ta);
}
//else if(event == LV_EVENT_INSERT) {
// const char * str = lv_event_get_data();
// if(str[0] == '\n') {
// printf("Ready\n");
// }
//}
}
#endif
@@ -1489,7 +1458,6 @@ void MenuFunctions::RunSetup()
// Main menu stuff
wifiMenu.list = new LinkedList<MenuNode>(); // Get list in second menu ready
bluetoothMenu.list = new LinkedList<MenuNode>(); // Get list in third menu ready
//badusbMenu.list = new LinkedList<MenuNode>();
generalMenu.list = new LinkedList<MenuNode>();
deviceMenu.list = new LinkedList<MenuNode>();
@@ -1497,7 +1465,6 @@ void MenuFunctions::RunSetup()
failedUpdateMenu.list = new LinkedList<MenuNode>();
whichUpdateMenu.list = new LinkedList<MenuNode>();
confirmMenu.list = new LinkedList<MenuNode>();
//espUpdateMenu.list = new LinkedList<MenuNode>();
updateMenu.list = new LinkedList<MenuNode>();
settingsMenu.list = new LinkedList<MenuNode>();
specSettingMenu.list = new LinkedList<MenuNode>();
@@ -1524,13 +1491,11 @@ void MenuFunctions::RunSetup()
// Work menu names
mainMenu.name = text_table1[6];
wifiMenu.name = text_table1[7];
//badusbMenu.name = text_table1[8];
deviceMenu.name = text_table1[9];
generalMenu.name = text_table1[10];
failedUpdateMenu.name = text_table1[11];
whichUpdateMenu.name = text_table1[12];
confirmMenu.name = text_table1[13];
//espUpdateMenu.name = text_table1[14];
updateMenu.name = text_table1[15];
languageMenu.name = text_table1[16];
infoMenu.name = text_table1[17];
@@ -1578,9 +1543,6 @@ void MenuFunctions::RunSetup()
addNodes(&wifiMenu, text_table1[31], TFT_YELLOW, NULL, SNIFFERS, [this]() {
changeMenu(&wifiSnifferMenu);
});
//addNodes(&wifiMenu, "Scanners", TFT_ORANGE, NULL, SCANNERS, [this]() {
// changeMenu(&wifiScannerMenu);
//});
addNodes(&wifiMenu, text_table1[32], TFT_RED, NULL, ATTACKS, [this]() {
changeMenu(&wifiAttackMenu);
});
@@ -1632,11 +1594,11 @@ void MenuFunctions::RunSetup()
this->drawStatusBar();
wifi_scan_obj.StartScan(WIFI_SCAN_PWN, TFT_RED);
});
/*addNodes(&wifiSnifferMenu, text_table1[48], TFT_ORANGE, NULL, ESPRESSIF, [this]() {
addNodes(&wifiSnifferMenu, "Evil Portal", TFT_ORANGE, NULL, BEACON_SNIFF, [this]() {
display_obj.clearScreen();
this->drawStatusBar();
wifi_scan_obj.StartScan(WIFI_SCAN_ESPRESSIF, TFT_ORANGE);
});*/
wifi_scan_obj.StartScan(WIFI_SCAN_EVIL_PORTAL, TFT_ORANGE);
});
addNodes(&wifiSnifferMenu, text_table1[49], TFT_MAGENTA, NULL, BEACON_SNIFF, [this]() {
display_obj.clearScreen();
this->drawStatusBar();

View File

@@ -79,8 +79,8 @@ File SDInterface::getFile(String path) {
if (this->supported) {
File file = SD.open(path, FILE_READ);
if (file)
return file;
//if (file)
return file;
}
}

View File

@@ -620,19 +620,7 @@ void WiFiScan::RunEvilPortal(uint8_t scan_mode, uint16_t color)
display_obj.tft.setTextColor(TFT_MAGENTA, TFT_BLACK);
display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
#endif
//esp_wifi_init(&cfg);
//esp_wifi_set_storage(WIFI_STORAGE_RAM);
//esp_wifi_set_mode(WIFI_MODE_NULL);
//esp_wifi_start();
//esp_wifi_set_promiscuous(true);
//esp_wifi_set_promiscuous_filter(&filt);
//if (scan_mode == WIFI_SCAN_TARGET_AP_FULL)
//esp_wifi_set_promiscuous_rx_cb(&apSnifferCallbackFull);
//else
// esp_wifi_set_promiscuous_rx_cb(&apSnifferCallback);
//esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
if (!evil_portal_obj.begin())
if (!evil_portal_obj.begin(ssids))
this->StartScan(WIFI_SCAN_OFF, TFT_MAGENTA);
this->wifi_initialized = true;
initTime = millis();
@@ -3797,7 +3785,6 @@ void WiFiScan::main(uint32_t currentTime)
// WiFi operations
if ((currentScanMode == WIFI_SCAN_PROBE) ||
(currentScanMode == WIFI_SCAN_AP) ||
(currentScanMode == WIFI_SCAN_EVIL_PORTAL) ||
(currentScanMode == WIFI_SCAN_STATION) ||
(currentScanMode == WIFI_SCAN_SIG_STREN) ||
(currentScanMode == WIFI_SCAN_TARGET_AP) ||
@@ -3812,13 +3799,9 @@ void WiFiScan::main(uint32_t currentTime)
channelHop();
}
}
/*else if (currentScanMode == WIFI_SCAN_EVIL_PORTAL) {
String evil_portal_result = "";
evil_portal_result = evil_portal_obj.main(currentScanMode);
if (evil_portal_result != "") {
this->addLog(evil_portal_result, strlen(evil_portal_result.c_str()));
}
}*/
else if (currentScanMode == WIFI_SCAN_EVIL_PORTAL) {
evil_portal_obj.main(currentScanMode);
}
else if (currentScanMode == WIFI_PACKET_MONITOR)
{
#ifdef HAS_SCREEN

View File

@@ -114,12 +114,12 @@ extern Settings settings_obj;
esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
//int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, int32_t arg3);
struct ssid {
/*struct ssid {
String essid;
uint8_t channel;
int bssid[6];
bool selected;
};
};*/
struct AccessPoint {
String essid;

View File

@@ -722,15 +722,15 @@
//// EVIL PORTAL STUFF
#ifdef MARAUDER_M5STICKC
#define MAX_HTML_SIZE 7000
#define MAX_HTML_SIZE 11400
#elif defined(MARAUDER_MINI)
#define MAX_HTML_SIZE 7000
#define MAX_HTML_SIZE 11400
#elif defined(MARAUDER_V4)
#define MAX_HTML_SIZE 11400
#elif defined(MARAUDER_V6)
#define MAX_HTML_SIZE 7000
#define MAX_HTML_SIZE 11400
#elif defined(MARAUDER_KIT)
#define MAX_HTML_SIZE 7000
#define MAX_HTML_SIZE 11400
#elif defined(GENERIC_ESP32)
#define MAX_HTML_SIZE 20000
#elif defined(MARAUDER_FLIPPER)

View File

@@ -374,7 +374,7 @@ void loop()
display_obj.main(wifi_scan_obj.currentScanMode);
#endif
wifi_scan_obj.main(currentTime);
evil_portal_obj.main(wifi_scan_obj.currentScanMode);
//evil_portal_obj.main(wifi_scan_obj.currentScanMode);
#ifdef WRITE_PACKETS_SERIAL
buffer_obj.forceSaveSerial();