#!/usr/bin/env python3 from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import urlparse, parse_qs import re from time import sleep import socket hostName = "0.0.0.0" serverPort = 8080 class MyServer(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() parsed_path = urlparse(self.path) param=parse_qs(parsed_path.query) host=str(self.client_address[0]) if "host" in param: p = re.compile("[a-zA-Z0-9_.-]*") print(param["host"][0]) if p.match(param["host"][0])[0] == param["host"][0]: host=param["host"][0] try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("127.0.0.1",4444)) s.send(bytes(host,"UTF-8")) s.close() except: pass else: host="invalide" self.wfile.write(bytes(""" vnctv
""", "utf-8")) if __name__ == "__main__": webServer = HTTPServer((hostName, serverPort), MyServer) print("Server started http://%s:%s" % (hostName, serverPort)) try: webServer.serve_forever() except KeyboardInterrupt: pass webServer.server_close() print("Server stopped.")