1- <h1 align =" center " >
2- <img src =" static/simplehttpserver-logo.png " alt =" simplehttpserver " width =" 200px " ></a >
3- <br >
4- </h1 >
1+ <h1 align =" center " >SimpleHTTPserver</h1 >
2+ <h4 align =" center " >Go alternative of python SimpleHTTPServer</h4 >
53
6- [ ![ License] ( https://img.shields.io/badge/license-MIT-_red.svg )] ( https://opensource.org/licenses/MIT )
7- [ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/projectdiscovery/simplehttpserver )] ( https://goreportcard.com/report/github.com/projectdiscovery/simplehttpserver )
8- [ ![ contributions welcome] ( https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat )] ( https://github.com/projectdiscovery/simplehttpserver/issues )
9- [ ![ GitHub Release] ( https://img.shields.io/github/release/projectdiscovery/simplehttpserver )] ( https://github.com/projectdiscovery/simplehttpserver/releases )
10- [ ![ Follow on Twitter] ( https://img.shields.io/twitter/follow/pdiscoveryio.svg?logo=twitter )] ( https://twitter.com/pdiscoveryio )
11- [ ![ Docker Images] ( https://img.shields.io/docker/pulls/projectdiscovery/simplehttpserver.svg )] ( https://hub.docker.com/r/projectdiscovery/simplehttpserver )
12- [ ![ Chat on Discord] ( https://img.shields.io/discord/695645237418131507.svg?logo=discord )] ( https://discord.gg/KECAGdH )
134
14- simplehttpserver is a go enhanced version of the well known python simplehttpserver.
5+ <p align =" center " >
6+ <a href =" https://opensource.org/licenses/MIT " ><img src =" https://img.shields.io/badge/license-MIT-_red.svg " ></a >
7+ <a href =" https://github.com/projectdiscovery/simplehttpserver/issues " ><img src =" https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat " ></a >
8+ <a href =" https://goreportcard.com/badge/github.com/projectdiscovery/simplehttpserver " ><img src =" https://goreportcard.com/badge/github.com/projectdiscovery/simplehttpserver " ></a >
9+ <a href =" https://hub.docker.com/r/projectdiscovery/simplehttpserver " ><img src =" https://img.shields.io/docker/pulls/projectdiscovery/simplehttpserver.svg " ></a >
10+ <a href =" https://twitter.com/pdiscoveryio " ><img src =" https://img.shields.io/twitter/follow/pdiscoveryio.svg?logo=twitter " ></a >
11+ <a href =" https://discord.gg/projectdiscovery " ><img src =" https://img.shields.io/discord/695645237418131507.svg?logo=discord " ></a >
12+ </p >
1513
16- # Resources
14+ <p align =" center " >
15+ <a href =" #features " >Features</a > •
16+ <a href =" #usage " >Usage</a > •
17+ <a href =" #installing-simplehttpserver " >Installation</a > •
18+ <a href =" #running-simplehttpserver-in-the-current-folder " >Run SimpleHTTPserver</a > •
19+ <a href =" https://discord.gg/projectdiscovery " >Join Discord</a >
20+ </p >
1721
18- - [ Features] ( #features )
19- - [ Usage] ( #usage )
20- - [ Installation Instructions] ( #installation-instructions )
21- - [ Running simplehttpserver] ( #running-simplehttpserver-in-the-current-folder )
22- - [ Thanks] ( #thanks )
23-
24- # Features
25-
26- <h1 align =" left " >
27- <img src =" static/simplehttpserver-run.png " alt =" simplehttpserver " width =" 700px " ></a >
28- <br >
29- </h1 >
30-
31- - File server in arbitrary directory
32- - Full request/response dump
33- - Configurable ip address and listening port
34-
35-
36- # Installation Instructions
22+ ---
3723
24+ SimpleHTTPserver is a go enhanced version of the well known python simplehttpserver with in addition a fully customizable TCP server, both supporting TLS.
3825
39- ### From Binary
4026
41- The installation is easy. You can download the pre-built binaries for your platform from the [ Releases ] ( https://github.com/projectdiscovery/simplehttpserver/releases/ ) page. Extract them using tar, move it to your ` $PATH ` and you're ready to go.
27+ # Features
4228
43- ``` sh
44- Download latest binary from https://github.com/projectdiscovery/simplehttpserver/releases
29+ - HTTPS support
30+ - File server in arbitrary directory
31+ - Full request/response dump
32+ - Configurable ip address and listening port
33+ - Configurable HTTP/TCP server with customizable response via YAML template
4534
46- ▶ tar -xvf simplehttpserver-linux-amd64.tar
47- ▶ mv simplehttpserver-linux-amd64 /usr/local/bin/simplehttpserver
48- ▶ simplehttpserver -h
49- ```
5035
51- ### From Source
36+ # Installing SimpleHTTPserver
5237
53- simplehttpserver requires ** go1.14+** to install successfully. Run the following command to get the repo -
38+ SimpleHTTPserver requires ** go1.14+** to install successfully. Run the following command to get the repo -
5439
5540``` sh
56- ▶ GO111MODULE=on go get -v github.com/projectdiscovery/simplehttpserver
57- ```
58-
59- ### From Github
60-
61- ``` sh
62- ▶ git clone https://github.com/projectdiscovery/simplehttpserver.git; cd simplehttpserver; go build; mv simplehttpserver /usr/local/bin/; simplehttpserver -h
41+ ▶ GO111MODULE=on go get -v github.com/projectdiscovery/cmd/simplehttpserver
6342```
6443
6544# Usage
@@ -70,11 +49,23 @@ simplehttpserver -h
7049
7150This will display help for the tool. Here are all the switches it supports.
7251
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 |
52+ | Flag | Description | Example |
53+ | ----------- | -------------------------------------------------------------------- | ------------------------------------------------- |
54+ | listen | Configure listening ip: port (default 127.0.0.1:8000) | simplehttpserver -listen 127.0.0.1:8000 |
55+ | path | Fileserver folder (default current directory) | simplehttpserver -path /var/docs |
56+ | verbose | Verbose (dump request/response, default false) | simplehttpserver -v |
57+ | tcp | TCP server (default 127.0.0.1:8000) | simplehttpserver -tcp 127.0.0.1:8000 |
58+ | tls | Enable TLS for TCP server | simplehttpserver -tls |
59+ | rules | File containing yaml rules | simplehttpserver -rules rule.yaml | |
60+ | upload | Enable file upload in case of http server | simplehttpserver -upload |
61+ | https | Enable HTTPS in case of http server | simplehttpserver -https |
62+ | cert | HTTPS/TLS certificate (self generated if not specified) | simplehttpserver -cert cert.pem |
63+ | key | HTTPS/TLS certificate private key (self generated if not specified) | simplehttpserver -key cert.key |
64+ | domain | Domain name to use for the self-generated certificate | simplehttpserver -domain projectdiscovery.io |
65+ | basic-auth | Basic auth (username: password ) | simplehttpserver -basic-auth user: password |
66+ | realm | Basic auth message | simplehttpserver -realm "insert the credentials" |
67+ | version | Show version | simplehttpserver -version |
68+ | silent | Show only results | simplehttpserver -silent |
7869
7970### Running simplehttpserver in the current folder
8071
@@ -87,6 +78,91 @@ This will run the tool exposing the current directory on port 8000
87782021/01/11 21:41:15 [::1]:50181 " GET /favicon.ico HTTP/1.1" 404 19
8879```
8980
81+ ### Running simplehttpserver in the current folder with HTTPS
82+
83+ This will run the tool exposing the current directory on port 8000 over HTTPS with user provided certificate:
84+
85+ ``` sh
86+ ▶ simplehttpserver -https -cert cert.pen -key cert.key
87+ 2021/01/11 21:40:48 Serving . on http://0.0.0.0:8000/...
88+ 2021/01/11 21:41:15 [::1]:50181 " GET / HTTP/1.1" 200 383
89+ 2021/01/11 21:41:15 [::1]:50181 " GET /favicon.ico HTTP/1.1" 404 19
90+ ```
91+
92+ Instead, to run with self-signed certificate and specific domain name:
93+ ``` sh
94+ ▶ simplehttpserver -https -domain localhost
95+ 2021/01/11 21:40:48 Serving . on http://0.0.0.0:8000/...
96+ 2021/01/11 21:41:15 [::1]:50181 " GET / HTTP/1.1" 200 383
97+ 2021/01/11 21:41:15 [::1]:50181 " GET /favicon.ico HTTP/1.1" 404 19
98+ ```
99+
100+ ### Running simplehttpserver with basic auth and file upload
101+
102+ This will run the tool and will request the user to enter username and password before authorizing file uploads
103+
104+ ``` sh
105+ ▶ simplehttpserver -basic-auth root:root -upload
106+ 2021/01/11 21:40:48 Serving . on http://0.0.0.0:8000/...
107+ ```
108+
109+ To upload files use the following curl request with basic auth header:
110+ ``` sh
111+ ▶ curl -v --user ' root:root' --upload-file file.txt http://localhost:8000/file.txt
112+ ```
113+
114+ ### Running TCP server with custom responses
115+
116+ This will run the tool as TLS TCP server and enable custom responses based on YAML templates:
117+
118+ ``` sh
119+ ▶ simplehttpserver -rule rules.yaml -tcp -tls -domain localhost
120+ ```
121+
122+ The rules are written as follows:
123+ ``` yaml
124+ rules :
125+ - match : regex
126+ response : response data
127+ ` ` `
128+
129+ For example to handle two different paths simulating an HTTP server or SMTP commands:
130+ ` ` ` yaml
131+ rules :
132+ # HTTP Requests
133+ - match : GET /path1
134+ response : |
135+ HTTP/1.0 200 OK
136+ Server: httpd/2.0
137+ x-frame-options: SAMEORIGIN
138+ x-xss-protection: 1; mode=block
139+ Date: Fri, 16 Apr 2021 14:30:32 GMT
140+ Content-Type: text/html
141+ Connection: close
142+
143+ <HTML><HEAD><script>top.location.href='/Main_Login.asp';</script>
144+ </HEAD></HTML>
145+ - match : GET /path2
146+ response : |
147+ HTTP/1.0 404 OK
148+ Server: httpd/2.0
149+
150+ <HTML><HEAD></HEAD><BODY>Not found</BODY></HTML>
151+ # SMTP Commands
152+ - match : " EHLO example.com"
153+ response : |
154+ 250-localhost Nice to meet you, [127.0.0.1]
155+ 250-PIPELINING
156+ 250-8BITMIME
157+ 250-SMTPUTF8
158+ 250-AUTH LOGIN PLAIN
159+ 250 STARTTLS
160+ - match : " MAIL FROM: <noreply@example.com>"
161+ response : 250 Accepted
162+ - match : " RCPT TO: <test@example.com>"
163+ response : 250 Accepted
164+ ` ` `
165+
90166# Thanks
91167
92- simplehttpserver 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 .
168+ SimpleHTTPserver is made with 🖤 by the [projectdiscovery](https://projectdiscovery.io) team.
0 commit comments