Awesome
SharpPageGrab
A .NET utility to make web requests, similar to curl. It can be run from a PowerShell session, command prompt, or in-memory using the execute-assembly command of C2 frameworks such as Cobalt Strike or Mythic's Apollo.
Some potential use cases are:
- Checking external Internet or internal website connectivity without needing to set up a SOCKS proxy
- Getting or posting data to a REST API
- Checking SSL/TLS certificate information
It was originally released as part of SharpUtils, but this version was split off because the SSL/TLS checking code requires .NET Framework 4.6 to function properly.
Usage
You can specify:
- The HTTP method using
-m <method>
- A proxy server/port using
-p http(s)://<proxy>:<proxy_port>
- POST request data, if applicable, using
-d <URL_encoded_data>
- An arbitrary number of custom headers using
-h <name> <value>
- Headers must be specified in space-separated key-value pairs
- Headers are case sensitive and will be sent exactly the way they are specified on the command-line
Date
,Host
, andIf-Modified-Since
are set automatically by .NET and cannot be overridden- If no
User-Agent
is specified, the program will attempt to construct a user-agent with the Edge version read from the registry- This is not perfect since the current version of Edge will not match the Chrome version, but it's probably better than sending no user-agent
The -c
flag displays info about the SSL / TLS certificate. The -v
flag causes the HTML contents of the page to be printed; if omitted, only the response headers will be shown.
pagegrab.exe [-p http(s)://<proxy>:<proxy_port>] [-m <method>] [-d <URL encoded POST data>] [-h <header_1_name> <header_1_value> [-h <header_2_name> <header_2_value>]] [-c] [-v] <URL> [/?]
-c Display the SSL / TLS certificate
-v Print the HTML contents of the response
Examples
pagegrab.exe https://google.com -h User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36 Edg/89.0.774.75"
GET https://example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36 Edg/89.0.774.75
pagegrab.exe https://example.com -h Referer https://www.google.com -h DNT 1 -h Cache-Control no-cache
GET https://example.com
Proxy: None
Referer: https://www.google.com
DNT: 1
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36 Edg/92.0.902.67
.\SharpPageGrab.exe -c https://microsoft.com
REQUEST
---------------
GET https://microsoft.com/
Proxy: None
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.1774.42 Safari/537.36 Edg/113.0.1774.42
RESPONSE
---------------
Status: OK
Connection: keep-alive
Accept-Ranges: bytes
Content-Length: 1020
Content-Type: text/html
Date: Sat, 13 May 2023 23:31:40 GMT
ETag: "6082151bd56ea922e1357f5896a90d0a:1425454794"
Last-Modified: Wed, 04 Mar 2015 07:39:54 GMT
Server: AkamaiNetStorage
SSL / TLS Certificate
---------------------
Subject: CN=www.microsoft.com, O=Microsoft Corporation, L=Redmond, S=WA, C=US
Issuer: CN=Microsoft Azure TLS Issuing CA 06, O=Microsoft Corporation, C=US
Valid From: 10/4/2022 19:23:11 PM
Valid To: 9/29/2023 19:23:11 PM
Serial Number: 330059F8B6DA8689706FFA1BD900000059F8B6
SHA-1 Fingerprint: 2D6E2AE5B36F22076A197D50009DEE66396AA99C
Public Key: 3082010A0282010100B75F23136D6F9BFA84D14648ABA448EC1FF2621760ECCBC4A3286B824F949208EEAA7C36ADCDB505CEF327ED3145032384590863A79BE902EDF3653BBD8DE7B3B975C9C75FB6132D7956764957743BF33C0927FDF24DB8977F386A616AF7D4D9B76E81732995991990C7818EDEA40758C2539D2D09384111E6DDA24D38958281CD69AD277F5E03FEABDB183A7018551BFDB46B64CE74D7E90692F368D68C31FCCC78B6F7D2BC610A64D5AA29853049022B6BA66045487BC3830329BABA71D2B8C0BEAD50DBB9930161B4ECB31DEC9EE7C99885CD4C661430EADA2C76DB4C8F1262FEC25CF5752AB035A2198BB7FAED0F5A4391A713403920FB4AD1E629D406EF0203010001
Certificate PEM:
----BEGIN CERTIFICATE----
MIII1jCCBr6gAwIBAgITMwBZ+Lbaholwb/ob2QAAAFn4tjANBgkqhkiG9w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