-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
432 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from collections import namedtuple | ||
|
||
import r2pipe, json | ||
|
||
func_model = namedtuple('funcModel','address name rows') | ||
opcode_model = namedtuple('opcodeModel','offset bytes type opcode size') | ||
|
||
|
||
class r2Helper: | ||
def __init__(self, filename): | ||
self.r2 = r2pipe.open(filename) | ||
self.cmd('e arm.lines=false arm.varsub=false arm.comments=false') | ||
self.cmd('aaa') | ||
|
||
def open(self,filename): | ||
self.cmd('o--') | ||
self.cmd('o {0}'.format(filename)) | ||
self.cmd('e arm.lines=false arm.varsub=false arm.comments=false') | ||
self.cmd('aaa') | ||
|
||
def cmd(self, s): | ||
return self.r2.cmd(s) | ||
|
||
def cmdJson(self, s, *args): | ||
return json.loads(self.cmd(s)) | ||
|
||
def getFunctions(self): | ||
funcList = self.cmdJson('aflj') | ||
funcTypes = ['fcn','sub','aav'] #todo | ||
return [self.getFuncInfo(f) for f in funcList if f['type'] in funcTypes] | ||
|
||
def getFuncInfo(self,funcname): | ||
func_info = self.cmdJson('pdfj @ {0}'.format(funcname['name'])) | ||
print(funcname['name']) | ||
opcodes_info = func_info['ops'] | ||
opcodes = [opcode_model(oc['offset'], oc['bytes'], oc['type'], oc['opcode'], oc['size']) | ||
for oc in opcodes_info | ||
if self.valid(oc['type']) and self.valid(oc['opcode'])] | ||
return func_model(func_info["addr"], func_info["name"], opcodes) | ||
|
||
def valid(self, item): | ||
return item!='invalid' | ||
|
||
|
||
r2 = r2Helper('/home/daria/Documents/dimplom/apps/audio/lib/armeabi-v7a/libnative-audio-jni.so') | ||
functions = r2.getFunctions() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,38 @@ | ||
from os import listdir | ||
from os.path import isfile, join | ||
import main_insert_border_regs, sys, colored | ||
import main_insert_border_regs, sys, colored, config_parser | ||
|
||
#path = 'data/com.instagram.android/lib/armeabi-v7a/' | ||
#path = 'data/noassertTel/lib/armeabi-v7a/' | ||
#path = 'apps/telegram/lib/armeabi-v7a/' | ||
#harded_path = 'apps/app-debug/lib/armeabi-v7a/' | ||
harded_path = 'apps/test2/lib/armeabi-v7a/' | ||
harded_path = 'apps/curl/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!!! | ||
config_path = sys.argv[2] if len(sys.argv)>2 else 'config.ini' | ||
start_group = sys.argv[3] if len(sys.argv)>3 else 0 | ||
end_group = sys.argv[4] if len(sys.argv)>4 else sys.maxsize #todo LAST ELEMENT!!! | ||
|
||
#todo debug only | ||
#start_group = 0 | ||
#end_group = 1000 | ||
# start_group = 387 | ||
# end_group = 388 #388 | ||
#2314 | ||
|
||
# 1-путь к либами,2-конфиг, 3-начало, 4-конец | ||
|
||
|
||
|
||
files = [f for f in listdir(path) if isfile(join(path, f)) and f.endswith('_old.so')] | ||
config = config_parser.ConfigParser(config_path) | ||
for file in files: | ||
# if file[:-7]=='libcurl': | ||
# start_group = 0 | ||
# #end_group = 387 | ||
# end_group = -1 | ||
# else: | ||
# start_group = 0 | ||
# end_group = 1 | ||
|
||
|
||
colored.printColored (file[:-7], colored.HEADER) | ||
main_insert_border_regs.run(join(path, file)[:-7], int(start_group), int(end_group), DEBUG) | ||
main_insert_border_regs.run(join(path, file)[:-7], int(start_group), int(end_group), DEBUG, config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters