From 2cb8a4e070b26f026769ec6d6f10df385d3ce704 Mon Sep 17 00:00:00 2001 From: disconnect3d Date: Wed, 6 Mar 2024 12:33:23 +0100 Subject: [PATCH] asm command: fix default arch Before this commit, running `asm mov rax, 0xdeadbeef` would not work on amd64 targets because the default arch was set in the argparse default argument value and it was populated once. Now, this `default=...` kwarg is not set and instead we fetch current arch inside the `asm` command directly when the user did not pass any architecture value. --- pwndbg/commands/asm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pwndbg/commands/asm.py b/pwndbg/commands/asm.py index 7fc647ba..e2d738ed 100644 --- a/pwndbg/commands/asm.py +++ b/pwndbg/commands/asm.py @@ -16,7 +16,6 @@ parser.add_argument( parser.add_argument( "--arch", - default=pwnlib.context.context.arch, choices=pwnlib.context.context.architectures.keys(), type=str, help="Target architecture", @@ -63,6 +62,9 @@ def asm(shellcode, format, arch, avoid, infile) -> None: with open(infile) as file: shellcode = [file.read()] + if not arch: + arch = pwnlib.context.context.arch + bits_for_arch = pwnlib.context.context.architectures.get(arch, {}).get("bits") assembly = pwnlib.asm.asm(" ".join(shellcode), arch=arch, bits=bits_for_arch)