diff --git a/risky-business/casino b/risky-business/casino new file mode 100644 index 0000000..7cda6be Binary files /dev/null and b/risky-business/casino differ diff --git a/risky-business/description.md b/risky-business/description.md new file mode 100644 index 0000000..e0285df --- /dev/null +++ b/risky-business/description.md @@ -0,0 +1 @@ +We wanted to branch into the casino business, but human employees are too expensive so we decided to automate it. I feel like we missed something obvious though... Oh well! Here's the binary: [casino](casino) (MZ SHELL SERVER THING) \ No newline at end of file diff --git a/risky-business/flag.txt b/risky-business/flag.txt new file mode 100644 index 0000000..a32695c --- /dev/null +++ b/risky-business/flag.txt @@ -0,0 +1 @@ +easyctf{m4by3_w3_c0u1d_h4v3_d0n3_th47_b3t7er} \ No newline at end of file diff --git a/risky-business/grader.py b/risky-business/grader.py new file mode 100644 index 0000000..3b92c76 --- /dev/null +++ b/risky-business/grader.py @@ -0,0 +1,4 @@ +def grade(autogen, key): + if key.find("m4by3_w3_c0u1d_h4v3_d0n3_th47_b3t7er") != -1: + return True, "Correct!" + return False, "Nope!" diff --git a/risky-business/main.cpp b/risky-business/main.cpp new file mode 100644 index 0000000..aba1945 --- /dev/null +++ b/risky-business/main.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +#include + + +bool gamble() +{ + if (rand() % 5 == 0) + { + return true; + } + return false; +} + +void printflag() +{ + std::cout << "Welcome to our exclusive club!" << std::endl; + std::ifstream flagI("flag.txt"); + std::string flag; + getline(flagI, flag); + flagI.close(); + std::cout << "Here's our special flag: " << flag << std::endl; +} + + +int networth = 100000; +int main() +{ + std::cout << "Welcome to the EasyCTF 2017 Casino" << std::endl; + std::cout << "Try your luck and gain access to our exclusive club!" << std::endl; + while (true) + { + std::cout << std::endl; + std::cout << "Your net worth is: $" << networth << std::endl; + if (networth > 2000000000) + { + printflag(); + break; + } + std::cout << "Please enter how much you would like to bet:" << std::endl; + std::string tmp; + getline(std::cin, tmp); + std::stringstream s(tmp); + int inp; + s >> inp; + if (!s.eof() || s.fail()) + { + std::cout << "That was not a valid number :("; + continue; + } + if (inp <= 0) + { + std::cout << "You must bet a positive amount" << std::endl; + continue; + } + if (inp > 100000000) + { + std::cout << "Sorry, the most we can allow you to bet is $100,000,000" << std::endl; + continue; + } + if (!gamble()) + { + std::cout << "Sorry, I'm afraid you've lost :(" << std::endl; + networth -= inp; + } + else + { + std::cout << "Congratulations, you won!" << std::endl; + networth += inp; + } + + } + return 0; +} \ No newline at end of file diff --git a/risky-business/problem.yml b/risky-business/problem.yml new file mode 100644 index 0000000..b9f93b6 --- /dev/null +++ b/risky-business/problem.yml @@ -0,0 +1,9 @@ +author: GenericNickname +title: Risky Business +hint: I wonder how you could make a lot of money... +category: Binary Exploitation +autogen: false +programming: false +value: 100 +files: + - casino