54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
import argparse
|
|
import os
|
|
import sys
|
|
import re
|
|
from enum import IntEnum
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-f", "--filetoparse", help="RBF file which should be encrypted")
|
|
parser.add_argument("-b", "--benign", help="Output issues but don't return error", action="store_true")
|
|
args = parser.parse_args()
|
|
|
|
fileToParse = args.filetoparse
|
|
if fileToParse == None:
|
|
print("Please supply a filename")
|
|
return 1
|
|
|
|
fileToCompareArray = os.path.splitext(fileToParse)
|
|
fileToCompare = fileToCompareArray[0]+"_comp"+fileToCompareArray[1]
|
|
|
|
print("File to parse: " + fileToParse)
|
|
print("File to compare: " + fileToCompare)
|
|
|
|
if not os.path.isfile(fileToParse):
|
|
print("Please supply a valid file, cannot find {0}".format(fileToParse))
|
|
if args.benign:
|
|
return 0
|
|
return 1
|
|
|
|
if not os.path.isfile(fileToCompare):
|
|
print("Please supply a valid comparison file, cannot find {0}".format(fileToCompare))
|
|
if args.benign:
|
|
return 0
|
|
return 1
|
|
|
|
import filecmp
|
|
if not filecmp.cmp(fileToParse,fileToCompare):
|
|
print("/////////////////////////////////////////////////////////////////////////////")
|
|
print('RBF ENCRYPTION SUCCESSFUL')
|
|
print("/////////////////////////////////////////////////////////////////////////////")
|
|
return 0
|
|
else:
|
|
print("/////////////////////////////////////////////////////////////////////////////")
|
|
print('RBF ENCRYPTION FAILED: File {0} and {1} are identical, therefore probably NOT encrypted'.format(fileToParse,fileToCompare))
|
|
print("/////////////////////////////////////////////////////////////////////////////")
|
|
|
|
|
|
if args.benign:
|
|
return 0
|
|
return 1
|
|
|
|
if __name__ == "__main__":
|
|
# Always set an exit code!
|
|
sys.exit(main())
|