6 ms·
> It is unclear to me whether the C libs include TCP. The exercise states that you have a Linux kernel and there is a network connection. If the kernel does no
by datenwolf 6y ago
> It is unclear to me whether the C libs include TCP.
The exercise states that you have a Linux kernel and there is a network connection. If the kernel does not have TCP, but only offers a raw socket, well, then you have to write down a very simple TCP stack.
But if the kernel does have TCP, the exercise boils down to writing a very simple HTTP client, a very simple DNS resolver and a bare bones XZ decompressor and tar reader. From there I'd grab myself https://alpha.de.repo.voidlinux.org/static/xbps-static-latest.x86_64-musl.tar.xz https://alpha.de.repo.voidlinux.org/static/xbps-static-lates... then execute
./xbps-install -S --repository=https://alpha.de.repo.voidlinux.org/current https://alpha.de.repo.voidlinux.org/current -r / base-system
and call it a day.
- anthk 6y agoOr just get a static tar and xz static build, they must be somewhere. Better: busybox build. It already has tar, xz and wget. You just need to compile a simple HTTP client, or better: find a gopher mirror. Bare netcat would work against that. gopher://ftp.icm.edu.pl:70/1/vol/rzm6/busybox/binaries With NetCat: echo vol/rzm6/busybox/binaries/1.21.1/ | nc ftp.icm.edu.pl 70 echp vol/rzm6/busybox/binaries/1.21.1/busybox-i586 | nc ftp.icm.edu.pl 70 > busybox Then ln all the binaries. Or run busybox wget. Accesign the rest of the files is the same, just redirect the nc command to a file. If tar is missing, you can just get for sure an static build and compile it. Or try to find an sltar mirror to github ;). But that busybox has ustar, so look how easy it was with just netcat and Gopher, so writting an nc clone (openbsd's netcat portable version is really easy, altough there are another ones many more times dumbed down) would be the easiest win.
- datenwolf 6y ago> Or just get a static tar and xz static build, they must be somewhere. That is, that you can find them in an uncompressed form. If you fees adventurous you can probably coax the compressed data somehow through the bootloader decompressor, or the xz or deflate implementation found in the Linux kernel. Unfortunately these days modules tend to be compressed as well, but it should be possible to convice libdl to open a .ko file. If not you can always mmap it PROT_READ|PROT_EXEC and follow the symbols entries through the TLD yourself.
- anthk 6y agoBusybox has these in binary form, in either HTTP/FTP/Gopher servers or who knows which other protos. Pick your poison. Once you set a barebones connection to a gopher server from stdin using a little of C socket establishing code, you can just send the commands to fetch the binary, redirect it to a file and chmod(2) +x it with ease.
- chrisbroadfoot 6y ago> telnet, nc, ftp, ncftp, lftp, wget, curl, lynx, links? Luxury! Gone. No nc.
- anthk 6y agoOk, switch the C compiler to a Go one: https://github.com/kisom/goat/blob/master/goat.go https://github.com/kisom/goat/blob/master/goat.go Well, JK. A simple, braindead, ugly and fast netcat clone (client only) can be done in C in few functions.