FIX: improved the compareFingerprintDir, split find fingerprint functions, bug fixes
This commit is contained in:
parent
44e853484b
commit
f738006147
47
dbfp.py
47
dbfp.py
|
@ -63,23 +63,38 @@ def indexFingerprints(fp_dir):
|
|||
|
||||
#
|
||||
def compareFingerprintDir(file_in, fp_dir):
|
||||
db = FingerprintDB()
|
||||
db.scanDBFile(file_in)
|
||||
md5_db = db.getMD5DB()
|
||||
md5_tables = db.getMD5Tables()
|
||||
fp = FingerprintIndex()
|
||||
fp.openIndex(fp_dir)
|
||||
fp_list = fp.findFP(md5_db, md5_tables)
|
||||
results = []
|
||||
for fp in fp_list:
|
||||
fq_fp = fp_dir + os.path.sep + fp
|
||||
print "[ OPEN fingerprint ] [ {} ]".format(fq_fp)
|
||||
percent = db.compareDB(fq_fp)
|
||||
results.append(percent)
|
||||
try:
|
||||
db = FingerprintDB()
|
||||
db.scanDBFile(file_in)
|
||||
fp = FingerprintIndex()
|
||||
fp.openIndex(fp_dir)
|
||||
|
||||
print "RESULTS: {}".format(results)
|
||||
results.sort()
|
||||
print "RESULTS: {}".format(results)
|
||||
# search for fingerprints with exact database match
|
||||
fp_ret = fp.findFP(db.getMD5DB())
|
||||
if (fp_ret):
|
||||
print "Database matche(s) found"
|
||||
print "RESULTS:"
|
||||
for fp_list in fp_ret:
|
||||
for fp in fp_list[1].split(','):
|
||||
print fp
|
||||
print
|
||||
# search for fingerprints with similar tables
|
||||
else:
|
||||
fp_list = fp.findFPTables(db.getMD5Tables())
|
||||
results = []
|
||||
for fp in fp_list:
|
||||
fq_fp = fp_dir + os.path.sep + fp
|
||||
print "[ OPEN fingerprint ] [ {} ]".format(fq_fp)
|
||||
percent = db.compareDB(fq_fp)
|
||||
results.append(percent)
|
||||
|
||||
print "Table matche(s) found"
|
||||
print "RESULTS: {}".format(results)
|
||||
results.sort()
|
||||
print "RESULTS: {}".format(results)
|
||||
except Exception as ex:
|
||||
print "Error comparing fingerprint"
|
||||
print ex
|
||||
|
||||
#
|
||||
def androidPull():
|
||||
|
|
|
@ -148,6 +148,9 @@ class FingerprintDB:
|
|||
def getMD5DB(self):
|
||||
return self.db_hash
|
||||
|
||||
def getMD5Tables(self):
|
||||
return self.table_hashes
|
||||
|
||||
#
|
||||
# def getMD5Tables(self):
|
||||
# if (self.table_hashes):
|
||||
|
|
|
@ -72,12 +72,16 @@ class FingerprintIndex:
|
|||
raise FingerprintIndexWrite("Error creating an index file\n")
|
||||
return retVal
|
||||
|
||||
#
|
||||
def findFP(self, md5_db, md5_tables):
|
||||
# looking for databases with exact schema match
|
||||
# RETURN: (fingerprint list, json_filename list, fingerprint count)
|
||||
def findFP(self, md5_db):
|
||||
rows = self.__qDatabaseMD5(md5_db)
|
||||
if len(rows) > 0:
|
||||
return rows
|
||||
return None
|
||||
|
||||
# return an a list of json fingerprint files to open
|
||||
def findFPTables(self, md5_tables):
|
||||
for md5_table in md5_tables:
|
||||
retval = {}
|
||||
rows = self.__qTableMD5(md5_table)
|
||||
|
@ -86,7 +90,6 @@ class FingerprintIndex:
|
|||
fps = fp_list.split(',')
|
||||
for fp in fps:
|
||||
retval[fp] = 1
|
||||
#print "***** __qTableMD5 *****\n{}\n".format(retval.keys())
|
||||
return retval.keys()
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue