#!/usr/bin/env python3 # Author: Bandie Canis # License: 2-Clause BSD license import ssl, socket, subprocess, time, os, sys import configparser def getTimestamp(): t = "[" + time.strftime("%Y-%m-%d %H:%M:%S") + "]" return t def execFromConfig(option, pw=False): cfg = configparser.SafeConfigParser() cfg.read(CONFIG) if(pw): if(option == password): return 4 else: return 5 else: try: cmd = cfg.get("Commands", option).replace("\"", "").replace("\'", "") cmd = cmd.split(" ") try: subprocess.Popen(cmd) return 0 except FileNotFoundError: print(getTimestamp(), "Can't execute", cmd, ". File not found.") return 2 except configparser.NoOptionError: print(getTimestamp(), "No execution set:", option) return 1 def main(): while True: newsocket, fromaddr = bindsocket.accept() try: connstream = context.wrap_socket(newsocket, server_side=True) print(getTimestamp(), "Incoming connection:", fromaddr[0]) connstream.send(b"OK 1337\n") con_loop = True while con_loop: global tmppw_on, pw_on, pwtimeout if('timeout' in locals() and timeout