Curl

From Omnia
Revision as of 00:46, 1 June 2026 by Kenneth (talk | contribs) (→‎Connect to server by ip and pass hostname)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Return status code only

curl -s -o /dev/null -w "%{http_code}" google.com
curl -s -o /dev/null -i -w "%{http_code}" google.com
curl -s -o /dev/null -I -w "%{http_code}" google.com
curl -s -o /dev/null -I -w "%{http_code}\n" google.com

ref: [1]

Return fail status code

curl --fail http://some-url.com
echo $?
-f, --fail (HTTP) Fail silently (no output at all) on server errors

Connect to server by ip and pass hostname

Option #1:

  • Add to C:\windows\system32\drivers\etc\hosts

Option #2: (will convert connection of example.com to altexample.com) [2]

curl --connect-to example.com:80:altexample.com:80 http://example.com
# shorthand:
curl --connect-to ::altexample.com http://example.com
curl --connect-to ::altexample.com:8080 http://example.com

Option #3:

curl --resolve <host:port:address> <URL>
 host: The hostname you want to use in the request.
 port: The port number for the connection.
 address: The IP address you want to connect to.
 URL: The URL you want to request, using the specified hostname.
curl --resolve example.com:443:192.168.1.100 https://example.com
"This command will send a request to the IP address 192.168.1.100, but it will include example.com in the Host header, which is crucial for virtual hosting and TLS/SSL certificate validation."

Option #4: (this does not seem to work??)

curl [IP] -k -H 'Host: example.com'

Ignore SSL Revocation Check

C:\> curl -v -I https://github.com/
* Host github.com:443 was resolved.
* IPv6: (none)
* IPv4: 140.82.116.4
*   Trying 140.82.116.4:443...
* schannel: disabled automatic use of client certificate
* ALPN: curl offers http/1.1
* schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.
* closing connection #0
curl: (35) schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.

Option #1 - brute force (Insecure):

curl ---k -v -I https://github.com/

Option #2 - no revoke check (more secure):

curl --ssl-no-revoke -v -I https://github.com/

Option #3 - best effort revoke check (best attempt secure):

curl --ssl-revoke-best-effort -v -I https://github.com/

keywords