Skip to content

Commit

Permalink
Merge branch 'master' of github.com:doronz88/fa
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Jul 25, 2020
2 parents e894479 + 8fb2a37 commit 94495d9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
16 changes: 14 additions & 2 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,30 @@ optional arguments:
```
## function-start
```
usage: function-start [-h]
usage: function-start [-h] [cmd [cmd ...]]
goto function's start
EXAMPLE:
0x00000000: push {r4-r7, lr} -> function's prolog
...
0x000000f0: push {r4-r7, pc} -> function's epilog
0x000000f0: pop {r4-r7, pc} -> function's epilog
results = [0xf0]
-> function-start
result = [0]
EXAMPLE 2:
0x00000000: push {r4-r7, lr} -> function's prolog
...
0x000000f0: pop {r4-r7, pc} -> function's epilog
results = []
-> function-start arm-find-all 'pop {r4-r7, pc}'
result = [0]
positional arguments:
cmd command
optional arguments:
-h, --help show this help message and exit
Expand Down
18 changes: 17 additions & 1 deletion fa/commands/function_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@
EXAMPLE:
0x00000000: push {r4-r7, lr} -> function's prolog
...
0x000000f0: push {r4-r7, pc} -> function's epilog
0x000000f0: pop {r4-r7, pc} -> function's epilog
results = [0xf0]
-> function-start
result = [0]
EXAMPLE 2:
0x00000000: push {r4-r7, lr} -> function's prolog
...
0x000000f0: pop {r4-r7, pc} -> function's epilog
results = []
-> function-start arm-find-all 'pop {r4-r7, pc}'
result = [0]
'''


Expand All @@ -30,6 +39,7 @@ def get_parser():
p = utils.ArgumentParserNoExit('function-start',
description=DESCRIPTION,
formatter_class=RawTextHelpFormatter)
p.add_argument('cmd', nargs='*', default='', help='command')
return p


Expand All @@ -43,4 +53,10 @@ def function_start(addresses):


def run(segments, args, addresses, interpreter=None, **kwargs):
if len(args.cmd) > 0:
cmd = args.cmd[0] + ' ' + \
''.join('"{}"'.format(c) for c in args.cmd[1:])
addresses = interpreter.find_from_instructions_list(
[cmd],
addresses=addresses)
return list(function_start(addresses))
6 changes: 6 additions & 0 deletions fa/signatures/test-project-ida/test-ida-context.sig
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@

offset 4
set-struct-member test_struct_t test_member_offset_4 'unsigned int'

clear

function-start arm-find-all 'pop {r4-r7, pc}'
single 0
set-name test_function_start_cmd
]
}
1 change: 1 addition & 0 deletions tests/test_commands/test_idalink.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ def test_ida_symbols(ida, sample_elf):
assert symbols['test_find_immediate'] == 0x1240
assert symbols['test_find_immediate'] == 0x1240
assert symbols['test_operand'] == 1
assert symbols['test_function_start_cmd'] == 0x1248

0 comments on commit 94495d9

Please sign in to comment.