1111[ ![ Docker Images] ( https://img.shields.io/docker/pulls/projectdiscovery/simplehttpserver.svg )] ( https://hub.docker.com/r/projectdiscovery/simplehttpserver )
1212[ ![ Chat on Discord] ( https://img.shields.io/discord/695645237418131507.svg?logo=discord )] ( https://discord.gg/KECAGdH )
1313
14- simplehttpserver is a go enhanced version of the well known python simplehttpserver.
14+ simplehttpserver is a go enhanced version of the well known python simplehttpserver with in addition a fully customizable TCP server, both supporting TLS .
1515
1616# Resources
1717
1818- [ Features] ( #features )
1919- [ Usage] ( #usage )
2020- [ Installation Instructions] ( #installation-instructions )
21- - [ Running simplehttpserver] ( #running-simplehttpserver-in-the-current-folder )
21+ - [ Running simplehttpserver] ( #running-simplehttpserver-in-the-current-folder )
2222- [ Thanks] ( #thanks )
2323
2424# Features
@@ -28,9 +28,11 @@ simplehttpserver is a go enhanced version of the well known python simplehttpser
2828 <br >
2929</h1 >
3030
31- - File server in arbitrary directory
32- - Full request/response dump
33- - Configurable ip address and listening port
31+ - HTTPS support
32+ - File server in arbitrary directory
33+ - Full request/response dump
34+ - Configurable ip address and listening port
35+ - Configurable HTTP/TCP server with customizable response via YAML template
3436
3537
3638# Installation Instructions
@@ -70,11 +72,23 @@ simplehttpserver -h
7072
7173This will display help for the tool. Here are all the switches it supports.
7274
73- | Flag | Description | Example |
74- | ------ | ---------------------------------------------------- | --------------------------------------- |
75- | listen | Configure listening ip: port (default 127.0.0.1:8000) | simplehttpserver -listen 127.0.0.1:8000 |
76- | path | Fileserver folder (default current directory) | simplehttpserver -path /var/docs |
77- | v | Verbose (dump request/response, default false) | simplehttpserver -v |
75+ | Flag | Description | Example |
76+ | ----------- | -------------------------------------------------------------------- | ------------------------------------------------- |
77+ | listen | Configure listening ip: port (default 127.0.0.1:8000) | simplehttpserver -listen 127.0.0.1:8000 |
78+ | path | Fileserver folder (default current directory) | simplehttpserver -path /var/docs |
79+ | verbose | Verbose (dump request/response, default false) | simplehttpserver -v |
80+ | tcp | TCP server (default 127.0.0.1:8000) | simplehttpserver -tcp 127.0.0.1:8000 |
81+ | tls | Enable TLS for TCP server | simplehttpserver -tls |
82+ | rules | File containing yaml rules | simplehttpserver -rules rule.yaml | |
83+ | upload | Enable file upload in case of http server | simplehttpserver -upload |
84+ | https | Enable HTTPS in case of http server | simplehttpserver -https |
85+ | cert | HTTPS/TLS certificate (self generated if not specified) | simplehttpserver -cert cert.pem |
86+ | key | HTTPS/TLS certificate private key (self generated if not specified) | simplehttpserver -key cert.key |
87+ | domain | Domain name to use for the self-generated certificate | simplehttpserver -domain projectdiscovery.io |
88+ | basic-auth | Basic auth (username: password ) | simplehttpserver -basic-auth user: password |
89+ | realm | Basic auth message | simplehttpserver -realm "insert the credentials" |
90+ | version | Show version | simplehttpserver -version |
91+ | silent | Show only results | simplehttpserver -silent |
7892
7993### Running simplehttpserver in the current folder
8094
@@ -87,6 +101,91 @@ This will run the tool exposing the current directory on port 8000
871012021/01/11 21:41:15 [::1]:50181 " GET /favicon.ico HTTP/1.1" 404 19
88102```
89103
104+ ### Running simplehttpserver in the current folder with HTTPS
105+
106+ This will run the tool exposing the current directory on port 8000 over HTTPS with user provided certificate:
107+
108+ ``` sh
109+ ▶ simplehttpserver -https -cert cert.pen -key cert.key
110+ 2021/01/11 21:40:48 Serving . on http://0.0.0.0:8000/...
111+ 2021/01/11 21:41:15 [::1]:50181 " GET / HTTP/1.1" 200 383
112+ 2021/01/11 21:41:15 [::1]:50181 " GET /favicon.ico HTTP/1.1" 404 19
113+ ```
114+
115+ Instead, to run with self-signed certificate and specific domain name:
116+ ``` sh
117+ ▶ simplehttpserver -https -domain localhost
118+ 2021/01/11 21:40:48 Serving . on http://0.0.0.0:8000/...
119+ 2021/01/11 21:41:15 [::1]:50181 " GET / HTTP/1.1" 200 383
120+ 2021/01/11 21:41:15 [::1]:50181 " GET /favicon.ico HTTP/1.1" 404 19
121+ ```
122+
123+ ### Running simplehttpserver with basic auth and file upload
124+
125+ This will run the tool and will request the user to enter username and password before authorizing file uploads
126+
127+ ``` sh
128+ ▶ simplehttpserver -basic-auth root:root -upload
129+ 2021/01/11 21:40:48 Serving . on http://0.0.0.0:8000/...
130+ ```
131+
132+ To upload files use the following curl request with basic auth header:
133+ ``` sh
134+ ▶ curl -v --user ' root:root' --upload-file file.txt http://localhost:8000/file.txt
135+ ```
136+
137+ ### Running TCP server with custom responses
138+
139+ This will run the tool as TLS TCP server and enable custom responses based on YAML templates:
140+
141+ ``` sh
142+ ▶ simplehttpserver -rule rules.yaml -tcp -tls -domain localhost
143+ ```
144+
145+ The rules are written as follows:
146+ ``` yaml
147+ rules :
148+ - match : regex
149+ response : response data
150+ ` ` `
151+
152+ For example to handle two different paths simulating an HTTP server or SMTP commands:
153+ ` ` ` yaml
154+ rules :
155+ # HTTP Requests
156+ - match : GET /path1
157+ response : |
158+ HTTP/1.0 200 OK
159+ Server: httpd/2.0
160+ x-frame-options: SAMEORIGIN
161+ x-xss-protection: 1; mode=block
162+ Date: Fri, 16 Apr 2021 14:30:32 GMT
163+ Content-Type: text/html
164+ Connection: close
165+
166+ <HTML><HEAD><script>top.location.href='/Main_Login.asp';</script>
167+ </HEAD></HTML>
168+ - match : GET /path2
169+ response : |
170+ HTTP/1.0 404 OK
171+ Server: httpd/2.0
172+
173+ <HTML><HEAD></HEAD><BODY>Not found</BODY></HTML>
174+ # SMTP Commands
175+ - match : " EHLO example.com"
176+ response : |
177+ 250-localhost Nice to meet you, [127.0.0.1]
178+ 250-PIPELINING
179+ 250-8BITMIME
180+ 250-SMTPUTF8
181+ 250-AUTH LOGIN PLAIN
182+ 250 STARTTLS
183+ - match : " MAIL FROM: <noreply@example.com>"
184+ response : 250 Accepted
185+ - match : " RCPT TO: <test@example.com>"
186+ response : 250 Accepted
187+ ` ` `
188+
90189# Thanks
91190
92191simplehttpserver is made with 🖤 by the [projectdiscovery](https://projectdiscovery.io) team. Community contributions have made the project what it is. See the **[Thanks.md](https://github.com/projectdiscovery/simplehttpserver/blob/master/THANKS.md)** file for more details.
0 commit comments