![]() |
An Introduction to HTTP fingerprinting |
Saumil Shah
saumil@net-square.com
15th June, 2003
HTTP Fingerprinting is a relatively new topic of discussion in the context of application security. One of the biggest challenges of maintaining a high level of network security is to have a complete and accurate inventory of networked assets. Web servers and web applications have now become a part of the scope of a network security assessment exercise. In this paper, we present techniques to identify various types of HTTP servers. We shall discuss some of the problems faced in inventorying HTTP servers and how we can overcome them.
A fingerprint is defined as:
The process of fingerprinting can be broken up into two sub processes, namely gathering and classification of fingerprints, and comparision of unknown fingerprints with the stored database of known fingerprints.
While gathering fingerprints, it is essential to capture all the key characteristics of the object revealed in the fingerprint. Capturing more details and traits helps in the comparision process. While comparing fingerprints, there may be chances that a fingerprint can be improperly matched, because of subtle differences that can be easily mistaken.
Fingerprinting is a known technique in network security. Operating system fingerprinting is a common task in any network assessment or inventorying exercise. There are many techniques to perform operating system fingerprinting. What makes operating system fingerprinting successful and accurate is the fact that each operating system implements the TCP/IP stack slightly differently. The way a system responds to malformed packets, either the presence of an error response, or absence thereof, is one example of an implementation difference. A detailed discussion on operating system fingerprinting, or TCP/IP stack fingerprinting, is presented in Fyodor's paper, titled "Remote OS detection via TCP/IP Stack Fingerprinting" [1]
The theory behind HTTP fingerprinting is more or less on the same lines - identifying HTTP servers by their implementation differences in the HTTP protocol. HTTP fingerprinting gets slightly more complicated than TCP/IP stack fingerprinting. The reason being that it is easily possible to customize the responses of an HTTP server by just changing its configuration file, or adding plug-ins or modules, whereas customizing the behaviour of the TCP/IP stack requires access to the network code at the kernel layer. Despite this difficulty, it is possible to devise tests to overcome the various customizable features of a web server.
The simplest and most basic form of identifying HTTP servers is to look at the Server field in the HTTP response header [2]. Using a TCP client like netcat [3], it is possible to send an HTTP request to return the HTTP response header of the server, as shown below:
$ nc 202.41.76.251 80 HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Mon, 16 Jun 2003 02:53:29 GMT Server: Apache/1.3.3 (Unix) (Red Hat/Linux) Last-Modified: Wed, 07 Oct 1998 11:18:14 GMT ETag: "1813-49b-361b4df6" Accept-Ranges: bytes Content-Length: 1179 Connection: close Content-Type: text/html $
Three examples of the HTTP response header are shown below:
From an Apache 1.3.23 server:
HTTP/1.1 200 OK Date: Sun, 15 Jun 2003 17:10:49 GMT Server: Apache/1.3.23 Last-Modified: Thu, 27 Feb 2003 03:48:19 GMT ETag: "32417-c4-3e5d8a83" Accept-Ranges: bytes Content-Length: 196 Connection: close Content-Type: text/html
From a Microsoft IIS 5.0 server:
HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Expires: Tue, 17 Jun 2003 01:41:33 GMT Date: Mon, 16 Jun 2003 01:41:33 GMT Content-Type: text/html Accept-Ranges: bytes Last-Modified: Wed, 28 May 2003 15:32:21 GMT ETag: "b0aac0542e25c31:89d" Content-Length: 7369
From a Netscape Enterprise 4.1 server:
HTTP/1.1 200 OK Server: Netscape-Enterprise/4.1 Date: Mon, 16 Jun 2003 06:19:04 GMT Content-type: text/html Last-modified: Wed, 31 Jul 2002 15:37:56 GMT Content-length: 57 Accept-ranges: bytes Connection: close
From a network management standpoint, HTTP fingerprinting comes in very handy when keeping track of the various web servers on a network. HTTP fingerprinting can also be used to automate information systems and security audits. Automated security testing tools can use HTTP fingerprinting to narrow down the set of tests required, based on the specific platform or the specific web server being audited.
Banner grabbing proves to be a good method of HTTP fingerprinting in many cases. However, many times, server administrators chose to disguise the server banner string, by providing one of their own. Such, "security-by-obscurity" methods help thwart a lot of automated attacks against web servers.
It is easy to configure servers to return different server banner strings. In open source servers such as Apache, one can change the banner string in the source code and re-compile the server. For non-open source servers such as Microsoft IIS or Netscape Enterprise, it is possible to "patch" the binary by opening it up in a hex editor and changing the string embedded in the binary. It is not so easy to do this always, but it has been done successfully. Another way of obscuring the server banner string is to write a custom plug-in for the web server, which can provide customized HTTP responses. A commercial product, called ServerMask [4] from Port 80 Software performs such obfuscation on HTTP responses.
The example below shows the response from an HTTP server with a customized server banner string:
Apache Server recompiled with "Unknown-Webserver/1.0" as the server banner string
HTTP/1.1 403 Forbidden Date: Mon, 16 Jun 2003 02:41:27 GMT Server: Unknown-Webserver/1.0 Connection: close Content-Type: text/html; charset=iso-8859-1
The example below shows the response from an HTTP server using ServerMask:
IIS Server using the ServerMask plug-in
HTTP/1.1 200 OK Server: Yes we are using ServerMask Date: Mon, 16 Jun 2003 02:54:17 GMT Connection: Keep-Alive Content-Length: 18273 Content-Type: text/html Set-Cookie: It works on cookies too=82.3S3.O12.NT2R0RE,4147ON3P,.4OO.; path=/ Cache-control: private
As we can see from the above examples, relying purely upon the contents of the server banner string is not enough for identifying the type of HTTP server.
Almost all HTTP servers differ in the way they implement the HTTP protocol. In the case where the HTTP request is well formed and legitimate, the response returned by all HTTP servers is more or less compliant with the specifications laid out in the RFCs for HTTP[5]. However, when confronted with malformed HTTP requests, these servers differ in their responses. Differences in the way the HTTP protocol is handled by various HTTP servers forms the basis of the HTTP fingerprinting technique.
Let us illustrate these differences with examples. We shall analyze the response to four HTTP requests, coming from an Apache 1.3.23 server, a Microsoft IIS 5.0 server and a Netscape Enterprise 4.1. The requests are:
HTTP Test | What to expect |
---|---|
HEAD / HTTP/1.0 |
Normal HTTP header response |
DELETE / HTTP/1.0 |
Response when operations such as DELETE aren't generally allowed |
GET / HTTP/3.0 |
Response to a request with an improper HTTP protocol number |
GET / JUNK/1.0 |
Response to a request with an improper protocol specification |
In each of these responses, we shall identify key differences between the responses of Apache 1.3.23, IIS 5.0 and Netscape Enterprise 4.1. We shall not take into consideration differences in customizable parameters such as the server banner string.
Taking the first request HEAD / HTTP/1.0, we shall analyze the HTTP response header and inspect the order of appearance of the various fields returned within it.
Response from Apache 1.3.23
$ nc apache.example.com 80 HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Sun, 15 Jun 2003 17:10:49 GMT Server: Apache/1.3.23 Last-Modified: Thu, 27 Feb 2003 03:48:19 GMT ETag: "32417-c4-3e5d8a83" Accept-Ranges: bytes Content-Length: 196 Connection: close Content-Type: text/html
Response from IIS 5.0
$ nc iis.example.com 80 HEAD / HTTP/1.0 HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Content-Location: http://iis.example.com/Default.htm Date: Fri, 01 Jan 1999 20:13:52 GMT Content-Type: text/html Accept-Ranges: bytes Last-Modified: Fri, 01 Jan 1999 20:13:52 GMT ETag: W/"e0d362a4c335be1:ae1" Content-Length: 133
Response from Netscape Enterprise 4.1
$ nc netscape.example.com 80 HEAD / HTTP/1.0 HTTP/1.1 200 OK Server: Netscape-Enterprise/4.1 Date: Mon, 16 Jun 2003 06:01:40 GMT Content-type: text/html Last-modified: Wed, 31 Jul 2002 15:37:56 GMT Content-length: 57 Accept-ranges: bytes Connection: close
If we observe the ordering of the response header fields Server and Date, we notice that Apache orders the fields differently than IIS and Netscape.
Next, we shall take the request DELETE / HTTP/1.0 and observe what the response of each of the servers is, when the requested operation is generally forbidden.
Response from Apache 1.3.23
$ nc apache.example.com 80 DELETE / HTTP/1.0 HTTP/1.1 405 Method Not Allowed Date: Sun, 15 Jun 2003 17:11:37 GMT Server: Apache/1.3.23 Allow: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, TRACE Connection: close Content-Type: text/html; charset=iso-8859-1
Response from IIS 5.0
$ nc iis.example.com 80 DELETE / HTTP/1.0 HTTP/1.1 403 Forbidden Server: Microsoft-IIS/5.0 Date: Fri, 01 Jan 1999 20:13:57 GMT Content-Type: text/html Content-Length: 3184
Response from Netscape Enterprise 4.1
$ nc netscape.example.com 80 DELETE / HTTP/1.0 HTTP/1.1 401 Unauthorized Server: Netscape-Enterprise/4.1 Date: Mon, 16 Jun 2003 06:03:18 GMT WWW-authenticate: Basic realm="WebServer Server" Content-length: 223 Content-type: text/html Connection: close
Apache responds with a 405 "Method not allowed" response, IIS responds with a 403 "Operation on resource forbidden" response, and Netscape responds with a 401 "Authorization credentials required" response. Each of the servers differs in their response to the DELETE request.
The next test consists of sending an HTTP request with an improper HTTP version number, such as GET / HTTP/3.0, to the server. HTTP 3.0 is not even in existence as of this writing, and none of the candidate servers implement it.
Response from Apache 1.3.23
$ nc apache.example.com 80 GET / HTTP/3.0 HTTP/1.1 400 Bad Request Date: Sun, 15 Jun 2003 17:12:37 GMT Server: Apache/1.3.23 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1
Response from IIS 5.0
$ nc iis.example.com 80 GET / HTTP/3.0 HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Content-Location: http://iis.example.com/Default.htm Date: Fri, 01 Jan 1999 20:14:02 GMT Content-Type: text/html Accept-Ranges: bytes Last-Modified: Fri, 01 Jan 1999 20:14:02 GMT ETag: W/"e0d362a4c335be1:ae1" Content-Length: 133
Response from Netscape Enterprise 4.1
$ nc netscape.example.com 80 GET / HTTP/3.0 HTTP/1.1 505 HTTP Version Not Supported Server: Netscape-Enterprise/4.1 Date: Mon, 16 Jun 2003 06:04:04 GMT Content-length: 140 Content-type: text/html Connection: close
Apache responds with a 400 "Bad HTTP request" response, IIS ignores the improper HTTP protocol number, and responds with a 200 "OK" along with the contents of the HTML data for the root document, and Netscape responds with a 505 "HTTP version not supported" response.
The next test involves observing the response to the request GET / JUNK/1.0.
Response from Apache 1.3.23
$ nc apache.example.com 80 GET / JUNK/1.0 HTTP/1.1 200 OK Date: Sun, 15 Jun 2003 17:17:47 GMT Server: Apache/1.3.23 Last-Modified: Thu, 27 Feb 2003 03:48:19 GMT ETag: "32417-c4-3e5d8a83" Accept-Ranges: bytes Content-Length: 196 Connection: close Content-Type: text/html
Response from IIS 5.0
$ nc iis.example.com 80 GET / JUNK/1.0 HTTP/1.1 400 Bad Request Server: Microsoft-IIS/5.0 Date: Fri, 01 Jan 1999 20:14:34 GMT Content-Type: text/html Content-Length: 87
Response from Netscape Enterprise 4.1
$ nc netscape.example.com 80 GET / JUNK/1.0 <HTML><HEAD><TITLE>Bad request</TITLE></HEAD> <BODY><H1>Bad request</H1> Your browser sent a query this server could not understand. </BODY></HTML>
In this case, Apache ignores the improper protocol "JUNK", and responds with a 200 "OK" along with the contents of the root document, IIS responds with a 400 "Bad Request" response and Netscape does not even return an HTTP response header, but instead just returns an HTML formatted error message stating that this request is a bad request.
The following table summarizes the various tests and the responses from each of the HTTP servers. It is easy to figure out how to distinguish HTTP servers from such tests.
Server | Field Ordering | DELETE Method | Improper HTTP version | Improper protocol |
---|---|---|---|---|
Apache/1.3.23 | Date, Server | 405 | 400 | 200 |
Microsoft-IIS/5.0 | Server, Date | 403 | 200 | 400 |
Netscape-Enterprise/4.1 | Server, Date | 401 | 505 | no header |
In the above example, we discussed four HTTP tests, and observed the differences in the responses from three popular HTTP servers. For an industrial strength HTTP fingerprinting engine, we require more than four HTTP tests. The larger the number of HTTP tests, the better the results of fingerprinting, and the greater the accuracy in matching fingerprints. On the other hand, fewer HTTP tests imply faster execution time.
Fingerprinting tests are of two types
Decision tree based tests rely on the construction of a tree of tests, which eliminates possibilities progressively, much in the same manner as testing for an unknown chemical compound, based on the results of progressive chemical reaction tests. Decision tree based tests are difficult to scale, and each HTTP server would have specific contributions to the construction of the decision tree. Adding tests for a new HTTP server would involve re-writing the entire decision tree.
Statistical analysis tests usually involve a fixed set of tests, which result in an array of weights being generated for each type of HTTP server. The decision as to what the outcome is, is based on comparing the various weights generated for each server. The accuracy of statistical analysis tests depends on the algorithms used to assign and compare the weights for each HTTP server. Statistical based models yield themselves quite easily to be adapted into neural machines, which can be trained with a set of known values.
The HTTPRINT [6] fingerprinting engine uses statistical analysis, combined with fuzzy logic techniques, to determine the type of HTTP server.
HTTPRINT can be used to both gather as well as analyze signatures generated from HTTP servers. HTTP signatures generated by HTTPRINT are hexadecimal encoded ASCII strings, as the ones shown below:
Microsoft-IIS/5.0 CD2698FD6ED3C295E4B1653082C10D64811C9DC594DF1BD04276E4BB811C9DC5 0D7645B5811C9DC52A200B4C9D69031D6014C217811C9DC5811C9DC52655F350 FCCC535BE2CE6923E2CE6923F2454256E2CE69272576B769E2CE6926CD2698FD 6ED3C295E2CE692009DB9B3E6ED3C2956ED3C2956ED3C2956ED3C295E2CE6923 6ED3C295 Apache/1.3.x 9E431BC86ED3C295811C9DC5811C9DC5050C5D32505FCFE84276E4BB630A04DB 0D7645B5970EE6BB811C9DC5CD37187C11DDC7D78398721EB06FE5D78A91CF57 FCCC535B6ED3C295FCCC535B811C9DC5E2CE69272576B769E2CE69269E431BC8 6ED3C295E2CE69262A200B4C811C9DC5811C9DC5811C9DC5811C9DC5811C9DC5 811C9DC5
HTTPRINT maintains a set of signatures in a text file, and uses these to analyze the results generated from an unknown server. It is easily possible to extend the signatures database, by simply cutting-and-pasting the signature output of HTTPRINT, when used against a known server whose fingerprint is not in the database. The next time HTTPRINT is run, the signature will be used to compare against.
An example of the output generated by HTTPRINT is shown below:
$ ./httprint unknown.example.com Reported signature: Netscape-Enterprise/6.1 AOL 811C9DC5FCCC535A811C9DC5811C9DC5811C9DC594DF1BD04276E4BB811C9DC5 7FC8D095811C9DC5811C9DC54D0ACB9C11DDC7D7811C9DC51F3B8C162655F350 FCCC535B811C9DC5FCCC535B811C9DC5E2CE69272576B769E2CE6926811C9DC5 E2CE6927FCCC535A811C9DC5811C9DC5811C9DC56ED3C2956ED3C295E2CE6923 E2CE6923 Best Match: Netscape-Enterprise/6.1 AOL Weights: Microsoft-IIS/4.0: 30 Microsoft-IIS/5.0: 55 Microsoft-IIS/5.1: 55 Microsoft-IIS/6.0: 65 Netscape-Enterprise/6.0: 50 Netscape-Enterprise/6.1 AOL: 86 Netscape-FastTrack/4.1: 63 Netscape-Enterprise/4.0: 45 Netscape-Enterprise/4.1: 61 Netscape-Enterprise/3.6: 43 Apache/2.0.x: 23 Apache/1.3.27: 31 Apache/1.3.26: 30 Apache/1.3.x: 31 Apache/1.2.6: 31 Zeus/4.0: 45 Zeus/4.1: 46 Zeus/4_2: 53 Lotus-Domino/5.0.x: 12 Microsoft-IIS/URLScan: 31 Stronghold/4.0-Apache/1.3.x: 28 Stronghold/2.4.2-Apache/1.3.x: 16 AOLserver/3.4.2-3.5.1: 13 Jana Server/1.45: 21 Xerver_v3: 11 RemotelyAnywhere: 0 MiniServ/0.01: 10
In the above example, HTTPRINT first displays the signature it generates from the server "unknown.example.com". It then proceeds to compare the signature with those stored in its database, and assigns weights for every fingerprint. The weight with the highest value is chosen to be the best match. In this case, it is "Netscape-Enterprise/6.1 AOL" server.
HTTPRINT is available in both command-line and GUI versions, running on Windows, Linux and Mac OS X for this release. The screenshot of the GUI version is shown below:
HTTPRINT generates reports in HTML format, along with some verbose output results embedded as HTML comments, which may be useful for further analysis. A sample report is shown below:
HTTPRINT uses ASCII text files for storing server signatures. It is possible to extend HTTPRINT's set of signatures, for covering a wider variety of web servers, by simply running HTTPRINT against the unknown server, and then including the generated signature in the signatures file. For reporting, it is also possible to associate GIF files having server icons with each signature, which will be then used when generating the HTML report.
Although HTTPRINT is not open source, it is available at no cost for personal, educational and non-commercial use.
The technique of system fingerprinting is not yet as foolproof as human fingerprinting. It is possible to disguise and customize HTTP servers quite sufficiently to ensure that they give unexpected results for all HTTP tests. One such product on the market is ServerMask [4], which is a plug-in to Microsoft IIS servers. ServerMask not only obfuscates the server banner string, but also re-arranges the HTTP response header field order, to mimic servers like Apache, obscures internal server generated cookies, and even has the ability to pose as a random HTTP server for every HTTP request.
However, ServerMask can yet be defeated by fingerprinting engines like HTTPRINT, which use fuzzy logic analysis on the test results, as shown in the example below:
$ ./httprint unknown.example.com Reported signature: Protected by ServerMask CD2698FD6ED3C295811C9DC5811C9DC5811C9DC594DF1BD04276E4BB811C9DC5 0D7645B5811C9DC5811C9DC59D69031D6014C217811C9DC5811C9DC580FF2CD2 FCCC535BE2CE6923E2CE6923811C9DC5E2CE69272576B769E2CE69262CEAB43E 6ED3C295FCCC535B811C9DC56ED3C2956ED3C2956ED3C2956ED3C295E2CE6923 6ED3C295 Best Match: Microsoft-IIS/5.0,Microsoft-IIS/5.1 Weights: Microsoft-IIS/4.0: 86 Microsoft-IIS/5.0: 101 Microsoft-IIS/5.1: 101 Microsoft-IIS/6.0: 56 Netscape-Enterprise/6.0: 29 Netscape-Enterprise/6.1 AOL: 55 Netscape-FastTrack/4.1: 32 Netscape-Enterprise/4.0: 21 Netscape-Enterprise/4.1: 32 Netscape-Enterprise/3.6: 32 Apache/2.0.x: 26 Apache/1.3.27: 35 Apache/1.3.26: 36 Apache/1.3.x: 34 Apache/1.2.6: 34 Zeus/4.0: 24 Zeus/4.1: 25 Zeus/4_2: 32 Lotus-Domino/5.0.x: 12 Microsoft-IIS/URLScan: 61 Stronghold/4.0-Apache/1.3.x: 19 Stronghold/2.4.2-Apache/1.3.x: 18 AOLserver/3.4.2-3.5.1: 11 Jana Server/1.45: 14 Xerver_v3: 13 RemotelyAnywhere: 0 MiniServ/0.01: 15
Here, even though the server's responses were obfuscated by ServerMask, HTTPRINT still accurately identifies it as a Microsoft-IIS/5.0 or 5.1 web server.
This paper was meant to serve as an introduction to HTTP fingerprinting, and has provided an overview of some of the techniques used. HTTP fingerprinting can be also extended to various other areas of research, such as fingerprinting applications running on HTTP, embedded devices that run an HTTP interface, etc.
[1]
http://www.insecure.org/nmap/nmap-fingerprinting-article.html
[2]
Section 6.2 of RFC 2616 http://www.ietf.org/rfc/rfc2616.txt
[3]
Netcat for Unix http://www.atstake.com/research/tools/network_utilities/nc110.tgz, Netcat for Windows http://www.atstake.com/research/tools/network_utilities/nc11nt.zip
[4]
http://www.port80software.com/products/servermask/
[5]
HTTP/1.1 RFC 2616 http://www.ietf.org/rfc/rfc2616.txt
[6]
HTTPRINT from Net-Square http://net-square.com/httprint/
revised 30/07/03 - saumil
|