def main(): #get config start_ip, end_ip, skip_ip, port, submit_addr, script_function, url_file, flag_file, round_time, token, success_request, failed_request, flag_start, flag_end = resolve_config.main( ) ip_list = target.main(start_ip, end_ip, skip_ip) if script_function == "pwn": while 1: for ip in ip_list: message = pwn_flag.main(ip, port) submit_status = submit.main(submit_addr, message, token, success_request, failed_request) message['submit_status'] = submit_status['status'] log.main(ip, message) time.sleep(round_time) elif script_function == "web": while 1: for url in url_file: message = web_flag.main(url, flag_start, flag_end) submit_status = submit.main(submit_addr, message, token, success_request, failed_request) message['submit_status'] = submit_status['status'] log.main(url, message) time.sleep(round_time) elif script_function == "local": while 1: for flag in flag_file: message = {'getflag_status': 'getflag success', 'flag': flag} submit_status = submit.main(submit_addr, message, token, success_request, failed_request) message['submit_status'] = submit_status['status'] log.main(flag, message) time.sleep(round_time) else: print "script_function set error" clean()
def main(): #get config con = resolve_config.main() if con.script_function == "pwn": while 1: for ip in con.ip_list: message = pwn_attack.main(ip) message = submit.main(con.submit, message) log.main(ip, message) time.sleep(con.submit_wait) time.sleep(con.round_time) elif con.script_function == "web": while 1: for ip in con.ip_list: message = web_attack.main(ip) message = submit.main(con.submit, message) log.main(ip, message) time.sleep(con.submit_wait) time.sleep(con.round_time) elif con.script_function == "local": while 1: for flag in con.flag_list: message = {'getflag_status': 'getflag success', 'flag': flag} message = submit.main(con.submit, message) log.main(flag, message) time.sleep(con.submit_wait) time.sleep(con.round_time) else: print "script_function set error" clean()
def test_002(self, capfd): sys.stdin = StringIO(u'4\n') submit.main( self.parser.parse_args( ['-m', './test/_coursera2', '-c', './test/_credentials2'])) resout, reserr = capfd.readouterr() assert ('Unable to locate assignment file' in resout)
def test_002(self, capfd): sys.stdin = StringIO(u'1\n') submit.main( self.parser.parse_args( ['-m', './test/_coursera', '-c', './test/_credentials'])) resout, reserr = capfd.readouterr() assert (output_worked in resout)
def test_001(self, capfd): sys.stdin = StringIO(u'1\n') submit.main( self.parser.parse_args( ['-m', './test/_coursera', '-c', './test/_credentials'])) output = 'Unable to locate assignment file' resout, reserr = capfd.readouterr() assert (output in resout)
def test_003(self, capfd): sys.stdin = StringIO(u'1\n') submit.main(self.parser.parse_args(['-m', './test/_coursera', '-c', './test/_credentials', '-rs'])) output = 'writting submission file: _awPVV' resout, reserr = capfd.readouterr() assert(output in resout) assert(not output_worked in resout) os.remove('_awPVV/submission.sub') os.rmdir('_awPVV')
def test_003(self, capfd): login, token = submit.login_prompt('./test/_credentials') sys.stdin = StringIO(u'1\n%s\n%s\n' % (login, token)) submit.main( self.parser.parse_args([ '-o', './test/model/model.mzn', '-m', './test/_coursera', '-c', './test/_credentials3' ])) resout, reserr = capfd.readouterr() assert (output_worked in resout)
def test_002(self, capfd): sys.stdin = StringIO(u'1\n') submit.main( self.parser.parse_args([ '-m', './test/_coursera3', '-c', './test/_credentials', '-o', './test/model/model.mzn' ])) output = 'Please use a token for the assignment you are submitting.' resout, reserr = capfd.readouterr() print(resout) assert (output in resout)
def test_003(self, capfd): sys.stdin = StringIO(u'1\n') submit.main( self.parser.parse_args( ['-m', './test/_coursera', '-c', './test/_credentials', '-rs'])) output = 'writting submission file: _awPVV' resout, reserr = capfd.readouterr() assert (output in resout) assert (not output_worked in resout) os.remove('_awPVV/submission.sub') os.rmdir('_awPVV')
def test_001(self, capfd): sys.stdin = StringIO(u'1\n') submit.main( self.parser.parse_args([ '-m', './test/_coursera3', '-c', './test/_credentials2', '-o', './test/model/model.mzn' ])) output_1 = 'Unexpected response code, please contact the course staff.' output_2 = 'Expected parts: ' output_3 = 'but found: ' resout, reserr = capfd.readouterr() print(resout) assert (output_1 in resout) assert (output_2 in resout) assert (output_3 in resout)
def test_002(self, capfd): sys.stdin = StringIO(u'1\n') submit.main(self.parser.parse_args(['-m', './test/_coursera', '-c', './test/_credentials'])) resout, reserr = capfd.readouterr() assert(output_worked in resout)
import grace import submit import time tmp_name = "tmp-{}".format(int(time.time())) grace.main(tmp_name) submit.main(tmp_name)
def main(): main_parser = argparse.ArgumentParser( description= 'Deploy and monitor Google Dataproc clusters to use with Hail.') subs = main_parser.add_subparsers() start_parser = subs.add_parser( 'start', help='Start a Dataproc cluster configured for Hail.', description='Start a Dataproc cluster configured for Hail.') submit_parser = subs.add_parser( 'submit', help='Submit a Python script to a running Dataproc cluster.', description='Submit a Python script to a running Dataproc cluster.') connect_parser = subs.add_parser( 'connect', help='Connect to a running Dataproc cluster.', description='Connect to a running Dataproc cluster.') diagnose_parser = subs.add_parser( 'diagnose', help='Diagnose problems in a Dataproc cluster.', description='Diagnose problems in a Dataproc cluster.') stop_parser = subs.add_parser('stop', help='Shut down a Dataproc cluster.', description='Shut down a Dataproc cluster.') start_parser.set_defaults(module='start') start.init_parser(start_parser) submit_parser.set_defaults(module='submit') submit.init_parser(submit_parser) connect_parser.set_defaults(module='connect') connect.init_parser(connect_parser) diagnose_parser.set_defaults(module='diagnose') diagnose.init_parser(diagnose_parser) stop_parser.set_defaults(module='stop') stop.init_parser(stop_parser) if len(sys.argv) == 1: main_parser.print_help() sys.exit(0) args = main_parser.parse_args() if args.module == 'start': start.main(args) elif args.module == 'submit': submit.main(args) elif args.module == 'connect': connect.main(args) elif args.module == 'diagnose': diagnose.main(args) elif args.module == 'stop': stop.main(args)