接收远端传回的数据

1
2
3
4
5
6
7
8
9
10
11
interactive() : 在取得shell之后使用,直接进行交互,相当于回到shell的模式。

recv(numb=字节大小, timeout=default) : 接收指定字节数。

recvall() : 一直接收直到达到文件EOF。

recvline(keepends=True) : 接收一行,keepends为是否保留行尾的\n。

recvuntil(delims, drop=False) : 一直读到delims的pattern出现为止。

recvrepeat(timeout=default) : 持续接收直到EOF或timeout。

详细讲解

p64

当要接受%p的数据时 (以buu——actf_2019_babystack部分为例)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
signed __int64 __fastcall main(__int64 a1, char **a2, char **a3)
{
signed __int64 result; // rax
char s; // [rsp+0h] [rbp-D0h]

setbuf(stdin, 0LL);
setbuf(stdout, 0LL);
setbuf(stderr, 0LL);
signal(0xE, (__sighandler_t)handler);
alarm(0x3Cu);
memset(&s, 0, 0xD0uLL);
puts("Welcome to ACTF's babystack!");
sleep(3u);
puts("How many bytes of your message?");
putchar(0x3E);
sub_400A1A(0x3ELL, 0LL);
if ( nbytes <= 0xE0 )
{
printf("Your message will be saved at %p\n", &s); #这里接收s的地址
puts("What is the content of your message?");
putchar(0x3E);
read(0, &s, nbytes);
puts("Byebye~");
result = 0LL;
}
else
{
puts("I've checked the boundary!");
result = 1LL;
}
return result;
}

可以写为

1
s_addr=int(p.recvuntil('\n',drop=True),16)

还可以

1
2
r.recvuntil('0x')
cancry = int(r.recv(16),16)

像接收的是ROP的puts输出的puts_plt(write一样)

1.

1
2
r.recv()
puts_addr=u64(r.recv(6).ljust(8,'\x00'))

2.

1
puts_addr=u64(r.recvuntil('\n',drop=True).ljust(8,'\x00'))

p32

一般为

1
write_addr=u32(r.recv(4))

不适应所有,有待完善