class MaltegoMessage(MaltegoElement): """This is the root element for all Maltego request, response, and exception messages that are exchanged between the client and the transform server. In the case of local transforms, only response and exception messages are exchanged from transform to client.""" message = fields_.Choice(fields_.Model(MaltegoTransformExceptionMessage), fields_.Model(MaltegoTransformResponseMessage), fields_.Model(MaltegoTransformRequestMessage))
class EntityProperties(MaltegoElement): class meta: tagname = 'Properties' value = fields_.String(required=False) groups = fields_.Model(Groups, required=False) fields = fields_.Dict(Field, key='name', tagname='Fields', required=False)
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 __iadd__(self, other): if isinstance(other, Transform): self.transforms.append(other) return self
class MaltegoEntity(MaltegoElement): id = fields_.String() displayname = fields_.String(attrname='displayName', required=False) plural = fields_.String(attrname='displayNamePlural', required=False) description = fields_.String(default='', required=False) category = fields_.String(required=False) smallicon = fields_.String(attrname='smallIconResource', required=False) largeicon = fields_.String(attrname='largeIconResource', required=False) allowedRoot = fields_.Boolean(default=True, required=False) conversion_order = fields_.Integer(attrname='conversionOrder', default=2147483647, required=False) visible = fields_.Boolean(default=True, required=False) largeicontag = fields_.String(tagname='Icon', required=False) smallicontag = fields_.String(tagname='SmallIcon', required=False) converter = fields_.Model(Converter, required=False) properties = fields_.Model(EntityProperties, required=False)
class MaltegoTransformRequestMessage(MaltegoElement): __entities = fields_.List(_Entity, tagname='Entities', required=False) _entities = None # This is so we can cache the transform entity object list. _parameters = fields_.Dict(Field, tagname='TransformFields', key='name', required=False) limits = fields_.Model(Limits, required=False) def __iadd__(self, other): if isinstance(other, Entity): self.__entities.append(other.__entity__) elif isinstance(other, _Entity): self.__entities.append(other) elif isinstance(other, Field): self._parameters[other.name] = other elif isinstance(other, Limits): self.limits = other return self @property def entity(self): """Returns the first Entity object in the transform request. :return: first Entity object.""" if self.entities: return self.entities[0] return Entity('') @property def entities(self): if not self._entities: self._entities = [ EntityTypeFactory.create(e.type)(e) for e in self.__entities ] return self._entities @property def parameters(self): """Returns a list of passed transform parameters in the event that a transform has additional parameters that are required in order to operate (i.e. API key). For local transforms, the program arguments are returned instead. :return: list of parameters.""" if 'canari.local.arguments' in self._parameters: return self._parameters['canari.local.arguments'].value return self._parameters
class MaltegoTransform(MaltegoElement): """This is the complete MaltegoTransform element definition that is present in Maltego profiles. It defines every aspect of a transform including it's input entity type, transform set, template, etc.""" 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 __iadd__(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) return self