forked from RedSiege/WMIOps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
https_server.py
executable file
·35 lines (30 loc) · 1 KB
/
https_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import os
import socket
import ssl
import sys
from weblib import base_handler
from weblib import threaded_http
from threading import Thread
def serve_on_port():
try:
cert_path = 'weblib/server.pem'
server = threaded_http.ThreadingHTTPServer(
("0.0.0.0", 443), base_handler.GetHandler)
server.socket = ssl.wrap_socket(
server.socket, certfile=cert_path, server_side=True)
server.serve_forever()
except socket.error:
print "[*][*] Error: Port 443 is currently in use!"
print "[*][*] Error: Please restart when port is free!\n"
sys.exit()
return
try:
print "[*] Starting web (https) server..."
# bind to all interfaces
Thread(target=serve_on_port).start()
print "[*] Web server is currently running"
print "[*] Type \"kill -9 " + str(os.getpid()) + "\" to stop the web server."
# handle keyboard interrupts
except KeyboardInterrupt:
print "[!] Rage quiting, and stopping the web server!"