def readLocal(): handlers.register("sendline", sendline) for f in os.listdir("plugins"): if not f.endswith(".py"): # Not python? skip. continue if f.endswith("test.py"): # Python, but is a test? skip. continue name = f.split(".")[0] __import__("plugins." + name) data = "" socks.local.settimeout(.1) while True: try: read = socks.local.recv(1024).decode('utf-8') except socket.timeout: continue print(">>", read) if read == '': print("[remote disconnect]") shutdown() return data += read while "\n" in data: line, data = data.split("\n", 1) try: handleLine(line.replace("\r","")) except Exception as e: import traceback traceback.print_exc()
def loadPlugins(sendline): handlers.register("sendline", sendline) for f in os.listdir("plugins"): if not f.endswith(".py"): # Not python? skip. continue if f.endswith("test.py"): # Python, but is a test? skip. continue name = f.split(".")[0] try: __import__("plugins." + name) print("[ OK ]", name) except Exception as e: print("[FAIL]", name, e)
def mainLoop(): handlers.register("sendline", sendline) for f in os.listdir("plugins"): if not f.endswith(".py"): # Not python? skip. continue if f.endswith("test.py"): # Python, but is a test? skip. continue name = f.split(".")[0] __import__("plugins." + name) #handlers.emitEvent("ready") while True: try: line = sys.stdin.readline() except KeyboardInterrupt: print("Keyboard interrupt. closing socket") socks.local.close() return socks.local.send(line.encode('utf-8'))
def decorator(func): register("line", func) return func