我希望将输入发送到包含"\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);
}发布于 2020-06-02 03:59:43
使用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。
发布于 2021-10-08 09:05:57
实际上pwntools完全正常工作,真正的问题是由python的语法产生的。如果只使用print()打印反馈,python会将其视为'string‘而不是'byte’。
https://stackoverflow.com/questions/61117223
复制相似问题