* [gentoo-user] Bash & Server Sockets
@ 2009-01-16 5:53 Hilco Wijbenga
2009-01-16 15:17 ` Albert Hopkins
0 siblings, 1 reply; 3+ messages in thread
From: Hilco Wijbenga @ 2009-01-16 5:53 UTC (permalink / raw
To: Gentoo User
Hi all,
In Bash /dev/tcp/host/port can be used to write to a TCP socket. This
works nicely so I was very curious whether it would work the other way
too: is it possible to have a Bash script listen on a particular port
as if it were a server? I couldn't find anything in the Bash manual
about it. Google does find a few examples but they all use nc. But
that's cheating! ;-) Is it possible with just Bash, no extra tools?
(If yes, please enlighten me as to how, obviously I could not get it
to work.)
On a related note, I read some comments about Debian having /dev/tcp
disabled in Bash because of security concerns. Would someone
knowledgeable about security be able to comment on that? It doesn't
make much sense to me. I mean, any Perl, Python, Ruby, etcetera script
can write to a socket. Even Debian (with every option deselected)
comes installed with Perl. (Yes, I installed Debian just to find out!)
:-) So why should /dev/tcp in Bash be deemed such a security risk?
Cheers,
Hilco
P.S. For the curious:
#!/bin/bash
exec 3<>/dev/tcp/www.google.ca/80
echo -ne "GET / HTTP/1.1\r\n">&3
echo -ne "Host: www.google.ca\r\n">&3
echo -ne "Connection: close\r\n">&3
echo -ne "\r\n">&3
cat <&3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-user] Bash & Server Sockets
2009-01-16 5:53 [gentoo-user] Bash & Server Sockets Hilco Wijbenga
@ 2009-01-16 15:17 ` Albert Hopkins
2009-01-19 20:14 ` Eric Martin
0 siblings, 1 reply; 3+ messages in thread
From: Albert Hopkins @ 2009-01-16 15:17 UTC (permalink / raw
To: gentoo-user
On Thu, 2009-01-15 at 21:53 -0800, Hilco Wijbenga wrote:
> Hi all,
>
> In Bash /dev/tcp/host/port can be used to write to a TCP socket. This
> works nicely so I was very curious whether it would work the other way
> too: is it possible to have a Bash script listen on a particular port
> as if it were a server? I couldn't find anything in the Bash manual
> about it. Google does find a few examples but they all use nc. But
> that's cheating! ;-) Is it possible with just Bash, no extra tools?
> (If yes, please enlighten me as to how, obviously I could not get it
> to work.)
... and some would even say using bash to begin with is cheating.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-user] Bash & Server Sockets
2009-01-16 15:17 ` Albert Hopkins
@ 2009-01-19 20:14 ` Eric Martin
0 siblings, 0 replies; 3+ messages in thread
From: Eric Martin @ 2009-01-19 20:14 UTC (permalink / raw
To: gentoo-user
While I don't think there's a way. I took a shell scripting class a
year or two ago and we used netpipes for tcp connecrions. Since it was
a very bash class we'd have used bash if possible
On 1/16/09, Albert Hopkins <marduk@letterboxes.org> wrote:
> On Thu, 2009-01-15 at 21:53 -0800, Hilco Wijbenga wrote:
>> Hi all,
>>
>> In Bash /dev/tcp/host/port can be used to write to a TCP socket. This
>> works nicely so I was very curious whether it would work the other way
>> too: is it possible to have a Bash script listen on a particular port
>> as if it were a server? I couldn't find anything in the Bash manual
>> about it. Google does find a few examples but they all use nc. But
>> that's cheating! ;-) Is it possible with just Bash, no extra tools?
>> (If yes, please enlighten me as to how, obviously I could not get it
>> to work.)
>
> ... and some would even say using bash to begin with is cheating.
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-01-19 20:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-16 5:53 [gentoo-user] Bash & Server Sockets Hilco Wijbenga
2009-01-16 15:17 ` Albert Hopkins
2009-01-19 20:14 ` Eric Martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox