I need a very simple web server on a very small embedded system with a MISP processor. I thought that the simplest server could be a shell script listening to a TCP port.
The problem is that the system doesn't have even perl. Only some basic shell /bin/sh
. I searched the web for "how to listen to a port from a shell", but answers I found all referred to some other tools like nc
, which I don't have.
Is it even possible to do?
The system, it's a router, has busybox installed and some other binaries in the /bin
directory, they are:
#ls /bin
chown df fatattr gzip login mount
ping rm shuf touch usleep
busybox comgt dmesg fgrep hostname ls
mv ping6 rmdir sleep true vi
busybox-new cp echo flock ip mkdir
netstat printf sdparm split umount watch
cat date egrep grep kill mknod
nice ps sed sync uname wget
chmod dd false gunzip ln more
pidof pwd sh tar unlink zcat
And the busybox:
Currently defined functions:
[, arp, ash, awk, basename, busybox, cat, chmod, chown, cp, crond,
cut,date, dd, df, dirname, dmesg, du, echo, egrep, env, expr, false,
fdisk, fgrep, find, free, ftpget, getty, grep, head, hexdump,
hostname, ifconfig, init, insmod, ip, kill, killall, klogd, ln,
login, ls, lsmod, md5sum, mkdir, mknod, mkswap, modprobe, more,
mount, mv, netstat, nslookup, passwd, pidof, ping, ping6, ps, pwd,
readlink, reboot, renice, rm, rmdir, rmmod, route, sed, seq, sh,
sleep, sort, swapoff, swapon, sync, sysctl, syslogd, tail, tar,
taskset, test, tftp, time, top, touch, tr, traceroute, true, udhcpd,
umount, uname, unzip, uptime, usleep, vi, watch, wc, which,
xargs, yes
It has some other stuff too in other locations from the PATH, but no nc
, no httpd
or something like that
busybox
has a build-in http daemon.busybox-new
, I wonder what is available with that. Anyway you can have multiple instances of busybox installed, so you could compile busybox yourself with the httpd option enabled and install it.egrep, ether-wake, fatattr, fgrep, flock, grep, gunzip, gzip, nice, printf, shuf, split, udhcpc, unlink, wget, zcat
. But the router has alighthttpd
binary, found it withfind / -name "*http*"
. I'll try to research this one