def server_judge(): round_id = randomize_round_id() token = request.headers.get('Token') if not verify_token(token): return jsonify({'status': -1, message: "illegal token"}) __data = request.get_json() hh = Handler(__data, round_id) hh.run() return jsonify({"message": "ok"})
def server_judge(): result = {'status': 'reject'} round_id = randomize_round_id() round_dir = os.path.join(ROUND_DIR, str(round_id)) try: if verify_token(request.authorization): result.update(Handler(request.get_json(), round_id).run()) result['status'] = 'received' except Exception as e: traceback.print_exc() result['message'] = repr(e) finally: shutil.rmtree(round_dir, ignore_errors=True) return jsonify(result)
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)
import sys import os import traceback from core.handler import Handler from colorama import Fore, Style from argparse import ArgumentParser, RawDescriptionHelpFormatter HANDLER = Handler() def py_errors(PATH): if not os.path.isfile(PATH): print( Fore.RED + '[×] ERROR: No such file was found, check your path and try again.' + Style.RESET_ALL) else: print(Fore.GREEN + '[✓] File Located: Script is busy' + Style.RESET_ALL) try: print(Fore.GREEN + "[*] Running ..." + Style.RESET_ALL) exec(open(PATH).read()) print(Fore.GREEN + "[✓] Your script is ok!" + Style.RESET_ALL) sys.exit() except KeyboardInterrupt as err: print(Fore.RED + '[×] KEYBOARD INTERRUPT ERROR' + Style.RESET_ALL) except Exception as err: error_class = err.__class__.__name__ cl, exc, tb = sys.exc_info()
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()
#!/usr/bin/env python import os import sys import argparse BASE_DIR = os.path.dirname(os.getcwd()) sys.path.append(BASE_DIR) from core.handler import Handler if __name__ == '__main__': parser = argparse.ArgumentParser(description='collect client info') group = parser.add_mutually_exclusive_group() group.add_argument('-c', '--collect-data', action="store_true", help="collect client data") group.add_argument('-r', '--report-data', action="store_true", help="collect and report client data") args = parser.parse_args() if args.collect_data: Handler.collect_data() elif args.report_data: Handler.report_data() else: print('Do Nothing! please add -h argument to get help.')
if args.convo is not None and args.message is not None: log.info("Convo: %s" % args.convo) log.info("Message: %s" % args.message) log.info("Username: %s" % args.username) slack_client.api_call("chat.postMessage", as_user=False, username=args.username, icon_emoji=":%s:" % args.emoji, channel=args.convo, text=args.message) sys.exit(" ... exiting") if __name__ == "__main__": if slack_client.rtm_connect(with_team_state=False): try: handler = Handler(config) while True: handler.handle_events(slack_client.rtm_read()) time.sleep(RTM_READ_DELAY) except (KeyboardInterrupt, SystemExit) as e: config.pop('commands') config.pop('plugins') config.dump(os.path.join(script_path, 'slack_settings.json')) # persistence.close_db() slack_client.api_call("chat.postMessage", as_user=True, channel=config.get('slackbot.botchannel.id'), text='Bye bye ... Reason: %s' % str(e)) sys.exit(" ... exiting")