From 0239696efbd8f96c7638683f602e1abba3a253c9 Mon Sep 17 00:00:00 2001 From: JohnE Date: Fri, 19 Feb 2016 01:33:52 -0800 Subject: [PATCH] NEW: md5 serach complete --- dbfp.py | 16 +++++++++++++++- docs/devnotes | 4 ++++ libs/fingerprint_index.py | 19 +++++++------------ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/dbfp.py b/dbfp.py index ca531de..80e49aa 100644 --- a/dbfp.py +++ b/dbfp.py @@ -121,6 +121,17 @@ def androidData(data_dir): print "COMPLETED: created {} fingerprints\n".format(str(fin_count)) +# +def queryMD5(fp_dir, md5_db): + try: + fp = FingerprintIndex() + fp.openIndex(fp_dir) + results = fp.findDB(md5_db) + print results + except Exception as ex: + print "ERROR: {}".format(ex) + + # in_dir: fully qualified directory path to find sqlite files def __createFingerprint(in_dir, out_dir, dir_name): fin_count = 0 @@ -175,6 +186,7 @@ def parseArgs(): parser.add_argument('-ad', '--android_dir', required=False, help="path to a directory with android folder structure sqlite files") parser.add_argument('-dd', '--data_dir', required=False, help="path to a directory to search for sqlite files") parser.add_argument('-idx', '--index_fingerprints', required=False, help="path to a directory with sqlite files") + parser.add_argument('-md5', required=False, help="md5 hash to query the index`") parser.add_argument('-an', '--app_name', required=False) parser.add_argument('-av', '--app_version', required=False) parser.add_argument('-n', '--notes', required=False) @@ -199,12 +211,14 @@ def parseArgs(): compareFingerprint(args.database, args.fingerprint) elif (args.database and args.fpdir): compareFingerprintDir(args.database, args.fpdir) + elif (args.fpdir and args.md5): + queryMD5(args.fpdir, args.md5) elif (args.android_dir): androidData(args.android_dir) elif (args.index_fingerprints): indexFingerprints(args.index_fingerprints) elif (args.android_pull): - androidPull() + androidPull() elif (args.database): createFingerprint(args.database, args.app_name, args.app_version, args.notes) else: diff --git a/docs/devnotes b/docs/devnotes index 2cbd0ec..acb0b36 100644 --- a/docs/devnotes +++ b/docs/devnotes @@ -19,6 +19,10 @@ http://stackoverflow.com/questions/11942762/get-application-version-name-using-a +com.google.android.gms__node.db +0b48447805d645966439e1b4042d2625 + + [ Regression Testing ] android pull, data dir, comparison diff --git a/libs/fingerprint_index.py b/libs/fingerprint_index.py index 089705a..7f447ab 100644 --- a/libs/fingerprint_index.py +++ b/libs/fingerprint_index.py @@ -58,10 +58,8 @@ class FingerprintIndex: # def findFP(self, md5_db, md5_tables): - rows = self.__qDatabaseMD5(md5_db) - # rowcount will be -1 if nothing was returned - if rows.rowcount > 0: - #print "***** __qDatabaseMD5 *****\n{}\n".format(rows) + rows = self.__qDatabaseMD5(md5_db) + if len(rows) > 0: return rows for md5_table in md5_tables: @@ -76,12 +74,9 @@ class FingerprintIndex: return retval.keys() # - def findTable(self, md5_db): + def findDB(self, md5_db): rows = self.__qDatabaseMD5(md5_db) - # rowcount will be -1 if nothing was returned - if rows.rowcount > 0: - #print "***** __qDatabaseMD5 *****\n{}\n".format(rows) - return rows + return rows # def __qDatabaseMD5(self, md5_db): @@ -92,10 +87,10 @@ class FingerprintIndex: WHERE md5_db=? ''', [md5_db]) + results = [] for row in rows: - # normalize the data, go from tuple to array - # https://docs.python.org/2/library/sqlite3.html - return rows + results.append((row[0], row[1], row[2])) + return results except Exception as ex: logging.error(ex)