10

I would like to find an easy way to find out what headers are visible on my websites. For example PHP version, server etc.

I've looked around and can't seem to find a good explanation on the subject for a novice like myself. So what's the easiest way to get all the headers a hacker could use against me? Would prefer to see it in the browser without downloading an external program for this, but it seems necessary from what I've seen sofar.

Could anyone point me in the right direction?

3 Answers 3

12

You're probably using one of the possible tools right now. Both Firefox and Chrome have developer tools that allow you to see both the request and response headers for any request that is made.

In Firefox go to Tools -> Web Developer -> Network and then make a new request by clicking on a link or refreshing the page.

In Chrome, go to the menu -> Tools -> Developer Tools and choose the Network tab and then make a new request by clicking on a link or refreshing the page.

To see the headers for a request in either browser, just click on the request in the list in the developer tools.

0
6

Sure, browsers work, but I think they're a bit overkill for this task. My favorite method is using the curl command line utility, which is available on almost all Unix-like systems. Use the -I flag, which tells curl to make an HTTP HEAD request and print just the headers:

$> curl -I http://example.com/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Thu, 31 Oct 2013 15:49:18 GMT
Etag: "359670651"
Expires: Thu, 07 Nov 2013 15:49:18 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (sea/55ED)
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 1270

Note that using the -I flag makes an HTTP HEAD request; the server should send you the same headers you would have received had you made an HTTP GET request, but a misconfigured or buggy one may not (I've only encountered this once). If you suspect that's the case, use the -i flag (lowercase instead of uppercase), which will do a GET request and print the headers followed by the body of the response. You'll also need to use the -i flag if you need to do another type of HTTP request, such as POST.

1
  • Remember that a HEAD request against a PHP script executes the script as if it was a GET request. Unless the script itself intercepts the HEAD request, which is rare. But if it actually did that, you might actually get different headers compared to a normal GET or POST request. So for the OP's objective of knowing what his script is actually sending, I'd recommend curl -v -o tmp.html http://example.com/ (The html file gets saved in tmp.html, and you just gets to see headers sent and received.) Nov 4, 2013 at 23:52
2

when curl is not available, but telnet:

$ telnet host 80
  HEAD / HTTP/1.0

  (<-2 newlines) 


  HTTP/1.1 302 Moved Temporarily
  Server: nginx
  Date: Wed, 06 Nov 2013 07:16:23 GMT
  Content-Type: text/html
  Content-Length: 154
  Connection: close
  Location: http://blah.org/
  X-Frame-Options: SAMEORIGIN

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .