Skip to content

Commit b3463a9

Browse files
authored
Add LDM / LDMDB JOP gadgets for ARM Thumb2 (#207)
* Add LDM / LDMDB JOP gadgets for ARM Thumb2 * tests: add arm thumb test
1 parent 90d9ff7 commit b3463a9

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

ropgadget/gadgets.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,17 @@ def addJOPGadgets(self, section):
288288
gadgets = [
289289
[b"\x47[\x00\x08\x10\x18\x20\x28\x30\x38\x40\x48\x70]{1}", 2, 2], # bx reg
290290
[b"\x47[\x80\x88\x90\x98\xa0\xa8\xb0\xb8\xc0\xc8\xf0]{1}", 2, 2], # blx reg
291-
[b"\xbd[\x00-\xff]{1}", 2, 2] # pop {,pc}
291+
[b"\xbd[\x00-\xff]{1}", 2, 2], # pop {,pc}
292+
[b"\xe8[\x90-\x9f\xb0-\xbf][\x00-\xff]{4}", 4, 2], # ldm.w reg{!}, {,pc}
293+
[b"\xe9[\x10-\x1f\x30-\x3f][\x00-\xff]{4}", 4, 2] # ldmdb reg{!}, {,pc}
292294
]
293295
else:
294296
gadgets = [
295297
[b"[\x00\x08\x10\x18\x20\x28\x30\x38\x40\x48\x70]{1}\x47", 2, 2], # bx reg
296298
[b"[\x80\x88\x90\x98\xa0\xa8\xb0\xb8\xc0\xc8\xf0]{1}\x47", 2, 2], # blx reg
297-
[b"[\x00-\xff]{1}\xbd", 2, 2] # pop {,pc}
299+
[b"[\x00-\xff]{1}\xbd", 2, 2], # pop {,pc}
300+
[b"[\x90-\x9f\xb0-\xbf]\xe8[\x00-\xff]{4}", 4, 2], # ldm.w reg{!}, {,pc}
301+
[b"[\x10-\x1f\x30-\x3f]\xe9[\x00-\xff]{4}", 4, 2] # ldmdb reg{!}, {,pc}
298302
]
299303
arch_mode = CS_MODE_THUMB
300304
else:

test-suite-binaries/ref_output.bz2

8.97 KB
Binary file not shown.

test-suite-binaries/test.sh

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ echo "RUN Linux_lib64.so --offset 0xdeadbeef00000000" | tee -a ./test_output
5757
$RUN --binary ./Linux_lib64.so --offset 0xdeadbeef00000000 1>> ./test_output
5858
echo "RUN elf-ARMv7-ls --depth 5" | tee -a ./test_output
5959
$RUN --binary ./elf-ARMv7-ls --depth 5 1>> ./test_output
60+
echo "RUN elf-ARMv7-ls --thumb --depth 5" | tee -a ./test_output
61+
$RUN --binary ./elf-ARMv7-ls --thumb --depth 5 1>> ./test_output
6062
echo "RUN elf-ARM64-bash --depth 5" | tee -a ./test_output
6163
$RUN --binary ./elf-ARM64-bash --depth 5 1>> ./test_output
6264
echo "RUN elf-PPC64-bash --depth 5" | tee -a ./test_output

0 commit comments

Comments
 (0)