Skip to content

Commit

Permalink
Add LDM / LDMDB JOP gadgets for ARM Thumb2 (#207)
Browse files Browse the repository at this point in the history
* Add LDM / LDMDB JOP gadgets for ARM Thumb2

* tests: add arm thumb test
  • Loading branch information
face0xff authored Jan 22, 2025
1 parent 90d9ff7 commit b3463a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ropgadget/gadgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,17 @@ def addJOPGadgets(self, section):
gadgets = [
[b"\x47[\x00\x08\x10\x18\x20\x28\x30\x38\x40\x48\x70]{1}", 2, 2], # bx reg
[b"\x47[\x80\x88\x90\x98\xa0\xa8\xb0\xb8\xc0\xc8\xf0]{1}", 2, 2], # blx reg
[b"\xbd[\x00-\xff]{1}", 2, 2] # pop {,pc}
[b"\xbd[\x00-\xff]{1}", 2, 2], # pop {,pc}
[b"\xe8[\x90-\x9f\xb0-\xbf][\x00-\xff]{4}", 4, 2], # ldm.w reg{!}, {,pc}
[b"\xe9[\x10-\x1f\x30-\x3f][\x00-\xff]{4}", 4, 2] # ldmdb reg{!}, {,pc}
]
else:
gadgets = [
[b"[\x00\x08\x10\x18\x20\x28\x30\x38\x40\x48\x70]{1}\x47", 2, 2], # bx reg
[b"[\x80\x88\x90\x98\xa0\xa8\xb0\xb8\xc0\xc8\xf0]{1}\x47", 2, 2], # blx reg
[b"[\x00-\xff]{1}\xbd", 2, 2] # pop {,pc}
[b"[\x00-\xff]{1}\xbd", 2, 2], # pop {,pc}
[b"[\x90-\x9f\xb0-\xbf]\xe8[\x00-\xff]{4}", 4, 2], # ldm.w reg{!}, {,pc}
[b"[\x10-\x1f\x30-\x3f]\xe9[\x00-\xff]{4}", 4, 2] # ldmdb reg{!}, {,pc}
]
arch_mode = CS_MODE_THUMB
else:
Expand Down
Binary file modified test-suite-binaries/ref_output.bz2
Binary file not shown.
2 changes: 2 additions & 0 deletions test-suite-binaries/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ echo "RUN Linux_lib64.so --offset 0xdeadbeef00000000" | tee -a ./test_output
$RUN --binary ./Linux_lib64.so --offset 0xdeadbeef00000000 1>> ./test_output
echo "RUN elf-ARMv7-ls --depth 5" | tee -a ./test_output
$RUN --binary ./elf-ARMv7-ls --depth 5 1>> ./test_output
echo "RUN elf-ARMv7-ls --thumb --depth 5" | tee -a ./test_output
$RUN --binary ./elf-ARMv7-ls --thumb --depth 5 1>> ./test_output
echo "RUN elf-ARM64-bash --depth 5" | tee -a ./test_output
$RUN --binary ./elf-ARM64-bash --depth 5 1>> ./test_output
echo "RUN elf-PPC64-bash --depth 5" | tee -a ./test_output
Expand Down

0 comments on commit b3463a9

Please sign in to comment.