Beispiel #1
0
def scrypt_password():
    password = b"hunter2"
    hashed = scrypt.hash(password)
    if scrypt.verify(password, hashed):
        print("It matches! :)")
    else:
        print("It does not match :(")
Beispiel #2
0
def Crypter(args):
    if args.encrypt == 'pbkdf2_sha256':
        return pbkdf2_sha256.hash(args.text)
    elif args.encrypt == 'oracle11':
        return oracle11.hash(args.text)
    elif args.encrypt == 'argon2':
        return argon2.hash(args.text)
    elif args.encrypt == 'bcrypt':
        return bcrypt.hash(args.text)
    elif args.encrypt == 'bcrypt_sha256':
        return bcrypt_sha256.hash(args.text)
    elif args.encrypt == 'cisco_asa':
        return cisco_asa.hash(args.text)
    elif args.encrypt == 'cisco_pix':
        return cisco_pix.hash(args.text)
    elif args.encrypt == 'cisco_type7':
        return cisco_type7.hash(args.text)
    elif args.encrypt == 'bigcrypt':
        return bigcrypt.hash(args.text)
    elif args.encrypt == 'bsdi_crypt':
        return bsdi_crypt.hash(args.text)
    elif args.encrypt == 'des_crypt':
        return des_crypt.hash(args.text)
    elif args.encrypt == 'hex_md4':
        return hex_md4.hash(args.text)
    elif args.encrypt == 'hex_md5':
        return hex_md5.hash(args.text)
    elif args.encrypt == 'hex_sha1':
        return hex_sha1.hash(args.text)
    elif args.encrypt == 'hex_sha256':
        return hex_sha256.hash(args.text)
    elif args.encrypt == 'hex_sha512':
        return hex_sha512.hash(args.text)
    elif args.encrypt == 'django_bcrypt':
        return django_bcrypt.hash(args.text)
    elif args.encrypt == 'django_disabled':
        return django_disabled.hash(args.text)
    elif args.encrypt == 'django_bcrypt_sha256':
        return django_bcrypt_sha256.hash(args.text)
    elif args.encrypt == 'django_des_crypt':
        return django_des_crypt.hash(args.text)
    elif args.encrypt == 'django_pbkdf2_sha1':
        return django_pbkdf2_sha1.hash(args.text)
    elif args.encrypt == 'django_pbkdf2_sha256':
        return django_pbkdf2_sha256.hash(args.text)
    elif args.encrypt == 'django_salted_md5':
        return django_salted_md5.hash(args.text)
    elif args.encrypt == 'django_salted_sha1':
        return django_salted_sha1.hash(args.text)
    elif args.encrypt == 'fshp':
        return fshp.hash(args.text)
    elif args.encrypt == 'ldap_bcrypt':
        return ldap_bcrypt.hash(args.text)
    elif args.encrypt == 'ldap_md5':
        return ldap_md5.hash(args.text)
    elif args.encrypt == 'ldap_plaintext':
        return ldap_plaintext.hash(args.text)
    elif args.encrypt == 'ldap_sha1':
        return ldap_sha1.hash(args.text)
    elif args.encrypt == 'ldap_bsdi_crypt':
        return ldap_bsdi_crypt.hash(args.text)
    elif args.encrypt == 'ldap_hex_md5':
        return ldap_hex_md5.hash(args.text)
    elif args.encrypt == 'ldap_hex_sha1':
        return ldap_hex_sha1.hash(args.text)
    elif args.encrypt == 'ldap_md5_crypt':
        return ldap_md5_crypt.hash(args.text)
    elif args.encrypt == 'ldap_pbkdf2_sha1':
        return ldap_pbkdf2_sha1.hash(args.text)
    elif args.encrypt == 'ldap_pbkdf2_sha256':
        return ldap_pbkdf2_sha256.hash(args.text)
    elif args.encrypt == 'ldap_pbkdf2_sha512':
        return ldap_pbkdf2_sha512.hash(args.text)
    elif args.encrypt == 'ldap_salted_md5':
        return ldap_salted_md5.hash(args.text)
    elif args.encrypt == 'ldap_salted_sha1':
        return ldap_salted_sha1.hash(args.text)
    elif args.encrypt == 'ldap_sha1_crypt':
        return ldap_sha1_crypt.hash(args.text)
    elif args.encrypt == 'ldap_sha256_crypt':
        return ldap_sha256_crypt.hash(args.text)
    elif args.encrypt == 'ldap_sha512_crypt':
        return ldap_sha512_crypt.hash(args.text)
    elif args.encrypt == 'apr_md5_crypt':
        return apr_md5_crypt.hash(args.text)
    elif args.encrypt == 'md5_crypt':
        return md5_crypt.hash(args.text)
    elif args.encrypt == 'plaintext':
        return plaintext.hash(args.text)
    elif args.encrypt == 'unix_disabled':
        return unix_disabled.hash(args.text)
    elif args.encrypt == 'unix_fallback':
        return unix_fallback.hash(args.text)
    elif args.encrypt == 'mssql2000':
        return mssql2000.hash(args.text)
    elif args.encrypt == 'mssql2005':
        return mssql2005.hash(args.text)
    elif args.encrypt == 'mysql323':
        return mysql323.hash(args.text)
    elif args.encrypt == 'mysql41':
        return mysql41.hash(args.text)
    elif args.encrypt == 'atlassian_pbkdf2_sha1':
        return atlassian_pbkdf2_sha1.hash(args.text)
    elif args.encrypt == 'cta_pbkdf2_sha1':
        return cta_pbkdf2_sha1.hash(args.text)
    elif args.encrypt == 'dlitz_pbkdf2_sha1':
        return dlitz_pbkdf2_sha1.hash(args.text)
    elif args.encrypt == 'grub_pbkdf2_sha512':
        return grub_pbkdf2_sha512.hash(args.text)
    elif args.encrypt == 'pbkdf2_sha1':
        return pbkdf2_sha1.hash(args.text)
    elif args.encrypt == 'pbkdf2_sha512':
        return pbkdf2_sha512.hash(args.text)
    elif args.encrypt == 'phpass':
        return phpass.hash(args.text)
    elif args.encrypt == 'roundup_plaintext':
        return roundup_plaintext.hash(args.text)
    elif args.encrypt == 'sun_md5_crypt':
        return sun_md5_crypt.hash(args.text)
    elif args.encrypt == 'scram':
        return scram.hash(args.text)
    elif args.encrypt == 'scrypt':
        return scrypt.hash(args.text)
    elif args.encrypt == 'sha1_crypt':
        return sha1_crypt.hash(args.text)
    elif args.encrypt == 'sha256_crypt':
        return sha256_crypt.hash(args.text)
    elif args.encrypt == 'sha512_crypt':
        return sha512_crypt.hash(args.text)
    elif args.encrypt == 'bsd_nthash':
        return bsd_nthash.hash(args.text)
    elif args.encrypt == 'lmhash':
        return lmhash.hash(args.text)
    elif args.encrypt == 'nthash':
        return nthash.hash(args.text)
Beispiel #3
0
 def set_password(self, password):
     from passlib.hash import scrypt
     self.password = scrypt.hash(password)
Beispiel #4
0
def process(data, peer):
    supported = [
        'Available APIs: ', '/listAPI ', '/ping ',
        '/recieveMessage [sender] [destination] [message] [stamp(opt)] [markdown] [encryption(opt)] [hashing(opt)] [hash(opt)]',
        '/recieveFile [sender] [destination] [file] [filename] [content_type] [stamp] [encryption] [hash] ',
        'Encryption: 0', 'Hashing: 0'
    ]
    try:
        if peer['username'] == 'ssit662':
            peer['ip'] = 'localhost'
        respdata = urllib2.urlopen('http://' + unicode(peer['ip']) + ':' +
                                   unicode(peer['port']) + '/listAPI',
                                   timeout=1).read()
        if 'crypt' in respdata:
            if 'ash' in respdata:
                supported = respdata.split("\n")
    except:
        pass

    if '8' in supported[-1]:
        data['hashing'] = '8'
    if '7' in supported[-1]:
        data['hashing'] = '7'
    if '6' in supported[-1]:
        data['hashing'] = '6'
    if '5' in supported[-1]:
        data['hashing'] = '5'
    if '1' in supported[-1]:
        data['hashing'] = '1'
    if '2' in supported[-1]:
        data['hashing'] = '2'
    if '3' in supported[-1]:
        data['hashing'] = '3'
    if '4' in supported[-1]:
        data['hashing'] = '4'

    text = ''
    salt = data['sender'].encode('ascii')
    if 'message' in data:
        data['message'] = data['message'].encode('utf-8')
        text = data['message']
    if 'file' in data:
        text = data['file']

    if data['hashing'] == '1':
        data['hash'] = SHA256.new(text).hexdigest()
    if data['hashing'] == '2':
        data['hash'] = SHA256.new(text + salt).hexdigest()
    if data['hashing'] == '3':
        data['hash'] = SHA512.new(text).hexdigest()
    if data['hashing'] == '4':
        data['hash'] = SHA512.new(text + salt).hexdigest()
    if data['hashing'] == '5':
        data['hash'] = bcrypt.hash(text)
    if data['hashing'] == '6':
        data['hash'] = bcrypt.hash(text + salt)
    if data['hashing'] == '7':
        data['hash'] = scrypt.hash(text)
    if data['hashing'] == '8':
        data['hash'] = scrypt.hash(text + salt)

    hashing = data['hashing']
    hashe = data['hash']

    if '1' in supported[-2]:
        data['encryption'] = '1'
    if '2' in supported[-2]:
        data['encryption'] = '2'
    if '3' in supported[-2] and (len(data['message']) < 128):
        data['encryption'] = '3'
    if '4' in supported[-2]:
        data['encryption'] = '4'

    if data['encryption'] == '1':
        for thing in data:
            if thing == 'encryption' or thing == 'destination' or thing == 'sender':
                pass
            else:
                data[thing] = Ciphers.XORCipher.encrypt(data[thing])
    if data['encryption'] == '2':
        for thing in data:
            if thing == 'encryption' or thing == 'destination' or thing == 'sender':
                pass
            else:
                data[thing] = Ciphers.AESCipher.encrypt(
                    data[thing], '41fb5b5ae4d57c5ee528adb078ac3b2e')
    if data['encryption'] == '3':
        data = Ciphers.RSA1024Cipher.encrypt(data, peer['publicKey'])
    if data['encryption'] == '4':
        key = Ciphers.AESCipher.generateKeys()
        data['decryptionKey'] = Ciphers.RSA1024Cipher.encryptValue(
            key, peer['publicKey'])
        for thing in data:
            if thing == 'encryption' or thing == 'destination' or thing == 'sender' or thing == 'decryptionKey':
                pass
            else:
                data[thing] = Ciphers.AESCipher.encrypt(data[thing], key)

    return (data, hashing, hashe)
Beispiel #5
0
def scrypt_hash(string, salt=None, front=False, back=False):
    raise NotImplementedError("Scrypt hashes are not implemented yet")
    if salt is not None and front is True and not back:
        obj = scrypt.hash(string)