This repository has been archived on 2026-05-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
simple-nc-server/README.md
T

1.0 KiB

simple-nc-server

Ncat

Only works with Ncat versions that are compiled with the -c switch.

while true; do nc -lnp 1337 -c 'read REQ; GET=$(echo $REQ | sed -E "s/GET \/(.*) HTTP.*/\1/"); echo -e "HTTP/1.1 200 OK\nContent-Type: text/html; charset=UTF-8\n\n"; eval "$(echo "%>$(cat index.sh.html)<%" | sed -e "s/<%=/<%echo /g" -e "s/<%/\nRAW\n/g" -e "s/%>/\ncat <<- RAW\n/g")"'; done

Busybox httpd

If Busybox was compiled with httpd, it can serve simple scripts. If there is no index.html it tries cgi-bin/index.cgi next using whatever is in the shebang. It can be further customized by having a httpd.conf around but keeping it minimal, this works in this repo:

busybox httpd -p 1337 -f

(Note: Alpine Linux now splits Busybox into multiple packages: apk add busybox-extras)

PHP

PHP has a built-in server which can come in handy. For this example there is an index.php with index.sh.html compatible instructions but PHP is quite easy to write so it's better without this extra hoop.

php -S 0.0.0.0:1337