Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
goelp14
GitHub Repository: goelp14/easyctf-iv-problems
Path: blob/master/ez_rev/source.cpp
650 views
1
#include <unistd.h>
2
#include <stdio.h>
3
#include <cstdio>
4
#include <signal.h>
5
6
char * target;
7
void print_5(int * arr){
8
printf("%d%d%d%d%d\n", arr[0], arr[1], arr[2], arr[3], arr[4]);
9
return;
10
}
11
12
void sigintHandler(int sig_num)
13
{
14
signal(SIGINT, sigintHandler);
15
printf("\n You thought you could avoid it huh?\n");
16
fflush(stdout);
17
std::remove(target);
18
}
19
20
int main( int argc, char * argv[] ){
21
signal(SIGINT, sigintHandler);
22
target = argv[0];
23
switch( argc ){
24
case 2: goto TOP;
25
default: goto SAD;
26
}
27
SAD: return 2;
28
TOP: char * input = argv[1];
29
int arr [] = {1, 2, 3, 4, 5};
30
arr[0] += input[0];
31
arr[1] += input[1];
32
arr[2] += input[2];
33
arr[3] += input[3];
34
arr[4] += input[4];
35
if (arr[3] == 111){
36
if(arr[2] == arr[3] + 14){
37
if(arr[0] == arr[4] - 10){
38
if((arr[1] == 53) && (arr[4] == arr[3] + 3)){
39
printf("Now here is your flag: ");
40
print_5(arr);
41
return 1;
42
}
43
}
44
}
45
}
46
goto END;
47
END:
48
sleep(2);
49
std::remove(argv[0]);
50
printf("successfully deleted!\n");
51
return 2;
52
}
53
54
55