-
Notifications
You must be signed in to change notification settings - Fork 2
/
GetShell.c
54 lines (49 loc) · 1.36 KB
/
GetShell.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
unsigned long hashcode = 0xddaa1234;
char *keypt = NULL;
void print_bomb(){
system("cat /home/ctf/graph");
fflush(stdout);
}
void md5bof(char *mid){
char overflow[40];
keypt = mid;
printf("Start overflow!!!! : ");
scanf("%s", overflow);
int i = 0;
unsigned long result = 0;
int *convert = (int*)keypt;
for(i = 0; i < 5; ++i){
result += convert[i];
}
if(result == hashcode){
system("/bin/sh");
}
else{
printf("Oh no, plz try again!!\n");
}
}
int main(){
setvbuf(stdout, 0LL, 2, 0LL);
setvbuf(stdin, 0LL, 1, 0LL);
char choice;
print_bomb();
printf("**********************************************************\n");
printf("* Emergency! Emergency! *\n");
printf("* There is a dark-matter-bomb going to exploit!! *\n");
printf("* You, the one who can save the world need to solve this *\n");
printf("* buffer overflow with md5 problem to find the passcode! *\n");
printf("**********************************************************\n");
printf("\nWould you like to take this important task?(y/n)");
scanf("%c", &choice);
getchar();
if(choice == 'y' | choice == 'Y'){
printf("Then try to overflow me!!!\n");
char blank[20] = {0};
md5bof(blank);
}
else
printf("The bomb is gonna to explode.....\n");
}