Malware Adventure ================= This is a small text adventure that I wrote in 2013. It was for the "Advanced Topics in Computer Security" course during my last semester at Johns Hopkins. Each of us had to review papers and do an activity at the end of the each presentation. I decided to do a text adventure. The solutions are based on other papers presented in class and the contents of my presentation which dealt with malware. Take it with a grain of salt. I am not a native speaker (although my parents ~~forced~~ sent me to English classes when I was seven years old and I am deeply grateful). The "game" is basically a Python program written in **PAWS**. PAWS stands for **Python Adventure Writing System**. It was written by **Roger Plowman**. Essentially it's a python library which allows you to write your own text adventure games. What I liked about this library is that it has a huge technical document explaining every class and method. On top of that the code is hugely commented and there is an example and tutorial with lots of comment to get you started. You can get it from How to play Malware Adventure ====== Our goal is to try and finish the game collectively. We have a basic set of commands like *look* and *examine*. To take an object use *take*. To use an object with another use *put objectone on objecttwo* or *use objectone with objecttwo*. Every door is to the *north*. The puzzles are based on the presented paper and also the papers that we have read until now (remembering the major idea is sufficient). I tried to make good puzzles with my limited time and language-barrier. I hope you like them. My connection to text adventures started when I found Zork. My childhood happened in the 80s; but because technology was slow in getting to my home country, I experienced a mix of 70s and 80s childhood which is awesome as I can connect with both generations quite comfortably. I think text adventures are one of best genres. ``` You were a prosperous grad student at Johns Hopkins. Enjoying the free food and pizza. "Thinking" about stuff all day. Deciding to write your thesis from tomorrow for 10th time this month. One day an envelope arrives in the mail. There is a USB drive and a single sheet of paper inside. The paper says "README". Being the awesome security person that you are, you decide to investigate it. But you plug it into your uber protected disk encrypted virtual machine. The USB stick is empty. But your computer feels sluggish. Suddenly the monitor goes dark and you a see flash. When you wake up, you are in a dark cave. A sound says "I hope you were not snoozing during the paper presentations, because you need all you know to get back". ``` Gentle Guide to PAWS ==================== PAWS is now at version 2.03 and development has stopped at 2008. But it is completely compatible with python 2.7.3 (which I used). You write your own game and then open it with the module. This is an emulator that reads your python code and runs the adventure game. There are ton of capabilities and classes. I could only learn how to use a few of them to write "Malware Adventure" in the limited time that I had. I would suggest to use one of the heavily commented examples. There are two games included. "Cloak Of Darkness" is short and easy while "Thief's Quest" is longer and more complex. There is also a tutorial and the aforementioned detailed documentation. To make a room, use one of the provided room classes to make an object. ``` python StartingRoom0 = MakeRoom() # Make Room Object StartingRoom0.NamePhrase = "The Adventure Begins" # Name of the room StartingRoom0.SetDesc("L", """ You wake up in a cave, it's damp and gloomy. There is a door to the north, a message above it reads "Malware Adventure Awaits"\n """) # This is displayed as room description upon arrival ``` To specify which rooms are connected use the map property which is a dictionary. Although it is suggested to put the maps in the end after all room declarations. ``` python StartingRoom0.Map = {North : Room1, South : Room 2} # Up / Down and NorthEast/West SouthEast/West are also usable. ``` To make objects you can use the ClassItem to make your own classes. I made two main object classes : ``` python class MakePickableItem(ClassItem): """Blueprint for items that you can pick up.""" def SetMyProperties(self): self.Bulk = 1 # The game supports bulk and weight for inventory self.Weight = 1 # Your character can only carry so much and so many large objects def Drop(self, Multiple=FALSE): """You can't drop items""" # Changed so you cannot drop stuff in my game return Complain("This isn't the best place to leave this around") # Complain is said when you try to drop an object. ``` ``` python class MakeStationaryItem(ClassItem): """Blueprint for interactable items.""" """To make the stationary items unpickable""" def SetMyProperties(self): self.SetDesc("Take", "Why do you want to take it, you don't know where it has been.") # Will be shown when you try to take this item. self.Bulk = 100 # Heavy Object self.Weight = 100 # Bulky Object ``` To make an object, simply use one of the above classes. ``` python Airduster = MakePickableItem("Airduster") # "Airduster" is the name of object in game Airduster.StartingLocation = Room1 # set stating location Airduster.Article = "an" # make it say an Airduster in inventory Airduster.SetDesc("L", # this text will be shown when you look at/examine object """ This is an ordinary Airduster. It appears to be nearly empty, choose what to dust wisely. """) Airduster.SetDesc("Take","You take the Airduster") # this text will be shown when you take this item. ``` To make shelf items (items that you can put items in them). Make a new class for each item (as you have to define the interaction of each of these items when one item is stored in them differently). ``` python class MakeBasicShelf(ServiceActivation, ClassShelf): """Basic Shelf Blueprint""" def Enter(self, Object): # What to do when Object is inserted into this object if Object == Airduster: # If you inserted Airduster Complain("You put airduster into Basic Shelf") return ClassShelf.Enter(self, Object) # puts the object inside basic shelf if Object == AnotherObject: # do another thing ``` Now you can make a basic shelf from this class like a normal object. ``` python NewShelf = MakeBasicShelf("NewShelfName") NewShelf.StartingLocation = Room1 NewShelf.SD("L", """ This is what will be shown when you LOOK at or EXAMINE the item. SD = SetDesc ``` Populate **def MalwarePostGameWrapUp()** for finishing conditions. In order to finish the game at anytime, you can do **Global.GameState = FINISHED**. When the block setting that property ends, the game will finish.