当前位置:网站首页>PWN:Bad Seed
PWN:Bad Seed
2022-06-10 08:19:00 【we have a whole life】
It doesn't feel so special , It's just to use the original code , So I think these things , It's not interesting .
The above code is extracted from the article by myself , Then I read the code written by the solution in the article .
The first question is :
Crack the following program :
random.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand((unsigned int)time(NULL));
int targetnum=rand();
int destnum;
printf("Please enter:\n");
scanf("%d",&destnum);
if(destnum==targetnum)
{
printf("OK\n");
}
else
{
printf("No\n");
}
return 0;
}
solve.c
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<stdint.h>
#include<string.h>
int main()
{
uint32_t rand_num;
srand((unsigned int)time(NULL)); //seed with current time
rand_num = rand();
//uint32_t ans;
printf("%d\n", rand_num);
}
Execution results :
$ ./solve | ./random
Please enter:
OK
The second question is :
Crack the following program :
random.c
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main()
{
srand((unsigned int)time(NULL));
int array[6];
array[0] = 0x79;
array[1] = 0x12c97f;
array[2] = 0x135f0f8;
array[3] = 0x74acbc6;
array[4]=0x56c614e;
array[5]=0xffffffe2;
int j = 0;
while (j < 6)
{
int randVal = rand();
array[(long)j] = array[(long)j] - ((randVal%10) + -1);
j = j + 1;
}
int targetNumber = 0;
int i = 0;
while (i < 6)
{
targetNumber = targetNumber + array[(long)i];
i = i + 1;
}
int destnum;
scanf("%d",&destnum);
if(targetNumber==destnum)
{
printf("OK\n");
}
else
{
printf("NO\n");
}
//printf("targetNumber=%d\n",targetNumber);
//printf("destnum=%d\n",destnum);
return 0;
}
solve.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand((unsigned int)time(NULL));
int array[6];
array[0] = 0x79;
array[1] = 0x12c97f;
array[2] = 0x135f0f8;
array[3] = 0x74acbc6;
array[4]=0x56c614e;
array[5]=0xffffffe2;
int j = 0;
while (j < 6)
{
int randVal = rand();
array[(long)j] = array[(long)j] - ((randVal % 10) + -1);
j = j + 1;
}
int targetNumber = 0;
int i = 0;
while (i < 6)
{
targetNumber = targetNumber + array[(long)i];
i = i + 1;
}
printf("%d\n",targetNumber);
}
Third question :
Crack the following program :
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
int main()
{
char target [504];
char input [512];
srand((unsigned int)time(NULL));
int i = 0;
while (i < 50)
{
int randVal = rand();
printf("%d days without an incident.\n",i);
sprintf(target,"%d",(randVal % 100));
scanf(" %10s",input);
strtok(input,"\n");
int check = strcmp(target,input);
if (check != 0)
{
puts("Well that didn\'t take long.");
printf("You should have used %s.\n",target);
exit(0);
}
i = i + 1;
}
puts("Success");
return 0;
}
solve.c
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
int main()
{
char target [504];
char input [512];
srand((unsigned int)time(NULL));
int i = 0;
while (i < 50)
{
int randVal = rand();
sprintf(target,"%d",(randVal % 100));
strtok(input,"\n");
printf("%s\n",target);
i++;
}
}
边栏推荐
- Easyexcel realizes simple uploading and downloading
- Resistance, capacitance, inductance
- 10 个派上用场的 Flutter 小部件
- [untitled]
- 業務系統該如何防病毒
- Notice on the issuance of Shenzhen action plan for cultivating and developing new material industry clusters (2022-2025)
- Comment le système d'affaires devrait - il être antivirus?
- Convenient ultraviolet air purifier 2022 Global Industry Analysis Report
- International PEO and EOR services 2022 Global Industry Analysis Report
- OS实验六【设备管理】
猜你喜欢

不要停止预训练实战(二)-一日看尽MLM

完美人生PerfectLife——角色:Chenyuxin
![[lingo] operator](/img/c1/b0f7c4285b882278874f9bc6abed95.png)
[lingo] operator

How to use module export import: uncaught syntaxerror: cannot use import statement outside a module

List, set and sorted of redis data types_ Set sort

Download the slicing software preform for form1 SLA light curing domestic imitation printer
![[homeassistant shakes hands with 28byj-48 stepping motor]](/img/ed/c71b9e83df4b60d395e30cb969d05a.png)
[homeassistant shakes hands with 28byj-48 stepping motor]

Chinese in putty is displayed as frames and garbled codes, which cannot be displayed in Chinese

One's deceased father grind adjusts, read this you will understand!
![[lingo] solving equations](/img/4b/c54c4df3f9fb4675ab4fdca68e365b.png)
[lingo] solving equations
随机推荐
What is unit testing and why
归并排序最简单的写法——只需要不到15行
[lingo] linear programming
How to use module export import: uncaught syntaxerror: cannot use import statement outside a module
Qt5.9.5+Jetson Nano开发:unknown module(s) in qt designer
业务系统该如何防病毒
Projector integrated smart phone 2022 Global Industry Analysis Report
業務系統該如何防病毒
Basic exercise decimal to hexadecimal
How to use mind mapping to design test cases
数据库主键用uuid好还是雪花或者其他什么比较好呢
浏览器中如何使用 module export import: Uncaught SyntaxError: Cannot use import statement outside a module 问题
idea jdbc报错
"Minesweeping", a masterpiece abandoned by Microsoft, has been played out by Chinese players?
Basic exercise rectangular area intersection
Genesis public chain is determined to appear at the consensus 2022 Conference
Research Report on water jet industry - market status analysis and development prospect forecast
使用快慢指针实现链表找中点问题
The latest Jilin construction safety officer simulation question bank and answers in 2022
Global industry analysis report of food dehydrators in 2022