WIP: fingerprint comparison with MD5 index
This commit is contained in:
parent
4fa3286859
commit
50a8e10988
46
dbfp.py
46
dbfp.py
|
@ -20,7 +20,7 @@ def main():
|
||||||
parseArgs()
|
parseArgs()
|
||||||
|
|
||||||
#
|
#
|
||||||
def compareFingerprintDir(filein, filejson, fpdir):
|
def compareFingerprintDir(filein, fpdir):
|
||||||
db = fingerprint.DBSchema()
|
db = fingerprint.DBSchema()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -112,7 +112,7 @@ def parseArgs():
|
||||||
parser = argparse.ArgumentParser(description='Fingerprint a sqlite database based on its schema')
|
parser = argparse.ArgumentParser(description='Fingerprint a sqlite database based on its schema')
|
||||||
parser.add_argument('-f', '--file', required=False)
|
parser.add_argument('-f', '--file', required=False)
|
||||||
parser.add_argument('-fd', '--fpdir', required=False, help="path to dirctory of fingerprint files")
|
parser.add_argument('-fd', '--fpdir', required=False, help="path to dirctory of fingerprint files")
|
||||||
parser.add_argument('-fp', '--fp', required=False, help="fingerprint file to use in comparison")
|
parser.add_argument('-fp', '--fingerprint', required=False, help="fingerprint file to use in comparison")
|
||||||
parser.add_argument('-an', '--app_name', required=False)
|
parser.add_argument('-an', '--app_name', required=False)
|
||||||
parser.add_argument('-av', '--app_version', required=False)
|
parser.add_argument('-av', '--app_version', required=False)
|
||||||
parser.add_argument('-n', '--notes', required=False)
|
parser.add_argument('-n', '--notes', required=False)
|
||||||
|
@ -125,8 +125,8 @@ def parseArgs():
|
||||||
filename = toolbox.ToolBox.parseFilename(args.file)
|
filename = toolbox.ToolBox.parseFilename(args.file)
|
||||||
fileout = filename + "_" + timestr + '.json'
|
fileout = filename + "_" + timestr + '.json'
|
||||||
createFingerprint(args.file, fileout, args.verbose, args.app_name, args.app_version, args.notes)
|
createFingerprint(args.file, fileout, args.verbose, args.app_name, args.app_version, args.notes)
|
||||||
elif (args.fp and args.fpdir):
|
elif (args.file and args.fpdir):
|
||||||
compareFingerprintDir(args.file, args.fp, args.fpdir)
|
compareFingerprintDir(args.file, args.fpdir)
|
||||||
elif (args.fp):
|
elif (args.fp):
|
||||||
compareFingerprint(args.file, args.fp)
|
compareFingerprint(args.file, args.fp)
|
||||||
elif (args.pull):
|
elif (args.pull):
|
||||||
|
@ -134,31 +134,31 @@ def parseArgs():
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
||||||
return
|
# return
|
||||||
|
|
||||||
|
|
||||||
if (args.pull):
|
# if (args.pull):
|
||||||
fingerprintDir()
|
# fingerprintDir()
|
||||||
return
|
# return
|
||||||
|
|
||||||
if (args.file is None) or (args.fp is None) or (args.pull is None):
|
# if (args.file is None) or (args.fp is None) or (args.pull is None):
|
||||||
parser.print_help()
|
# parser.print_help()
|
||||||
return
|
# return
|
||||||
|
|
||||||
# compare a sqlite database file to all fingerprints
|
# # compare a sqlite database file to all fingerprints
|
||||||
if (args.fp and args.fpdir):
|
# if (args.fp and args.fpdir):
|
||||||
compareFingerprintDir(args.file, args.fp, args.fpdir)
|
# compareFingerprintDir(args.file, args.fp, args.fpdir)
|
||||||
return
|
# return
|
||||||
|
|
||||||
# compare a sqlite database file to a fingerprint
|
# # compare a sqlite database file to a fingerprint
|
||||||
if (args.fp):
|
# if (args.fp):
|
||||||
compareFingerprint(args.file, args.fp)
|
# compareFingerprint(args.file, args.fp)
|
||||||
return
|
# return
|
||||||
|
|
||||||
# create a fingerprint from the sqlite file
|
# # create a fingerprint from the sqlite file
|
||||||
filename = toolbox.ToolBox.parseFilename(args.file)
|
# filename = toolbox.ToolBox.parseFilename(args.file)
|
||||||
fileout = filename + "_" + timestr + '.json'
|
# fileout = filename + "_" + timestr + '.json'
|
||||||
createFingerprint(args.file, fileout, args.verbose, args.app_name, args.app_version, args.notes)
|
# createFingerprint(args.file, fileout, args.verbose, args.app_name, args.app_version, args.notes)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -71,6 +71,16 @@ class DBSchema:
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
#
|
||||||
|
def writeFingerprint(self, filein):
|
||||||
|
self.DBSchema()
|
||||||
|
retVal = self.scanDBFile(filein)
|
||||||
|
if (retVal > 0):
|
||||||
|
fh = open(fileout, "w")
|
||||||
|
self.__writeFingerprint(fh)
|
||||||
|
fh.close()
|
||||||
|
else:
|
||||||
|
print self.getErrorString(retVal)
|
||||||
|
|
||||||
# import fingerprint from a json file
|
# import fingerprint from a json file
|
||||||
def importJson(self, filejson):
|
def importJson(self, filejson):
|
||||||
|
@ -201,7 +211,7 @@ class DBSchema:
|
||||||
tableDef.toJSON()
|
tableDef.toJSON()
|
||||||
|
|
||||||
|
|
||||||
def writeFingerprint(self, filehandle):
|
def __writeFingerprint(self, filehandle):
|
||||||
ahash = {}
|
ahash = {}
|
||||||
thash = {}
|
thash = {}
|
||||||
dmhash = {}
|
dmhash = {}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
from libs import fingerprint
|
||||||
|
|
||||||
|
|
||||||
class FingerprintRunner:
|
class FingerprintRunner:
|
||||||
|
@ -16,3 +17,7 @@ class FingerprintRunner:
|
||||||
def dirCompare(self, folder):
|
def dirCompare(self, folder):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def compareFingerprint(self, fp1, fp2):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue