Exemple #1
0
def find_thumb_gadget(e, gadget):
   gadget_bytes = asm.asm(gadget, arch='thumb')
   gadget_address = None
   for address in e.search(gadget_bytes):
	   if address % 2 == 0:
	      gadget_address = address + 1
	      if gadget_bytes == e.read(gadget_address - 1, len(gadget_bytes)):
		      print asm.disasm(gadget_bytes, vma=gadget_address-1, arch='thumb')
		      break
   return gadget_address
Exemple #2
0
def find_arm_gadget(e, gadget):
   gadget_bytes = asm.asm(gadget, arch='arm')
   gadget_address = None
   for address in e.search(gadget_bytes):
	   if address % 4 == 0:
	      gadget_address = address
	   if gadget_bytes == e.read(gadget_address, len(gadget_bytes)):
		   print asm.disasm(gadget_bytes, vma=gadget_address, arch='arm')
		   break
   return gadget_address
Exemple #3
0
def main():
    args = parser.parse_args()

    if len(args.hex) > 0:
        dat = ''.join(args.hex)
        dat = dat.translate(None, whitespace)
        if not set(hexdigits) >= set(dat):
            print "This is not a hex string"
            exit(-1)
        dat = dat.decode('hex')
    else:
        dat = sys.stdin.read()

    print asm.disasm(dat, arch = args.context)
Exemple #4
0
def main():
    args = parser.parse_args()

    if len(args.hex) > 0:
        dat = ''.join(args.hex)
        dat = dat.translate(None, whitespace)
        if not set(hexdigits) >= set(dat):
            print "This is not a hex string"
            exit(-1)
        dat = dat.decode('hex')
    else:
        dat = sys.stdin.read()

    print asm.disasm(dat, arch=args.context)