Skip to content

Commit

Permalink
Merge pull request #170 from nename0/fix-badbytes-ranges
Browse files Browse the repository at this point in the history
Fix badbytes ranges python3 compatibility
  • Loading branch information
SweetVishnya authored Mar 30, 2021
2 parents 7c5d4cf + f18d25f commit a4b583f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
Expand Down
13 changes: 5 additions & 8 deletions ropgadget/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,18 @@ def __deleteBadBytes(self):
rng = bb.split('-')
low = ord(codecs.decode(rng[0], "hex"))
high = ord(codecs.decode(rng[1], "hex"))
for i in range(low, high):
bbytes.append(chr(i))
bbytes += bytes(bytearray(i for i in range(low, high)))
else:
bbytes.append(codecs.decode(bb.encode("ascii"), "hex"))

archMode = self.__binary.getArchMode()
for gadget in self.__gadgets:
gadAddr = pack("<L", gadget["vaddr"]) if archMode == CS_MODE_32 else pack("<Q", gadget["vaddr"])
try:
for x in bbytes:
if x in gadAddr:
raise
for x in bbytes:
if x in gadAddr:
break
else:
new += [gadget]
except:
pass
self.__gadgets = new

def getGadgets(self):
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 @@ -51,6 +51,8 @@ echo "RUN elf-Linux-x86 --memstr \"/bin/sh\"" | tee -a ./test_output
$RUN --binary ./elf-Linux-x86 --memstr "/bin/sh" 1>> ./test_output
echo "RUN elf-Linux-x86 --badbytes \"00|01-1f|7f|42\"" | tee -a ./test_output
$RUN --binary ./elf-Linux-x86 --badbytes "00|01-1f|7f|42" 1>> ./test_output
echo "RUN elf-Linux-x86 --offset 5555e000 --badbytes \"00-20|80-ff|ff\"" | tee -a ./test_output
$RUN --binary ./elf-Linux-x86 --offset 5555e000 --badbytes "00-20|80-ff|ff" 1>> ./test_output
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
Expand Down

0 comments on commit a4b583f

Please sign in to comment.