def get_registers(_view): res = binjatron.custom_request("registers", { "block": False, "deref": True }, alert=False) if (res.is_error): log_error("Could not get registers!" + " -- " + res.message) return None, res.message return res.registers, res.deref
def get_memory(_view, address, length): res = binjatron.custom_request("memory", { "block": False, "address": address, "length": length }, alert=False) if (res.is_error): log_error("Could not get memory at address ``" + str(address) + " -- " + res.message) return None return res.memory
def set_arguments(arguments, _view): version = get_version(_view).host_version if 'gdb' in version: # Voltron doesn't like commands that aren't UTF-8, but for exploit work we're going to need # arbitary byte support. A named temporary file that we can source commands from is the best # solution I've come up with so far, despite the fact that it's inelegant. with tempfile.NamedTemporaryFile() as tempf: tempf.write('set args ') tempf.write(arguments) tempf.write('\n') tempf.flush() binjatron.custom_request( "command", _build_command_dict("source " + tempf.name)) elif 'lldb' in version: with tempfile.NamedTemporaryFile() as tempf: tempf.write('settings set target.run-args ') tempf.write(arguments) tempf.write('\n') tempf.flush() binjatron.custom_request( "command", _build_command_dict("command source " + tempf.name))
def get_backtrace(_view): try: res = binjatron.custom_request("backtrace", {"block:": False}, alert=False) except: import traceback traceback.print_exc() log_error( "Voltron encountered an exception while getting the backtrace. Maybe this is a stripped binary?" ) return [{'index': 0, 'addr': 0, 'name': 'Exception! Voltron Bug?'}] if (res.is_error): log_error("Could not get backtrace -- " + res.message) return None return res.frames
def set_tty(_view, tty): version = get_version(_view).host_version if 'gdb' in version: binjatron.custom_request("command", _build_command_dict("tty " + tty)) elif 'lldb' in version: binjatron.custom_request( "command", _build_command_dict("settings set target.input-path " + tty)) binjatron.custom_request( "command", _build_command_dict("settings set target.output-path " + tty))
def continue_exec(_view): binjatron.custom_request("command", _build_command_dict("continue"))
def kill(_view): binjatron.custom_request("command", _build_command_dict("ki"), alert=False)
def step_out(_view): binjatron.custom_request("command", _build_command_dict("finish"))
def step_over(_view): binjatron.custom_request("command", _build_command_dict("ni"))
def run_binary(_view): binjatron.custom_request("command", _build_command_dict("run"))
def get_version(_view): return binjatron.custom_request("version", {})