Simple Executable HTTP Server for pentester

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


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

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

if PORT < 2 or PORT > 65535:
print("Invalid Port : " , str(PORT))
print("Port must be 2-65535")
print("------------------------------------------")
else:
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(('8.8.8.8', 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")
httpd.serve_forever()

--

--

--

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
AliBawazeEer

AliBawazeEer

More from Medium

Python Algorithm: Pt. 10 Bellman Ford

Learning Dijkstra’s Algorithm

Bellman-Ford Algorithm & its applications