Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of Troll Hunter challenge
- Loading branch information
0 parents
commit c6dc468
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Jared | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CC=gcc | ||
FLAGS=-ggdb -O0 -m64 | ||
|
||
release: | ||
mkdir -p ./bin/ | ||
$(CC) $(FLAGS) ./src/main.c -o ./bin/dungeons_and_hackers-lvl-1 | ||
|
||
clean: | ||
rm ./bin/dungeons_and_hackers-lvl-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Dungeons & Hackers: Troll Hunter | ||
Hack Fortress DEFCON 2019 RE challenge 1, "Troll Hunter". | ||
|
||
#### Requirements | ||
* gcc | ||
* make | ||
|
||
#### To Build | ||
``` | ||
make | ||
``` | ||
#### Walkthrough | ||
[Arch Cloud Labs' Walkthrough](https://www.archcloudlabs.com/re-1/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
|
||
/** | ||
*@brief get a random value via seed from /dev/urandom. | ||
*@param N/A | ||
*@return integer value | ||
*/ | ||
int roll() | ||
{ | ||
char *buff = (char *) malloc(100); | ||
int fd = open("/dev/urandom", O_RDONLY); | ||
read(fd, buff, 100); | ||
close(fd); | ||
|
||
srand( (int) buff); | ||
int val = rand(); | ||
free(buff); | ||
|
||
return val; | ||
} | ||
|
||
/** | ||
*@brief XoR decode and print of char pointer | ||
*@param [val] char pointer | ||
*@return N/A | ||
*/ | ||
void decode(char *val) { | ||
|
||
for (int i = 0; i < 22; i++) { | ||
printf("%c",(val[i] ^ 51)); | ||
} | ||
printf("\n"); | ||
|
||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
|
||
char *title = | ||
"██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗ ██████╗ ███╗ ██╗███████╗ ██╗ ██╗ ██╗ █████╗ ██████╗██╗ ██╗███████╗██████╗ ███████╗\n" | ||
"██╔══██╗██║ ██║████╗ ██║██╔════╝ ██╔════╝██╔═══██╗████╗ ██║██╔════╝ ██║ ██║ ██║██╔══██╗██╔════╝██║ ██╔╝██╔════╝██╔══██╗██╔════╝\n" | ||
"██║ ██║██║ ██║██╔██╗ ██║██║ ███╗█████╗ ██║ ██║██╔██╗ ██║███████╗ ████████╗ ███████║███████║██║ █████╔╝ █████╗ ██████╔╝███████╗\n" | ||
"██║ ██║██║ ██║██║╚██╗██║██║ ██║██╔══╝ ██║ ██║██║╚██╗██║╚════██║ ██╔═██╔═╝ ██╔══██║██╔══██║██║ ██╔═██╗ ██╔══╝ ██╔══██╗╚════██║\n" | ||
"██████╔╝╚██████╔╝██║ ╚████║╚██████╔╝███████╗╚██████╔╝██║ ╚████║███████║ ██████║ ██║ ██║██║ ██║╚██████╗██║ ██╗███████╗██║ ██║███████║\n" | ||
"╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝\n"; | ||
printf("%s",title); | ||
printf("\t\t\t\t\t\t\t[==== D&H Adventure Simulator - 3000 ====]\n"); | ||
printf("\t\t\t\t\t\t\t[===== Troll Hunter Edition =====]\n"); | ||
|
||
char hostname[200]; | ||
gethostname(hostname, 200); | ||
|
||
//char *flag = "flag{troll_destroyer_!!}"; | ||
char *flag="U_RTHGA\\__lWV@GA\\JVAlN"; | ||
char *story = "You're venturing through the woods of memes. Suddenly a "\ | ||
"troll appears!\nA troll throws a mighty fist at your skull!\nAuto" \ | ||
"rolling to dodge!\n"; | ||
|
||
printf("[*] Welcome mighty challenger who hails from %s!\n", hostname); | ||
printf("%s", story); | ||
|
||
char buffer[10]; | ||
int num = roll(); // Value you're going to try to modify via r2 | ||
num = num % 20; | ||
|
||
printf("\nClick to roll> "); | ||
gets(buffer); | ||
printf("\nYou auto rolled a %d!", num); | ||
|
||
char *winning = "\nWith a mighty swing of your sword, you defeat the troll!"; | ||
char *you_win = "[+] You win!!\n"; | ||
char *losing= "\nThe troll swings his club and knocks you into next Tuesday!"; | ||
|
||
|
||
if (num != 9000) { | ||
printf("%s", losing); | ||
printf("\n[!] Oh dear, you died! Better luck next time friend."); | ||
exit(31337); | ||
} | ||
else { | ||
printf("%s", winning); | ||
printf("%s", you_win); | ||
decode(flag); | ||
return 0; | ||
} | ||
return 1; | ||
} |