TIL: You can make HTTP requests without curl using Bash /dev/TCP
111–120 of 255 posts
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#112Using /dev/tcp was also handy in getting that initial low-priv shell.
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#113Earlier quoted context omitted.
Why wouldn’t you use curl for the quick test?
Sometimes you want to do something that curl cannot express, e.g. timing, protocol oddities, etc. For example you may want to issue a CONNECT to an echo server through a proxy and observe the bytes flowing back and forth. You may want to see what happens when conflicting hop-by-hop headers are specified without worrying about the client's (curl's) interpretation of them. A simple nc -c (or openssl s_client -crlf) let…
export http_proxy=http://your.proxy.server:port/
export HTTPS_PROXY=https://your.proxy.server:port/
curl -x http://proxy_server:proxy_port --proxy-user username:password
or $socks-wrapper curl # [2]
[1] - https://dev.to/gbhorwood/curl-getting-performance-data-with-...[2] - torsocks, tsocks, wireproxy, shadowsocks-rust, proxychains-ng, etc...
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#114Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#115Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#116As a kid in the late 90s my mind was blown when I realized I could telnet to port 80, 25, or 110 and interact with the servers manually. Simple get: GET / HTTP/1.1 Content-Type: text/html User-Agent: l33t hax0rs lol X-Funny-Monkey: farts For sending a mail message on port 25: HELO mail-from: whoever@whatever.com mail-to: sysadmin@yaya.com Body of the message yay. POP3 was so long ago I forgot but you could list the m…
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#117Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#118Once had a coworker tell me to never to use this because "you never know when the customer doesn't have bash installed; use python instead" even though our contract required that the customer had bash. I'm still laughing at that.
FWIW, some distributions (I forget which ones, but I've seen it more than once) compile bash without the network features. Python is ubiquitous, and I've never seen it subsetted this way, so I'd have sided with the coworker.
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#119Earlier quoted context omitted.
it's not that insane. i've been manually typing http requests in since before http/1.1 and the mandatory host header. it is insane to use it for anything serious (also the opposite, implementing webservers in bash), but for quick testing it's pretty great!
Why wouldn’t you use curl for the quick test?
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#120Earlier quoted context omitted.
because in those days there was no curl, or wget. and then when there was, there was no guarantee they'd be installed. telnet was always there though. it also worked for speaking all the other plaintext internet protocols. (imap, pop, smtp, etc)
I used telnet to send mail via SMTP once, it's quite literally a good social protocol because it begins with a polite 'HELO'.
Like if my server replied with ‘HI PLEASURE TO MEET YOU 127.0.0.1 THAT NAME SOUNDS FAMILIAR ARE YOU BY CHANCE FROM BOSTON MY MOTHER IS FROM BOSTON WELL QUINCY ACTUALLY BUT DO YOU KNOW 127.0.1.1 THEY ARE A REALLY GOOD FRIEND OF MINE YOU SHOULD MEET I HEAR THEIR DAUGHTER IS A DOCTOR DONTYAKNOW AND YOU COULD…”
etc, etc?