Skip to content

Instantly share code, notes, and snippets.

@erm3nda
Last active January 27, 2020 20:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save erm3nda/8a50b285d355a8bdbe8cbdcf5a7a07a5 to your computer and use it in GitHub Desktop.
Dumping javascript window and navigator variables to screen and to file with PHP
<?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