def validateSched(sched, sessions, entries, logger): returnVal = 0 #Check that every entry is in the schedule only once for entry in entries: entryFoundCount = 0 for session in sched['lst']: if 'entry' in session and session['entry']['index'] == entry[ 'index']: entryFoundCount += 1 if entryFoundCount > 1: print('Entry scheduled more than once') returnVal += 1 elif entryFoundCount == 0: print('Entry not scheduled') returnVal += 2 #No breaks get filled with an entry for session in sched['lst']: if session['isBreak'] == True and 'entry' in session: print('Entry scheduled during a break') returnVal += 4 if returnVal > 0: logger.msg('Validation Failed, score %d' % returnVal) else: logger.msg('Validation Passed')
def validateSched (sched, sessions, entries, logger): returnVal = 0 #Check that every entry is in the schedule only once for entry in entries: entryFoundCount = 0 for session in sched['lst']: if 'entry' in session and session['entry']['index'] == entry['index']: entryFoundCount += 1 if entryFoundCount > 1: print ('Entry scheduled more than once') returnVal += 1 elif entryFoundCount == 0: print ('Entry not scheduled') returnVal += 2 #No breaks get filled with an entry for session in sched['lst']: if session['isBreak'] == True and 'entry' in session: print ('Entry scheduled during a break') returnVal += 4 if returnVal > 0: logger.msg ('Validation Failed, score %d' % returnVal) else: logger.msg ('Validation Passed')
def wrapper(func): logger.msg(str(func)) name = escape_name(func.__name__) func_args[name] = list(reversed(prompts)) commands[name] = func help_text[name] = inspect.getdoc(func) sourcelookup[name] = (filename, line_number) return func
def parametrizied(usrnam, passwd): query = "SELECT * FROM users where userid = ? and passwd= ?" args = (usrnam, passwd) try: if database.executeParameter(query, args) is not None: print(logger.tick(), logger.msg('Login successful')) else: print(logger.cross(), logger.msg('Login failed')) except: print(logger.cross(), logger.msg('Login failed'))
def basic(usrnam, passwd): query = "SELECT * FROM users where userid = '" + str( usrnam) + "' and passwd='" + str(passwd) + "'" try: if database.execute(query) is not None: print(logger.tick(), logger.msg('Login successful')) else: print(logger.cross(), logger.msg('Login failed')) except: print(logger.cross(), logger.msg('Login failed'))
def whitelist(usrnam, passwd): query = "SELECT * FROM users where userid = '" + str( usrnam) + "' and passwd='" + str(passwd) + "'" flag = 0 if re.findall(r'^[A-Za-z0-9]+$', passwd) and re.findall( r'^[A-Za-z0-9]+$', usrnam): flag = 1 try: if flag == 1 and database.execute(query) is not None: print(logger.tick(), logger.msg('Login successful')) else: print(logger.cross(), logger.msg('Login failed')) except: print(logger.cross(), logger.msg('Login failed'))
def main(): print(logger.star(), logger.level(0), logger.sep(), logger.msg('Database Creation'), end='\r') try: database.initDB() print(logger.tick(), logger.level(1), logger.sep(), logger.msg('Database Creation'), end='\n') except: print(logger.cross(), logger.level(2), logger.sep(), logger.msg('Database Creation'), end='\n')
def wrapper(func): logger.msg(str(func)) name = escape_name(func.__name__) func_args[name] = list(reversed(prompts)) commands[name] = func help_text[name] = inspect.getdoc(func) sourcelookup[name] = (filename, line_number) try: _aliases = kwargs['alias'] if not hasattr(_aliases, "__iter__"): _aliases = [_aliases] for _alias in _aliases: alias(_alias, name) except KeyError: pass if kwargs.get("nohistory", False): nohistory.append(name) return func
def blacklist(usrnam, passwd): bFile = open('blacklist', 'r') blacklist = [_.strip() for _ in bFile.readlines()] query = "SELECT * FROM users where userid = '" + str( usrnam) + "' and passwd='" + str(passwd) + "'" flag = 0 for _ in usrnam.replace("\\", "").split(' '): if _ in blacklist: flag = 1 for _ in passwd.replace("\\", "").split(' '): if _ in blacklist: flag = 1 if flag == 1: print(logger.cross(), logger.msg('Login failed')) else: try: if database.execute(query) is not None: print(logger.tick(), logger.msg('Login successful')) else: print(logger.cross(), logger.msg('Login failed')) except: print(logger.cross(), logger.msg('Login failed'))
stageNum = 1 stageStart = time.time() flushCycleStart = time.time() printCnt = 1 waitCnt = 0 prevBestScore = 999999999999 scoreLastImprovedTime = time.time() jobMaxSize = 1000 jobMinSize = 10 jobSizeIncr = 10 lastScorePrintTime = time.time() logger.msg('Start Main Loop') jobCurrentSize = jobMinSize while True: parentsList = findParentSchedules(rdm, jobCurrentSize, randGenMain) for x in parentsList: taskQueue.put({'cmd':'XOver', 'idx':x[0], 'sch1':rdm[x[0]], 'sch2':rdm[x[1]]}) for x in range(jobCurrentSize): mutateIdx = randGenMain.randint(0, len(rdm)-1) taskQueue.put({'cmd':'Mutate', 'idx':mutateIdx, 'sch1':rdm[mutateIdx]}) taskQueue.put({'cmd':'Done'}) #End of job marker jobCurrentSize = min(jobCurrentSize + jobSizeIncr, jobMaxSize) if jobCurrentSize == jobMaxSize - 10: logger.msg('*')
try: if database.executeParameter(query, args) is not None: print(logger.tick(), logger.msg('Login successful')) else: print(logger.cross(), logger.msg('Login failed')) except: print(logger.cross(), logger.msg('Login failed')) if not os.path.isfile('demo.db'): init.main() else: print(logger.tick(), logger.level(1), logger.sep(), logger.msg('Database Creation'), end='\n') level = [{ 'type': 'list', 'name': 'lvl', 'message': 'Select level of SQLi testing?', 'choices': ['Basic', 'Whitelist', 'Blacklist', 'Parametrizied Query'] }] choice = prompt(level, style=style)['lvl'] username, password = loginForm() if choice == 'Basic': basic(username, password) elif choice == 'Whitelist': whitelist(username, password)
except FileExistsError: sys.exit('Need to wait 1 minute between runs') logger = logger.Logger(outFolder) schedIO.setLogger(logger) schedFitness.setLogger(logger) #Load config file configRaw = {} config = {} exec(open(os.path.join(jobFolder, "settings.py")).read(), config) for key, value in configRaw: #For some reason the raw config isnt pickleable config[key] = value if dryRunMode: print('--++## Dry Run Mode ##++--') logger.msg('Running on %s' % platform.node()) #Tell schedIO and Categories object if we are group or individal. if 'G' in config['CONTEST_TYPE'].upper(): schedIO.setCats('group') else: schedIO.setCats('indiv') #Read input files sessionsFile = os.path.join(jobFolder, 'Sessions.txt') restrSheetFile = os.path.join(jobFolder, 'restrSheet.csv') lcl_schoolCsvFile = os.path.join(jobFolder, 'schoolReg.csv') schoolCsvFile = os.path.join(config['MASTER_FILE_PATH'], 'schoolReg.csv') lcl_schoolExportFile = os.path.join(jobFolder, 'schoolsExport.csv') schoolExportFile = os.path.join(config['MASTER_FILE_PATH'],