Follow us on Twitter!
It is the path of least resistance that makes rivers and men crooked. - Bj Palmer
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 26
Guests Online: 20
Members Online: 6

Registered Members: 82895
Newest Member: kevy90
Latest Articles
View Thread

HellBound Hackers | Computer General | Web hacking

Author

Request header parsing


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 07-09-08 02:31
Does anyone know a good way to get the request header details using javascript? I had a quick go with ajax and its xmlhttprequest class, but I couldnt get it to work for me. Its worth noting I want to read the request headers, not the response headers.

Id much prefer a simple javascript DOM affair, but other than document.cookie I cant seem to find one for the other request headers. The AJAX code im using now is:

Code

<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("HEAD", "<url>",true);
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) {
            alert(xmlhttp.getAllResponseHeaders());
            }
    }
xmlhttp.send(null)
</script>





Am I on the right track with AJAX, or am I gonna need something else?




Edited by on 07-09-08 02:32
Author

RE: Request header parsing


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 07-09-08 02:35
Ok, i found this on a site, not sure but worth a try
Code

<script language="JavaScript"><!--
var xmlhttp            = new ActiveXObject("Microsoft.XMLHTTP");
var dateSent         = null;
var dateComplete      = null;

function RetrieveHTTPHeaders(url)
{
   if (chkHEAD.checked)
      xmlhttp.open("HEAD", "http:\/\/" + url, true);         // Request just the header in an asynchronous call
   else
      xmlhttp.open("GET", "http:\/\/" + url, true);          // Request all in an asynchronous call
   
    xmlhttp.onreadystatechange = HandleState;
    xmlhttp.setRequestHeader("pragma", "nocache");
    dateSent = new Date();
    xmlhttp.send("");
}

function HandleState()
{

  var state = xmlhttp.readyState;
 
  if (state == 1)
  {
   btnSubmit.disabled = true;
   Status.innerText="";
   Result.innerText="";
   Body.innerText="";
   ResponseTime.innerText="";
  }
  else if (state == 4)
  {
   dateComplete = new Date();
    Status.innerText = xmlhttp.statusText + " (" + xmlhttp.status + ")";
    Result.innerText = xmlhttp.getAllResponseHeaders();
    Body.innerText = xmlhttp.responseText;
    ResponseTime.innerText = ((dateComplete.valueOf() - dateSent.valueOf())/1000) + " seconds";
   btnSubmit.disabled = false;   
  }
}
--></script>






And this is the site
http://www.whirlywiryweb.com/articles/getheaders.html


Author

RE: Request header parsing


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 07-09-08 08:36
Thanks for the reply, but im trying to actually understand this, not be a skid. Also,from my (very) limited knowledge of AJAX, that code doesnt do quite what I want, but it has some of the bits I was coding in it.


Author

RE: Request header parsing


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-09-08 12:01
Ok, does anyone know if it is at least possible to read request headers with JS?