Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import required modules
- Import-Module Net.Sockets
- Import-Module System.Net.NetworkInformation
- # Define the target website URL
- $url = "https://www.example.com/"
- # Create a new TCP socket connection
- $tcpClient = New-Object System.Net.Sockets.TcpClient($url.Host, 80)
- # Send an HTTP GET request to the target website
- $request = "GET / HTTP/1.1\r\nHost: $url.Host\r\nConnection: close\r\n\r\n"
- $tcpClient.GetStream().Write($request.ToCharArray(), 0, $request.Length)
- # Read the server's response headers
- $headers = ""
- while ($true) {
- $line = $tcpClient.GetStream().ReadLine()
- if ($line -eq "") {
- break
- }
- $headers += $line + "\r\n"
- }
- # Close the TCP socket connection
- $tcpClient.Close()
- # Convert headers to byte array
- $headersByteArray = [System.Text.Encoding]::UTF8.GetBytes($headers)
- # Hex dump the headers
- $headersHexDump = Format-Hex -InputObject $headersByteArray
- # Display the hex dump of the website's headers
- Write-Host "Headers hex dump:"
- Write-Host $headersHexDump
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement