The Server Fingerprinter is a Java application designed to retrieve and present key technical information about a specified target website's server and its associated SSL certificate. By establishing a secure connection to the target server and utilizing HTTPS protocols, the program extracts a range of details, including server-related information, IP address allocation, SSL certificate specifications, and more! It helps users make informed decisions about visiting websites and trusting them, especially relevant in the age of data theft. However, it is important to note that this program is built for educational purposes and trusts all certificates.
-
Default HTTP Headers Configuration:
- The application starts by setting up a default collection of HTTP headers, comprising standard values like User-Agent, Accept-Language, Accept-Charset, and Connection.
- These headers are essential for establishing communications with the server.
-
User Input and URL Parsing:
- The user is asked to input the URL of the target website.
- The user given URL is parsed to extract the hostname and (in some cases) the port number. If no port number is provided- we use the HTTPS protocol by default!
-
SSL Context and Trust Management Configuration:
- An SSL context is established, incorporating a custom trust manager that accepts all certificates. It's still pretty rudimentary and accepts faked certificates.
-
Connection Establishment:
- Using the provided URL, an HTTPS connection is established with the target server.
- The default SSL socket factory and the customized trust manager are associated with the connection, ensuring SSL handling.
-
Setting HTTP Headers:
- The predefined default headers are added to the connection request.
- These headers provide essential information to the server and contribute to a seamless connection.
-
Connection and Response Handling:
- A GET request is sent to the server to retrieve the response.
- The response headers and the content body are extracted for further processing.
- If "Set-Cookie" headers are present, they are displayed to show any cookies provided by the server.
-
Server Information Extraction:
- Details about the server are extracted from the response headers. This includes the server header, content type, content length, and keywords found within the response body.
-
IP Address Allocation:
- The program obtains IP address allocations associated with the target URL by performing a DNS lookup.
- The retrieved IP addresses are presented for informational purposes.
-
SSL Certificate Information Retrieval:
- Another connection to the target server is established using the HEAD method, specifically to retrieve the SSL certificate information.
- The program extracts various details from the SSL certificate, such as the subject, issuer, serial number, validity period, and expiration status.
-
Certificate Expiration Check:
- A function is employed to evaluate whether the SSL certificate has expired.
- The certificate's "notAfter" date is compared with the current date to ascertain its validity.
- Depending on the result, an appropriate message is displayed indicating whether the certificate is expired or valid.
- Compile!: Compile the Java code using an appropriate compiler. I use BlueJ.
- Execute!: Run the compiled program.
- Input!: Provide the target URL when prompted.
- Results!: The application will display comprehensive information about the server, IP address allocation, SSL certificate, and its validity status.
This code employs a custom trust manager that trusts all certificates. While useful for educational purposes and exploring server details, this configuration is not recommended for the real world.