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.
This commit is contained in:
disconnect3d 2024-03-06 12:33:23 +01:00
parent 994505b8be
commit 2cb8a4e070
1 changed files with 3 additions and 1 deletions

View File

@ -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)