Example #1
0
    def setSambaPassword(self, user, object_dn, password):
        """
        Set a new samba-password for a user
        """

        # Do we have read permissions for the requested attribute
        env = Environment.getInstance()
        topic = "%s.objects.%s.attributes.%s" % (env.domain, "User", "sambaNTPassword")
        aclresolver = PluginRegistry.getInstance("ACLResolver")
        if not aclresolver.check(user, topic, "w", base=object_dn):
            self.__log.debug("user '%s' has insufficient permissions to write %s on %s, required is %s:%s" % (
                user, "isLocked", object_dn, topic, "w"))
            raise ACLException(C.make_error('PERMISSION_ACCESS', topic, target=object_dn))

        topic = "%s.objects.%s.attributes.%s" % (env.domain, "User", "sambaLMPassword")
        aclresolver = PluginRegistry.getInstance("ACLResolver")
        if not aclresolver.check(user, topic, "w", base=object_dn):
            self.__log.debug("user '%s' has insufficient permissions to write %s on %s, required is %s:%s" % (
                user, "isLocked", object_dn, topic, "w"))
            raise ACLException(C.make_error('PERMISSION_ACCESS', topic, target=object_dn))

        # Set the password and commit the changes
        user = ObjectProxy(object_dn)
        user.sambaNTPassword = nthash.encrypt(password)
        user.sambaLMPassword = lmhash.encrypt(password)
        user.commit()
Example #2
0
 def change_password(cls, self, password):
     if isinstance(password, six.text_type):
         password = password.encode()
     self.sambaNTPassword = nthash.encrypt(password)
     self.sambaLMPassword = lmhash.encrypt(password)
     self.sambaPwdMustChange = None
     self.sambaPwdLastSet = datetime.datetime.now()
 def change_password(cls, self, password):
     if isinstance(password, six.text_type):
         password = password.encode()
     self.sambaNTPassword = nthash.encrypt(password)
     self.sambaLMPassword = lmhash.encrypt(password)
     self.sambaPwdMustChange = None
     self.sambaPwdLastSet = datetime.datetime.now()
Example #4
0
File: hash.py Project: gonicus/gosa
    def process(self, obj, key, valDict):
        if len(valDict[key]['value']) and type(valDict[key]['value'][0]) == str:
            valDict['sambaNTPassword']['value'] = [nthash.encrypt(valDict[key]['value'][0])]
            valDict['sambaLMPassword']['value'] = [lmhash.encrypt(valDict[key]['value'][0])]
        else:
            raise ValueError(C.make_error("TYPE_UNKNOWN", self.__class__.__name__, type=type(valDict[key]['value'])))

        return key, valDict
Example #5
0
def genhash(password, htype):
    """ Generate one of our supported hashes
    """

    hsh = None
    if htype == "nt":
        hsh = nthash.encrypt(password)
    elif htype == "lm":
        hsh = lmhash.encrypt(password)

    return hsh
Example #6
0
def lmOffDecryptFile(hashs, wordlist):
    try:
        if check_file(wordlist):
            with open(wordlist) as wordlistfile:
                for line in wordlistfile:
                    line = line.replace("\n", "")
                    wordencrypted = lmhash.encrypt(line).upper()
                    if wordencrypted == hashs:
                        print(colors.GREEN + " [i]" + colors.INFO + " Password: "******"\n")
        else:
            print (colors.FAIL + colors.BOLD + "\n[!] Dicctionary not found!!" + colors.ENDC)
    except Exception, e:
        print(colors.BOLD + colors.FAIL + "\n [!] Error: " + colors.ENDC + str(e))
Example #7
0
    def process(self, obj, key, valDict):
        if len(valDict[key]['value']) and type(
                valDict[key]['value'][0]) == str:
            valDict['sambaNTPassword']['value'] = [
                nthash.encrypt(valDict[key]['value'][0])
            ]
            valDict['sambaLMPassword']['value'] = [
                lmhash.encrypt(valDict[key]['value'][0])
            ]
        else:
            raise ValueError(
                C.make_error("TYPE_UNKNOWN",
                             self.__class__.__name__,
                             type=type(valDict[key]['value'])))

        return key, valDict
Example #8
0
    def save(self, *args, **kwargs):
        """
        save the model and set implicit attributes like sambaSID etc
        """
        # userGroups is given as kwarg by the view as list of strings
        # we get the corresponding ldapgroups and check which are new
        # and which can be deleted
        userGroups = kwargs.pop('userGroups', [])
        newUserGroups = map(lambda g: get_or_none(LdapGroup, cn=g), userGroups)
        newUserGroups = filter(None, newUserGroups)
        currentUserGroups = LdapGroup.objects.filter(
            memberUid__contains=self.uid)
        deletedGroups = [
            g for g in currentUserGroups if g not in newUserGroups
        ]
        for group in deletedGroups:
            group.memberUid.remove(self.uid)
            group.save()
        for group in newUserGroups:
            if self.uid not in group.memberUid:
                group.memberUid.append(self.uid)
                group.save()

        # implicit attributes
        self.cn = self.givenName + ' ' + self.sn
        self.sambaSID = settings.SAMBA_SID + '-' + str(self.uidNumber * 2 +
                                                       1000)
        self.homeDirectory = '/home/' + self.uid
        self.loginShell = settings.DEFAULT_SHELL
        # build unix timestamp from given date format (dd.mm.yyyy)
        if self.deIappBirthday:
            self.deIappBirthday = date2timestamp(self.deIappBirthday)
        # password is given as kwarg by the view
        # sha1, lm/nt hashes are build from this password and will be saved
        password = kwargs.pop('password', False)
        if password:
            from passlib.hash import ldap_salted_sha1 as lss
            from passlib.hash import lmhash
            from passlib.hash import nthash
            self.userPassword = lss.encrypt(password)
            self.sambaLMPassword = lmhash.encrypt(password).upper()
            self.sambaNTPassword = nthash.encrypt(password).upper()
        super(LdapUser, self).save(*args, **kwargs)
Example #9
0
    def save(self, *args, **kwargs):
        """
        save the model and set implicit attributes like sambaSID etc
        """
        # userGroups is given as kwarg by the view as list of strings
        # we get the corresponding ldapgroups and check which are new
        # and which can be deleted
        userGroups = kwargs.pop('userGroups', [])
        newUserGroups = map(lambda g: get_or_none(LdapGroup, cn=g), userGroups)
        newUserGroups = filter(None, newUserGroups)
        currentUserGroups = LdapGroup.objects.filter(memberUid__contains=self.uid)
        deletedGroups = [g for g in currentUserGroups if g not in newUserGroups]
        for group in deletedGroups:
            group.memberUid.remove(self.uid)
            group.save()
        for group in newUserGroups:
            if self.uid not in group.memberUid:
                group.memberUid.append(self.uid)
                group.save()

        # implicit attributes
        self.cn = self.givenName + ' ' + self.sn
        self.sambaSID = settings.SAMBA_SID + '-' + str(self.uidNumber * 2 + 1000)
        self.homeDirectory = '/home/' + self.uid
        self.loginShell = settings.DEFAULT_SHELL
        # build unix timestamp from given date format (dd.mm.yyyy)
        if self.deIappBirthday:
            self.deIappBirthday = date2timestamp(self.deIappBirthday)
        # password is given as kwarg by the view
        # sha1, lm/nt hashes are build from this password and will be saved
        password = kwargs.pop('password', False)
        if password:
            from passlib.hash import ldap_salted_sha1 as lss
            from passlib.hash import lmhash
            from passlib.hash import nthash
            self.userPassword = lss.encrypt(password)
            self.sambaLMPassword = lmhash.encrypt(password).upper()
            self.sambaNTPassword = nthash.encrypt(password).upper()
        super(LdapUser, self).save(*args, **kwargs)
Example #10
0
def main():
    parser = optparse.OptionParser(
        "Usage: pswd2lmnthash.py -d <Password names file>")
    parser.add_option('-d', dest='passfile', type='string',
                          help='specify dictionnary with passwords')
    (options, args) = parser.parse_args()

    passfile = options.passfile

    if passfile == None:
        print parser.usage
        exit(0)
    #
    hashlist=[]
    passnames = open(passfile).read().splitlines()
    print "\nStarting hashing\n======================"
    for pwd in passnames:
      lm = lmhash.encrypt(pwd)
      nt = nthash.encrypt(pwd)
      hashlist.append((lm+":"+nt))
    for hash in hashlist:
      print hash
Example #11
0
                      str(line.replace(
                          '\n', '')).encode("utf-8")).hexdigest()  # MD4 Hash
    sha1 = hashlib.sha1(str(line).replace('\n', '')).hexdigest()  # SHA1 Hash
    sha224 = hashlib.sha224(str(line).replace('\n',
                                              '')).hexdigest()  # SHA224 Hash
    sha256 = hashlib.sha256(str(line).replace('\n',
                                              '')).hexdigest()  # SHA256 Hash
    sha384 = hashlib.sha384(str(line).replace('\n',
                                              '')).hexdigest()  # SHA384 Hash
    sha512 = hashlib.sha512(str(line).replace('\n',
                                              '')).hexdigest()  # SHA512 Hash
    ntlm = hashlib.new('md4',
                       str(line).replace(
                           '\n', '').encode('utf-16le')).digest()  # NTLM Hash
    ntlm = binascii.hexlify(ntlm)  # NTLM Hash
    lm = lmhash.encrypt(str(line).replace('\n', ''))  # LM Hash
    ########################################################################################### HASHES
    sql = "INSERT INTO " + DB_TABLE + " VALUES ('" + word + "','" + md5 + "','" + md4 + "','" + sha1 + "','" + sha224 + "','" + sha256 + "','" + sha384 + "','" + sha512 + "','" + ntlm + "','" + lm + "');"  # SQL
    try:
        cursor.execute(sql)
        db.commit()
        print("OK! " + str(i) + "/" + str(numLines))
    except:
        db.rollback()
        try:
            failed.write(word)
            print("Fail! (saved...) " + str(i) + "/" + str(numLines))
        except:
            print("Fail! " + str(i) + "/" + str(numLines))

db.close()
Example #12
0
def main():
    argp = ArgumentParser(
            description="Crypt - Decrypt Tool",
            usage="./crypt-decrypt.py [options] [-w word/hash] \nSamples: ./crypt-decrypt.py",
            version="Crypt - Decrypt Tool v" + VERSION)

    argp.add_argument('-e', '--encrypt', dest='encrypt', action='store_true',
                      help='Encrypt word/s (offline mode)')

    argp.add_argument('-d', '--decrypt', dest='decrypt', action='store_true',
                      help='Decrypt a hash')

    argp.add_argument('-i', '--identify', dest='identify', action='store_true',
                      help='Identify type of hash')

    argp.add_argument('-t', '--hash-type', dest='type',
                      help='Hash type to encrypt/decrypt word/hash')

    argp.add_argument('-w', '--word', dest='word',
                      help='Word or hash to encrypt/decrypt/identify')

    argp.add_argument('-o', '--online', dest='online', action='store_true',
                      help='Decrypt online mode')

    argp.add_argument('-f', '--offline', dest='offline', action='store_true',
                      help='Decrypt offline mode')

    argp.add_argument('-l', '--wordlist', dest='wordlist',
                      help='Dictionary to decrypt hash (offline mode only)')

    argp.add_argument('-a', '--all', dest='all', action='store_true',
                      help='Encrypt word/s with all hash types')

    argp.add_argument('-F', '--file', dest='file',
                      help='File with hashes to decrypt/identify')

    args = argp.parse_args()

    if args.encrypt and not args.all and not args.decrypt and not args.identify:  # ENCRYPTER
        alg = args.type.lower()
        word = args.word
        print("\n [+]" + colors.INFO + " Word: " + colors.ENDC + word)
        print(" [+]" + colors.INFO + " Type: " + colors.ENDC + alg)
        if alg == "md5":
            encrypted = hashlib.md5(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha1":
            encrypted = hashlib.sha1(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha224":
            encrypted = hashlib.sha224(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha256":
            encrypted = hashlib.sha256(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha384":
            encrypted = hashlib.sha384(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha512":
            encrypted = hashlib.sha512(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "ntlm":
            encrypted = hashlib.new("md4", word.encode("utf-16le")).digest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + binascii.hexlify(encrypted).upper() + colors.ENDC + "\n")
        elif alg == "lm":
            encrypted = lmhash.encrypt(word).upper()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + encrypted + colors.ENDC + "\n")
        else:
            print (colors.FAIL + colors.BOLD + "\n[!] Incorrect algorithm!!\n" + colors.ENDC)

    elif args.encrypt and args.all and not args.decrypt and not args.identify:  # ALL TYPES
        word = args.word
        print("\n [+]" + colors.INFO + " Word: " + colors.ENDC + word)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "md5")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + hashlib.md5(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha1")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + hashlib.sha1(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha224")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + hashlib.sha224(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha256")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + hashlib.sha256(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha384")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + hashlib.sha384(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha512")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + hashlib.sha512(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "lm")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + lmhash.encrypt(word).upper() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "ntlm")
        encrypted = hashlib.new("md4", word.encode("utf-16le")).digest()
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " + colors.GREEN + binascii.hexlify(encrypted).upper() + colors.ENDC)

    elif args.decrypt and not args.encrypt and not args.identify and not args.file:  # DECRYPTER
        alg = args.type.lower()
        hashs = args.word
        if args.online and not args.offline:  # Online
            print("\n [+]" + colors.INFO + " Hash: " + colors.ENDC + hashs)
            print(" [+]" + colors.INFO + " Type: " + colors.ENDC + alg)
            if alg == "md5":
                md5OnDecrypt(hashs)
                md5OnDecrypt3(hashs)
                md5OnDecrypt4(hashs)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha1":
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha224":
                MultiOnDecrypt3(hashs)
            elif alg == "sha256":
                web = "Sha256/"
                MultiOnDecrypt(hashs, web)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha384":
                web = "Sha384/"
                MultiOnDecrypt(hashs, web)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha512":
                web = "Sha512/"
                MultiOnDecrypt(hashs, web)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "ntlm":
                web = "Ntlm/"
                MultiOnDecrypt(hashs, web)
            elif alg == "lm":
                print(colors.FAIL + colors.BOLD + "\n[!] Hash type not supported in this mode" + colors.ENDC + "\n")
            else:
                print (colors.FAIL + colors.BOLD + "\n[!] Incorrect algorithm!!" + colors.ENDC)

        elif args.offline and not args.online:  # Offline
            print("\n [+]" + colors.INFO + " Hash: " + colors.ENDC + hashs)
            print(" [+]" + colors.INFO + " Type: " + colors.ENDC + alg)
            if alg == "md5":
                MultiOffDecrypt(hashs, args.wordlist, "md5")
            elif alg == "sha1":
                MultiOffDecrypt(hashs, args.wordlist, "sha1")
            elif alg == "sha224":
                MultiOffDecrypt(hashs, args.wordlist, "sha224")
            elif alg == "sha256":
                MultiOffDecrypt(hashs, args.wordlist, "sha256")
            elif alg == "sha384":
                MultiOffDecrypt(hashs, args.wordlist, "sha384")
            elif alg == "sha512":
                MultiOffDecrypt(hashs, args.wordlist, "sha512")
            elif alg == "ntlm":
                print(colors.FAIL + colors.BOLD + "\n[!] Hash type not supported in this mode" + colors.ENDC + "\n")
            elif alg == "lm":
                lmOffDecryptFile(hashs, args.wordlist)
            else:
                print (colors.FAIL + colors.BOLD + "\n[!] Incorrect algorithm!!" + colors.ENDC)

    elif args.identify and not args.encrypt and not args.decrypt:  # IDENTIFIER
        if args.file:
            with open(args.file, 'r') as f:
                for h in f.readlines():
                    print("\n [+]" + colors.INFO + " Hash: " + colors.GREEN + h.strip("\n") + colors.ENDC)
                    r = commands.getoutput('./hash-identifier.py %s' % h.strip('\n'))
                    for x in r.split("\n"):
                        if not "Least Possible" in x:
                            print(x + "\n"),
                        else:
                            break
        else:
            r = commands.getoutput('./hash-identifier.py %s' % args.word)
            print(r)

    elif args.file and args.decrypt and not args.encrypt and not args.identify:  # FILE
        alg = args.type
        with open(args.file, 'r') as myfile:
            if args.online:  # Online
                for line in myfile.readlines():
                    if alg == "md5":
                        md5OnDecrypt(line)
                        md5OnDecrypt3(line)
                        md5OnDecrypt4(line)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha1":
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha224":
                        MultiOnDecrypt3(line)
                    elif alg == "sha256":
                        web = "Sha256/"
                        MultiOnDecrypt(line, web)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha384":
                        web = "Sha384/"
                        MultiOnDecrypt(line, web)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha512":
                        web = "Sha512/"
                        MultiOnDecrypt(line, web)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "ntlm":
                        web = "Ntlm/"
                        MultiOnDecrypt(line, web)
                    elif alg == "lm":
                        print(colors.FAIL + colors.BOLD + "\n[!] Hash type not supported in this mode" + colors.ENDC + "\n")
                    else:
                        print (colors.FAIL + colors.BOLD + "\n[!] Incorrect algorithm!!" + colors.ENDC)

            elif args.offline:  # Offline
                for line in myfile.readlines():
                    line = line.strip("\n")
                    print("\n [+]" + colors.INFO + " Hash: " + colors.ENDC + line)
                    print(" [+]" + colors.INFO + " Type: " + colors.ENDC + args.type)
                    if alg == "md5":
                        MultiOffDecrypt(line, args.wordlist, "md5")
                    elif alg == "sha1":
                        MultiOffDecrypt(line, args.wordlist, "sha1")
                    elif alg == "sha224":
                        MultiOffDecrypt(line, args.wordlist, "sha224")
                    elif alg == "sha256":
                        MultiOffDecrypt(line, args.wordlist, "sha256")
                    elif alg == "sha384":
                        MultiOffDecrypt(line, args.wordlist, "sha384")
                    elif alg == "sha512":
                        MultiOffDecrypt(line, args.wordlist, "sha512")
                    elif alg == "ntlm":
                        print(colors.FAIL + colors.BOLD + "\n[!] Hash type not supported in this mode" + colors.ENDC + "\n")
                    elif alg == "lm":
                        lmOffDecryptFile(line, args.wordlist)
                    else:
                        print (colors.FAIL + colors.BOLD + "\n[!] Incorrect algorithm!!" + colors.ENDC)

    else:
        print(SAMPLES)
Example #13
0
def hashLm(word):
    return lmhash.encrypt(word, encoding="utf-8")
Example #14
0
 def run(self, text):
     from passlib.hash import lmhash
     return lmhash.encrypt(text.encode('utf-8', errors='surrogateescape'))
Example #15
0
 def digest(self):
     return unhexlify(lmhash.encrypt(self.data[:15]))
Example #16
0
                encrypted = hashlib.sha224(word).hexdigest()
                print("\n\t [+]" + colors.INFO + " Hash: " + colors.GREEN + encrypted.upper() + colors.ENDC)
            elif option == "sha256" or option == "SHA256":
                encrypted = hashlib.sha256(word).hexdigest()
                print("\n\t [+]" + colors.INFO + " Hash: " + colors.GREEN + encrypted.upper() + colors.ENDC)
            elif option == "sha384" or option == "SHA384":
                encrypted = hashlib.sha384(word).hexdigest()
                print("\n\t [+]" + colors.INFO + " Hash: " + colors.GREEN + encrypted.upper() + colors.ENDC)
            elif option == "sha512" or option == "SHA512":
                encrypted = hashlib.sha512(word).hexdigest()
                print("\n\t [+]" + colors.INFO + " Hash: " + colors.GREEN + encrypted.upper() + colors.ENDC)
            elif option == "ntlm" or option == "NTLM":
                hashs = hashlib.new("md4", word.encode("utf-16le")).digest()
                print("\n\t [+]" + colors.INFO + " Hash: " + colors.GREEN + binascii.hexlify(hashs).upper() + colors.ENDC)
            elif option == "lm" or option == "LM":
                hashs = lmhash.encrypt(word).upper()
                print("\n\t [+]" + colors.INFO + " Hash: " + colors.GREEN + hashs + colors.ENDC)
            else:
                pass
        else:
            print (colors.FAIL + colors.BOLD + "\n[!] Incorrect algorithm!!" + colors.ENDC)
        raw_input("\npress enter to continue...")

    elif optionMenu == "crypt_on" or optionMenu == "CRYPT_ON":  # ONLINE ENCRYPTER
        banner()
        print(colors.INFO + "\t\t >> Online Encrypter <<" + colors.ENDC)
        print("+--------------------------------------------------------------+")
        print("\n [+] " + colors.INFO + "List of algorithms available:" + colors.ENDC)
        print("\n\t [-] " + colors.GREEN + "MD2" + colors.ENDC + "\t[-] " + colors.GREEN + "SHA1" + colors.ENDC)
        print("\n\t [-] " + colors.GREEN + "MD4" + colors.ENDC + "\t[-] " + colors.GREEN + "SHA256" + colors.ENDC)
        print("\n\t [-] " + colors.GREEN + "MD5" + colors.ENDC + "\t[-] " + colors.GREEN + "SHA384" + colors.ENDC)
Example #17
0
def hash():
    banner()

    hash_str = raw_input(B + "[" + W + "?" + B + "]" + G + " Hash : " + W)
    #	time.sleep(0.5)
    print(B + "[" + R + "=" + B + "] " + G + "Cek Hash Type ...")
    #	time.sleep(1)

    # Contoh Hash nya , nb : jangan di ubah ntar error

    SHA512 = (
        'dd0ada8693250b31d9f44f3ec2d4a106003a6ce67eaa92e384b356d1b4ef6d66a818d47c1f3a2c6e8a9a9b9bdbd28d485e06161ccd0f528c8bbb5541c3fef36f'
    )
    md = ('ae11fd697ec92c7c98de3fac23aba525')
    sha1 = ('4a1d4dbc1e193ec3ab2e9213876ceb8f4db72333')
    sha224 = ('e301f414993d5ec2bd1d780688d37fe41512f8b57f6923d054ef8e59')
    sha384 = (
        '3b21c44f8d830fa55ee9328a7713c6aad548fe6d7a4a438723a0da67c48c485220081a2fbc3e8c17fd9bd65f8d4b4e6b'
    )
    sha256 = (
        '2c740d20dab7f14ec30510a11f8fd78b82bc3a711abe8a993acdb323e78e6d5e')
    mysql1323 = ("5d2e19393cc5ef67")
    mysql41 = ("*88166B019A3144C579AC4A7131BCC3AD6FF61DA6")
    mssql2000 = (
        "0x0100DE9B3306258B37432CAC3A6FB7C638946FA393E09C9CBC0FA8C6E03B803390B1C3E7FB112A21B2304595D490"
    )
    mssql2005 = ('0x01008110620C7BD03A38A28A3D1D032059AE9F2F94F3B74397F8')

    if len(hash_str) == len(mysql1323) and hash_str.isdigit(
    ) == False and hash_str.isalpha() == False and hash_str.isalnum() == True:
        print(B + "[" + R + "=" + B + "] " + G + "hash type : " + W +
              "mysql 3.2.3")
        hash = "mysql1323"

    elif len(hash_str) == len(mysql41) and "*" in hash_str:
        print(B + "[" + R + "=" + B + "] " + G + "hash type : " + W +
              "mysql 4.1")
        hash = "mysql41"

    elif len(hash_str) == len(mssql2000) and "0x0" in hash_str:
        print(B + "[" + R + "=" + B + "] " + G + "hash type : " + W +
              "Mssql2000")
        hash = "mssql2000"

    elif len(hash_str) == len(mssql2005) and "0x0" in hash_str:
        print(B + "[" + R + "=" + B + "] " + G + "hash type : " + W +
              "Mssql2005")
        hash = "mssql2005"

    elif len(hash_str) == len(SHA512) and hash_str.isdigit(
    ) == False and hash_str.isalpha() == False and hash_str.isalnum() == True:
        print(Y + "   [" + W + "01" + Y + "] " + C + "sha512")
        print(Y + "   [" + W + "02" + Y + "] " + C + "whirlpool")
        #		time.sleep(0.3)
        cek = raw_input(B + "[" + W + "?" + B + "] " + G + "Choose hash " + Y +
                        ">>> " + W)

        if cek == "1" or cek == "01" or cek == "sha512":
            hash = "sha512"
        elif cek == "2" or cek == "02" or cek == "whirlpool":
            hash = "whirlpool"
        else:
            print(R + "[" + W + "!" + R + "] " + G + "Exiting ... \n")
            #                       time.sleep(0.5)
            sys.exit()

    elif len(hash_str) == len(md) and hash_str.isdigit(
    ) == False and hash_str.isalpha() == False and hash_str.isalnum() == True:

        print(Y + "   [" + W + "01" + Y + "] " + C + "md4")
        print(Y + "   [" + W + "02" + Y + "] " + C + "md5")
        print(Y + "   [" + W + "03" + Y + "] " + C + "Nthash")
        print(Y + "   [" + W + "04" + Y + "] " + C + "Lmhash")
        print(Y + "   [" + W + "05" + Y + "] " + C + "Ntlm hash")

        #		time.sleep(0.3)
        cek = raw_input(B + "[" + W + "?" + B + "] " + G + "Choose Hash " + Y +
                        ">>> " + W)

        if cek == "1" or cek == "01" or cek == "md4" or cek == "MD4" or cek == "Md4":
            hash = "md4"
        elif cek == "2" or cek == "02" or cek == "md5" or cek == "MD5" or cek == "Md5":
            try:
                print(B + "[" + R + "=" + B + "] " + G + "open google")
                #				time.sleep(0.3)
                print(B + "[" + W + "*" + B + "] " + G + "Start ...")
                #				time.sleep(0.3)
                start = ("00:00:00")
                start1 = time.time()
                print(B + "\n[" + W + "{}" + B + "] " + G + "Searching..." +
                      Y).format(start)

                data = urlencode({"md5": hash_str, "x": "21", "y": "8"})
                html = urlopen(
                    "http://md5.my-addr.com/md5_decrypt-md5_cracker_online/md5_decoder_tool.php",
                    data)
                find = html.read()
                match = search(
                    r"<span class='middle_title'>Hashed string</span>: [^<]*</div>",
                    find)
                if match:

                    end = time.strftime("%H:%M:%S",
                                        time.gmtime(time.time() - start1))
                    print(B + "[" + W + "{}" + B + "] " + G +
                          "Stopped...").format(end)
                    #	                                time.sleep(0.3)
                    print(B + "\n[" + W + "=" + B + "]" + G +
                          " password found ")
                    print(B + "[" + W + "+" + B + "] " + W + (hash_str) + Y +
                          " 0={==> " + W +
                          (match.group().split('span')[2][3:-6]) + "\n")
                    sys.exit()
                else:
                    data = urlencode({"md5": hash_str, "x": "21", "y": "8"})
                    html = urlopen(
                        "http://md5.my-addr.com/md5_decrypt-md5_cracker_online/md5_decoder_tool.php",
                        data)
                    find = html.read()
                    match = search(
                        r"<span class='middle_title'>Hashed string</span>: [^<]*</div>",
                        find)
                    if match:

                        end = time.strftime("%H:%M:%S",
                                            time.gmtime(time.time() - start1))
                        print(B + "[" + W + "{}" + B + "] " + G +
                              "Stopped...").format(end)
                        #						time.sleep(0.3)
                        print(B + "\n[" + W + "=" + B + "]" + G +
                              " password found ")
                        print(B + " [" + W + "+" + B + "] " + W + hash_str +
                              Y + " 0={==> " + W +
                              match.group().split('span')[2][3:-6] + W + " \n")
                        sys.exit()
                    else:
                        url = "http://www.nitrxgen.net/md5db/" + hash_str
                        cek = urlopen(url).read()
                        if len(cek) > 0:

                            end = time.strftime(
                                "%H:%M:%S", time.gmtime(time.time() - start1))
                            print(B + "[" + W + "{}" + B + "] " + G +
                                  "Stopped...").format(end)
                            #							time.sleep(0.3)
                            print(B + "\n[" + W + "=" + B + "]" + G +
                                  " password found ")
                            print(B + "[" + W + "+" + B + "] " + W + hash_str +
                                  Y + " 0={==> " + W + cek + "\n")
                            sys.exit()
                        else:

                            end = time.strftime(
                                "%H:%M:%S", time.gmtime(time.time() - start1))
                            print(B + "[" + W + "{}" + B + "]" + G +
                                  " password not found\n").format(end)
                            hash = "md5"

            except IOError:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                print(B + "[" + W + "{}" + B + "]" + G +
                      " Timeout\n").format(end)
                hash = "md5"

        elif cek == "03" or cek == "3" or cek.upper() == "NTHASH":
            hash = "nthash"

        elif cek == "04" or cek == "4" or cek.upper() == "LMHASH":
            hash = "lmhash"

        elif cek == "05" or cek == "5" or cek.upper() == "NTLM":
            hash = "ntlm"

        else:
            print(R + "[" + W + "!" + R + "] " + G + "Exiting ... \n" + W)
            #			time.sleep(0.5)
            sys.exit()

    elif len(hash_str) == len(sha1) and hash_str.isdigit(
    ) == False and hash_str.isalpha() == False and hash_str.isalnum() == True:

        print(Y + "   [" + W + "01" + Y + "] " + C + "sha1")
        print(Y + "   [" + W + "02" + Y + "] " + C + "ripemd160")
        #		time.sleep(0.3)
        cek = raw_input(B + "[" + W + "?" + B + "] " + G + "Choose Hash " + Y +
                        ">>> " + W)

        if cek == "1" or cek == "01" or cek == "sha1" or cek == "SHA1" or cek == "Sha1":
            #			time.sleep(0.5)
            print(B + "[" + R + "=" + B + "] " + G + "open google")
            #			time.sleep(0.3)
            print(B + "[" + W + "*" + B + "] " + G + "Start ...")
            #			time.sleep(0.3)
            start = ("00:00:00")
            start1 = time.time()
            print(B + "\n[" + W + "{}" + B + "] " + G + "Searching..." +
                  Y).format(start)
            try:

                data = urlencode({
                    "auth": "8272hgt",
                    "hash": hash_str,
                    "string": "",
                    "Submit": "Submit"
                })
                html = urlopen("http://hashcrack.com/index.php", data)
                find = html.read()
                match = search(
                    r'<span class=hervorheb2>[^<]*</span></div></TD>', find)
                if match:

                    end = time.strftime("%H:%M:%S",
                                        time.gmtime(time.time() - start1))
                    print(B + "[" + W + "{}" + B + "] " + G +
                          "Stopped...").format(end)
                    #					time.sleep(0.3)
                    print(B + "\n[" + W + "=" + B + "]" + G +
                          " password found ")
                    print(B + "[" + W + "+" + B + "] " + W + hash_str + Y +
                          " 0={==> " + W +
                          match.group().split('hervorheb2>')[1][:-18] + "\n")
                    sys.exit()

                else:

                    end = time.strftime("%H:%M:%S",
                                        time.gmtime(time.time() - start1))
                    print(B + "[" + W + "{}" + B + "]" + G +
                          " password not found\n").format(date)
                    hash = "sha1"
            except IOError:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                print(B + "[" + W + "{}" + B + "]" + G +
                      " Timeout\n").format(end)
                hash = "sha1"

        elif cek == "2" or cek == "02" or cek == "ripemd160":
            hash = 'ripemd160'
        else:
            print(R + "[" + W + "!" + R + "] " + G + "Exiting ... \n" + W)
            #			time.sleep(0.5)
            sys.exit()

    elif len(hash_str) == len(sha224) and hash_str.isdigit(
    ) == False and hash_str.isalpha() == False and hash_str.isalnum() == True:
        print(B + "[" + R + "=" + B + "] " + G + "hash type : " + W + "SHA224")
        hash = "SHA224"

    elif len(hash_str) == len(sha384) and hash_str.isdigit(
    ) == False and hash_str.isalpha() == False and hash_str.isalnum() == True:
        print(B + "[" + R + "=" + B + "] " + G + "hash type : " + W + "SHA384")
        hash = "SHA384"

    elif len(hash_str) == len(sha256) and hash_str.isdigit(
    ) == False and hash_str.isalpha() == False and hash_str.isalnum() == True:
        print(B + "[" + R + "=" + B + "] " + G + "hash type : " + W + "sha256")
        #		time.sleep(0.5)
        print(B + "[" + R + "=" + B + "] " + G + "open google")
        #		time.sleep(0.3)
        print(B + "[" + W + "*" + B + "] " + G + "Start ...")
        #		time.sleep(0.3)
        start = ("00:00:00")
        start1 = time.time()
        print(B + "\n[" + W + "{}" + B + "] " + G + "Searching..." +
              Y).format(start)

        try:
            data = urlencode({"hash": hash_str, "decrypt": "Decrypt"})
            html = urlopen("http://md5decrypt.net/en/Sha256/", data)
            find = html.read()
            match = search(r'<b>[^<]*</b><br/><br/>', find)
            if match:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                print(B + "[" + W + "{}" + B + "] " + G +
                      "Stopped...").format(end)
                #				time.sleep(0.3)
                print(B + "\n[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + W + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + match.group().split('<b>')[1][:-14] +
                      "\n")
                sys.exit()

            else:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                print(B + "[" + W + "{}" + B + "]" + G +
                      " password not found\n").format(end)
                hash = "sha256"
        except IOError:

            end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
            print(B + "[" + W + "{}" + B + "]" + G + " Timeout\n").format(end)
            hash = "sha256"

    else:
        print(R + "[" + W + "!" + R + "] " + G + "Hash error\n" + W)
        sys.exit()

    time.sleep(0.1)
    print(B + "[" + W + "=" + B + "] " + G + "cek wordlist ..")

    try:
        w = open("wordlist.txt", "r").readlines()
        x = len(w)
    except IOError:
        #		time.sleep(0.5)
        print(B + "[" + R + "=" + B + "]" + G + " Can't load " + W +
              "wordlist.txt, " + G + "file not exist\n" + W)
        sys.exit()


#	time.sleep(0.3)
    print(B + "[" + R + "=" + B + "] " + G + "load " + W + "{}" + G +
          " words in " + W + "wordlist.txt").format(x)
    print(B + "[" + W + "*" + B + "] " + G + "start ..\n")
    #	time.sleep(1)

    start = ("00:00:00")
    start1 = time.time()
    print(B + "[" + W + "{}" + B + "] " + G + "Cracking..." + Y).format(start)

    pbar = progressbar.ProgressBar()

    if hash == "mysql1323":

        hash_str = hash_str.lower()
        for line in pbar(w):
            line = line.strip()
            h = m20.encrypt(line)

            if h == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #                                time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #                                time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()

    elif hash == "lmhash":

        hasb_str = hash_str.upper()
        for line in pbar(w):
            line = line.strip()
            h = lmhash.encrypt(line)
            if h == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #                                time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #                                time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()

    elif hash == "nthash":

        hasb_str = hash_str.upper()
        for line in pbar(w):
            line = line.strip()
            h = nthash.encrypt(line)

            if h == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #                                time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #                                time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()

    elif hash == "mysql41":

        hash_str = hash_str.upper()
        for line in pbar(w):
            line = line.strip()
            h = m25.encrypt(line)

            if h == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #                                time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #                                time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()

    elif hash == "mssql2000":

        hash_str = hash_str.upper()
        for line in pbar(w):
            line = line.strip()
            h = ms20.encrypt(line)

            if h == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #                                time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #                                time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()

    elif hash == "ntlm":

        hash_str = hash_str.lower()
        for line in pbar(w):
            line = line.strip()
            h = ntlm_hash = binascii.hexlify(
                hashlib.new('md4', line.encode('utf-16le')).digest())
            if h == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #				time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #                                time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()

    elif hash == "mssql2005":

        hasb_str = hash_str.upper()
        for line in pbar(w):
            line = line.strip()
            h = ms25.encrypt(line)

            if h == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #                                time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #                                time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()

    else:

        hash_str = hash_str.lower()
        for line in pbar(w):

            line = line.strip()
            h = hashlib.new(hash)
            h.update(line)

            if h.hexdigest() == hash_str:

                end = time.strftime("%H:%M:%S",
                                    time.gmtime(time.time() - start1))
                #				time.sleep(0.3)
                print(B + "\n[" + W + "{}" + B + "] " + G +
                      "Stopped...\n").format(end)
                #				time.sleep(0.3)
                print(B + "[" + W + "=" + B + "]" + G + " password found ")
                print(B + "[" + R + "+" + B + "] " + W + hash_str + Y +
                      " 0={==> " + W + line + W + "\n")
                sys.exit()

        end = time.strftime("%H:%M:%S", time.gmtime(time.time() - start1))
        print(B + "[" + W + "{}" + B + "]" + G + " password not found\n" +
              W).format(end)
        sys.exit()
 def digest(self):
     return lmhash.encrypt(self._data[:15]).decode('hex')
Example #19
0
def main():
    argp = ArgumentParser(
        description="Crypt - Decrypt Tool",
        usage=
        "./crypt-decrypt.py [options] [-w word/hash] \nSamples: ./crypt-decrypt.py",
        version="Crypt - Decrypt Tool v" + VERSION)

    argp.add_argument('-e',
                      '--encrypt',
                      dest='encrypt',
                      action='store_true',
                      help='Encrypt word/s (offline mode)')

    argp.add_argument('-d',
                      '--decrypt',
                      dest='decrypt',
                      action='store_true',
                      help='Decrypt a hash')

    argp.add_argument('-i',
                      '--identify',
                      dest='identify',
                      action='store_true',
                      help='Identify type of hash')

    argp.add_argument('-t',
                      '--hash-type',
                      dest='type',
                      help='Hash type to encrypt/decrypt word/hash')

    argp.add_argument('-w',
                      '--word',
                      dest='word',
                      help='Word or hash to encrypt/decrypt/identify')

    argp.add_argument('-o',
                      '--online',
                      dest='online',
                      action='store_true',
                      help='Decrypt online mode')

    argp.add_argument('-f',
                      '--offline',
                      dest='offline',
                      action='store_true',
                      help='Decrypt offline mode')

    argp.add_argument('-l',
                      '--wordlist',
                      dest='wordlist',
                      help='Dictionary to decrypt hash (offline mode only)')

    argp.add_argument('-a',
                      '--all',
                      dest='all',
                      action='store_true',
                      help='Encrypt word/s with all hash types')

    argp.add_argument('-F',
                      '--file',
                      dest='file',
                      help='File with hashes to decrypt/identify')

    args = argp.parse_args()

    if args.encrypt and not args.all and not args.decrypt and not args.identify:  # ENCRYPTER
        alg = args.type.lower()
        word = args.word
        print("\n [+]" + colors.INFO + " Word: " + colors.ENDC + word)
        print(" [+]" + colors.INFO + " Type: " + colors.ENDC + alg)
        if alg == "md5":
            encrypted = hashlib.md5(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha1":
            encrypted = hashlib.sha1(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha224":
            encrypted = hashlib.sha224(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha256":
            encrypted = hashlib.sha256(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha384":
            encrypted = hashlib.sha384(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "sha512":
            encrypted = hashlib.sha512(word).hexdigest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + encrypted + colors.ENDC + "\n")
        elif alg == "ntlm":
            encrypted = hashlib.new("md4", word.encode("utf-16le")).digest()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + binascii.hexlify(encrypted).upper() +
                  colors.ENDC + "\n")
        elif alg == "lm":
            encrypted = lmhash.encrypt(word).upper()
            print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
                  colors.GREEN + encrypted + colors.ENDC + "\n")
        else:
            print(colors.FAIL + colors.BOLD + "\n[!] Incorrect algorithm!!\n" +
                  colors.ENDC)

    elif args.encrypt and args.all and not args.decrypt and not args.identify:  # ALL TYPES
        word = args.word
        print("\n [+]" + colors.INFO + " Word: " + colors.ENDC + word)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "md5")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + hashlib.md5(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha1")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + hashlib.sha1(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha224")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + hashlib.sha224(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha256")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + hashlib.sha256(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha384")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + hashlib.sha384(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "sha512")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + hashlib.sha512(word).hexdigest() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "lm")
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + lmhash.encrypt(word).upper() + colors.ENDC)
        print("\n [+]" + colors.INFO + " Type: " + colors.ENDC + "ntlm")
        encrypted = hashlib.new("md4", word.encode("utf-16le")).digest()
        print(colors.GREEN + "   [i]" + colors.INFO + " Hash: " +
              colors.GREEN + binascii.hexlify(encrypted).upper() + colors.ENDC)

    elif args.decrypt and not args.encrypt and not args.identify and not args.file:  # DECRYPTER
        alg = args.type.lower()
        hashs = args.word
        if args.online and not args.offline:  # Online
            print("\n [+]" + colors.INFO + " Hash: " + colors.ENDC + hashs)
            print(" [+]" + colors.INFO + " Type: " + colors.ENDC + alg)
            if alg == "md5":
                md5OnDecrypt(hashs)
                md5OnDecrypt3(hashs)
                md5OnDecrypt4(hashs)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha1":
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha224":
                MultiOnDecrypt3(hashs)
            elif alg == "sha256":
                web = "Sha256/"
                MultiOnDecrypt(hashs, web)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha384":
                web = "Sha384/"
                MultiOnDecrypt(hashs, web)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "sha512":
                web = "Sha512/"
                MultiOnDecrypt(hashs, web)
                MultiOnDecrypt2(hashs)
                MultiOnDecrypt3(hashs)
            elif alg == "ntlm":
                web = "Ntlm/"
                MultiOnDecrypt(hashs, web)
            elif alg == "lm":
                print(colors.FAIL + colors.BOLD +
                      "\n[!] Hash type not supported in this mode" +
                      colors.ENDC + "\n")
            else:
                print(colors.FAIL + colors.BOLD +
                      "\n[!] Incorrect algorithm!!" + colors.ENDC)

        elif args.offline and not args.online:  # Offline
            print("\n [+]" + colors.INFO + " Hash: " + colors.ENDC + hashs)
            print(" [+]" + colors.INFO + " Type: " + colors.ENDC + alg)
            if alg == "md5":
                MultiOffDecrypt(hashs, args.wordlist, "md5")
            elif alg == "sha1":
                MultiOffDecrypt(hashs, args.wordlist, "sha1")
            elif alg == "sha224":
                MultiOffDecrypt(hashs, args.wordlist, "sha224")
            elif alg == "sha256":
                MultiOffDecrypt(hashs, args.wordlist, "sha256")
            elif alg == "sha384":
                MultiOffDecrypt(hashs, args.wordlist, "sha384")
            elif alg == "sha512":
                MultiOffDecrypt(hashs, args.wordlist, "sha512")
            elif alg == "ntlm":
                print(colors.FAIL + colors.BOLD +
                      "\n[!] Hash type not supported in this mode" +
                      colors.ENDC + "\n")
            elif alg == "lm":
                lmOffDecryptFile(hashs, args.wordlist)
            else:
                print(colors.FAIL + colors.BOLD +
                      "\n[!] Incorrect algorithm!!" + colors.ENDC)

    elif args.identify and not args.encrypt and not args.decrypt:  # IDENTIFIER
        if args.file:
            with open(args.file, 'r') as f:
                for h in f.readlines():
                    print("\n [+]" + colors.INFO + " Hash: " + colors.GREEN +
                          h.strip("\n") + colors.ENDC)
                    r = commands.getoutput('./hash-identifier.py %s' %
                                           h.strip('\n'))
                    for x in r.split("\n"):
                        if not "Least Possible" in x:
                            print(x + "\n"),
                        else:
                            break
        else:
            r = commands.getoutput('./hash-identifier.py %s' % args.word)
            print(r)

    elif args.file and args.decrypt and not args.encrypt and not args.identify:  # FILE
        alg = args.type
        with open(args.file, 'r') as myfile:
            if args.online:  # Online
                for line in myfile.readlines():
                    if alg == "md5":
                        md5OnDecrypt(line)
                        md5OnDecrypt3(line)
                        md5OnDecrypt4(line)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha1":
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha224":
                        MultiOnDecrypt3(line)
                    elif alg == "sha256":
                        web = "Sha256/"
                        MultiOnDecrypt(line, web)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha384":
                        web = "Sha384/"
                        MultiOnDecrypt(line, web)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "sha512":
                        web = "Sha512/"
                        MultiOnDecrypt(line, web)
                        MultiOnDecrypt2(line)
                        MultiOnDecrypt3(line)
                    elif alg == "ntlm":
                        web = "Ntlm/"
                        MultiOnDecrypt(line, web)
                    elif alg == "lm":
                        print(colors.FAIL + colors.BOLD +
                              "\n[!] Hash type not supported in this mode" +
                              colors.ENDC + "\n")
                    else:
                        print(colors.FAIL + colors.BOLD +
                              "\n[!] Incorrect algorithm!!" + colors.ENDC)

            elif args.offline:  # Offline
                for line in myfile.readlines():
                    line = line.strip("\n")
                    print("\n [+]" + colors.INFO + " Hash: " + colors.ENDC +
                          line)
                    print(" [+]" + colors.INFO + " Type: " + colors.ENDC +
                          args.type)
                    if alg == "md5":
                        MultiOffDecrypt(line, args.wordlist, "md5")
                    elif alg == "sha1":
                        MultiOffDecrypt(line, args.wordlist, "sha1")
                    elif alg == "sha224":
                        MultiOffDecrypt(line, args.wordlist, "sha224")
                    elif alg == "sha256":
                        MultiOffDecrypt(line, args.wordlist, "sha256")
                    elif alg == "sha384":
                        MultiOffDecrypt(line, args.wordlist, "sha384")
                    elif alg == "sha512":
                        MultiOffDecrypt(line, args.wordlist, "sha512")
                    elif alg == "ntlm":
                        print(colors.FAIL + colors.BOLD +
                              "\n[!] Hash type not supported in this mode" +
                              colors.ENDC + "\n")
                    elif alg == "lm":
                        lmOffDecryptFile(line, args.wordlist)
                    else:
                        print(colors.FAIL + colors.BOLD +
                              "\n[!] Incorrect algorithm!!" + colors.ENDC)

    else:
        print(SAMPLES)
Example #20
0
 def lmhash(self, plain):
     return lmhash.encrypt(plain)
Example #21
0
 def lmhash(self, plain):
     return lmhash.encrypt(plain)