Update handlers: add default and load_handler method execution
parent
776feac515
commit
9f620d4f33
33
core/ssrf.py
33
core/ssrf.py
|
@ -7,6 +7,7 @@ import logging
|
|||
|
||||
class SSRF(object):
|
||||
modules = set()
|
||||
handler = None
|
||||
requester = None
|
||||
|
||||
def __init__(self, args):
|
||||
|
@ -15,10 +16,14 @@ class SSRF(object):
|
|||
self.load_modules()
|
||||
|
||||
# Start a reverse shell handler
|
||||
if args.handler:
|
||||
handler = Handler(args.handler)
|
||||
if args.handler == "1":
|
||||
handler = Handler(args.lport)
|
||||
handler.start()
|
||||
|
||||
else:
|
||||
self.load_handler(args.handler)
|
||||
handler = self.handler.exploit(args.lport)
|
||||
handler.start()
|
||||
|
||||
# Init a requester
|
||||
self.requester = Requester(args.reqfile, args.useragent, args.ssl)
|
||||
|
||||
|
@ -40,19 +45,21 @@ class SSRF(object):
|
|||
|
||||
# Handling a shell
|
||||
while args.handler:
|
||||
if handler.connected == True:
|
||||
cmd = input("Shell> $ ")
|
||||
if cmd == "exit":
|
||||
handler.kill()
|
||||
print("BYE !")
|
||||
exit()
|
||||
handler.send_command(cmd+"\n\n")
|
||||
else:
|
||||
time.sleep(5)
|
||||
handler.listen_command()
|
||||
time.sleep(5)
|
||||
|
||||
def load_modules(self):
|
||||
for index,name in enumerate(os.listdir("./modules")):
|
||||
location = os.path.join("./modules", name)
|
||||
if ".py" in location:
|
||||
mymodule = SourceFileLoader(name, location).load_module()
|
||||
self.modules.add(mymodule)
|
||||
self.modules.add(mymodule)
|
||||
|
||||
def load_handler(self, name):
|
||||
handler_file = "{}.py".format(name)
|
||||
try:
|
||||
location = os.path.join("./handlers", handler_file)
|
||||
self.handler = SourceFileLoader(handler_file, location).load_module()
|
||||
except Exception as e:
|
||||
logging.error("Invalid no such handler: {}".format(name))
|
||||
exit(1)
|
||||
|
|
Loading…
Reference in New Issue