From 638cd45e5ec1b2900829e167c78759d4faf8109a Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Wed, 6 Mar 2024 15:37:57 +0100 Subject: [PATCH] asm command: fix default arch (#2066) 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 7fc647ba1..e2d738edb 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)