elks icon indicating copy to clipboard operation
elks copied to clipboard

Add Netcat to ELKS

Open miragu opened this issue 2 months ago • 1 comments

This is a feature request to add Netcat to ELKS. Netcat is a simple yet fantastic swiss army knife of networking because it allows to send and receive data through pipes over the network. I realize there's "urlget tcp://" but that only allows to receive; in order to send, our options are limited to httpd or similar, which is less versatile. Using pipes over the network allows to use "tar" on the fly, or "dd" disks/partitions, for example, without creating temporary files or symlinks, which is very useful with real hardware.

The full version of this utility is already quite small; in the modern system where I'm posting this, the binary is only 39064 bytes (original version from sourceforge). With some effort it could probably be shrunk enough to feature in most floppies, which would be ideal.

miragu avatar Oct 12 '25 21:10 miragu

Hi, I took a quick look at the original netcat source on Sourceforge, and also the much cleaner version on OpenBSD. Overall, the sourceforge version might possibly be easier to port, but both emit tons of warnings and a number of errors.

ELKS networking is still missing a number of capabilities that would have to be patched out or otherwise dealt with in either netcat version:

  • No UDP, so all references and special defines need to be removed in order to compile.
  • Fleshing out differences in gethostbyname and ELKS in_gethostbyname incomplete version; structure differences prohibit compilation. Lots of other changes with various helper routines such as inet_aton, inet_ntoa, gethostbyaddr, getservbyport, getservbyname, shutdown, etc. Each of these has to be individually studied and ported, or commented out if possible.
  • Very limited capabilities in the ELKS DNS resolver.
  • For the OpenBSD version, lack of struct iov for network I/O using readv/writev and other BSD library code called.
  • Overall testing after getting it compiling.

The good news is that the sourceforge netcat.c is probably small enough to get running, after spending time getting it compiling and linking with our more limited networking subset.

The sourceforge code is pretty dense and will require someone with some time to get initially compiling. I can help discussing the porting issues, but don't have time to start the initial port.

Thank you!

ghaerr avatar Oct 12 '25 23:10 ghaerr

I have created a pull request with a netcat-style app. It could serve as a basis for something better later on https://github.com/ghaerr/elks/pull/2524

sepen avatar Dec 12 '25 22:12 sepen