justcallmekoko / ESP32Marauder

A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32
4.86k stars 534 forks source link

Evil Portal - URL Results Parameter #510

Open jamescussen opened 3 months ago

jamescussen commented 3 months ago

An improvement for the Evil Portal (i'm using the esp32_marauder version) is to include a result parameter in the returned redirect page.

This will allow for a "You are now signed in" page to be shown after the sign in process, or to present error messages if the email/password provided is not suitable.

The specific code is below and just needs to include a parameter in the window.location.href:

request->send(
      200, "text/html",
      "<html><head><script>setTimeout(() => { window.location.href ='/' }, 100);</script></head><body></body></html>");
  });

Here are some examples of return results that could be included:

"/?result=success" - This is when the user has provided an email address and password text successfully.

"/?result=email-error" - Do a regex test on the inbound email to check the format. If it's not formatted correctly respond with this error.

"/?result=email-blank" - The email field was blank

"/?result=password-blank" - The password field was blank

"/?result=general-failure" - Any other failure allows for a general error message.

In the index.html file you can use javascript to get these parameters and render a different page in response:

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const result = urlParams.get('result')

document.addEventListener("DOMContentLoaded", function(){
    if(result == "success"){
        //Render page elements appropriately.
    }
});