diff --git a/tests/Vagrantfile b/tests/Vagrantfile index b9e37f5a..152bbb7e 100644 --- a/tests/Vagrantfile +++ b/tests/Vagrantfile @@ -7,7 +7,7 @@ Vagrant.configure(2) do |config| v.linked_clone = true end - config.vm.network "forwarded_port", guest: 5555, host: 5556 + config.vm.network "forwarded_port", guest: 22222, host: 5556 config.vm.synced_folder "../", "/voltron" config.vm.synced_folder "~/shared", "/shared" diff --git a/tests/http_api_tests.py b/tests/http_api_tests.py index 5e604374..c0509ac3 100644 --- a/tests/http_api_tests.py +++ b/tests/http_api_tests.py @@ -52,7 +52,7 @@ def setup(): voltron.setup_env() voltron.config['server'] = { "listen": { - "tcp": ["127.0.0.1", 5555] + "tcp": ["127.0.0.1", 22222] } } pm = PluginManager() @@ -76,30 +76,30 @@ def teardown(): def test_disassemble(): - data = requests.get('http://localhost:5555/api/disassemble?count=16').text + data = requests.get('http://localhost:22222/api/disassemble?count=16').text res = APIResponse(data=data) assert res.is_success assert res.disassembly == disassemble_response def test_command(): - data = requests.get('http://localhost:5555/api/command?command=reg%20read').text + data = requests.get('http://localhost:22222/api/command?command=reg%20read').text res = APIResponse(data=data) assert res.is_success assert res.output == command_response def test_targets(): - data = requests.get('http://localhost:5555/api/targets').text + data = requests.get('http://localhost:22222/api/targets').text res = api_response('targets', data=data) assert res.is_success assert res.targets == targets_response def test_memory(): - data = requests.get('http://localhost:5555/api/registers').text + data = requests.get('http://localhost:22222/api/registers').text res = api_response('registers', data=data) - url = 'http://localhost:5555/api/memory?address={}&length=64'.format(res.registers['rip']) + url = 'http://localhost:22222/api/memory?address={}&length=64'.format(res.registers['rip']) data = requests.get(url).text res = api_response('memory', data=data) assert res.is_success @@ -107,35 +107,35 @@ def test_memory(): def test_registers(): - data = requests.get('http://localhost:5555/api/registers').text + data = requests.get('http://localhost:22222/api/registers').text res = api_response('registers', data=data) assert res.is_success assert res.registers == registers_response def test_stack_length_missing(): - data = requests.get('http://localhost:5555/api/stack').text + data = requests.get('http://localhost:22222/api/stack').text res = APIErrorResponse(data=data) assert res.is_error assert res.message == 'length' def test_stack(): - data = requests.get('http://localhost:5555/api/stack?length=64').text + data = requests.get('http://localhost:22222/api/stack?length=64').text res = api_response('stack', data=data) assert res.is_success assert res.memory == stack_response def test_state(): - data = requests.get('http://localhost:5555/api/state').text + data = requests.get('http://localhost:22222/api/state').text res = api_response('state', data=data) assert res.is_success assert res.state == state_response def test_version(): - data = requests.get('http://localhost:5555/api/version').text + data = requests.get('http://localhost:22222/api/version').text res = api_response('version', data=data) assert res.is_success assert res.api_version == 1.1 @@ -143,21 +143,21 @@ def test_version(): def test_bad_json(): - data = requests.post('http://localhost:5555/api/request', data='xxx').text + data = requests.post('http://localhost:22222/api/request', data='xxx').text res = APIResponse(data=data) assert res.is_error assert res.code == 0x1001 def test_bad_request(): - data = requests.post('http://localhost:5555/api/request', data='{"type":"request","request":"no_such_request"}').text + data = requests.post('http://localhost:22222/api/request', data='{"type":"request","request":"no_such_request"}').text res = APIResponse(data=data) assert res.is_error assert res.code == 0x1002 def test_breakpoints(): - data = requests.get('http://localhost:5555/api/breakpoints').text + data = requests.get('http://localhost:22222/api/breakpoints').text res = api_response('breakpoints', data=data) assert res.is_success assert res.breakpoints == breakpoints_response diff --git a/voltron/config/default.cfg b/voltron/config/default.cfg index 631aef2e..98ab05fa 100644 --- a/voltron/config/default.cfg +++ b/voltron/config/default.cfg @@ -5,10 +5,10 @@ server: domain: "~/.voltron/sock" tcp: - 127.0.0.1 - - 5555 + - 22222 view: #api_url: "http+unix://~%2f.voltron%2fsock/api/request", - api_url: http://localhost:5555/api/request + api_url: http://localhost:22222/api/request reconnect: true all_views: clear: true diff --git a/voltron/core.py b/voltron/core.py index 351a0ea1..32195505 100644 --- a/voltron/core.py +++ b/voltron/core.py @@ -392,7 +392,7 @@ class Client(object): """ Used by a client (ie. a view) to communicate with the server. """ - def __init__(self, host='127.0.0.1', port=5555, sockfile=None, url=None, + def __init__(self, host='127.0.0.1', port=22222, sockfile=None, url=None, build_requests=None, callback=None, supports_blocking=True): """ Initialise a new client diff --git a/voltron/dbg.py b/voltron/dbg.py index 4d92f5b7..d3c73468 100644 --- a/voltron/dbg.py +++ b/voltron/dbg.py @@ -24,6 +24,7 @@ def validate_target(func, *args, **kwargs): Raises a NoSuchTargetException if the target does not exist. """ + def inner(self, *args, **kwargs): # find the target param target_id = None @@ -38,6 +39,7 @@ def inner(self, *args, **kwargs): # call the function return func(self, *args, **kwargs) + return inner @@ -50,6 +52,7 @@ def validate_busy(func, *args, **kwargs): Raises a TargetBusyException if the target does not exist. """ + def inner(self, *args, **kwargs): # find the target param target_id = None @@ -64,6 +67,7 @@ def inner(self, *args, **kwargs): # call the function return func(self, *args, **kwargs) + return inner @@ -72,6 +76,7 @@ def lock_host(func, *args, **kwargs): A decorator that acquires a lock before accessing the debugger to avoid API locking related errors with the debugger host. """ + def inner(self, *args, **kwargs): self.host_lock.acquire() try: @@ -81,6 +86,7 @@ def inner(self, *args, **kwargs): self.host_lock.release() raise e return res + return inner @@ -91,26 +97,28 @@ class DebuggerAdaptor(object): """ reg_names = { - "x86": {"pc": "eip", "sp": "esp"}, - "x86_64": {"pc": "rip", "sp": "rsp"}, - "arm": {"pc": "pc", "sp": "sp"}, - "armv6": {"pc": "pc", "sp": "sp"}, - "armv7": {"pc": "pc", "sp": "sp"}, - "armv7s": {"pc": "pc", "sp": "sp"}, - "arm64": {"pc": "pc", "sp": "sp"}, - "powerpc": {"pc": "pc", "sp": "r1"}, + "x86": {"pc": "eip", "sp": "esp"}, + "x86_64": {"pc": "rip", "sp": "rsp"}, + "arm": {"pc": "pc", "sp": "sp"}, + "armv6": {"pc": "pc", "sp": "sp"}, + "armv7": {"pc": "pc", "sp": "sp"}, + "armv7s": {"pc": "pc", "sp": "sp"}, + "arm64": {"pc": "pc", "sp": "sp"}, + "aarch64": {"pc": "pc", "sp": "sp"}, + "powerpc": {"pc": "pc", "sp": "r1"}, } cs_archs = {} if capstone: cs_archs = { - "x86": (capstone.CS_ARCH_X86, capstone.CS_MODE_32), - "x86_64": (capstone.CS_ARCH_X86, capstone.CS_MODE_64), - "arm": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), - "armv6": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), - "armv7": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), - "armv7s": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), - "arm64": (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM), - "powerpc": (capstone.CS_ARCH_PPC, capstone.CS_MODE_32), + "x86": (capstone.CS_ARCH_X86, capstone.CS_MODE_32), + "x86_64": (capstone.CS_ARCH_X86, capstone.CS_MODE_64), + "arm": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), + "armv6": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), + "armv7": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), + "armv7s": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM), + "arm64": (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM), + "aarch64": (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM), + "powerpc": (capstone.CS_ARCH_PPC, capstone.CS_MODE_32), } def __init__(self, *args, **kwargs): @@ -220,10 +228,11 @@ def disassemble_capstone(self, target_id=0, address=None, count=None): return '\n'.join(output) -class DebuggerCommand (object): +class DebuggerCommand(object): """ The `voltron` command in the debugger. """ + def __init__(self, *args, **kwargs): super(DebuggerCommand, self).__init__(*args, **kwargs) self.adaptor = voltron.debugger diff --git a/voltron/plugins/view/register.py b/voltron/plugins/view/register.py index a4a0a4ae..286ae8e9 100644 --- a/voltron/plugins/view/register.py +++ b/voltron/plugins/view/register.py @@ -128,6 +128,7 @@ class RegisterView (TerminalView): } ], } + FORMAT_INFO['aarch64'] = FORMAT_INFO['arm64'] TEMPLATES = { 'x86_64': { 'horizontal': { @@ -389,6 +390,7 @@ class RegisterView (TerminalView): } } } + TEMPLATES['aarch64'] = TEMPLATES['arm64'] FLAG_BITS = {'c': 0, 'p': 2, 'a': 4, 'z': 6, 's': 7, 't': 8, 'i': 9, 'd': 10, 'o': 11} FLAG_TEMPLATE = "{o} {d} {i} {t} {s} {z} {a} {p} {c}" XMM_INDENT = 7 @@ -442,11 +444,6 @@ def build_requests(self): ] def render(self, results): - error = None - t_res, d_res, r_res = results - formatter = pygments.formatters.get_formatter_by_name(self.config.format.pygments_formatter, - style=self.config.format.pygments_style) - def format(tok, tik=None): if tik: tok = (tok, tik) @@ -454,6 +451,10 @@ def format(tok, tik=None): return pygments.format([tok], formatter) else: return pygments.format(tok, formatter) + error = None + t_res, d_res, r_res = results + formatter = pygments.formatters.get_formatter_by_name(self.config.format.pygments_formatter, + style=self.config.format.pygments_style) self.f = format if t_res and t_res.is_error: