Advertisement
Sweetening

hexdump powershell.ps1

Nov 24th, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. # Import required modules
  2. Import-Module Net.Sockets
  3. Import-Module System.Net.NetworkInformation
  4.  
  5. # Define the target website URL
  6. $url = "https://www.example.com/"
  7.  
  8. # Create a new TCP socket connection
  9. $tcpClient = New-Object System.Net.Sockets.TcpClient($url.Host, 80)
  10.  
  11. # Send an HTTP GET request to the target website
  12. $request = "GET / HTTP/1.1\r\nHost: $url.Host\r\nConnection: close\r\n\r\n"
  13. $tcpClient.GetStream().Write($request.ToCharArray(), 0, $request.Length)
  14.  
  15. # Read the server's response headers
  16. $headers = ""
  17. while ($true) {
  18. $line = $tcpClient.GetStream().ReadLine()
  19. if ($line -eq "") {
  20. break
  21. }
  22.  
  23. $headers += $line + "\r\n"
  24. }
  25.  
  26. # Close the TCP socket connection
  27. $tcpClient.Close()
  28.  
  29. # Convert headers to byte array
  30. $headersByteArray = [System.Text.Encoding]::UTF8.GetBytes($headers)
  31.  
  32. # Hex dump the headers
  33. $headersHexDump = Format-Hex -InputObject $headersByteArray
  34.  
  35. # Display the hex dump of the website's headers
  36. Write-Host "Headers hex dump:"
  37. Write-Host $headersHexDump
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement