Exemplo n.º 1
0
 def initialize(self):
     self.bot_manager = BotManager.Instance()
     self.team_name = None
     self.uuid = unicode(uuid4())
     self.opcodes = {
         'auth': self.auth,
     }
Exemplo n.º 2
0
def score_bots():
    ''' Award money for botnets '''
    logging.info("Scoring botnets, please wait ...")
    bot_manager = BotManager.Instance()
    config = ConfigManager.Instance()
    for team in Team.all():
        bots = bot_manager.by_team(team.name)
        reward = 0
        for bot in bots:
            try:
                reward += config.bot_reward
                bot.write_message({
                    'opcode':
                    'status',
                    'message':
                    'Collected $%d reward' % config.bot_reward
                })
            except:
                logging.info("Bot at %s failed to respond to score ping" %
                             bot.remote_ip)
        if 0 < len(bots):
            logging.debug("%s was awarded $%d for controlling %s bot(s)" % (
                team.name,
                reward,
                len(bots),
            ))
            bot_manager.add_rewards(team.name, config.bot_reward)
            bot_manager.notify_monitors(team.name)
            team.money += reward
            dbsession.add(team)
            dbsession.flush()
Exemplo n.º 3
0
 def initialize(self):
     self.bot_manager = BotManager.Instance()
     self.event_manager = EventManager.Instance()
     self.team_name = None
     self.team_uuid = None
     self.box_uuid = None
     self.remote_ip = None
     self.uuid = unicode(uuid4())
     self.opcodes = {
         'set_user': self.set_user,
     }
Exemplo n.º 4
0
 def __now__(self):
     ''' Returns snapshot object it as a dict '''
     snapshot = Snapshot()
     bot_manager = BotManager.Instance()
     for team in Team.all():
         snapshot_team = SnapshotTeam(team_id=team.id,
                                      money=team.money,
                                      bots=bot_manager.count_by_team(team))
         snapshot_team.game_levels = team.game_levels
         snapshot_team.flags = team.flags
         dbsession.add(snapshot_team)
         dbsession.flush()
         snapshot.teams.append(snapshot_team)
     dbsession.add(snapshot)
     dbsession.flush()
     return snapshot
Exemplo n.º 5
0
 def bot_count(self):
     bot_manager = BotManager.Instance()
     return bot_manager.count_by_team_uuid(self.uuid)