示例#1
0
def des_hash(txt):
    """
    Returns the DES Hashed secret for use as a password hash in the PanOS configuration
    :param txt: text to be hashed
    :return: password hash of the string with salt and configuration information. Suitable to place in the phash field
    in the configurations
    """
    return des_crypt.hash(txt)
示例#2
0
def generate_trip(tripstr: str) -> str:
    '''
    >>> generate_trip('#istrip')
    '◆/WG5qp963c'
    >>> generate_trip('#ニコニコ')
    '◆pA8Bpf.Qvk'

    (from https://w.atwiki.jp/aaaaaaaaaasaaaa/pages/11.html)
    >>> generate_trip('#t%{rシ)L,')
    '◆HAckEr.Tac'
    >>> generate_trip('#DRL諞Qq@')
    '◆AAAAAAAc.s'
    >>> generate_trip('#JM@/!詫8')
    '◆GoGoGO/Bos'
    >>> generate_trip('#s0ンX[aF-')
    '◆1uzee/wmbQ'
    >>> generate_trip('#ゥ.N避y承')
    '◆4/9.......'
    >>> generate_trip('#DRL諞Qq@')
    '◆AAAAAAAc.s'
    '''
    if len(tripstr[1:]) >= 12:
        mark = tripstr[0]
        if mark == '#' or mark == '$':
            m = re.match(r'^#([0-9a-fA-F]{16})([\./0-9A-Za-z]{0,2})$', tripstr)
            if m:
                trip = des_crypt.hash(bytes(int(m.group(1)), 'shift-jis'), salt=(m.group(2).encode('shift-jis') + b'..').decode('shift-jis'))[-10:]
            else:
                trip = '???'
        else:
            m = sha1(tripstr[1:])
            trip = b64encode(m.digest())[:12]
            trip = trip.replace('+', '.')
    else:
        tripkey = tripstr[1:]
        # treat as Shift-JIS bytes
        tripkey = bytes(tripkey, encoding='shift-jis')
        salt = (tripkey + b'H.')[1:3]
        salt = re.sub(rb'[^\.-z]', b'.', salt)
        salt = salt.translate(bytes.maketrans(b':;<=>?@[\\]^_`', b'ABCDEFGabcdef'))
        trip = des_crypt.hash(tripkey, salt=salt.decode('shift-jis'))
        trip = trip[-10:]
    trip = '◆' + trip

    return trip
示例#3
0
def bf(h, dictionary):

    f = open(dictionary, 'r')
    lines = f.readlines()
    print('\033[1;34m[*]\033[0m Starting Brute Force - hash = ' + h)
    for i in lines:

        h2 = des_crypt.hash(i[:-1])

        if h == h2:

            print('\033[1;32m[+]\033[0m Hash Cracked! - Password = ' + i)
示例#4
0
def des_hash(txt):
    return des_crypt.hash(txt)
示例#5
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)
示例#6
0
from passlib.hash import md5_crypt, sha1_crypt, sha256_crypt, sha512_crypt, des_crypt

var = "Hello"

salt = "ZDzPE45C"
desSalt = "e4"

md5 = md5_crypt.hash(var, salt=salt)
sha1 = sha1_crypt.hash(var, salt=salt)
sha256 = sha256_crypt.hash(var, salt=salt)
sha512 = sha512_crypt.hash(var, salt=salt)
des = des_crypt.hash(var, salt=desSalt)

print("MD5 Hash of {}: {}...    Length = {}".format(var, md5[12:18], len(md5)))
print("SHA1 Hash of {}: {}...    Length = {}".format(var, sha1[13:19],
                                                     len(sha1)))
print("SHA256 Hash of {}: {}...    Length = {}".format(var, sha256[26:32],
                                                       len(sha256)))
print("SHA512 Hash of {}: {}...    Length = {}".format(var, sha512[26:32],
                                                       len(sha512)))
print("Des hash of {}: {}...    Length = {}".format(var, des, len(des)))
示例#7
0
def hash_user_password(password):
    return des_crypt.hash(password)
示例#8
0
def enc():
    awal()
    putih = "\033[97m"
    dfv = raw_input(W + "[" + B + "+" + W + "] Your Text     " + B + ": " + G)
    asw = raw_input(W + "[" + B + "+" + W + "] Your Password " + B + ": " + G)
    print W + "\n* Generate Hash . . . . Please Wait !!!"
    time.sleep(1)
    print(W + '  ------------------------------------------------')
    #md5
    daf1 = hashlib.md5(dfv.encode("utf -8")).hexdigest()
    print W + "[" + B + "+" + W + "] Md5    " + B + ":" + W, daf1
    time.sleep(0.1)
    #sha256
    daf2 = hashlib.sha256(dfv.encode()).hexdigest()
    print W + "[" + B + "+" + W + "] Sha256 " + B + ":" + W, daf2
    time.sleep(0.1)
    #sha224
    daf4 = hashlib.sha224(dfv.encode()).hexdigest()
    print W + "[" + B + "+" + W + "] Sha224 " + B + ":" + W, daf4
    time.sleep(0.1)
    #sha512
    daf5 = hashlib.sha512(dfv.encode()).hexdigest()
    print W + "[" + B + "+" + W + "] Sha512 " + B + ":" + W, daf5
    time.sleep(0.1)
    #sha384
    daf6 = hashlib.sha384(dfv.encode()).hexdigest()
    print W + "[" + B + "+" + W + "] Sha384 " + B + ":" + W, daf6
    time.sleep(0.1)
    #sha1
    daf11 = hashlib.sha1(dfv.encode()).hexdigest()
    print W + "[" + B + "+" + W + "] Sha1   " + B + ":" + W, daf11
    time.sleep(0.1)
    #pbkdf2_sha1
    daf12 = pbkdf2_sha1.hash(dfv)
    print W + "[" + B + "+" + W + "] Pbkdf2_sha1   " + B + ":" + W, daf12
    time.sleep(0.1)
    #pbkdf2_sha256
    daf13 = pbkdf2_sha256.hash(dfv)
    print W + "[" + B + "+" + W + "] Pbkdf2_sha256 " + B + ":" + W, daf13
    time.sleep(0.1)
    #pbkdf2_sha512
    daf14 = pbkdf2_sha512.hash(dfv)
    print W + "[" + B + "+" + W + "] Pbkdf2_sha512 " + B + ":" + W, daf14
    time.sleep(0.1)
    #sha256_crypt
    daf15 = sha256_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Sha256_crypt  " + B + ":" + W, daf15
    time.sleep(0.1)
    #sha512_crypt
    daf16 = sha512_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Sha512_crypt  " + B + ":" + W, daf16
    time.sleep(0.1)
    #md5_crypt
    daf17 = md5_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Md5_crypt  " + B + ":" + W, daf17
    time.sleep(0.1)
    #sha1_crypt
    daf18 = sha1_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Sha_crypt  " + B + ":" + W, daf18
    time.sleep(0.1)
    #sha1_crypt
    daf18 = sha1_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Sha_crypt  " + B + ":" + W, daf18
    time.sleep(0.1)
    #sun_md5_crypt
    daf19 = sun_md5_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Sun_md5_crypt " + B + ":" + W, daf19
    time.sleep(0)
    #des_crypt
    daf20 = des_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Des_crypt  " + B + ":" + W, daf20
    time.sleep(0.1)
    #bsdi_crypt
    daf21 = bsdi_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Bsdi_crypt " + B + ":" + W, daf21
    time.sleep(0.1)
    #bigcrypt
    daf22 = bigcrypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Bigcrypt   " + B + ":" + W, daf22
    time.sleep(0.1)
    #crypt16
    daf23 = crypt16.hash(dfv)
    print W + "[" + B + "+" + W + "] Crypt16 " + B + ":" + W, daf23
    time.sleep(0.1)
    #phpass
    daf24 = phpass.hash(dfv)
    print W + "[" + B + "+" + W + "] Phpass  " + B + ":" + W, daf24
    time.sleep(0.1)
    #scram
    daf25 = scram.hash(dfv)
    print W + "[" + B + "+" + W + "] Scram   " + B + ":" + W, daf25
    time.sleep(0.1)
    #apr_md5_crypt
    daf27 = apr_md5_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Apr_Md5_Crypt    " + B + ":" + W, daf27
    time.sleep(0.1)
    #cta_pbkdf2
    daf28 = cta_pbkdf2_sha1.hash(dfv)
    print W + "[" + B + "+" + W + "] Cta_pbkdf2_sha1  " + B + ":" + W, daf28
    time.sleep(0.1)
    #dlitz_pbdf2_sha1
    daf29 = dlitz_pbkdf2_sha1.hash(dfv)
    print W + "[" + B + "+" + W + "] Dlitz_pbkdf_sha1 " + B + ":" + W, daf29
    time.sleep(0.1)
    #ldap_md5_crypt
    daf30 = ldap_md5_crypt.hash(dfv)
    print W + "[" + B + "+" + W + "] Ldap_Md5_Crypt   " + B + ":" + W, daf30
    time.sleep(0.1)
    #ldap_hex_md5
    daf31 = ldap_hex_md5.hash(dfv)
    print W + "[" + B + "+" + W + "] Ldap_Hex_Md5   " + B + ":" + W, daf31
    time.sleep(0.1)
    #ldao_hex_sha1
    daf32 = ldap_hex_sha1.hash(dfv)
    print W + "[" + B + "+" + W + "] Ldap_Hex_Sha1  " + B + ":" + W, daf32
    time.sleep(0.1)
    #ldap_pbkdf2_sha1
    daf33 = ldap_pbkdf2_sha1.hash(dfv)
    print W + "[" + B + "+" + W + "] Ldap_pbkdf2_sha1  " + B + ":" + W, daf33
    time.sleep(0.1)
    #ldap_pbkdf2_sha256
    daf34 = ldap_pbkdf2_sha256.hash(dfv)
    print W + "[" + B + "+" + W + "] Ldap_pbkdf2_sha256  " + B + ":" + W, daf34
    time.sleep(0.1)
    #ldap_pbkdf2_sha512
    daf35 = ldap_pbkdf2_sha512.hash(dfv)
    print W + "[" + B + "+" + W + "] Ldap_pbdf2_sha512   " + B + ":" + W, daf35
    time.sleep(0.1)
    #atlassian_pbkdf2_sha1
    daf36 = atlassian_pbkdf2_sha1.hash(dfv)
    print W + "[" + B + "+" + W + "] Atlassian_pbkdf2_sha1  " + B + ":" + W, daf36
    time.sleep(0.1)
    #fshp
    daf37 = fshp.hash(dfv)
    print W + "[" + B + "+" + W + "] Fshp  " + B + ":" + W, daf37
    time.sleep(0.1)
    #mysql323
    daf38 = mysql323.hash(dfv)
    print W + "[" + B + "+" + W + "] Mysql323 " + B + ":" + W, daf38
    time.sleep(0.1)
    #mysql41
    daf39 = mysql41.hash(dfv)
    print W + "[" + B + "+" + W + "] Mysql41  " + B + ":" + W, daf39
    time.sleep(0.1)
    #postgres_md5
    daf40 = postgres_md5.hash(dfv, user=asw)
    print W + "[" + B + "+" + W + "] Postgres_md5 " + B + ":" + W, daf40
    time.sleep(0.1)
    #oracle10
    daf41 = oracle10.hash(dfv, user=asw)
    print W + "[" + B + "+" + W + "] Oracle10 " + B + ":" + W, daf41
    time.sleep(0.1)
    #oracle11
    daf42 = oracle11.hash(dfv)
    print W + "[" + B + "+" + W + "] Oracle11 " + B + ":" + W, daf42
    time.sleep(0.1)
    #lmhash
    daf43 = lmhash.hash(dfv)
    print W + "[" + B + "+" + W + "] Lmhash  " + B + ":" + W, daf43
    time.sleep(0.1)
    #nthash
    daf44 = nthash.hash(dfv)
    print W + "[" + B + "+" + W + "] Nthash  " + B + ":" + W, daf44
    time.sleep(0.1)
    #msdcc
    daf45 = msdcc.hash(dfv, user=asw)
    print W + "[" + B + "+" + W + "] Msdcc   " + B + ":" + W, daf45
    time.sleep(0.1)
    #msdcc2
    daf46 = msdcc2.hash(dfv, user=asw)
    print W + "[" + B + "+" + W + "] Msdcc2  " + B + ":" + W, daf46
    time.sleep(0.1)
    #cisco_type7
    daf47 = cisco_type7.hash(dfv)
    print W + "[" + B + "+" + W + "] Cisco_type7  " + B + ":" + W, daf47
    time.sleep(0.1)
    #grub_pbkdf2_sha512
    daf48 = grub_pbkdf2_sha512.hash(dfv)
    print W + "[" + B + "+" + W + "] Grub_pbkdf2_sha512  " + B + ":" + W, daf48
    time.sleep(0.1)
    #hex_sha1
    daf49 = hex_sha1.hash(dfv)
    print W + "[" + B + "+" + W + "] Hex_Sha1   " + B + ":" + W, daf49
    time.sleep(0.1)
    #pwd
    daf50 = pwd.genword()
    print W + "[" + B + "+" + W + "] Pwd  " + B + ":" + W, daf50
    time.sleep(0.1)
    #mssql2005
    daf51 = cuk.hash(dfv)
    print W + "[" + B + "+" + W + "] Mssql2005  " + B + ":" + W, daf51
    time.sleep(0.1)
    #Mssql2000
    daf52 = cak.hash(dfv)
    print W + "[" + B + "+" + W + "] Mssql2000  " + B + ":" + W, daf52
    time.sleep(0.1)
    #ldap_salted_md5
    daf52 = cik.hash(dfv)
    print W + "[" + B + "+" + W + "] Ldap_salted_md5  " + B + ":" + W, daf52
    time.sleep(0.1)
示例#9
0
from passlib.hash import des_crypt
import string

target = "nr.Pp2GTcHqMc"
salt = "nr"
# print(des_crypt.hash("haslo",salt="Fb"))

for a in string.ascii_lowercase:
    for b in string.ascii_lowercase:
        for c in string.ascii_lowercase:
            pw = a + b + c
            hs = des_crypt.hash(pw, salt=salt)
            if hs == target:
                print(f"Password is {pw}")
    print(f"Checking {a}...")
# password = sys.argv[1]
#
# salt = ''.join(random.sample(string.ascii_letters, 2))
#
# protected_password = crypt.crypt(password, salt)
# print( protected_password )
示例#10
0
 def hash(plaintext):
     return des_crypt.hash(plaintext, salt="AB")