def identify_single_XOR(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['values'] = args.input if not args.dictionaryFile: raise Exception( 'This challenge must be provided a json data file with -d') # Complete challenge hexStrings = readFile(challengeData['values'][0]) scoreBoard = [Candidate(0, b'', b'', b'') ] * (args.candidates if args.candidates else 1) for hexString in hexStrings: candidate = crackXOR(hexString, args.dictionaryFile, XORType.SINGLE) for idx, finalist in enumerate(scoreBoard): if candidate.score > finalist.score: scoreBoard[idx] = candidate break challengeData['stringNumber'] = len(hexStrings) challengeData['scoreBoard'] = scoreBoard return challengeData
def pad_with_PKCS7(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['value'] = args.input[0] # Complete challenge output = pad(challengeData['value'].encode(), challengeData['length']) challengeData['output'] = output return challengeData
def fixed_XOR(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['values'] = args.input # Complete challenge values = challengeData['values'] output = fixedXOR(values[0], values[1]) challengeData['output'] = bytes2hex(output) return challengeData
def convert_hex_to_base64(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['values'] = args.input # Complete challenge value = challengeData['values'][0] output = hex2b64(value) challengeData['output'] = output.decode() return challengeData
def repeating_XOR(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['value'] = args.input[0] if args.key: challengeData['key'] = args.key # Complete challenge output = repeatingXOR(challengeData['value'], challengeData['key']) challengeData['output'] = output return challengeData
def crack_single_XOR(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['values'] = args.input if not args.dictionaryFile: raise Exception('This challenge must be provided a json data file with -d') # Complete challenge candidate = crackXOR(challengeData['values'][0], args.dictionaryFile, XORType.SINGLE) challengeData['candidate'] = candidate return challengeData
def decrypt_AES(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['value'] = args.input[0] # Complete challenge cipherBlocks = readFile(challengeData['value']) bestGuess = PossibleEncryption('', 0) for block in cipherBlocks: guess = maybeECB_AES128(block) if guess and guess.repetition > bestGuess.repetition: bestGuess = guess challengeData['guess'] = bestGuess challengeData['blockNumber'] = len(cipherBlocks) return challengeData
def decrypt_AES(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['value'] = args.input[0] if args.key: challengeData['key'] = args.key # Complete challenge key = challengeData['key'] f = readFile(challengeData['value']) ciphertext = b642bytes(''.join(f)) secret = ECB_AES128(key, ciphertext, Action.DECRYPT) challengeData['secret'] = secret challengeData['bytes'] = len(ciphertext) return challengeData
def repeating_XOR(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['value'] = args.input[0] if not args.dictionaryFile: raise Exception( 'This challenge must be provided a json data file with -d') # Complete challenge f = readFile(challengeData['value']) hexString = b642hex(''.join(f)) candidate = crackXOR(hexString, args.dictionaryFile, XORType.REPEATING) challengeData['candidate'] = candidate challengeData['lines'] = len(f) return challengeData
def decrypt_CBC_AES128(): # Set up args = getArgs() challengeData = getData()[getFilename(__file__)] if args.input: challengeData['value'] = args.input[0] if args.key: challengeData['key'] = args.key # Complete challenge f = ''.join(readFile(challengeData['value'])) b = b642bytes(f) VI = bytes([0] * 16) output = CBC_AES128(challengeData['key'], b, VI, Action.DECRYPT) challengeData['output'] = output challengeData['bytes'] = len(b) return challengeData