def fileinfo(self, f): if f == "emplrec0451.log": output.openline() output.scr.addstr("looks like ol' 0451 here was supposed to be at SenseNet earlier.") if self.state == 2: self.state = 3 return Host.fileinfo(self,f)
def save(argv): global gamestate, commands with open("savegame", "wb") as f: pickle.dump([gamestate, list(commands.keys())], f, 0) output.openline() output.scr.addstr("Game saved.") scr.refresh()
def run(self): curses.cbreak() curses.noecho() output.lastline() output.overwriteline() self.prompt() output.scr.refresh() last = None for item in self.data: if item[0] != None: if not self.inahurry: if last != None: curses.napms(600 + len(last)*30) else: curses.napms(1000) self.receive(item[0], item[1]) output.scr.refresh() last = item[1] else: self.send(item[1]) output.openline() self.prompt() output.scr.refresh() last = None output.removelastline()
def help(argv): global commands scr = output.scr output.openline() scr.addstr("Available commands:") for comm in commands: output.openline() scr.addstr(comm) scr.refresh()
def prompt(): global gamestate scr = output.scr attrs = output.magenta if gamestate["user"] == "root": attrs |= curses.A_BOLD output.openline() scr.addstr(gamestate["user"], attrs) scr.addstr("@") scr.addstr(gamestate["host"].address, output.cyan) scr.addstr("> ") scr.refresh()
def connect(self): scr = output.scr global gamestate if gamestate["localhost"].state in range(2, 8): error("You have been tempBanned.") output.openline() scr.addstr("You stay your ass away until you get the trace off your ass - v0rt3x") return None output.openline() scr.addstr("Welcome to ") scr.addstr("Cognitive ", output.yellow | curses.A_BOLD) scr.addstr("Dissidents", output.red | curses.A_BOLD) return "fall1ble"
def delete(argv): global gamestate scr = output.scr if gamestate["host"] is gamestate["localhost"]: deny(argv, "Yeah, I got like 300 Megs of Hard Disk Drive, I'm not deleting shit") elif len(argv) < 2: error("Delete what?") elif argv[1] not in gamestate["host"].files: error("File %s not found on remote host" % argv[1]) elif gamestate["host"].delete(argv[1]): output.openline() scr.addstr("File %s deleted" % argv[1], output.magenta) scr.refresh()
def connect(self): scr = output.scr output.openline() scr.addstr("User: "******"Password: "******"*") if self.state > 1 or u != "admin" or pw != "xfz453": global gamestate if gamestate["localhost"].state == 2: gamestate["localhost"].state = 3 return None else: return "admin"
def disconnect(argv): global gamestate scr = output.scr if gamestate["host"] is gamestate["localhost"]: deny(argv, "Not yet time to jack out...") return output.openline() scr.addstr("Disconnecting from %s" % gamestate["host"].name) if gamestate["host"].disconnect(): gamestate["host"] = gamestate["localhost"] gamestate["user"] = "******" scr.refresh() return True else: error("Could not disconnect") scr.refresh() return False
def message(argv): global gamestate scr = output.scr if len(argv) < 2: output.openline() scr.addstr("Usage: message <user>") elif argv[1] not in gamestate["host"].users + gamestate["localhost"].users: error("User %s not available" % argv[1]) else: m = None if argv[1] in gamestate["host"].users: m = gamestate["host"].message(argv[1]) else: m = gamestate["localhost"].message(argv[1]) if m != None: deny(argv, m) scr.refresh()
def opn(argv): global gamestate scr = output.scr if len(argv) < 2: error("Open what?") elif argv[1] not in gamestate["localhost"].files: if argv[1] in gamestate["host"].files: error("Can only open locally saved files. copy first") else: error("File %s not found" % argv[1]) elif gamestate["localhost"].fileinfo(argv[1]): if argv[1] == "decrypt.exe": output.openline() scr.addstr("Installing decrypt utility.") scr.refresh() curses.napms(1000) scr.addstr(".") scr.refresh() curses.napms(1000) scr.addstr(".") scr.refresh() curses.napms(1000) scr.addstr("Success") unlockcommand("decrypt") gamestate["localhost"].files.remove("decrypt.exe") elif argv[1] == "forkbomb.exe": for i in range(output.lines * output.cols): x = random.randint(0, output.cols -1) y = random.randint(0, output.lines -1) c = random.randint(32, 126) scr.addch(y, x, c) scr.refresh() curses.napms(1) curses.napms(2000) global gameover gameover = True else: output.openline() scr.addstr(files[argv[1]]) else: error("File not available") scr.refresh()
def info(argv): global gamestate scr = output.scr if len(argv) < 2: output.openline() scr.addstr("Usage: info host|user <name>|file <name>") elif argv[1] == "host": output.openline() scr.addstr(gamestate["host"].hostinfo()) elif argv[1] == "user": if len(argv) < 3: error("No user chosen") else: nfo = False found = False if argv[2] in gamestate["localhost"].users: found = True nfo = gamestate["localhost"].userinfo(argv[2]) if argv[2] in gamestate["host"].users: found = True nfo = nfo or gamestate["host"].userinfo(argv[2]) if not found: error("User %s not available" % argv[2]) elif not nfo: error("Info for user %s not available" % argv[2]) else: output.openline() scr.addstr(users[argv[2]]) elif argv[1] == "file": if len(argv) < 3: error("No file chosen") else: nfo = False found = False if argv[2] in gamestate["localhost"].files: found = True nfo = gamestate["localhost"].fileinfo(argv[2]) if argv[2] in gamestate["host"].files: found = True nfo = nfo or gamestate["host"].fileinfo(argv[2]) if not found: error("File %s not found" % argv[2]) elif not nfo: error("Info for file %s not available" % argv[2]) else: output.openline() scr.addstr(files[argv[2]]) else: error("Cannot display info on %s" % argv[1]) scr.refresh()
def copy(argv): global gamestate scr = output.scr if gamestate["host"] is gamestate["localhost"]: deny(argv, "I'm on my own machine!") return elif len(argv) < 2: error("No file specified") return elif argv[1] not in gamestate["host"].files: error("File not found") return r = gamestate["host"].copy(argv[1]) if r == True: gamestate["localhost"].addfile(argv[1]) output.openline() scr.addstr("File %s copied" % argv[1]) elif r == False: error("Could not copy file") else: deny(argv, r) scr.refresh()
def connect(argv): global gamestate scr = output.scr if len(argv) < 2: error("Connect to what?") return elif argv[1].lower() == "localhost" or argv[1] == "127.0.0.1": deny(argv, "That's my machine, I don't need to connect to that") return elif argv[1] == gamestate["host"].name or argv[1] == gamestate["host"].address: deny(argv, "I'm already connected to those guys") return targets = [x for x in gamestate["hosts"] if x.name.lower() == argv[1].lower() or x.address == argv[1]] if gamestate["host"] is gamestate["localhost"] or disconnect([]): output.openline() scr.addstr("Connecting to %s" % argv[1]) scr.refresh() curses.napms(1500) if len(targets) == 0: scr.addstr(", could not be resolved", output.magenta) error("Could not connect to %s" % argv[1]) scr.refresh() return scr.addstr(", resolved to %s" % targets[0].address) scr.refresh() curses.napms(500) output.openline() scr.addstr("Connected.") scr.refresh() curses.napms(500) u = targets[0].connect() if u != None: gamestate["host"] = targets[0] gamestate["user"] = u else: error("Connection refused by %s" % targets[0].name) scr.refresh()
def decr(f, f2): global gamesate gamestate["localhost"].files.remove(f) scr = output.scr output.openline() scr.addstr("Decrypting %s:" % f) output.openline() scr.addstr("[" + 30 * " " + "]") output.lastline() scr.addstr("[") scr.refresh() for i in range(30): curses.napms(100) scr.addstr("#") scr.refresh() output.openline() scr.addstr("File %s was decrypted successfully. Result saved in %s" % (f, f2)) gamestate["localhost"].addfile(f2)
def delete(self, f): if f == "sensenet.log": self.state = 2 self.removefile("sensenet.log") scr = output.scr output.openline() scr.addstr("WARNING: ", output.red | curses.A_BOLD) scr.addstr("Illegal action detected!") output.openline() conversations["systemname"].run() output.openline() scr.addstr("Placing linklock on illegal user.") self.addfile("fall1ble.lock") global gamestate gamestate["localhost"].state = 6 queueconv(conversations["sec1"]) return True return Host.delete(self, f)
readusers() output.init() try: scr = output.scr curses.napms(1000) localhost.start() unlockcommand("exit") unlockcommand("help") unlockcommand("save") unlockcommand("load") while not gameover: prompt() line = output.getline() argv = line.split(" ") if argv[0] in commands: commands[argv[0]](argv) elif argv[0] in ["f**k", "shit", "asshole"]: deny(argv, "Ain't no proper language for a lady!") elif argv[0] != "": error("Unknown command %s" % argv[0]) if queued != None: output.openline() queued.run() queued = None except KeyboardInterrupt: pass output.uninit()
def delete(self, f): output.openline() scr = output.scr scr.addstr("Access Denied") return False
def lst(argv): global gamestate scr = output.scr if len(argv) < 2: output.openline() scr.addstr("Usage: list files|users|hosts") elif argv[1] == "files": if gamestate["host"] is not gamestate["localhost"]: output.openline() scr.addstr("Files on remote host %s" % gamestate["host"].name) for f in gamestate["host"].filelist(): output.openline() # color? scr.addstr(f) if len(gamestate["localhost"].files) > 0: output.openline() scr.addstr("Files on local machine:") for f in gamestate["localhost"].filelist(): output.openline() scr.addstr(f) elif argv[1] == "users": if gamestate["host"] is not gamestate["localhost"]: output.openline() scr.addstr("Users connected to host %s:" % gamestate["host"].name) for u in gamestate["host"].userlist(): output.openline() scr.addstr(u) l = gamestate["localhost"].userlist() if len(l) > 0: output.openline() scr.addstr("Also available for messaging:") for u in l: output.openline() scr.addstr(u) elif argv[1] == "hosts": output.openline() scr.addstr("Known hosts:") for h in gamestate["hosts"]: output.openline() scr.addstr("%s (%s)" % (h.address, h.name)) else: error("Cannot list %s" % argv[1]) scr.refresh()
def error(text): scr = output.scr output.openline() scr.addstr("Error: ", output.red | curses.A_BOLD) scr.addstr(text)
def error(text): scr = output.scr for line in text.split('\n'): output.openline() scr.addstr("Error: ", output.red | curses.A_BOLD) scr.addstr(line)
def userlist(self): output.openline() output.scr.addstr("Listing public users only:") return Host.userlist(self)