Live data from Hacker News

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

mareksuppa.com

161–170 of 255 posts

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

#161

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…

Back in those days not only was there was no DKIM or SPF, most SMTP servers would accept email from anyone anywhere to anyone anywhere (i.e. 'open relay').

With agents in the house now, we don't use curl at all. Slowly they all are becoming implementation details.

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

#162
Note that this didn't work historically on Debian, and presumably Debian-derived distros, where the virtual file TCP access was disabled by default. The position was reversed (and the capability enabled) in 2009, AFAIU. There's discussion and links in Bug #146464:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=146464#37>

As others have mentioned, there are numerous other ways to directly access network features using shell tools, including curl (noted in TFA's title), wget, the HEAD and GET commands (from Perl), netcat (nc), socat, telnet, and I'm quite sure others.

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

#163

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…

I must have tried to write the same "perfect" IRC client from scratch in C a dozen times growing up...

any cool features you can share?

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

#164

Earlier quoted context omitted.

perhaps you meant "in previous millennium" ?

If someone referred to the "previous decade" in 2004, would you have said the same thing? As the calendar rolled from 1999 to 2000, we entered a new millennium, century, decade, year, day, ...

>As the calendar rolled from 1999 to 2000, we entered a new millennium, century, decade, year, day, ...

no, that all happened when we rolled from 2000 to 2001.

smh, even paedants today aren't what they used to be.

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

#165

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…

> Perhaps most people in the future won't bother. They'll just let agents do it all.

But can you imagine the look on some young teen’s face when they train their own GPT on their local computer for the first time?

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

#166

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

Someone did a Minecraft server in pure bash.

https://sdomi.pl/weblog/15-witchcraft-minecraft-server-in-ba...

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

#167

Earlier quoted context omitted.

Back in those days not only was there was no DKIM or SPF, most SMTP servers would accept email from anyone anywhere to anyone anywhere (i.e. 'open relay').

With agents in the house now, we don't use curl at all. Slowly they all are becoming implementation details.

Probably curl is safer than whatever cobbled up bash script your agent invented. Battle tested for years, and free, why replace that?

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

#168
post #76

Earlier quoted context omitted.

Need to be clear that "full http server in pure bash" is incorrect. Bash cannot listen on a TCP/UDP socket for incoming connections. bash-web-server project builds a C language socket listener [0] that is dynamically loaded at run-time as a "built-in" module that makes the functionality available. [0] https://github.com/bahamas10/bash-web-server/tree/main/loada...

By this logic, Linux does not support Wi-Fi, because all the driver modules are "dynamically loaded at run-time."

Pure Linux doesn't.

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

#169
post #64

Earlier quoted context omitted.

If the base image I use is based on Debian, it comes with more than 15 binaries that I don't use. But when Docker scans my image and notices that there is a CVE in one of those binaries, my image is currently out of compliance. FROM scratch just reduces the surface.

> FROM scratch just reduces the surface. The actual attack surface of your application? Or the attack surface of you and your team's attention from a busybody security org. It's important not to confuse the two.

Important to whom?

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

#170

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…

It was also cool discovering the ATA commands to drive the modem. You could “war-dial” numbers, or manually initiate Internet connection, or connecting to a bbs
Post reply on HN