Exemple #1
0
 def _get_all_state_modules(self):
     dirname = path.join(path.dirname(__file__), "states")
     states = []
     for imp, module, ispackage in pkgutil.walk_packages(
             path=[dirname], prefix="evscaperoom.states."):
         mod = mod_import(module)
         states.append(mod)
     return states
Exemple #2
0
    def load_state(self, statename):
        """
        Load state without initializing it
        """
        try:
            mod = utils.mod_import(f"{_ROOMSTATE_PACKAGE}.{statename}")
        except Exception as err:
            logger.log_trace()
            self.room.msg_room(
                None, f"|rBUG: Could not load state {statename}: {err}!")
            self.room.msg_room(
                None, f"|rBUG: Falling back to {self.current_state_name}")
            return

        state = mod.State(self, self.room)
        return state
Exemple #3
0
    def func(self):
        """
        Lists out your quests.
        """
        table = evtable.EvTable("Quest",
                                "Description",
                                border="cells",
                                maxwidth=80)
        for quest, quest_status in self.caller.db.quests.items():
            try:
                quest_module = mod_import(QUEST_DIR + quest)
            except Exception as e:
                logger.log_err("Failed to import module {}: e".format(
                    QUEST_DIR + quest, e))
                continue

            # Quest already completed
            if not quest_status:
                continue

            # If we're missing the quest name then we skip displaying it
            quest_name = getattr(quest_module, QUEST_NAME_CONST, None)
            if not quest_name:
                continue

            # Skip the description if it's not present
            quest_descs = getattr(quest_module, QUEST_DESC_CONST, None)
            if not quest_descs or len(quest_descs) < quest_status + 1:
                logger.log_warn(
                    "Quest {} missing description for progression {}.".format(
                        quest, quest_status))
                continue

            table.add_row(quest_name, quest_descs[quest_status])

        if table.nrows < 2:
            self.caller.msg("No active quests.")
        else:
            output = "|wActive Quests|n\n{}".format(table)
            self.caller.msg(output)
Exemple #4
0
AUDIT_MASKS = [
    {"connect": r"^[@\s]*[connect]{5,8}\s+(\".+?\"|[^\s]+)\s+(?P<secret>.+)"},
    {"connect": r"^[@\s]*[connect]{5,8}\s+(?P<secret>[\w]+)"},
    {"create": r"^[^@]?[create]{5,6}\s+(\w+|\".+?\")\s+(?P<secret>[\w]+)"},
    {"create": r"^[^@]?[create]{5,6}\s+(?P<secret>[\w]+)"},
    {"userpassword": r"^[@\s]*[userpassword]{11,14}\s+(\w+|\".+?\")\s+=*\s*(?P<secret>[\w]+)"},
    {"userpassword": r"^.*new password set to '(?P<secret>[^']+)'\."},
    {"userpassword": r"^.* has changed your password to '(?P<secret>[^']+)'\."},
    {"password": r"^[@\s]*[password]{6,9}\s+(?P<secret>.*)"},
] + getattr(ev_settings, "AUDIT_MASKS", [])


if AUDIT_CALLBACK:
    try:
        AUDIT_CALLBACK = getattr(
            mod_import(".".join(AUDIT_CALLBACK.split(".")[:-1])), AUDIT_CALLBACK.split(".")[-1]
        )
        logger.log_sec("Auditing module online.")
        logger.log_sec(
            "Audit record User input: {}, output: {}.\n"
            "Audit sparse recording: {}, Log callback: {}".format(
                AUDIT_IN, AUDIT_OUT, AUDIT_ALLOW_SPARSE, AUDIT_CALLBACK
            )
        )
    except Exception as e:
        logger.log_err("Failed to activate Auditing module. %s" % e)


class AuditedServerSession(ServerSession):
    """
    This particular implementation parses all server inputs and/or outputs and
Exemple #5
0
from builtins import range

import sys
import time
import random
from argparse import ArgumentParser
from twisted.conch import telnet
from twisted.internet import reactor, protocol
from twisted.internet.task import LoopingCall

from django.conf import settings
from evennia.utils import mod_import, time_format

# Load the dummyrunner settings module

DUMMYRUNNER_SETTINGS = mod_import(settings.DUMMYRUNNER_SETTINGS_MODULE)
if not DUMMYRUNNER_SETTINGS:
    raise IOError("Error: Dummyrunner could not find settings file at %s" %
                    settings.DUMMYRUNNER_SETTINGS_MODULE)

DATESTRING = "%Y%m%d%H%M%S"

# Settings

# number of clients to launch if no input is given on command line
NCLIENTS = 1
# time between each 'tick', in seconds, if not set on command
# line. All launched clients will be called upon to possibly do an
# action with this frequency.
TIMESTEP = DUMMYRUNNER_SETTINGS.TIMESTEP
# chance of a client performing an action, per timestep. This helps to
Exemple #6
0
"""

import sys
import time
import random
from argparse import ArgumentParser
from twisted.conch import telnet
from twisted.internet import reactor, protocol
from twisted.internet.task import LoopingCall

from django.conf import settings
from evennia.utils import mod_import, time_format

# Load the dummyrunner settings module

DUMMYRUNNER_SETTINGS = mod_import(settings.DUMMYRUNNER_SETTINGS_MODULE)
if not DUMMYRUNNER_SETTINGS:
    raise IOError("Error: Dummyrunner could not find settings file at %s" %
                  settings.DUMMYRUNNER_SETTINGS_MODULE)

DATESTRING = "%Y%m%d%H%M%S"

# Settings

# number of clients to launch if no input is given on command line
NCLIENTS = 1
# time between each 'tick', in seconds, if not set on command
# line. All launched clients will be called upon to possibly do an
# action with this frequency.
TIMESTEP = DUMMYRUNNER_SETTINGS.TIMESTEP
# chance of a client performing an action, per timestep. This helps to
Exemple #7
0
AUDIT_MASKS = [
    {'connect': r"^[@\s]*[connect]{5,8}\s+(\".+?\"|[^\s]+)\s+(?P<secret>.+)"},
    {'connect': r"^[@\s]*[connect]{5,8}\s+(?P<secret>[\w]+)"},
    {'create': r"^[^@]?[create]{5,6}\s+(\w+|\".+?\")\s+(?P<secret>[\w]+)"},
    {'create': r"^[^@]?[create]{5,6}\s+(?P<secret>[\w]+)"},
    {'userpassword': r"^[@\s]*[userpassword]{11,14}\s+(\w+|\".+?\")\s+=*\s*(?P<secret>[\w]+)"},
    {'userpassword': r"^.*new password set to '(?P<secret>[^']+)'\."},
    {'userpassword': r"^.* has changed your password to '(?P<secret>[^']+)'\."},
    {'password': r"^[@\s]*[password]{6,9}\s+(?P<secret>.*)"},
] + getattr(ev_settings, 'AUDIT_MASKS', [])


if AUDIT_CALLBACK:
    try:
        AUDIT_CALLBACK = getattr(
            mod_import('.'.join(AUDIT_CALLBACK.split('.')[:-1])), AUDIT_CALLBACK.split('.')[-1])
        logger.log_sec("Auditing module online.")
        logger.log_sec("Audit record User input: {}, output: {}.\n"
                       "Audit sparse recording: {}, Log callback: {}".format(
                            AUDIT_IN, AUDIT_OUT, AUDIT_ALLOW_SPARSE, AUDIT_CALLBACK))
    except Exception as e:
        logger.log_err("Failed to activate Auditing module. %s" % e)


class AuditedServerSession(ServerSession):
    """
    This particular implementation parses all server inputs and/or outputs and
    passes a dict containing the parsed metadata to a callback method of your
    creation. This is useful for recording player activity where necessary for
    security auditing, usage analysis or post-incident forensic discovery.
Exemple #8
0
    {
        'userpassword': r"^.*new password set to '(?P<secret>[^']+)'\."
    },
    {
        'userpassword':
        r"^.* has changed your password to '(?P<secret>[^']+)'\."
    },
    {
        'password': r"^[@\s]*[password]{6,9}\s+(?P<secret>.*)"
    },
] + getattr(ev_settings, 'AUDIT_MASKS', [])

if AUDIT_CALLBACK:
    try:
        AUDIT_CALLBACK = getattr(
            mod_import('.'.join(AUDIT_CALLBACK.split('.')[:-1])),
            AUDIT_CALLBACK.split('.')[-1])
        logger.log_sec("Auditing module online.")
        logger.log_sec("Audit record User input: {}, output: {}.\n"
                       "Audit sparse recording: {}, Log callback: {}".format(
                           AUDIT_IN, AUDIT_OUT, AUDIT_ALLOW_SPARSE,
                           AUDIT_CALLBACK))
    except Exception as e:
        logger.log_err("Failed to activate Auditing module. %s" % e)


class AuditedServerSession(ServerSession):
    """
    This particular implementation parses all server inputs and/or outputs and
    passes a dict containing the parsed metadata to a callback method of your
    creation. This is useful for recording player activity where necessary for