diff --git a/colored.py b/colored.py new file mode 100644 index 0000000..5098265 --- /dev/null +++ b/colored.py @@ -0,0 +1,16 @@ + +HEADER = '\033[95m' +OKBLUE = '\033[94m' +OKGREEN = '\033[92m' +WARNING = '\033[93m' +FAIL = '\033[91m' +ENDC = '\033[0m' +BOLD = '\033[1m' +UNDERLINE = '\033[4m' + + +def printColored(str, option): + print(option+str+ENDC) + +def setColored(str, oprtion): + return oprtion+str+ENDC \ No newline at end of file diff --git a/main_insert_border_regs.py b/main_insert_border_regs.py index 6f2b6ae..17cad24 100755 --- a/main_insert_border_regs.py +++ b/main_insert_border_regs.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import re, utils, arm_translate, parse,parse_functions_utils, static_functions_helper, config_parser, os -import cxxfilt +import cxxfilt, colored def run(path, start_group, end_group, DEBUG): @@ -154,11 +154,13 @@ def run(path, start_group, end_group, DEBUG): if len(inner_lines) > 0: to_write.extend(inner_lines) - print('{0}: old {1}, new {2}'.format(cxxfilt.demangle(functions[addr]),first[3], new_registers)) + print(colored.setColored('{0}: '.format(cxxfilt.demangle(functions[addr])), colored.OKGREEN) + 'old {0}, new {1}'.format(first[3], new_registers)) regs_added += len(new_registers) - len(first[3]) secured = groups_count/len(groups)*100 - print('\033[92m'+'End:{0}, full regs:{1}, secured:{2}%, average randomness:{3}\033[0m' - .format(groups_count, full_registers_count, secured, regs_added/groups_count)) + output = 'End:{0}, full regs:{1}, secured:{2}%, average randomness:{3}'\ + .format(groups_count, full_registers_count, secured, regs_added/groups_count) + + colored.printColored(output, colored.BOLD) #переписываем файл f = open(path+'_old.so', 'br') diff --git a/run.py b/run.py index 86a8048..58acc56 100755 --- a/run.py +++ b/run.py @@ -1,20 +1,23 @@ from os import listdir from os.path import isfile, join -import main_insert_border_regs, sys +import main_insert_border_regs, sys, colored #path = 'data/com.instagram.android/lib/armeabi-v7a/' #path = 'data/noassertTel/lib/armeabi-v7a/' -path = 'apps/telegram/lib/armeabi-v7a/' - -#path = sys.argv[1] #путь к папке todo uncomment +#path = 'apps/telegram/lib/armeabi-v7a/' +#harded_path = 'apps/app-debug/lib/armeabi-v7a/' +harded_path = 'apps/test2/lib/armeabi-v7a/' +DEBUG=1 +path = sys.argv[1] if len(sys.argv) > 1 else harded_path start_group = sys.argv[2] if len(sys.argv)>2 else 0 end_group = sys.argv[3] if len(sys.argv)>3 else -1 #todo LAST ELEMENT!!! #todo debug only -#start_group = 2314 -#end_group = 2315 +#start_group = 0 +#end_group = 1000 +#2314 files = [f for f in listdir(path) if isfile(join(path, f)) and f.endswith('_old.so')] for file in files: - print (file[:-7]) - main_insert_border_regs.run(join(path, file)[:-7], int(start_group), int(end_group)) \ No newline at end of file + colored.printColored (file[:-7], colored.HEADER) + main_insert_border_regs.run(join(path, file)[:-7], int(start_group), int(end_group), DEBUG) \ No newline at end of file