Пример #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()
Пример #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()
Пример #3
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()
Пример #4
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
Пример #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
Пример #6
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
Пример #7
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)
Пример #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)
Пример #9
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
Пример #10
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()
Пример #11
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Convert the hash to hex (for being readable)
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    for(i=0; i<4; i++)
    {
        int j = 0;
        unsigned int n = output[i];

        // Iterate the bytes of the integer
        for(; j<4; j++)
        {
            unsigned int convert = n % 256;
            hex_format[i * 8 + j * 2 + 1] = itoa16[convert % 16];
            convert = convert / 16;
            hex_format[i * 8 + j * 2 + 0] = itoa16[convert % 16];
            n = n / 256;
        }
    }       
}
""", no_extern_c=True)
expected = nthash.encrypt('then')
data = numpy.array(expected)
cleartext = numpy.zeros_like(data)
cleartext_gpu = cuda.mem_alloc(data.nbytes)
func = mod.get_function('NTBruteforce')
func(cleartext_gpu, block=(1,1,1))
cuda.memcpy_dtoh(cleartext, cleartext_gpu)
print 'Expected: {}'.format(expected.upper())
print "GPU     : {}".format(cleartext.tostring())
Пример #12
0
 def digest(self):
     return unhexlify(nthash.encrypt(self.data[:127]))
Пример #13
0
 def digest(self):
     return nthash.encrypt(self._data[:127]).decode('hex')
Пример #14
0
 def run(self, text):
     from passlib.hash import nthash
     return nthash.encrypt(text.encode('utf-8', errors='surrogateescape'))
Пример #15
0
 def update_samba(self, passwd=""):
     """Update Samba values in LDAP."""
     try:
         domain = conns.LDAP.search_s(self.rootdn, ldap.SCOPE_SUBTREE,
                                      "objectClass=sambaDomain", None)
     except ldap.NO_SUCH_OBJECT:
         domain = None
     if not domain:
         hostname = sysconfig.get_hostname().upper()
         sambaSID = "S-1-5-21-0-0-0"
         dldif = {
             "objectClass": [b"sambaDomain"],
             "sambaDomainName": [b(hostname)],
             "sambaSID": [b(sambaSID)],
             "sambaAlgorithmicRidBase": [b"1000"],
             "sambaNextUserRid": [b"1000"],
             "sambaMinPwdLength": [b"5"],
             "sambaPwdHistoryLength": [b"0"],
             "sambaLogonToChgPwd": [b"0"],
             "sambaMaxPwdAge": [b"-1"],
             "sambaMinPwdAge": [b"0"],
             "sambaLockoutDuration": [b"30"],
             "sambaLockoutObservationWindow": [b"30"],
             "sambaLockoutThreshold": [b"0"],
             "sambaForceLogoff": [b"-1"],
             "sambaRefuseMachinePwdChange": [b"0"],
             "sambaNextRid": [b(str(get_next_uid()))]
         }
         dldif = ldap.modlist.addModlist(dldif)
         try:
             conns.LDAP.add_s(
                 "sambaDomainName={0},{1}".format(hostname, self.rootdn),
                 dldif)
         except ldap.ALREADY_EXISTS:
             pass
     else:
         sambaSID = domain[0][1]["sambaSID"][0].decode()
         attrs = {"sambaNextRid": [b(str(get_next_uid()))]}
         dldif = ldap.modlist.modifyModlist(domain[0][1],
                                            attrs,
                                            ignore_oldexistent=1)
         conns.LDAP.modify_s(domain[0][0], dldif)
     if passwd:
         try:
             uldif = conns.LDAP.search_s(self.ldap_id, ldap.SCOPE_SUBTREE,
                                         "(objectClass=*)", None)
         except ldap.NO_SUCH_OBJECT:
             raise errors.InvalidConfigError("Users",
                                             "This user does not exist")
         uldif = uldif[0][1]
         attrs = {
             "objectClass": [
                 b"mailAccount", b"inetOrgPerson", b"posixAccount",
                 b"sambaSamAccount"
             ],
             "sambaSID": [b("{0}-{1}".format(sambaSID, self.uid))],
             "sambaAcctFlags": [b"[UX         ]"],
             "sambaNTPassword": [b(nthash.encrypt(passwd).upper())]
         }
         nldif = ldap.modlist.modifyModlist(uldif,
                                            attrs,
                                            ignore_oldexistent=1)
         conns.LDAP.modify_s(self.ldap_id, nldif)
Пример #16
0
def radius_create(raw_password):
    return nthash.encrypt(raw_password)