-
-
Save iqfareez/4861c6e5dc76c1190d8b1651def13d37 to your computer and use it in GitHub Desktop.
#include <WiFi.h> | |
#include <Wire.h> | |
#include <HTTPClient.h> | |
#define AP_SSID "IIUM-Student" | |
#define AP_PASSWORD "" // leaves empty if open wifi | |
const String username = "1111111"; | |
const String password = "blahblah"; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
// Connecting to the WIFI AP | |
WiFi.begin(AP_SSID, AP_PASSWORD); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.println("Connecting to WiFi.."); | |
} | |
Serial.println("Connected to the WiFi network"); | |
// Login to Captive Portal | |
HTTPClient login; | |
login.begin("http://captiveportalmahallahgombak.iium.edu.my/cgi-bin/login"); | |
String body = "user=" + String(username) + "&password=" + String(password) + "&cmd=authenticate&Login=Log%2BIn"; | |
int res = login.POST(body); | |
Serial.println(res); | |
if (res == 200) { | |
Serial.println("Authentication IIUM successful"); | |
} | |
login.end(); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
HTTPClient http; | |
http.begin("https://iqfareez.com/api/hello"); | |
int res = http.GET(); | |
Serial.println(res); // status code | |
Serial.println(http.getString()); // API response | |
delay(2000); | |
} |
@Johanjj You can try to use MD5 library for Arduino to Hash your password first before sending to the server. Example library I've found on the internet: https://github.com/tzikis/ArduinoMD5
@Johanjj You can try to use MD5 library for Arduino to Hash your password first before sending to the server. Example library I've found on the internet: https://github.com/tzikis/ArduinoMD5
Apparently, it didn't work. I have checked web element code and looks like I should get/read hash md5 from JavaScript function.
Any idea how to read the value from this function before send with esp32 POST method?
@Johanjj Try inspect the webpage to see any JS file included. Then, perhaps you can the calcMD5 function. Then, try to port to cpp code for it to work with Arduino.
Example:
Edit:
Check this out:
@iqfareez Thank you for giving me sources and information.
Hi, can I have your email? I'd like to discuss via email if allowed.
Hi thank you for sharing this code, it's really help me to figuring out how captive portal works with esp32. I still have a problem when try to login because captive portal in my campus is using hash MD5 for security. Here my payload tab in login response

Can you help me to solve this?
Thank you