Beispiel #1
0
    def run(self):
        try:
            self.cursor.execute(
                "SELECT id, email  FROM test.User WHERE email LIKE '%.com'")
            rows = self.cursor.fetchall()

            for row in rows:
                (id, email) = row
                print("Hit record: id {} email {}".format(id, email))

                token_generator = ZTokenGenerator()
                password_generator = ZPasswordGenerator()

                new_atoken = token_generator.generate(20)
                new_password = password_generator.generate()

                key = email
                cipher = ZAESIVEmbeddedCipher(ZCipher.AS_HEX)
                new_hex_iv_password = cipher.encrypt(new_password, key)

                print("New Auth_token   {}".format(new_atoken))
                print("New Password     {}".format(new_password))

                update = "UPDATE test.User SET auth_token=%s, password =%s WHERE id =%s"
                values = (new_atoken, new_hex_iv_password, id)

                self.cursor.execute(update, values)

            self.commit()

        except:
            traceback.print_exc()
            self.rollback()
Beispiel #2
0
    def run(self):
        try:
            for i in range(1000):
                token_generator = ZTokenGenerator()
                email_generator = ZEmailAddressGenerator()
                pass_generator = ZPasswordGenerator()

                atoken = token_generator.generate(20)
                email = email_generator.generate()
                password = pass_generator.generate()

                key = email
                cipher = ZAESIVEmbeddedCipher(ZCipher.AS_HEX)
                hex_iv_password = cipher.encrypt(password, key)
                print("No: {}".format(i))
                print("Auth_token   {}".format(atoken))
                print("Email        {}".format(email))

                print("Password     {}".format(password))
                try:
                    sql = "INSERT INTO test.User (auth_token, email, password) VALUES(%s, %s, %s)"
                    values = (atoken, email, hex_iv_password)

                    self.cursor.execute(
                        "INSERT INTO test.User (auth_token, email, password) VALUES(%s, %s, %s)",
                        (atoken, email, hex_iv_password))
                except:
                    traceback.print_exc()

            self.commit()

        except:
            traceback.print_exc()
            self.rollback()
Beispiel #3
0
    def run(self):
        try:
            select = "SELECT id, auth_token, email, password FROM test.User WHERE email LIKE %s OR email LIKE %s"
            values = ('%.com', '%.info')

            self.cursor.execute(select, values)

            rows = self.cursor.fetchall()

            for row in rows:
                (id, auth_token, email, hex_iv_password) = row
                cipher = ZAESIVEmbeddedCipher(ZCipher.AS_HEX)

                key = email
                decrypted = cipher.decrypt(hex_iv_password, key)

                utf8_decrypted = decrypted.decode('utf-8')
                print("id  {}".format(id))
                print("auth_token {}".format(auth_token))
                print("email      {}".format(email))
                print("password   {}".format(utf8_decrypted))

            self.commit()

        except:
            traceback.print_exc()
            self.rollback()
Beispiel #4
0
    db = ZMySQLDB(argv=sys.argv)

    try:

        for i in range(1000):
            token_generator = ZTokenGenerator()
            email_generator = ZEmailAddressGenerator()
            password_generator = ZPasswordGenerator()

            atoken = token_generator.generate(20)
            email = email_generator.generate()
            password = password_generator.generate()

            key = email
            cipher = ZAESIVEmbeddedCipher(ZCipher.AS_HEX)
            hex_iv_password = cipher.encrypt(password, key)

            print("Auth_token   {}".format(atoken))
            print("Email        {}".format(email))

            print("Password     {}".format(password))
            try:
                insert = "INSERT INTO test.User (auth_token, email, password) VALUES(%s, %s, %s)"
                values = (atoken, email, hex_iv_password)

                db.execute(insert, values)

            except:
                traceback.print_exc()
                db.rollback()
if main(__name__):
    # user passwd database

    db = ZMySQLDB(argv=sys.argv)

    try:
        select = "SELECT id, auth_token, email, password FROM test.User"

        cursor = db.connection.cursor()
        cursor.execute(select)

        rows = cursor.fetchall()

        for row in rows:
            (id, auth_token, email, hex_iv_password) = row
            cipher = ZAESIVEmbeddedCipher(ZCipher.AS_HEX)

            key = email
            decrypted = cipher.decrypt(hex_iv_password, key)

            utf8_decrypted = decrypted.decode('utf-8')

            print("auth_token {}".format(auth_token))
            print("email      {}".format(email))
            print("password   {}".format(utf8_decrypted))

        cursor.close()

    except:
        traceback.print_exc()
# AESIVEmbeddedCipher.py

# encoding: utf-8

import os
import base64
import traceback
import sys

sys.path.append('../')

from SOL4Py.crypto.ZAESIVEmbeddedCipher import *

if __name__ == '__main__':
    try:
        cipher = ZAESIVEmbeddedCipher(ZCipher.AS_HEX)
        key = '!C#$X%asZpo()/?sun'
        text = 'Antarctica will contribute about a foot of sea-level rise by 2100.'

        encrypted = cipher.encrypt(text, key)

        decrypted = cipher.decrypt(encrypted, key)
        decrypted = decrypted.decode('utf-8')
        print("AS_HEX format...")
        print("Text:     '{}'".format(text))
        print("Decrypted:'{}'".format(decrypted))
        print("")

        btext = b'The global warming is real. Welcome to TOKYO2020 in the hottest summer of Japan.'
        key = '&=~|%asZpo()/?moon'
        cipher = ZAESIVEmbeddedCipher(ZCipher.AS_BASE64)