示例#1
0
    def is_valid_user(self, username, password):
        self.conn = MySQLdb.connect(host=settings.dbhost, db=settings.dbname, user=settings.dbuser, passwd=settings.dbpass)
        self.cursor = self.conn.cursor()

        stmt = """
                SELECT
                    user_password
                FROM
                    %susers
                WHERE
                    username='******'
                """ % (settings.phpbb_table_prefix, username)
        num_rows = self.cursor.execute(stmt)
        retcode=0

        if num_rows == 0 or num_rows is None:
            settings.logEvent('Error - Authentication failed for username \'%s\' (user not found)' % (username))
        else:
            db_password = self.cursor.fetchone()[0]
            if db_password != phpass.crypt_private(password, db_password, '$H$'):
                settings.logEvent('Error - Authentication failed for username \'%s\' (incorrect password)' % (username))
            else:
                retcode=1

        self.cursor.close()
        self.conn.close()

        return retcode
示例#2
0
    def is_valid_user(self, username, password):
        stmt = """
                SELECT
                    user_password
                FROM
                    %susers
                WHERE
                    username='******'
                """ % (settings.phpbb_table_prefix,
                       self.quote_string(username))
        num_rows = self.query(stmt)

        if num_rows == 0 or num_rows is None:
            settings.logEvent(
                'Error - Authentication failed for username \'%s\' (user not found)'
                % (username))
            return 0
        else:
            db_password = self.cursor.fetchone()[0]
            if db_password != phpass.crypt_private(password, db_password,
                                                   '$H$'):
                settings.logEvent(
                    'Error - Authentication failed for username \'%s\' (incorrect password)'
                    % (username))
                return 0
            else:
                return 1
示例#3
0
    def run(self):
        global output_filename
        global userhashes
        global found_hashes
        global hashes_calculated
        global stop

        while True:
            if stop:
                break

            # grab user, passwd, and hash from the queue
            user, passwd, hash = self.queue.get()

            # hash it and compare results
            if phpass.crypt_private(passwd, hash) == hash:
                found_hash = '%s:%s' % (user, passwd)
                found_hashes.append(found_hash)

                # display success
                success = 'CRACKED: %s:%s' % (user, passwd)
                if self.verbose > 0:
                    print '\n%s' % success
                else:
                    print success

                # output to file -- I open and close the file each time so that the file gets written
                # to promptly, otherwise you can't tell if you've cracked a password sometimes until the
                # whole program finishes
                if output_filename != '':
                    output_file = open(output_filename, "a")
                    output_file.write('%s:%s\n' % (user, passwd))
                    output_file.close()

                # stop everything if we found all the hashes
                if len(found_hashes) == len(userhashes):
                    if self.verbose > 0:
                        print '\n%d out of %d have been cracked, therefore quitting\n' % (
                            len(found_hashes), len(userhashes))
                    stop = True
            hashes_calculated += 1

            # verbose
            if self.verbose == 1:
                sys.stdout.write('.')
            if self.verbose == 2:
                sys.stdout.write('%s ' % passwd)

            # all done
            self.queue.task_done()
示例#4
0
 def run (self):
     global output_filename
     global userhashes
     global found_hashes
     global hashes_calculated
     global stop
     
     while True:
         if stop:
             break
         
         # grab user, passwd, and hash from the queue
         user, passwd, hash = self.queue.get()
         
         # hash it and compare results
         if phpass.crypt_private(passwd, hash) == hash:
             found_hash = '%s:%s' % (user, passwd)
             found_hashes.append(found_hash)
             
             # display success
             success = 'CRACKED: %s:%s' % (user, passwd)
             if self.verbose > 0:
                 print '\n%s' % success
             else:
                 print success
             
             # output to file -- I open and close the file each time so that the file gets written
             # to promptly, otherwise you can't tell if you've cracked a password sometimes until the 
             # whole program finishes
             if output_filename != '':
                 output_file = open(output_filename, "a")
                 output_file.write('%s:%s\n' % (user, passwd))
                 output_file.close()
             
             # stop everything if we found all the hashes
             if len(found_hashes) == len(userhashes):
                 if self.verbose > 0:
                     print '\n%d out of %d have been cracked, therefore quitting\n' % (len(found_hashes), len(userhashes))
                 stop = True
         hashes_calculated += 1
         
         # verbose
         if self.verbose == 1:
             sys.stdout.write('.')
         if self.verbose == 2:
             sys.stdout.write('%s ' % passwd)
         
         # all done
         self.queue.task_done()
示例#5
0
文件: phpasscrack.py 项目: dre/appsec
 def run(self):
     if verbose:
         print '    [!] Running thread: %s' % self.threadID
     while not self.exit_event.isSet():
         self.times_run += 1
         try:
             for word in self.dic:
                 # matching hash to word
                 if phpass.crypt_private(word, self.thash) == self.thash:
                     fin.append(word + " : " + self.thash)
                     self.cracked += 1
                 else:
                     continue
         except KeyboardInterrupt:
             print '\n [*] Aborted: exiting'
             sys.exit(1)
示例#6
0
    def is_valid_user(self, username, password):
        stmt = """
                SELECT
                    user_password
                FROM
                    %susers
                WHERE
                    username='******'
                """ % (settings.phpbb_table_prefix, self.quote_string(username))
        num_rows = self.query(stmt)

        if num_rows == 0 or num_rows is None:
            settings.logEvent('Error - Authentication failed for username \'%s\' (user not found)' % (username))
            return 0
        else:
            db_password = self.cursor.fetchone()[0]
            if db_password != phpass.crypt_private(password, db_password, '$H$'):
                settings.logEvent('Error - Authentication failed for username \'%s\' (incorrect password)' % (username))
                return 0
            else:
                return 1
示例#7
0
    def is_valid_user(self, username, password):
        self.conn = MySQLdb.connect(host=settings.dbhost,
                                    db=settings.dbname,
                                    user=settings.dbuser,
                                    passwd=settings.dbpass)
        self.cursor = self.conn.cursor()

        stmt = """
                SELECT
                    user_password
                FROM
                    %susers
                WHERE
                    username='******'
                """ % (settings.phpbb_table_prefix, username)
        num_rows = self.cursor.execute(stmt)
        retcode = 0

        if num_rows == 0 or num_rows is None:
            settings.logEvent(
                'Error - Authentication failed for username \'%s\' (user not found)'
                % (username))
        else:
            db_password = self.cursor.fetchone()[0]
            if db_password != phpass.crypt_private(password, db_password,
                                                   '$H$'):
                settings.logEvent(
                    'Error - Authentication failed for username \'%s\' (incorrect password)'
                    % (username))
            else:
                retcode = 1

        self.cursor.close()
        self.conn.close()

        return retcode