2020-11-25 15:38:46 +00:00
|
|
|
## -*- coding: utf-8 -*-
|
|
|
|
##
|
|
|
|
## Jonathan Salwan - 2014-05-13
|
|
|
|
##
|
|
|
|
## http://shell-storm.org
|
|
|
|
## http://twitter.com/JonathanSalwan
|
|
|
|
##
|
|
|
|
|
|
|
|
from capstone import *
|
|
|
|
from ropgadget.ropchain.arch.ropmakerx86 import *
|
|
|
|
from ropgadget.ropchain.arch.ropmakerx64 import *
|
|
|
|
|
|
|
|
class ROPMaker(object):
|
2020-11-27 01:18:51 +00:00
|
|
|
def __init__(self, binary, gadgets, paddingLen, outFile, execPath, offset):
|
2020-11-25 18:55:01 +00:00
|
|
|
self.__binary = binary
|
|
|
|
self.__gadgets = gadgets
|
|
|
|
self.paddingLen = paddingLen
|
2020-11-27 01:18:51 +00:00
|
|
|
self.outFile = outFile
|
|
|
|
self.execPath = execPath
|
2020-11-25 18:55:01 +00:00
|
|
|
self.__offset = offset
|
2020-11-25 15:38:46 +00:00
|
|
|
|
|
|
|
self.__handlerArch()
|
|
|
|
|
|
|
|
def __handlerArch(self):
|
|
|
|
|
|
|
|
if self.__binary.getArch() == CS_ARCH_X86 \
|
|
|
|
and self.__binary.getArchMode() == CS_MODE_32 \
|
|
|
|
and self.__binary.getFormat() == "ELF":
|
2020-11-27 01:18:51 +00:00
|
|
|
ROPMakerX86(self.__binary, self.__gadgets, self.paddingLen, self.outFile, self.execPath, self.__offset)
|
2020-11-25 15:38:46 +00:00
|
|
|
|
|
|
|
elif self.__binary.getArch() == CS_ARCH_X86 \
|
|
|
|
and self.__binary.getArchMode() == CS_MODE_64 \
|
|
|
|
and self.__binary.getFormat() == "ELF":
|
2020-11-25 18:55:01 +00:00
|
|
|
ROPMakerX64(self.__binary, self.__gadgets, self.paddingLen, self.__offset)
|
2020-11-25 15:38:46 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
print("\n[Error] ROPMaker.__handlerArch - Arch not supported yet for the rop chain generation")
|
|
|
|
|