Simple Executable HTTP Server for pentester

import http.server
import socketserver
import sys
import socket
import os

if len(sys.argv) > 1:
PORT = int(sys.argv[1])
except ValueError:
PORT = -1
PORT = 8000

print("WinSimpleHTTP ----v1.1--------------------")

if PORT < 2 or PORT > 65535:
print("Invalid Port : " , str(PORT))
print("Port must be 2-65535")
path = os.path.dirname(os.path.realpath(__file__))

ip = [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0]

Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
print(path , " ---> ", ip , ":" ,str(PORT))
print("you are connected now try to access the server from the other machine")




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

How to add local dependency to a python project

If You Ask These 4 Python Questions, You Might Still Be a Nooby

Connect SAP Hana Cloud Database Through Python

Using Sqlite with Python