def main(argv=sys.argv[1:]): args = parse_args(argv) hostname = configHelper.config("config.ini").config["server"]["host"] consoleHelper.printServerStartHeader(True) if glob.conf.default: # We have generated a default config.ini, quit server consoleHelper.printWarning() consoleHelper.printColored( "[!] config.ini not found. A default one has been generated.", bcolors.YELLOW) consoleHelper.printColored( "[!] Please edit your config.ini and run the server again.", bcolors.YELLOW) sys.exit() if not glob.conf.checkConfig(): consoleHelper.printError() consoleHelper.printColored( "[!] Invalid config.ini. Please configure it properly", bcolors.RED) consoleHelper.printColored( "[!] Delete your config.ini to generate a default one", bcolors.RED) sys.exit() consoleHelper.printColored( "{}Proxying {} and hosting on 127.0.0.1:{}...".format( bcolors.UNDERLINE, hostname, args.port), bcolors.GREEN) if glob.verbose: consoleHelper.printColored("WARNING! VERBOSE MODE IS ON!", bcolors.YELLOW) server_address = ('127.0.0.1', args.port) httpd = HTTPServer(server_address, proxyHTTPRequestHandler.ProxyHTTPRequestHandler) httpd.timeout = 30 httpd.serve_forever()
if __name__ == "__main__": # AGPL license agreement try: agpl.check_license("ripple", "pep.py") except agpl.LicenseError as e: print(str(e)) sys.exit(1) try: # Server start consoleHelper.printServerStartHeader(True) # Read config.ini consoleHelper.printNoNl("> Loading config file... ") glob.conf = configHelper.config("config.ini") if glob.conf.default: # We have generated a default config.ini, quit server consoleHelper.printWarning() consoleHelper.printColored( "[!] config.ini not found. A default one has been generated.", bcolors.YELLOW) consoleHelper.printColored( "[!] Please edit your config.ini and run the server again.", bcolors.YELLOW) sys.exit() # If we haven't generated a default config.ini, check if it's valid if not glob.conf.checkConfig(): consoleHelper.printError()
import hashlib from helpers import configHelper from helpers import generalHelper from helpers import consoleHelper from objects import glob from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import urlencode, urljoin, urlparse, urlunparse, parse_qs from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings( InsecureRequestWarning) # I have got enough bullshit hostname = configHelper.config("config.ini").config["server"]["host"] username = configHelper.config("config.ini").config["server"]["username"] password = configHelper.config("config.ini").config["server"]["password"] certificate = configHelper.config("config.ini").config["server"]["certificate"] password_hashed = hashlib.md5( str(password).encode('utf-8')).hexdigest() # Hashed Password class ProxyHTTPRequestHandler(BaseHTTPRequestHandler): protocol_version = 'HTTP/1.0' def do_HEAD(self): self.do_GET(body=False) return def do_GET(self, body=True):