def __init__(self, args): # Load modules in memory self.load_modules() # Start a reverse shell handler if args.handler and args.lport and args.handler == "1": handler = Handler(args.lport) handler.start() elif args.handler and args.lport: self.load_handler(args.handler) handler = self.handler.exploit(args.lport) handler.start() proxies = None if args.proxy: proxies = { "http" : args.proxy, "https" : args.proxy, } # Init a requester self.requester = Requester(args.reqfile, args.useragent, args.ssl, proxies) # NOTE: if args.param == None, target everything if args.param == None: logging.warning("No parameter (-p) defined, nothing will be tested!") # NOTE: if args.modules == None, try everything if args.modules == None: logging.warning("No modules (-m) defined, everything will be tested!") for module in self.modules: module.exploit(self.requester, args) else: for modname in args.modules.split(','): for module in self.modules: if module.name == modname: module.exploit(self.requester, args) break # Handling a shell while args.handler: handler.listen_command() time.sleep(5)
def __init__(self, args): # Load modules in memory self.load_modules() # Start a reverse shell handler if args.handler: handler = Handler(args.handler) handler.start() # Init a requester self.requester = Requester(args.reqfile, args.useragent, args.ssl) # NOTE: if args.param == None, target everything if args.param == None: logging.warning( "No parameter (-p) defined, nothing will be tested!") # NOTE: if args.modules == None, try everything if args.modules == None: logging.warning( "No modules (-m) defined, everything will be tested!") for module in self.modules: module.exploit(self.requester, args) else: for modname in args.modules.split(','): for module in self.modules: if module.name == modname: module.exploit(self.requester, args) break # 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)
from system import Slave import signal import sys from core.interface import MainMenu from core.handler import Handler def terminate(signum, frame): print("Exiting program...") sys.exit(5) if __name__ == '__main__': signal.signal(signal.SIGTERM, terminate) signal.signal(signal.SIGINT, terminate) configuration = MainMenu.start_menu() configuration.Coils.show_blocks() configuration.DiscreteInputs.show_blocks() configuration.InputRegisters.show_blocks() configuration.HoldingRegisters.show_blocks() slave = Slave(configuration) handler = Handler(slave.Configuration.Data, slave.Configuration.Data.Blocks) handler.start() slave.start() handler.join() slave.join()