c - pwntools 中的 p64() 无法正常工作

标签 c python-2.7 format-string pwntools

我想将输入发送到包含“\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/

相关文章:

c - 用 C 写一个基本的 traceroute 脚本

python - 在 Python 中将 32 位整数写入缓冲区

c# - 如何在不乘以 ClosedXML 中的 100 的情况下以数字格式附加 % 符号

c - 如何使用Arduino在LCD上闪烁单个字符而没有延迟()方法?

c - 在 C 中使用消息队列时获取 "bad system call (core dumped)"

python - 使用 SMTP SSL/端口 465 发送电子邮件

python 映射/减少 : emit multiple keys values from single map lambda

c - 您是否知道%#x(采用C语言格式的字符串)

c - 使用 printf 的格式字符串打印可变数量的字节

c - 使用 C 在客户端服务器上 read() write() 整数值