MOD: improved the fingerprint comparison algorithm and the output
This commit is contained in:
parent
76a9dd1f8b
commit
ff1d7ab9ac
20
dbfp.py
20
dbfp.py
|
@ -61,7 +61,7 @@ def indexFingerprints(fp_dir):
|
|||
|
||||
#
|
||||
def compareFPIndex(fp_dir, db_in, json_in):
|
||||
# try:
|
||||
try:
|
||||
db = FingerprintDB()
|
||||
if (db_in):
|
||||
db.scanDBFile(db_in)
|
||||
|
@ -83,23 +83,17 @@ def compareFPIndex(fp_dir, db_in, json_in):
|
|||
print fp
|
||||
# search for fingerprints with similar tables
|
||||
else:
|
||||
print "[ Table percent match: ]"
|
||||
logging.info("Searching for md5 tables: {}".format(db.getMD5Tables()))
|
||||
fp_list = fp.findFPTables(db.getMD5Tables().values())
|
||||
results = []
|
||||
for fp in fp_list:
|
||||
fq_fp = fp_dir + os.path.sep + fp
|
||||
fq_fp = fp_dir + os.path.sep + fp[0]
|
||||
logging.info("Comparing 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
|
||||
|
||||
print "{:2.2f}%: {}".format(percent, fp[0])
|
||||
except Exception as ex:
|
||||
print "ERROR: error occured while comparing fingerprint"
|
||||
print ex
|
||||
#
|
||||
def androidPull():
|
||||
fin_count = 0
|
||||
|
|
|
@ -142,7 +142,6 @@ class FingerprintDB:
|
|||
fp = FingerprintDB();
|
||||
fp.__importJsonDBSchema(filejson)
|
||||
result = self.__DBSchemaCompare(fp)
|
||||
print "[ Percetage == %f]".format(result)
|
||||
return result
|
||||
|
||||
#
|
||||
|
@ -177,6 +176,7 @@ class FingerprintDB:
|
|||
self.db_hash = dbmd5
|
||||
self.table_hashes = dbht
|
||||
self.file_details = metadata
|
||||
self.init = True
|
||||
except Exception as ex:
|
||||
logging.error("ERROR: problem loading json file: \n{}\n{}".format(file_json, ex))
|
||||
|
||||
|
@ -220,7 +220,7 @@ class FingerprintDB:
|
|||
if (diff_total == all_total):
|
||||
percentage = 0
|
||||
else:
|
||||
percentage = float(diff_total / all_total)
|
||||
percentage = 100 * float(all_total-diff_total) / float(all_total)
|
||||
else:
|
||||
percentage = 100
|
||||
return percentage
|
||||
|
|
|
@ -96,18 +96,10 @@ class FingerprintIndex:
|
|||
retval[fp] = retval[fp] + 1
|
||||
else:
|
||||
retval[fp] = 1
|
||||
logging.debug("findFPTables::retval=={}\n".format(retval))
|
||||
|
||||
# retval_sorted = sorted(retval.items(), key==lambda x: x[1])
|
||||
retval_sorted = sorted(retval.items(), key=itemgetter(1))
|
||||
# retval_sorted = []
|
||||
# vals = retval.values()
|
||||
# vals.sort()
|
||||
# for val in vals:
|
||||
# retval_sorted.append(retval[val])
|
||||
logging.debug("findFPTables::retval_sorted=={}\n".format(retval_sorted))
|
||||
# logging.debug("findFPTables::retval=={}\n".format(retval))
|
||||
retval_sorted = sorted(retval.items(), key=itemgetter(1), reverse=True)
|
||||
# logging.debug("findFPTables::retval_sorted=={}\n".format(retval_sorted))
|
||||
return retval_sorted
|
||||
# return retval.keys()
|
||||
|
||||
#
|
||||
def findDB(self, md5_db):
|
||||
|
|
Loading…
Reference in New Issue