A new discovery: SimpleHTTPserver

SimpleHTTPserver is a go enhanced version of the well known python simplehttpserver with in addition a fully customizable TCP server, both supporting TLS.
It will be a handy tool during your pentests.

Installing

go install -v github.com/projectdiscovery/simplehttpserver/cmd/simplehttpserver@latest

Help

simplehttpserver -h

FlagDescriptionExample
-listenConfigure listening ip:port (default 127.0.0.1:8000)simplehttpserver -listen 127.0.0.1:8000
-pathFileserver folder (default current directory)simplehttpserver -path /var/docs
-verboseVerbose (dump request/response, default false)simplehttpserver -verbose
-tcpTCP server (default 127.0.0.1:8000)simplehttpserver -tcp 127.0.0.1:8000
-tlsEnable TLS for TCP serversimplehttpserver -tls
-rulesFile containing yaml rulessimplehttpserver -rules rule.yaml
-uploadEnable file upload in case of http serversimplehttpserver -upload
simplehttpserver -uploadMax Upload File Size (default 50 MB)simplehttpserver -max-file-size 100
-sandboxEnable sandbox modesimplehttpserver -sandbox
-httpsEnable HTTPS in case of http serversimplehttpserver -https
-http1Enable only HTTP1simplehttpserver -http1
-certHTTPS/TLS certificate (self generated if not specified)simplehttpserver -cert cert.pem
-keyHTTPS/TLS certificate private keysimplehttpserver -key cert.key
-domainDomain name to use for the self-generated certificatesimplehttpserver -domain projectdiscovery.io
-corsEnable cross-origin resource sharing (CORS)simplehttpserver -cors
-basic-authBasic auth (username:password)simplehttpserver -basic-auth user:password
-realmBasic auth messagesimplehttpserver -realm «insert the credentials»
-versionShow versionsimplehttpserver -version
-silentShow only resultssimplehttpserver -silent
-pyEmulate Python Stylesimplehttpserver -py
-headerHTTP response header (can be used multiple times)simplehttpserver -header ‘X-Powered-By: Go’

Usage examples

Running simplehttpserver in the current folder

$ simplehttpserver

...
Serving /home/ruben/tmp/folder on http://0.0.0.0:8000/
...

Running simplehttpserver in the current folder with HTTPS

$ simplehttpserver -https -cert cert.pen -key cert.key
$ simplehttpserver -https -domain localhost

...
Serving /home/ruben/tmp/folder on https://0.0.0.0:8000/
...

Running simplehttpserver with basic auth and file upload

simplehttpserver -basic-auth root:root -upload
curl -v --user 'root:root' --upload-file file.txt http://localhost:8000/file.txt

Serving /home/ruben/tmp/folder on http://0.0.0.0:8000/
...
[2023-08-19 12:56:42] 127.0.0.1:53762 "PUT /file.txt HTTP/1.1" 201 0
[2023-08-19 12:57:12] 127.0.0.1:39282 "GET / HTTP/1.1" 200 77