示例#1
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()
示例#2
0
 def __init__(self):
     config = ConfigManager.Instance()
     self.botnet = {}  # Holds refs to wsockets
     self.monitors = {}
     self.sqlite_engine = create_engine(u'sqlite://')
     setattr(self.sqlite_engine, 'echo', config.bot_sql)
     Session = sessionmaker(bind=self.sqlite_engine, autocommit=True)
     self.botdb = Session(autoflush=True)
     MemoryBaseObject.metadata.create_all(self.sqlite_engine)
示例#3
0
 def render(self, *args, **kwargs):
     ''' Includes different CSS themes based on user prefs '''
     if self.handler.session is not None:
         return self.render_string("theme/css.html",
                                   theme=self.handler.session['theme'])
     else:
         config = ConfigManager.Instance()
         default_theme = config.default_theme
         return self.render_string("theme/css.html", theme=default_theme)
示例#4
0
 def render(self, *args, **kwargs):
     config = ConfigManager.Instance()
     default_theme = config.default_theme
     if self.handler.session is not None:
         return self.render_string("theme/css.html",
             theme=self.handler.session['theme']
         )
     else:
         return self.render_string("theme/css.html", theme=default_theme)
示例#5
0
 def initialize(self):
     self.session = None
     self.manager = EventManager.Instance()
     self.config = ConfigManager.Instance()
     session_id = self.get_secure_cookie('session_id')
     if session_id is not None:
         self.conn = pylibmc.Client([self.config.memcached], binary=True)
         self.conn.behaviors['no_block'] = 1  # async I/O
         self.session = self._create_session(session_id)
         self.session.refresh()
示例#6
0
 def get(cls, file_path):
     ''' Lazy loads file from disk or memory cache '''
     config = ConfigManager.Instance()
     mem = pylibmc.Client([config.memcached], binary=True)
     key = b64encode(file_path)
     data = mem.get(key)
     if data is None:
         f = open(file_path, 'r')
         data = f.read()
         f.close()
         if len(data) < cls.MAX_FILE_SIZE:
             if mem.set(key, data):
                 logging.info("Cached %s in memory." % file_path)
             else:
                 logging.error("Failed to properly cache file.")
     return data
示例#7
0
 def post(self, *args, **kwargs):
     ''' Attempts to create an account, with shitty form validation '''
     form = Form(account="Please enter an account name",
                 handle="Please enter a handle",
                 team="Please select a team to join",
                 pass1="Please enter a password",
                 pass2="Please confirm your password",
                 token="Please enter a registration token")
     if form.validate(self.request.arguments):
         config = ConfigManager.Instance()
         account = self.get_argument('account').lower()
         handle = self.get_argument('handle').lower()
         rtok = self.get_argument('token', '__none__').lower()
         passwd = self.get_argument('pass1')
         if User.by_account(account) is not None:
             self.render('public/registration.html',
                         errors=['Account name already taken'])
         elif account == handle:
             self.render(
                 'public/registration.html',
                 errors=['Account name and hacker name must differ'])
         elif User.by_handle(handle) is not None:
             self.render('public/registration.html',
                         errors=['Handle already taken'])
         elif not passwd == self.get_argument('pass2'):
             self.render('public/registration.html',
                         errors=['Passwords do not match'])
         elif not 0 < len(passwd) <= config.max_password_length:
             self.render('public/registration.html',
                         errors=[
                             'Password must be 1-%d characters' %
                             config.max_password_length
                         ])
         elif Team.by_uuid(self.get_argument('team', '')) is None:
             self.render('public/registration.html',
                         errors=["Please select a team to join"])
         elif RegistrationToken.by_value(rtok) is None and not config.debug:
             self.render('public/registration.html',
                         errors=["Invalid registration token"])
         else:
             self.create_user(account, handle, passwd, rtok)
             self.render('public/successful_reg.html', account=account)
     else:
         self.render('public/registration.html', errors=form.errors)
示例#8
0
文件: bootstrap.py 项目: mgcfish/Veil
fills the database with some startup data.
usage: python -c 'import setup.auth'

"""

import os
import sys
import getpass

from libs.ConsoleColors import *
from libs.ConfigManager import ConfigManager
from models import dbsession, User, Permission
from models.User import ADMIN_PERMISSION

# Fills the database with some startup data.
config = ConfigManager.Instance()
password = ""

if config.debug:
    password = '******'
else:
    sys.stdout.write(PROMPT + "New Admin ")
    sys.stdout.flush()
    password1 = getpass.getpass()
    sys.stdout.write(PROMPT + "Confirm New Admin ")
    sys.stdout.flush()
    password2 = getpass.getpass()
    if password1 == password2 and 12 <= len(password1):
        password = password1
    else:
        print WARN + \
示例#9
0
 def initialize(self, dbsession):
     self.dbsession = dbsession
     self.config = ConfigManager.Instance()
 def __config__(self):
     self.config = ConfigManager.Instance()
示例#11
0
 def create_project_file(self):
     project_file = open(
         os.path.join(os.getcwd(), self.project_name, '.fujd'), 'w')
     project_file.write(ConfigManager.Instance().version)
     project_file.close()
     logging.debug("[*] Finished generating project file!")
示例#12
0
 def initialize(self):
     self.event_manager = EventManager.Instance()
     self.config = ConfigManager.Instance()
     self.team = None
     self.box = None
     self.remote_ip = None
from modules.Menu import Menu
from modules.Recaptcha import Recaptcha
from libs.ConfigManager import ConfigManager as ConfigMan
from tornado import netutil, options, process
from tornado.web import Application, StaticFileHandler
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop, PeriodicCallback
from handlers.CrackingHandlers import *
from handlers.UserHandlers import *
from handlers.ErrorHandlers import *
from handlers.AdminHandlers import *
from handlers.PublicHandlers import *


### Load configuration
config = ConfigMan.Instance()

### Application setup
app = Application([
    # Static Handlers - Serves static CSS, JavaScript and
    # image files
    (r'/static/(.*)', StaticFileHandler, {'path': 'static/'}),

    # User Handlers - Serves user related pages
    (r'/user', HomeHandler),
    (r'/settings', SettingsHandler),
    (r'/logout', LogoutHandler),

    # Cracking Handlers - Serves password cracking job related
    # pages
    (r'/cracking/jobs/create', CreateJobHandler),
示例#14
0
 def flush():
     ''' Flush memory cache '''
     config = ConfigManager.Instance()
     mem = pylibmc.Client([config.memcached], binary=True)
     mem.flush_all()
示例#15
0
 def delete(file_path):
     ''' Remove file from memory cache '''
     config = ConfigManager.Instance()
     mem = pylibmc.Client([config.memcached], binary=True)
     mem.delete(b64encode(file_path))
示例#16
0
 def render(self, *args, **kwargs):
     config = ConfigManager.Instance()
     if config.recaptcha_enabled:
         return self.render_string('recaptcha/captcha.html')
     else:
         return self.render_string('recaptcha/disabled.html')
示例#17
0
 def get_price(cls, user):
     ''' Calculate price of next bribe based on history '''
     config = ConfigManager.Instance()
     base_price = config.bribe_cost
     return base_price + (cls.count_completed_by_target_id(user.id) *
                          base_price)
示例#18
0
 def __init__(self):
     self.config = ConfigManager.Instance()
     self.cache = pylibmc.Client([self.config.memcached], binary=True)
     self.epoch = None  # Date/time of first snapshot
     self._load()
     self.event_manager = EventManager.Instance()