class InjectShell(cmd.Cmd): # Color Escape Sequences # http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html prompt = "\x1b[1;34m(binject)\x1b[0m " # highlight color def __init__(self): cmd.Cmd.__init__(self) self.injector = AutoInjector() if userHasRoot(): self.stdout.write("Mode: process\n") self.injector.setEditMode("process") else: self.stdout.write("Mode: binary\n") self.injector.setEditMode("binary") self.doPrintResult = True def convert(self, arg, typ): try: if typ == "int": return int(arg) if typ == "hex": return int(arg, 16) if typ == "str": return arg except Exception, e: return None return arg
def __init__(self): cmd.Cmd.__init__(self) self.injector = AutoInjector() if userHasRoot(): self.stdout.write("Mode: process\n") self.injector.setEditMode("process") else: self.stdout.write("Mode: binary\n") self.injector.setEditMode("binary") self.doPrintResult = True
def injectHyriseDemo(objdump_path, hyrise_binary, hyrise_src_path): inj = AutoInjector() # init inj.loadAnalysis(objdump_path) inj.setSourcePath(hyrise_src_path) inj.setTarget(hyrise_binary) inj.setEditMode("binary") # edit inj.openEditor() hooks = inj.extractHooks() for i, hook in enumerate(hooks): inj.injectHook(hook) print "%.2d at %s:%d" % (i, hook[0]["file"], hook[0]["lineno"]) inj.writeBinary("injected-%d" % (i)) inj.resetHook(hook) inj.closeEditor()