Skip to content

Commit

Permalink
Update handlers: add default and load_handler method execution
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzkab committed Jan 8, 2020
1 parent 776feac commit 9f620d4
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions core/ssrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class SSRF(object):
modules = set()
handler = None
requester = None

def __init__(self, args):
Expand All @@ -15,10 +16,14 @@ def __init__(self, args):
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)

Expand All @@ -40,19 +45,21 @@ def __init__(self, args):

# 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)

0 comments on commit 9f620d4

Please sign in to comment.