def getInfo(self, moduleId): """ Return hash of botnet monitored by module identified by moduleId """ try: conf = self.modules[moduleId].getConfig() except KeyError: return "" confStr = configHandler.ConfigHandler().getStrFromDict(conf, toDB=True) return configHandler.ConfigHandler().getHashFromConfStr(confStr, toDB=False)[0]
def __init__(self): """ Constructor to set up objects to be used """ self.allowNone = True self.useDateTime = False moduleManager.handle_modules_onstart() self.haleConf = configHandler.ConfigHandler().loadHaleConf() moduleCoordinator.ModuleCoordinator(self.haleConf).start() if self.haleConf.get("xmpp", "use") == 'True': producerBot.ProducerBot(self.haleConf).run() self.moduleDirChange = ModuleDirChangeThread() self.moduleDirChange.start() self.config = configHandler.ConfigHandler() self.modlist = []
def __init__(self): """ Constructor """ geodata = os.getcwd() + "/utils/GeoIP.dat" self.geo = GeoIP.open(geodata, GeoIP.GEOIP_STANDARD) self.haleConf = configHandler.ConfigHandler().loadHaleConf()
def __init__(self): """ Constructor sets up regular expression used to find urls """ self.prox = proxySelector.ProxySelector() self.url_expre = re.compile('((http|https|ftp)://[~@a-zA-Z0-9_\-/\\\.\+:]+)') self.haleConf = configHandler.ConfigHandler().loadHaleConf()
def __init__(self): """ Constructor, sets up cmd variables and other data structures holding modules, configs etc. Starts a manager thread taking care of newly added modules and errors from module threads """ cmd.Cmd.__init__(self) print " __ __ ___ " print "/\ \/\ \ /\_ \\" print "\ \ \_\ \ __ \//\ \ __" print " \ \ _ \ /'__`\ \ \ \ /'__`\\" print " \ \ \ \ \/\ \L\.\_ \_\ \_/\ __/" print " \ \_\ \_\ \__/.\_\/\____\ \____\\" print " \/_/\/_/\/__/\/_/\/____/\/____/\n" self.prompt = ">> " self.intro = "\nType help or '?' for a list of commands\n" self.conf = configHandler.ConfigHandler().loadHaleConf() host = self.conf.get("client", "server") port = self.conf.get("client", "port") self.config = configHandler.ConfigHandler() while True: self.user = raw_input("login: "******"password: "******"client", "server") port = self.conf.get("client", "port") url = "http://" + self.user + ":" + passwd + "@" + host + ":" + port self.config = configHandler.ConfigHandler() self.proxy = xmlrpclib.ServerProxy(url) try: self.proxy.auth("") except xmlrpclib.ProtocolError: print "Incorrect login/password\n" continue except socket.error: print "Incorrect login/password\n" continue break
def handleIncomingMessage(self, msg): """ Takes care of incoming private chat messages """ if msg['type'] == 'chat': body = msg['body'].split(' ') toStr = msg['from'] if body[0].strip() == 'startTrackReq': self.recvStartReq = True config = msg['body'].split('startTrackReq')[1] hash, moduleError = configHandler.ConfigHandler().getHashFromConfStr(config) if moduleError: self.xmpp.sendMessage(toStr, 'startTrackNack', None, "chat") return if hash not in self.monitoredBotnets and not self.sendTrackReq(hash): from utils import moduleCoordinator eventType = moduleCoordinator.START_EVENT configDict = configHandler.ConfigHandler().getDictFromStr(config) moduleCoordinator.ModuleCoordinator().addEvent(eventType, configDict, hash) self.xmpp.sendMessage(toStr, 'startTrackAck ' + hash, None, "chat") else: self.xmpp.sendMessage(toStr, 'startTrackNack', None, "chat")
def putToDB(self, data, botnethash, conf): """ Creates new log entry in the database """ confStr = configHandler.ConfigHandler().getStrFromDict(conf, toDB=True) coord = self.geo.record_by_name(conf['botnet']) print "Long: " + str(coord['longitude']) print "Lat: " + str(coord['latitude']) (b, created) = Botnet.objects.get_or_create(botnethashvalue = botnethash, defaults={'longitude': coord['longitude'], 'latitude':coord['latitude']}) if not created: b.botnettype = conf['module'] b.host = conf['botnet'] b.config = confStr b.save() botnetobject = Botnet.objects.get(botnethashvalue=botnethash) Log(botnet=b, logdata=data).save() botnetobject.save()
except User.DoesNotExist: request.setResponseCode(http.UNAUTHORIZED) return 'Authorization Failed!' if u.check_password(passwd) and u.is_staff == True: pass else: request.setResponseCode(http.UNAUTHORIZED) return 'Authorization Failed!' request.content.seek(0, 0) (args, functionPath) = xmlrpclib.loads(request.content.read()) try: function = self._getFunction(functionPath) except xmlrpclib.Fault, f: self._cbRender(f, request) else: request.setHeader("content-type", "text/xml") defer.maybeDeferred(function, *args).addErrback(self._ebRender).addCallback( self._cbRender, request) return server.NOT_DONE_YET if __name__ == '__main__': from twisted.internet import reactor s = Server() conf = configHandler.ConfigHandler().loadHaleConf() port = int(conf.get("server", "port")) reactor.listenTCP(port, server.Site(s)) reactor.run()