Skip to content

Commit

Permalink
Add colored print
Browse files Browse the repository at this point in the history
  • Loading branch information
DoroninaD committed Sep 3, 2017
1 parent d9b805f commit ff932e1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
16 changes: 16 additions & 0 deletions colored.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions main_insert_border_regs.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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')
Expand Down
19 changes: 11 additions & 8 deletions run.py
Original file line number Diff line number Diff line change
@@ -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))
colored.printColored (file[:-7], colored.HEADER)
main_insert_border_regs.run(join(path, file)[:-7], int(start_group), int(end_group), DEBUG)

0 comments on commit ff932e1

Please sign in to comment.