c - pwntools 中的 p64() 无法正常工作
问题描述
我想将输入发送到包含不可打印字符(如“\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);
}
解决方案
Usingp64()
确实将输入作为原始字节发送。DEBUG
您可以通过在运行脚本时添加 pwntools 标志来检查它。调试输出然后打印发送和接收的所有内容。例如:
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
。
推荐阅读
- java - 我需要帮助从方法更新 main 中的数组
- c - 在某些头文件中声明时,double 类型的 C 函数有时会起作用
- java - Intellij 右键单击“新建”未显示“类”
- python - 尽管代码以前可以工作,但出现关键错误
- angular - While 循环未读取数组对象的当前长度(角度 6)
- java - 准备好的语句中的动态 where 条件的 SQL 注入
- python - Flask render_template 上下文未显示在 URL 中
- python - Python - 选择所需选项时有关数组的问题
- javascript - 使用 PIXI.Sprite.fromImage 和 PIXI.loader.resources 有什么区别?
- c# - 如何在 selenium webdriver C# 中隐藏密码