Last active
January 27, 2020 20:52
Star
You must be signed in to star a gist
Dumping javascript window and navigator variables to screen and to file with PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); | |
//header('Access-Control-Allow-Origin: *'); | |
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS'); | |
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token'); | |
if(isset($_GET["navigator_info"])){ | |
$json_string = json_encode($_REQUEST); | |
$file_handle = fopen('navigator_info.json', 'w'); | |
fwrite($file_handle, $json_string); | |
fclose($file_handle); | |
} elseif(isset($_GET["window_info"])){ | |
$json_string = json_encode($_REQUEST); | |
$file_handle = fopen('window_info.json', 'w'); | |
fwrite($file_handle, $json_string); | |
fclose($file_handle); | |
} | |
?> | |
<body> | |
<script type="text/javascript"> | |
document.write("JAVASCRIPT WORKS <hr>"); | |
</script> | |
<script type="text/javascript"> | |
// window properties | |
var navigator_values = ""; | |
for (var property in navigator){ | |
var str = navigator[property]; | |
navigator_values += property + "=" + str + "&"; | |
} | |
document.write(navigator_values); | |
document.write("<hr>"); | |
if(document.location.href.indexOf("navigator_info") > -1){ | |
document.write("Found in URL"); | |
} else { | |
document.write("Not found in URL"); | |
//window.location.href = "http://192.168.1.152:8080/index.php?navigator_info&" + navigator_values; | |
//window.open("http://192.168.1.152:8080/index.php?navigator_info&" + navigator_values, true); | |
} | |
var xhttp = new XMLHttpRequest(); | |
xhttp.open("GET", "http://192.168.1.152:8080/index.php?navigator_info&" + navigator_values, true); | |
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
xhttp.send(); | |
</script> | |
<script type="text/javascript"> | |
// window properties | |
var window_values = ""; | |
for (var property in window){ | |
var str = window[property]; | |
window_values += property + "=" + str + "&"; | |
} | |
document.write(window_values); | |
document.write("<hr>"); | |
if(document.location.href.indexOf("window_info") > -1){ | |
document.write("Found in URL"); | |
} else { | |
document.write("Not found in URL"); | |
//window.location.href = "http://192.168.1.152:8080/index.php?navigator_info&" + window_values; | |
//window.open("http://192.168.1.152:8080/index.php?navigator_info&" + window_values, true); | |
} | |
var xhttp = new XMLHttpRequest(); | |
xhttp.open("GET", "http://192.168.1.152:8080/index.php?window_info&" + window_values, true); | |
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
xhttp.send(); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment