Ejemplo n.º 1
0
def WEP64():
    passphrase, keys = set_passphrase()
    index = get_index(keys)
    IV = 'a03177'.upper()
    # IV = gen_iv()
    #hex_IV = hex(IV)
    #shex_IV = (hex_IV[2:]).zfill(6)
    shex_IV = IV
    key = (shex_IV + index).upper()
    text = ''
    print('Hex IV is: 0x%s' % shex_IV)
    print('Working key is: %s' % key)

    text = input('Text to encrypt or decrypt: ')
    choice = input('Should text be encrypted? (y/n): ')
    if choice == 'y':
        text = RC4.encode(key, text)
    elif choice == 'n':
        text = RC4.decode(key, text)

    print('Changed text:\n%s' % text)
Ejemplo n.º 2
0
with open('cipher_simple.txt', 'r') as cfile:
    for line in cfile:
        for c in line:
            if c != ' ' and c != '\n':
                cipher += c

print('\nPlaintext challenge: \n%s\n' % plain)
print(len(plain))
print('\nCiphertext response: \n%s\n' % cipher)
print(len(cipher))

wait = input('Enter to start')

while current != 'FFFFFFFFFF':
    working_text = RC4.decode(combo, cipher)
    #print('Plantext: %s' % plain)
    #print('Working: %s' % working_text)
    if plain in working_text:
        print('PASSWORD FOUND! %s' % combo)
        print('Plaintext: %s' % plain)
        print('Working: %s' % working_text)
        break
    else:
        #print('Incrementing %s ' % current),
        current_int = int(current, 16)
        current_int += 1
        current = ((hex(current_int))[2:]).zfill(10)
        #print('to %s' % current)
        combo = (IV + current).upper()
        print('Incrementing to  %s' % combo)
Ejemplo n.º 3
0
with open('cipher_simple.txt', 'r') as cfile:
    for line in cfile:
        for c in line:
            if c != ' ' and c != '\n':
                cipher += c


print('\nPlaintext challenge: \n%s\n' % plain)
print(len(plain))
print('\nCiphertext response: \n%s\n' % cipher)
print(len(cipher))

wait = input('Enter to start')

while current != 'FFFFFFFFFF':
    working_text = RC4.decode(combo, cipher)
    #print('Plantext: %s' % plain)
    #print('Working: %s' % working_text)
    if plain in working_text:
        print('PASSWORD FOUND! %s' % combo)
        print('Plaintext: %s' % plain)
        print('Working: %s' % working_text)
        break
    else:
        #print('Incrementing %s ' % current),
        current_int = int(current, 16)
        current_int += 1
        current = ((hex(current_int))[2:]).zfill(10)
        #print('to %s' % current)
        combo = (IV + current).upper()
        print('Incrementing to  %s' % combo)
Ejemplo n.º 4
0
import RC4

n = 12
key = '12345'

with open('text.txt', 'r', encoding='utf-8') as input_data:
    # Открываем исходный файл и записываем данные из него в переменную data.
    data = input_data.read()

# Генерируем ключевой поток и шифруем исходные данные
s_block = RC4.s_block_generate(data, key, n)
encoded_data = RC4.encode(data, s_block)

with open('encoded.txt', 'w', encoding='utf-8') as out_data:
    # Выводим шифр в файл encoded.txt
    for element in encoded_data:
        out_data.write(str(element) + ' ')

with open('encoded.txt', 'r', encoding='utf-8') as inpt_data:
    # Открываем файл с шифром и записываем данные из него в переменную data.
    data = inpt_data.read().split()

# Повторно генерируем ключевой поток и расшифровываем данные.
s_block = RC4.s_block_generate(data, key, n)
decoded_data = RC4.decode(data, s_block)

with open('decoded.txt', 'w', encoding='utf-8') as out_data:
    # Записываем результат в decoded.txt
    for element in decoded_data:
        out_data.write(element)