Live data from Hacker News

TIL: You can make HTTP requests without curl using Bash /dev/TCP

mareksuppa.com

221–230 of 255 posts

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#221
post #125

As 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…

Yep! It’s all just text files. Lots of acronyms in top of lots of ways to generate, send, and read structured text files. One day I realized even databases were just text files and I had to sit down.

There are also many binary files. Most databases are binary files which are wide trees of some kind (e.g. B-trees, B+trees)

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#222

As 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…

You can't do that with HTTP/2 (but thankfully every server still talks HTTP/1). You also can't do that with TLS (and a lot of servers won't talk HTTP other than redirects). openssl s_client instead of telnet might allow you to tunnel text inside TLS, but that feels like a cheating. And many other modern protocols, sadly, prefer binary encoding, which makes it impossible to tinker with it on wire level, not without sp…

openssl s_client -host google.com -port 443

You're welcome. Works like netcat plus TLS. Kind of inconvenient though. Hey someone should write tlsnc.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#223

Earlier quoted context omitted.

Interesting. I have never heard kernel modules being regarded as non-linux, not in 30 years of LKM. Further compiling a monolithic Kernel is rather straight forward, in this day it is even possible to find wifi devices that do not require a an on device firmware blob uploaded from the kernel.

I don't know TBH. It's just that if you're going to have a 'pure' designation for a tech, it's going to be pretty strict (as per bash and adding modules). I've never heard of 'pure' linux, but 'pure' bash has a recognised meaning. If someone said 'pure Linux' and it meant the core without loaded modules I wouldn't be shocked. Not sure how useful it would be, though.

> If someone said 'pure Linux' and it meant the core without loaded modules I wouldn't be shocked. Not sure how useful it would be, though.

That probably wouldn't be a useful distinction because almost every module can be built in

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#224

In Plan 9 you did have a real (synthetic) /net, and could do that and more from any program. You could even mount /net from another machine via 9P protocol and have an instant VPN... 9front lets you play with that on Linux. Some Plan 9 like /net things are visible in Go libraries... (Rob Pike legacy)

> You could even mount /net from another machine via 9P protocol and have an instant VPN...

This is awesome.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#225
"This is not a real HTTP client."

It's a TCP client

curl is an HTTP client

I prefer TCP clients to HTTP clients. Simpler, easier to modify, faster to compile

There are many to choose from. For example, I use a modified version of tcploop

For generating HTTP, I use own utilties. This is more flexible than curl. There are some things curl cannot do, even though it has too many options

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#226
Reminds me of my teenage years when I'd echo spooky messages to other folks /dev/pttys to freak them out (messages i sent just magically appeared in their open terminals)

Why they didn't lock those down by using different creds per client in the computer lab I still don't know. Maybe it was a VAX limitation (at the time)?

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#227
post #132

Earlier quoted context omitted.

[ Note: Anyone who has been a geek since the 90s, there's nothing you don't already know here ] > most SMTP servers would accept email from anyone anywhere to anyone anywhere (i.e. 'open relay'). to date that claim, I'd say that by the late 90s at least, true open relays ("from anyone to anyone") were still numerous but carried a huge assumption of being part of spam operations (willingly or through ineptitude), and…

The magic for me, to this day in fact, is knowing that mail is essentially anyone on the internet being allowed to write to a mail servers disk. There are rules now, but the concept is still almost intact, random people writing to the servers disk - to be later read by someone

This generalises to NNTP, in which anyone writes to everyone and is read by no-one.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#228
post #13

> As it turns out, bash can speak HTTP by itself. No, it can not. Bash lets you open TCP sockets. What you are doing here is trying to speak HTTP yourself, which is fine for testing and debugging, and hella cool for fun to do by hand, but you will shoot yourself in the foot if you try to use this pseudo http client unattended in reality. This toy code does not parse HTTP properly and will break. You could of course w…

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!

I just want to note that HTTP only existed 5 years without curl or wget.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#229
Yep. I also learned that too when watching Bauhinia team members' using this to solve a CTF challenge :p It is a multi-series CTF that you get shell from first a ROP chain to system, but you are effectively jailed from running anything but bash, so the only thing you can use is read and cat, and they used the cat /dev/tcp, then redirected it to a pseudo-tty, and read the content of the pseudo-tty in order to get the URL to the inner system. The flag, there it is.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#230

As 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…

Also memories of making printing work on Linux in the late 90s to some old beast of an HP Laserjet. CUPS exited but was a pain to configure, so I’d just convert whatever I wanted to print to postscript, then

    Cat homework.ps > /dev/lp0
Post reply on HN