Example #1
0
def decryption_procedure(stego_image_name, key):
    # Decryption Procedure
    stego_image_name = output_path + "/" + stego_image_name
    steganography.decode(stego_image_name, output_path)
    shuffle.shuffle_unshuffle(output_path + "/" + encrypted_image_name)
    RC4.rc4_decryption(output_path + "/" + encrypted_image_name, key,
                       output_path, decrypted_image_name_without_extension)
Example #2
0
 def receive2(self, dt):
     global recv_sock, imageStart, mood_detect, RC4_on, message
     if not imageStart:
         return
     try:
         print("receive")
         mode, stringData = customRecv(recv_sock)
         if mode == 50:
             data = np.fromstring(stringData, dtype='uint8')
             if RC4_on:
                 KeyBytes = RC4.text_to_bytes('key.txt')
                 data = RC4.crypt(data, KeyBytes)
             decimg = cv2.imdecode(data, 1)
             if mood_detect:
                 decimg = fd.face_detect(decimg)
             buf = b''.join(decimg)
             image_texture = Texture.create(size=(640, 480), colorfmt='bgr')
             image_texture.blit_buffer(buf,
                                       colorfmt='bgr',
                                       bufferfmt='ubyte')
             self.texture = image_texture
         elif mode == 10:
             message = stringData.decode()
     except:
         pass
Example #3
0
def encryption_procedure(sec_image_name, cov_image_name, key):
    # Encryption Procedure
    sec_image_name = input_path + sec_image_name
    cov_image_name = input_path + cov_image_name
    RC4.rc4_encryption(sec_image_name, key, output_path, encrypted_image_name)
    shuffle.shuffle_unshuffle(output_path + "/" + encrypted_image_name)
    steganography.encode(output_path + "/" + encrypted_image_name, output_path,
                         cov_image_name)
Example #4
0
def threaded_client(conn):
    while True:
        data = conn.recv(1024)
        if not data:
            break
        x = RC4.decrypt(data)
        m = RC4.getMessage(x)
        print("\nRECEIVED: ", m)
        if not data:
            break
    conn.close()
Example #5
0
    def generate_keys(self):

        self.key_material()
        self.conn.read_key = self.conn.key_material[:16]
        self.conn.write_key = self.conn.key_material[16:]

        self.hexprint("generate_keys:\n", self.conn.read_key)
        self.hexprint("", self.conn.write_key)
        d = RC4.RC4()
        self.conn.rc4_read_key = d.RC4_set_key(self.conn.read_key)
        del d
        d = RC4.RC4()
        self.conn.rc4_write_key = d.RC4_set_key(self.conn.write_key)
        del d
Example #6
0
def connection_manager(clientSocket, clientAddress, inbox):

    clientIP, PORT = clientAddress

    if clientIP and PORT:
        print "\n\nACCEPTED connection from: ", clientIP, " on port number: ", PORT

        cipherText = clientSocket.recv(
            BUFFER_SIZE)  #retrieve the message from the client

        if not cipherText:
            print "\nMESSAGE WAS INVALID\n"

        else:
            dmessage = RC4.decrypt(
                cipherText, 20,
                "password")  #decryption; 20 rounds of key scheduling
            print "\nMESSAGE RECEIVED >> \r\n", dmessage

            LocalTime = time.asctime(time.localtime(
                time.time()))  #get current time
            savedMessage = "TIME RECEIVED: " + LocalTime + "\n\nMESSAGE: " + dmessage  #add time to message

            inbox.append(
                savedMessage)  ###STORE MESSAGE IN RECEIVED MESSAGES LIST

        clientSocket.close()
Example #7
0
    def read_ssl(self, len=0):

        buf = self.recvstuff(self.sck, 2)

        if not buf:
            raise OpenSSLException, "read_ssl: recv returned nothing. (IIS with no SSL config?)"

        a = struct.unpack(">B", buf[0])[0]
        b = struct.unpack(">B", buf[1])[0]

        if not (a & 0x80):
            read_len = ((a & 0x3f) << 8) | b
            buf = self.recvstuff(self.sck, 1)
            padding = struct.unpack(">B", buf[0])[0]
        else:
            read_len = ((a & 0x7f) << 8) | b
            padding = 0

        if len:
            if read_len <= 0 or read_len > len:
                print "warning! ssl_returned read_len: %d user_asked len: %d" % (
                    read_len, len)

        if self.debug:
            print "read_len %d padding %d" % (read_len, padding)

        buf = self.recvstuff(self.sck, read_len)

        if self.conn.encrypted:
            if (MD5_DIGEST_LENGTH + padding) >= read_len:
                if struct.unpack("B",
                                 buf[0])[0] == SSL2_MT_ERROR and read_len == 3:
                    raise OpenSSLException, "error in read_ssl: crypto related."
                else:
                    raise OpenSSLException, "read_ssl: short ssl packet."
        else:
            return buf

        self.hexprint("read_ssl enc(md5+pad+text): ", buf)
        d = RC4.RC4()
        #self.hexprint("read_key: ", self.conn.read_key)
        #d.RC4_set_key(self.conn.read_key)
        text = d.RC4_update(self.conn.rc4_read_key, buf)
        if padding > 0:
            text = text[MD5_DIGEST_LENGTH:-padding]
        else:
            text = text[MD5_DIGEST_LENGTH:]
        #text = MD5_DIGEST + clear text + padding
        #strip padding and MD5_DIGEST
        self.hexprint("read_ssl clear text:\n", text)

        if struct.unpack("B", text[0])[0] == SSL2_MT_ERROR:
            if read_len != 3:
                raise OpenSSLException, "read_ssl: bad reply from server"
            else:
                raise OpenSSLException, "read_ssl: error from server"

        return text
def encrypt(enc_type, message, key):
    if enc_type == 2:
        message = bbs.encrypt(message, key)
    elif enc_type == 0:
        message = des.encrypt(message, key)
    elif enc_type == 1:
        message = RC4.encrypt(message, key)
    message = message + str(hmac.hmac(key, message))
    return message
Example #9
0
def client(conn):
    while True:
        reply = input("\nSEND: ")
        if reply == "exit":
            break
        reply = "\nversion: 0.2" + "\r\nfrom: Jason" + "\r\nto: Friend" + "\r\n" + "\r\n" + reply
        reply = RC4.secret(reply)
        conn.send(reply)
    print("[DISCONNECTED]")
    conn.close()
Example #10
0
def getInfo():  # 接受消息
    while True:
        data = ck.recv(1024)  # 用于接受服务器发送的信息

        key = "569716548"
        box = RC4.init_box(key)
        mingwen = RC4.ex_decrypt(data, box)  # 解密消息

        p = chaifen(mingwen)  # 返回一个包含明文和签名的元组
        print("拆分出的签名:")
        print(p[1])
        s = p[1]
        s = s[2:len(s) - 1]  #base前两位字符是b' ,所以从第三个字符开始才是签名
        s = s.encode(encoding="utf-8")

        m = MD5.md5(p[0])  # 对明文部分使用md5算法生成摘要
        # signal2=KEY.sign(m)
        v = RSA.Verify(m, s)  # 验证签名
        judge(v)  # 判断安全性
        text.insert(tkinter.INSERT, p[0])
Example #11
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)
def decrypt(dec_type, message, key):
    mac = message[-40:]
    message = message[:-40]
    if dec_type == 2:
        message = ecc.decrypt(message, key)
    elif dec_type == 0:
        message = des.decrypt(message, key)
    elif dec_type == 1:
        message = RC4.decrypt(message, key)
    if (hmac.hmac(key, message) == mac):
        return -1
    return message
Example #13
0
def sendMail():
    friend = efriend.get()  #发给谁
    sendStr = esend.get()  #发送的消息

    #用MD5生成消息摘要
    abstract = MD5.md5(sendStr)

    #用RSA算法对消息摘要进行签名
    signal1 = RSA.sign(str(abstract))

    #生成消息
    message = sendStr + '@' + str(signal1)

    #用RC4算法对消息进行加密
    key = "569716548"
    box = RC4.init_box(key)
    cipher = RC4.ex_encrypt(message, box)

    #发送消息
    sendStr = friend + ":" + cipher
    ck.send(sendStr.encode("utf-8"))
Example #14
0
def sender():
    global conn_addr, RC4_on, send_sock
    print("prepare to send\n")
    sleep(2)
    send_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    send_sock.connect(conn_addr)
    encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90]
    ret, frame = capture.read()
    while ret:
        print("send")
        result, imgencode = cv2.imencode('.jpg', np.fliplr(np.flipud(frame)),
                                         encode_param)
        data = np.array(imgencode)
        if RC4_on:
            KeyBytes = RC4.text_to_bytes('key.txt')
            data = RC4.crypt(data, KeyBytes)
        stringData = data.tostring()
        customSend(send_sock, 50, stringData)  # mode = 50 (Video send)
        ret, frame = capture.read()
        sleep(0.1)
    send_sock.close()
    cv2.destroyAllWindows()
Example #15
0
def check(key):
    """
    Encrypt the IV with the given key and checks with the keystream
    """

    rc4 = RC4.RC4(key)

    keystream = rc4.getKeystream(CHALLENGE_LEN)[16:]
    #keystream = rc4.getKeystream(CHALLENGE_LEN)

    if keystream == KEY_STREAM:
        secret_key = unconvert_key(key)
        print('\n -----KEY FOUNDED----\n\nKey : {0}\n'.format(secret_key))
        raise Exception("Key founded stopping pool")
Example #16
0
def connection_manager(clientSocket, clientAddress):

    clientIP, PORT = clientAddress

    if clientIP and PORT:
        print "Accepted connection from: ", clientIP, " on port number: ", PORT

        cipherText = clientSocket.recv(BUFFER_SIZE)

        if cipherText:
            dmessage = RC4.decrypt(cipherText, 200, "test")
            print "\nMESSAGE RECEIVED >> ", dmessage
        else:
            print "\nMESSAGE WAS INVALID\n"

        clientSocket.close()
Example #17
0
    def write_ssl(self, data):

        if self.conn.encrypted:
            total_len = len(data) + MD5_DIGEST_LENGTH
        else:
            total_len = len(data)

        if total_len + 2 > MAX_BUFSIZ:
            raise OpenSSLException, "write_ssl: buffer size too big"

        if self.debug:
            print "write_ssl total_len %d" % total_len

        buf = struct.pack(">H", total_len | 0x8000)

        if self.debug:
            print "write seq: %d" % self.conn.write_seq
        if self.conn.encrypted:
            d = md5.new()
            d.update(self.conn.write_key)
            d.update(data)
            seq = struct.pack(">L", self.conn.write_seq)
            self.hexprint("sequence: ", seq)
            d.update(seq)
            self.hexprint("MD5 digest: \n", d.digest())
            #RC4 encrypt the md5_hash+data
            r = RC4.RC4()
            #r.RC4_set_key(self.conn.write_key)
            buf += r.RC4_update(self.conn.rc4_write_key, (d.digest() + data))
            #append
        else:
            buf += data
        if self.conn.encrypted:
            self.hexprint("write_ssl encrypt text:\n", buf)

        self.sendstuff(self.sck, buf)
        self.conn.write_seq += 1
Example #18
0
def main():

    #get the config instance
    config = Config()

    scrap = scrap_website(config.getUserId(), config.getCourseNumber())
    soup = BeautifulSoup(scrap.text, "html.parser")
    ciphertext = soup.find('input', {"name": "Ciphertext"})['value']

    if ciphertext:
        key = config.getKey()
        ciphertext, key = parsing_key_ciphertext(key, ciphertext)

        rc4 = RC4()

        rc4.set_key(key)

        for i in range(len(ciphertext)):
            ciphertext[i] ^= rc4.decrypt(i)

        #verify our key
        for i in range(20, 2):
            if (ciphertext[i] != ciphertext[i + 1]):
                print("wrong key")
                return

        res = ciphertext[20:len(ciphertext)].decode("ascii")
        print(res)

    elif ciphertext == None:
        print("We couldnt find any input text called ciphertext")
        print("Check to ensure you have the right website")
        return

    else:
        print("No grade to show at the moment")
Example #19
0
        mess = raw_input("What would you like to hash?\n")
        start = time.clock()
        md5.init_mess(mess)
        out_put = md5.hex_digest()
        print out_put
        end = time.clock()
        print('--------------------------MD5 end--------------------------\n')
        print('Cost ' + str(end - start) + 's\n')
        costdic[choose] = end - start
    elif choose == 7:
        print('--------------------------RC4--------------------------\n')
        mode = raw_input("1 Encrypt or 2 Decode \n")
        if mode == '1':
            start = time.clock()

            message = RC4.get_message()
            key = RC4.get_key()
            box = RC4.init_box(key)
            RC4.ex_encrypt(message, box, mode)
            end = time.clock()

        elif mode == '2':
            message = RC4.get_message()
            key = RC4.get_key()
            box = RC4.init_box(key)
            RC4.ex_encrypt(message, box, mode)
        print('--------------------------RC4 end--------------------------\n')
        print('Cost ' + str(end - start) + 's\n')
        costdic[choose] = end - start
    elif choose == 8:
        print('--------------------------A5--------------------------\n')
Example #20
0
    mkey = b""

    for line in tbslog.readlines():
        line = line.strip()
        if not line:
            continue

        flag = line[:len_of_mkey][:3]
        if flag != b"013":
            log_data += line
            continue
        else:
            log_data_list.append((mkey, log_data))

            log_data = line[len_of_mkey:]
            mkey = RC4.decrypt(line[:len_of_mkey][3:], key_of_mkey)
            if len(mkey) != 13:
                mkey = b""
                continue
    if mkey and log_data:
        log_data_list.append((mkey, log_data))

    for key, value in log_data_list:
        if not key or not value:
            continue
        log = RC4.decrypt(value, key)
        pass

    log_list = [
        RC4.decrypt(value, key) for key, value in log_data_list
        if key and value
Example #21
0
NNSTU IRIT 16-V-2
Student: Shunin Kirill
1 10 2019
"""
# coding=utf-8
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)
Example #22
0
    if clientSocket == None:
        clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        clientSocket.connect((phone_book[test], TCP_PORT))
    except socket.error as msg:
        print("\nError Message #" + str(errorCount + 1))
        print("There was an ERROR with the connection :(")
        clientSocket.close()
        clientSocket = None
        errorCount += 1

    if clientSocket != None:
        MESSAGE = raw_input("Enter a message to send: ")
        TEST = MESSAGE

        eMESSAGE = RC4.encrypt(MESSAGE, times, key)
        print("The encrypted message is: ")
        length = len(eMESSAGE)

        toPrint = []

        for i in range(0, length):
            toPrint.append(eMESSAGE[i])

        toShow = ''.join(toPrint)
        print(toShow)

        clientSocket.send(eMESSAGE)  #data = s.recv(BUFFER_SIZE)
        print("Sent message: ", eMESSAGE)
        clientSocket.close()
Example #23
0
def main():
    name = ""
    unable_to_connect = 1
    valid_responseY = ["yes", "Yes", "YES", "y", "Y"]
    valid_responseN = ["no", "No", "NO", "n", "N"]
    option = ""
    sent_messages = []
    inbox = []
    phone_book = {}
    fileName = "phoneBook.txt"
    welcome = "WELCOME TO TAUNET"

    print_alternate_color(welcome)

    phone_book = load_addresses(
        fileName)  #load usernames and addresses included in phoneBook.txt file

    ##START SERVER on its own thread##
    thread.start_new_thread(
        run_server, (inbox, 5))  #will queue 5 connections before refusing

    ##while not exit
    while option != "7":
        option = menu()

        if option == "1":  ##DISPLAY CONTACTS
            print "\nHere are the listed contacts >>\n"
            for j, k in phone_book.iteritems():
                print "Username: "******"..........Address: " + k

        if option == "2":
            option = "2"  ##ADD A CONTACT
            already_exists = 1

            while already_exists == 1:  #while the user already exists in the dictionary
                newUser = raw_input(
                    "\nEnter a new user name >> ")  #prompt for a user name
                if newUser in phone_book:  #if user name already in book-->error
                    print("\nIt looks like that user ALREADY EXISTS!\n")
                    already_exists = 1
                else:
                    already_exists = 0

                if already_exists == 0:
                    newAddress = raw_input(
                        "\nEnter the address here >> ")  #prompt for an address

                    addresses = phone_book.values()  #store addresses in a list

                    if newAddress in addresses:  #if address already in book-->error
                        already_exists = 1
                        print(
                            "\nIt looks like another user ALREADY has that address!!\n"
                        )
            ##END while user already exists loop

            phone_book[newUser] = newAddress  #else-->add to dictionary

        if option == "3":  #REMOVE A CONTACT
            already_exists = 0

            while already_exists == 0:  #while the user entered is NOT in the dictionary

                toRemove = raw_input("\nEnter a user name to remove >> "
                                     )  #prompt for a user name

                if toRemove not in phone_book:  #if user name not in book-->error
                    print("\nIt looks like that user DOES NOT EXIST!\n")
                    already_exists = 0
                else:
                    already_exists = 1

            choice = are_you_sure()

            if choice in valid_responseY:  #yes, remove this contact
                del phone_book[toRemove]
        ##END REMOVE CONTACT OPTION

        if option == "4":  ##SEND A MESSAGE
            unable_to_connect = 1
            name = ""
            while unable_to_connect == 1:
                choice = "no"

                while choice in valid_responseN:
                    while name not in phone_book:  #user name NOT in phone book
                        name = raw_input(
                            "\nEnter a username to send a message to >> ")
                        if name not in phone_book:  #if user entered does NOT exist
                            print "\nUsername is NOT in phone book. Make sure it's correct (including case).\n"
                    print "\nThe address of", name, "is", phone_book[
                        name], "\n"

                    choice = ""
                    while (choice not in valid_responseY
                           and choice not in valid_responseN
                           ):  #while user input is invalid
                        choice = raw_input(
                            "\nAre you sure this is who you want to send a message to? Enter 'yes' or 'no' >> "
                        )
                        if (choice not in valid_responseY
                                and choice not in valid_responseN):
                            print "\nEnter a VALID response!\n"
                    ##end while choice != "yes" and choice != "no" loop
                    if choice in valid_responseN:  #no
                        name = ""  #clear name
                ##end while choice == "no" loop
                choice = ""

                clientSocket = socket.socket(socket.AF_INET,
                                             socket.SOCK_STREAM)

                keylength = raw_input("\nEnter the keystream byte size: ")
                key = raw_input("\nEnter a key (for encryption): ")
                times = int(input("\nEnter the key scheduling count: "))

                errorCount = 0
                error = 1

                while (error == 1 and errorCount < 3):

                    if clientSocket == None:
                        clientSocket = socket.socket(socket.AF_INET,
                                                     socket.SOCK_STREAM)

                    try:
                        clientSocket.connect((phone_book[name], TCP_PORT))
                        print "\nTrying to CONNECT to " + phone_book[
                            name] + "\n"
                    except socket.error as msg:  #if cannot connect to user name provided (i.e. user is unavailable)
                        print "\nError Message #" + str(errorCount + 1)
                        print "\nThere was an ERROR with the connection :(\n"
                        clientSocket.close()
                        clientSocket = None
                        errorCount += 1

                    if clientSocket:
                        error = 0  #no error

                if errorCount == 3:  #failed to connect after 3 attempts
                    unable_to_connect = 1
                    errorCount = 0
                    print "\nIt looks like " + name + " is UNAVAILABLE...\n"
                    name = ""
                    break  ##go back to MENU
                else:
                    print "\nCONNECTION SUCCESSFUL :):):)\n"
                    unable_to_connect = 0
            ##end while unable_to_connect loop

            if unable_to_connect == 0:  #if CONNECTED

                ready_to_send = 0
                response = ""

                while ready_to_send == 0:
                    message = ""
                    count = 0
                    finished = "DONE"
                    full_message = ""

                    while 1:

                        if count == 0:
                            message = raw_input(
                                "\nEnter a message to send to '" + name +
                                "'. \nEnter 'DONE' followed by hitting the 'ENTER' button to finish your input. \nEnter your input here >> "
                            )
                        else:
                            message = raw_input(
                                "\nEnter the NEXT LINE of the message here >> "
                            )

                        if message.strip(
                        ) == finished:  #if user wants to stop entering lines, and enteres "DONE"
                            break  #leave message input loop
                        else:
                            if (count > 0):
                                message = "\t" + message + "\r\n"
                            else:
                                message = message + "\r\n"

                            full_message += message
                            count += 1

                    while (response not in valid_responseY
                           and response not in valid_responseN):
                        print "\nHere's the message you entered:\n\n >>\n\t" + full_message + " <<\n"
                        response = raw_input(
                            "\nAre you sure you want to send this? Enter 'yes' or 'no' (*Note* Entering 'no' will erase the previously entered message >> "
                        )

                        if (response not in valid_responseY
                                and response not in valid_responseN):
                            print "\nEnter a VALID response!\n"
                    #END while invalid response loop
                    if response in valid_responseY:
                        ready_to_send = 1
                    else:  #response = 'NO'
                        response = ""
                        ready_to_send = 0
                #END while NOT ready to send loop
                version = "version: 0.2\r\n"
                sender = "from: Josh\r\n"
                recipient = "to: " + name + "\r\n\r\n\t"
                header = version + sender + recipient

                hmessage = header + full_message  #prepend header to message

                ##STORE MESSAGE W/ HEADER IN SENT MESSAGES FILE
                LocalTime = time.asctime(time.localtime(
                    time.time()))  #get current time
                savedMessage = "TIME SENT: " + LocalTime + "\n\nMESSAGE: " + hmessage  #add time to message
                #savedMessage = LocalTime + "\n" + hmessage #add time to message
                sent_messages.append(savedMessage)  #add to sent messages list

                emessage = RC4.encrypt(
                    hmessage, times, key
                )  #encrypt message; prepend IV to encrypted message --> cipherText

                clientSocket.send(emessage)  #send
                clientSocket.close()
            #END IF CONNECTED statement
        #END IF OPTION == 3; return to main loop (menu)

        if option == "5":
            option = "5"  ##DISPLAY SENT MESSAGES
            count = len(sent_messages)

            if count != 0:
                print "\nHere are your SENT messages:\n"
                for j in range(0, count):
                    print str(j + 1) + "). " + sent_messages[j] + "\n"
            else:
                print "\nYou haven't sent any messages yet!\n"

        if option == "6":
            option = "6"  ##DISPLAY RECEIVED MESSAGES

            count = len(inbox)  #get number of messages in the inbox

            if count != 0:
                print "\nHere are your RECEIVED messages:\n"
                for j in range(0, count):
                    print str(j + 1) + "). " + inbox[j] + "\n"
            else:
                print "\nYou haven't received any messages yet!\n"

        if option == "7":
            option = "7"  ##EXIT PROGRAM
            #SAVE address to phoneBOOK.txt file

            file = open(fileName, "w")  #open file to save addresses

            for username, address in phone_book.iteritems():
                file.write(
                    username + "\n" + address + "\n"
                )  #write usernames and address to a file; each separated by a newline

            file.close()  #close file

            print "\n\nEXITING THE PROGRAM...\n\n\n\n...GOODBYE...\n\n\n"
Example #24
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)
Example #25
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)