Skip to content

Instantly share code, notes, and snippets.

@protosam
Created May 17, 2023 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save protosam/3fc5e2aecae30b9b2adde8b28b60ee63 to your computer and use it in GitHub Desktop.
Save protosam/3fc5e2aecae30b9b2adde8b28b60ee63 to your computer and use it in GitHub Desktop.

Bash can connect to stuff without the need for curl or nc.

exec 3<> /dev/tcp/google.com/80
echo -e 'GET / HTTP/1.1\r\nhost: www.google.com\r\nConnection: close\r\n\r\n' >&3
cat <&3

# result: 
# HTTP/1.1 200 OK
# Expires: -1
# Cache-Control: private, max-age=0
# Content-Type: text/html; charset=ISO-8859-1
# X-Frame-Options: SAMEORIGIN
# Accept-Ranges: none
# Vary: Accept-Encoding
# Connection: close
# Transfer-Encoding: chunked
# ...

If you're using Mac OS, this doesn't work in zsh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment