From 8f57dae32f84c7dd91c7b992c32c1e514b5d2351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Felipe=20Melchor?= Date: Sat, 21 Mar 2015 13:52:37 +0100 Subject: [PATCH] Bug fix and added script to test all files --- ropgadget/gadgets.py | 17 ++++++++++++----- test-suite-binaries/test.sh | 10 ++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100755 test-suite-binaries/test.sh diff --git a/ropgadget/gadgets.py b/ropgadget/gadgets.py index dcb635f..c00775d 100644 --- a/ropgadget/gadgets.py +++ b/ropgadget/gadgets.py @@ -117,7 +117,10 @@ class Gadgets: print "Gadgets().addROPGadgets() - Architecture not supported" return None - return self.__gadgetsFinding(section, gadgets, arch, arch_mode) + if len(gadgets) > 0 : + return self.__gadgetsFinding(section, gadgets, arch, arch_mode) + return gadgets + def addJOPGadgets(self, section): arch = self.__binary.getArch() @@ -125,7 +128,7 @@ class Gadgets: - if arch == CS_ARCH_X86: + if arch == CS_ARCH_X86: gadgets = [ ["\xff[\x20\x21\x22\x23\x26\x27]{1}", 2, 1], # jmp [reg] ["\xff[\xe0\xe1\xe2\xe3\xe4\xe6\xe7]{1}", 2, 1], # jmp [reg] @@ -171,7 +174,9 @@ class Gadgets: print "Gadgets().addJOPGadgets() - Architecture not supported" return None - return self.__gadgetsFinding(section, gadgets, arch, arch_mode) + if len(gadgets) > 0 : + return self.__gadgetsFinding(section, gadgets, arch, arch_mode) + return gadgets def addSYSGadgets(self, section): @@ -195,7 +200,7 @@ class Gadgets: elif arch == CS_ARCH_ARM: if self.__options.thumb or self.__options.rawMode == "thumb": gadgets = [ - ["\x00-\xff]{1}\xef", 2, 2], # svc + ["\x00-\xff]{1}\xef", 2, 2] # svc ] arch_mode = CS_MODE_THUMB else: @@ -207,7 +212,9 @@ class Gadgets: print "Gadgets().addSYSGadgets() - Architecture not supported" return None - return self.__gadgetsFinding(section, gadgets, arch, arch_mode) + if len(gadgets) > 0 : + return self.__gadgetsFinding(section, gadgets, arch, arch_mode) + return [] def passClean(self, gadgets, multibr): diff --git a/test-suite-binaries/test.sh b/test-suite-binaries/test.sh new file mode 100755 index 0000000..778814a --- /dev/null +++ b/test-suite-binaries/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash +FILES=`ls` +for f in $FILES +do + if [ "$f" != "test.sh" ] + then + python ../ROPgadget.py --binary $f 1>/dev/null + echo "$f analyzed" + fi +done