我想将输入发送到包含“\x90”等不可打印字符的进程。当我尝试像这样发送它时:p.sendline(p64(0x414190))
,我的程序将其打印回来,返回AA\x90
。它将“\x90”视为字符串,而不是字节。有人可以帮助我如何发送原始字节吗?
我的程序(容易格式化字符串,我不需要被告知):
#include <stdio.h>
int main() {
char name[512];
char passwd[512];
printf("Enter your name: ");
fgets(name, sizeof(name), stdin);
printf(name);
printf("Enter your password: ");
fgets(passwd, sizeof(passwd), stdin);
printf(passwd);
exit(1);
}
最佳答案
使用p64()
确实将输入作为原始字节发送。您可以通过在运行脚本时添加 pwntools 的 DEBUG
标志来检查它。然后调试输出打印发送和接收的所有内容。例如:
python2 solve.py DEBUG
[+] Starting local process './script': pid 23732
[DEBUG] Received 0x11 bytes:
'Enter your name: '
[DEBUG] Sent 0x9 bytes:
00000000 90 41 41 00 00 00 00 00 0a │·AA·│····│·│
00000009
[*] Switching to interactive mode
[DEBUG] Received 0x18 bytes:
00000000 90 41 41 45 6e 74 65 72 20 79 6f 75 72 20 70 61 │·AAE│nter│ you│r pa│
00000010 73 73 77 6f 72 64 3a 20 │sswo│rd: │
00000018
\x90AAEnter your password: $
在上面的示例中,您会看到字节 90 41 41 00 00 00 00 00 0a
被发送到程序,而不是字符串 \x90
。
关于c - pwntools 中的 p64() 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61117223/