Netcat Woes

Posted by: Dava

Netcat Woes - 05/05/2004 03:06

Hello All,

I have been away for some time but recently I have a need to do somthing new with my empeg other than play music.

I want to use netcat to send a wake packet to another server on my network. This works fine from a DOS version of nc but I cannot get the empeg build to do what I want. I am sending:

/drive1/var/nc -u -w 3 192.168.1.255 21 < /drive1/var/wakepkt
The result is Permission Denied.

If i change the command to direct it to the server in question rather than a broadcast address then it goes through OK.

How do I set the permissions of what I can send via UDP? Its my empeg surely I should be able to do what I want on my network

Any help would be appreciated.
Posted by: Roger

Re: Netcat Woes - 05/05/2004 04:47

nc requires a -b switch to enable UDP broadcasts.

Posted by: Dava

Re: Netcat Woes - 05/05/2004 05:16

Thanks Roger BUT

Unfortunately my version of nc v1.10 does not have -b listed in help, nor does it like it.

I tried to grab a newer version from your site but the links to it in the lazy bastards guide are broken.

Could you possibly attach here or point me in the direction of the binary?

By the way, does anyone have an empeg port of zebedee and know whether that can send to a broadcast address?
Posted by: Roger

Re: Netcat Woes - 05/05/2004 05:52

http://www.differentpla.net/~roger/empeg/car/files/binary-arm/netcat_1.10-12.1.tar.gz

Posted by: Dava

Re: Netcat Woes - 05/05/2004 06:21

Thanks!

What a sevice!

I will have a go with this one and let you know
Posted by: Roger

Re: Netcat Woes - 05/05/2004 06:37

You'd be better off taking the minimal .tar.gz from here. I've updated the lazy bastard's guide to point to this new page.
Posted by: Dava

Re: Netcat Woes - 05/05/2004 06:46

Hi Roger,

I have no idea what I am doing wrong but this seems to be the same version as I have (v1.10 without any other subdigits). This also does not list the -b option of which you speak.

Please enlighten me as to what to do now.
Posted by: Dava

Re: Netcat Woes - 05/05/2004 06:56

It seems that this is still the same one. I jst get this:

empeg:/drive1/var# ./nc -h
[v1.10]
connect to somewhere: nc [-options] hostname port[s] [ports] ...
listen for inbound: nc -l -p port [-options] [hostname] [port]
options:
-g gateway source-routing hop point[s], up to 8
-G num source-routing pointer: 4, 8, 12, ...
-h this cruft
-i secs delay interval for lines sent, ports scanned
-l listen mode, for inbound connects
-n numeric-only IP addresses, no DNS
-o file hex dump of traffic
-p port local port number
-r randomize local and remote ports
-q secs quit after EOF on stdin and delay of secs
-s addr local source address
-t answer TELNET negotiation
-u UDP mode
-v verbose [use twice to be more verbose]
-w secs timeout for connects and final net reads
-z zero-I/O mode [used for scanning]
port numbers can be individual or ranges: lo-hi [inclusive]
empeg:/drive1/var# ./nc -b
./nc: invalid option -- b
Posted by: Roger

Re: Netcat Woes - 05/05/2004 07:06

also does not list the -b option

OK. On further inspection, there are two versions of netcat, both announcing themselves as v1.10:

The version that comes with Debian potato is actually version 1.10-12.1, and doesn't support the -b switch. This is the version that works on the car player.

The version that comes with Debian woody is actually version 1.10-21, and does support the -b switch. This is the version I was using on my PC.

The woody version will not work on the car player without some work, since it requires libc-2.2, rather than the libc-2.1 that the car player has.
Posted by: Dava

Re: Netcat Woes - 05/05/2004 07:17

I see.

Thanks for all your help so far but, as I have no idea where to start to make that all work, I will have to investigate other means.

As the data that I want to send is just the mac address repeated 16 times, could I somehow trick a web page (hosted on the empeg with hijack's httpd) to send this to a broadcast address as a page request?

Does anyone have any other ideas?
Posted by: wfaulk

Re: Netcat Woes - 05/05/2004 09:14

No. Web pages are delivered via TCP, not UDP. In fact, TCP to a broadcast address doesn't even make sense, regardless of web pages.

The thing is that the lack of the -b option in the netcat you're using is a bug. Or at least a missing feature. I'd say bug.

Lemme see if I can compile it up for you. Here you go. No idea if it'll work or not. I've attached just the binary, compressed with gzip.
Posted by: Dava

Re: Netcat Woes - 05/05/2004 10:24

Thanks for doing this for me, unfortunately the attachment seems to be corrupt. I cannot ungzip it on the empeg or with Winzip. Could you try again for me?
Posted by: tman

Re: Netcat Woes - 05/05/2004 10:29

It is probably being uncompressed by your browser
Posted by: Dava

Re: Netcat Woes - 05/05/2004 10:32

Does this mean that YOU can ungzip it?

I am using Firebird. I will try IE.
Posted by: tman

Re: Netcat Woes - 05/05/2004 10:34

As I said, the file is probably being uncompressed by your browser and therefore the file you get saved is the actual binary.
Posted by: Dava

Re: Netcat Woes - 05/05/2004 10:44

I see... quite right. I renamed the file to be nc, chmodded it and it runs.

However, it still does not like the -b option.
Posted by: tman

Re: Netcat Woes - 05/05/2004 11:09

Untested blah blah etc....
Posted by: wfaulk

Re: Netcat Woes - 05/05/2004 12:05

Ah, crap. I misunderstood how the damn Debian patch works. (Terribly nonstandardly, apparently.) Let us know how Trevor's works. If it doesn't, I can try again.
Posted by: Dava

Re: Netcat Glee - 05/05/2004 13:17

It's tested now!

Fantastic. It works a dream. Thank you all for your help and time.

All I need to do now is work out how to make a web link, hosted on the empeg exec the script. Does Hijack have a http://player.ip/?exec equivilent to the site exec FTP command?
Posted by: wfaulk

Re: Netcat Glee - 05/05/2004 13:26

If you already have another computer, why don't you just send the wakeup from that computer anyway?

And, no, there's no exec from the network via Hijack. You could bind it to a button press, though, I think.
Posted by: mlord

Re: Netcat Glee - 05/05/2004 13:34

Anything that works from FTP, also works from HTTP in Hijack. I think.

EDIT: except for SITE EXEC.. So, NO!

Cheers
Posted by: tfabris

Re: Netcat Glee - 05/05/2004 13:40

Any reason for that?
Posted by: mlord

Re: Netcat Glee - 05/05/2004 14:52

For whatever reason, I added SITE EXEC outside of the the usual generic parser. Probably much safer this way, too, since commands could otherwise be issued via the web to nuke flash, etc..

Cheers
Posted by: tfabris

Re: Netcat Glee - 05/05/2004 14:54

I'm just thinking that an HTTP-based EXEC command would be cool. There's a lot of things we could do with it. For instance, if I'm testing a third party application, I can launch it without having to edit config.ini and reboot. I agree that it could be dangerous, so perhaps have it disabled by default for HTTP.
Posted by: Dava

Re: Netcat Glee - 05/05/2004 15:02

If you already have another computer, why don't you just send the wakeup from that computer anyway?

Well its a router thing. I used to route the packet (from the net) via an intel Wireless router connected to a 10Mb hub. This all worked fine for ages. Then I replaced these 2 with a shiny new 54Mb SMC router with a 4 port 100Mbps switch. It took me ages to work out why it became unreliable but it seems that the switch "forgets" how to send directed UDP packets to the server's IP after about 10 mins of it being standbyed (flushes ARP cache???) . However, it still responded to broadcast packets. I cannot send broadcast packets from the net via the router and here we are. The empeg is always on, and thanks to Mark's recent additions to hijack, namely authentication, I can open up the empeg to the net and make a web interface... maybe.

If I can bind the script to a button then I can send the /?bottonno from my page I think. This would give me the perfect solution.

I have also piped a netcat listener to another instance of netcat which broadcasts which gives me the same functionality as before my new hardware broke everything.
Posted by: Dava

Re: Netcat Glee - 05/05/2004 15:07

So can I assign a script to a button press as suggested earlier? This would make sense as far as security is concerned, I can only execute commands that I have assigned in config.ini.
Posted by: TheAmigo

Re: Netcat Glee - 02/08/2004 03:00

I just stumbled across this thread (was searching to see if anyone had compiled netcat)... thanks to those that did! I'm working on building a "carputer" to store in my trunk (GPS and WLAN, but not wardriving)... nc will help it integrate with the empeg.

Anyway, have you tried running two copies of netcat on the empeg? Have one listen on some port and pipe what it receives to another instance of nc that will send it out to the local broadcast?
#include <disclaimer.h> this may open security holes depending on your network setup.