示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
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
示例#5
0
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
示例#6
0
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
示例#7
0
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
示例#8
0
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
示例#9
0
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
示例#10
0
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