-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in shellcraft.execve() for AArch64 when specifying argv #2160
Comments
Busybox segfaults if argv is empty, can you try with a non-empty envp? It might be the same issue. |
Just tested with the following envp: from pwn import *
context.arch = "aarch64"
path = '/bin/busybox'
argv = ["sh"]
envp = {"SOME_ENV": "DEBUG"}
sc = shellcraft.execve(path, argv, envp)
#sc = sc.replace("[sp, #-8]!", "[sp, #-16]!")
#sc = sc.replace("mov x14, #8", "mov x14, #16")
print(sc)
io = run_assembly(sc)
io.interactive() Still getting SIGBUS. If I enable commented out lines (10 & 11) it works again. I have also tested with other binaries, and I am getting SIGBUS with those too, so it is not because of busybox. |
In [6]: print(pwnlib.shellcraft.mov('x0', 2**32))
eor x0, x0, x0
In [7]: print(pwnlib.shellcraft.mov('x0', 2**32 * 2))
eor x0, x0, x0
In [8]: print(pwnlib.shellcraft.mov('x0', 2**32 * 2 * 2))
eor x0, x0, x0
In [9]: print(pwnlib.shellcraft.mov('x0', 2**32 * 2 * 2 * 2))
eor x0, x0, x0 Maybe related, broken mov |
@Arusekk If you want apply patches. Fixed pushstr_array.asm:
Fixed mov.asm:
|
Please create a pull request ❤️ |
@patryk4815 - Could you please submit a PR with your fixes? |
There seems to be a bug in the shellcraft.execve() module for aarch64 when specifying arguments.
For some reason when pushing the null terminator string and pointers it uses 8 bytes instead of 16.
pwntools version:
$ pip freeze | grep pwntools pwntools==4.9.0
Example program (I am using busybox, and executing the command
/bin/busybox sh
as an example):The generated shellcode does not seem to be 16 byte aligned (the way AArch64 wants it to be), and therefore crashes.
By adding the two lines to modify the assembly to be 16 byte aligned, it works fine:
Full log file:
The text was updated successfully, but these errors were encountered: