Exemplo n.º 1
0
class MaltegoTransform(MaltegoElement):

    name = fields_.String()
    displayname = fields_.String(attrname='displayName', default='')
    abstract = fields_.String(default=False)
    template = fields_.Boolean(default=False)
    visibility = fields_.String(default=VisibilityType.Public)
    description = fields_.String(default='')
    helpurl = fields_.String(attrname='helpURL', default='')
    author = fields_.String(default='')
    owner = fields_.String(default='')
    locrel = fields_.String(attrname='locationRelevance', default='global')
    version = fields_.String(default='1.0')
    requireinfo = fields_.Boolean(default=False, attrname='requireDisplayInfo')
    adapter = fields_.String(tagname='TransformAdapter',
                             default=TransformAdapter.Local)
    properties = fields_.Model(Properties)
    input = fields_.List(InputConstraint,
                         tagname='InputConstraints',
                         required=False)
    output = fields_.List(OutputEntity,
                          tagname='OutputEntities',
                          required=False)
    help = fields_.CDATA(tagname='Help', default='')
    disclaimer = fields_.CDATA(tagname='Disclaimer', default='')
    sets = fields_.List(Set, tagname='defaultSets')
    stealthlevel = fields_.Integer(tagname='StealthLevel', default=0)
    authenticator = fields_.String(tagname='Authenticator', required=False)

    def appendelement(self, other):
        if isinstance(other, Set):
            self.sets.append(other)
        elif isinstance(other, TransformProperty):
            self.properties.fields_.append(other)
        elif isinstance(other, InputConstraint) or isinstance(
                other, InputEntity):
            self.input.append(other)
        elif isinstance(other, OutputEntity):
            self.output.append(other)

    def removeelement(self, other):
        if isinstance(other, Set):
            self.sets.remove(other)
        if isinstance(other, TransformProperty):
            self.properties.fields_.remove(other)
        elif isinstance(other, InputConstraint) or isinstance(
                other, InputEntity):
            self.input.remove(other)
        elif isinstance(other, OutputEntity):
            self.output.remove(other)
Exemplo n.º 2
0
class MaltegoTransformRequestMessage(MaltegoElement):
    entities = fields_.List(_Entity, tagname='Entities', required=False)
    parameters = fields_.Dict(Field,
                              tagname='TransformFields',
                              key='name',
                              required=False)
    limits = fields_.Model(Limits, required=False)

    def __init__(self, **kwargs):
        super(MaltegoTransformRequestMessage, self).__init__(**kwargs)
        self._canari_fields = dict([(f.name, f.value)
                                    for f in self.entity.fields.values()])

    @property
    def entity(self):
        if self.entities:
            return MetaEntityClass.to_entity_type(self.entities[0].type)(
                self.entities[0])
        return Entity('')

    @property
    def params(self):
        if 'canari.local.arguments' in self.parameters:
            return self.parameters['canari.local.arguments'].value
        return self.parameters

    @property
    def value(self):
        return self.entity.value

    @property
    def fields(self):
        return self._canari_fields
Exemplo n.º 3
0
class MaltegoTransformExceptionMessage(MaltegoElement):
    exceptions = fields_.List(MaltegoException, tagname='Exceptions')

    def appendelement(self, exception):
        if isinstance(exception, MaltegoException):
            self.exceptions.append(exception)
        else:
            self.exceptions.append(MaltegoException(str(exception)))
Exemplo n.º 4
0
class MaltegoTransformResponseMessage(MaltegoElement):
    uimessages = fields_.List(UIMessage, tagname='UIMessages')
    entities = fields_.List(_Entity, tagname='Entities')

    def appendelement(self, other):
        if isinstance(other, Entity):
            self.entities.append(other.__entity__)
        elif isinstance(other, _Entity):
            self.entities.append(other)
        elif isinstance(other, UIMessage):
            self.uimessages.append(other)

    def removeelement(self, other):
        if isinstance(other, Entity):
            self.entities.remove(other.__entity__)
        elif isinstance(other, _Entity):
            self.entities.append(other)
        elif isinstance(other, UIMessage):
            self.uimessages.remove(other)
Exemplo n.º 5
0
class TransformSet(MaltegoElement):

    name = fields_.String()
    description = fields_.String(default='')
    transforms = fields_.List(Transform, tagname='Transforms')

    def appendelement(self, other):
        if isinstance(other, Transform):
            self.transforms.append(other)

    def removeelement(self, other):
        if isinstance(other, Transform):
            self.transforms.remove(other)
Exemplo n.º 6
0
class TransformSettings(MaltegoElement):

    enabled = fields_.Boolean(default=True)
    accepted = fields_.Boolean(default=False, attrname='disclaimerAccepted')
    showhelp = fields_.Boolean(default=True, attrname='showHelp')
    properties = fields_.List(TransformPropertySetting, tagname='Properties')

    def appendelement(self, other):
        if isinstance(other, TransformPropertySetting):
            self.properties.append(other)

    def removeelement(self, other):
        if isinstance(other, TransformPropertySetting):
            self.properties.remove(other)
Exemplo n.º 7
0
class MaltegoServer(MaltegoElement):

    name = fields_.String(default='Local')
    enabled = fields_.Boolean(default=True)
    description = fields_.String(
        default='Local transforms hosted on this machine')
    url = fields_.String(default='http://localhost')
    lastsync = fields_.String(tagname='LastSync',
                              default=time.strftime('%Y-%m-%d'))
    protocol = fields_.Model(Protocol)
    authentication = fields_.Model(Authentication)
    transforms = fields_.List(Transform, tagname='Transforms')

    def appendelement(self, other):
        if isinstance(other, Transform):
            self.transforms.append(other)

    def removeelement(self, other):
        if isinstance(other, Transform):
            self.transforms.remove(other)