def textToI3visioEntities(argv, platform='all'):
    ''' 
        Method that obtains all the entities in a given i3visio.text entity.

        :param argv:    the uri to be received.
        :param platform:    a platform string representing the regular expression to be used.

        :return:    Nothing is returned but the code of the entities is created.
    '''
    me = MaltegoTransform(argv)

    # Trying to recover all the possible i3visio entities
    found_fields = {}
    
    # Getting the list of <RegExp> objects from entify
    lRegexp = regexp_selection.getRegexpsByName([platform])

    newEntities = entify.getEntitiesByRegexp(data=data, listRegexp = lRegexp)    
    # This returns a dictionary like the following:
    """
        [{
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'a9b8c5d848205db514d4097d2b78f4528d01a79f39601e0f9c5c40ed689471'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'b28b896e6eeb8d651cacd5f4a4d1490fbe9d05dbc92221609350b0ce7a68e9'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'd727fed4d969b14b28165c75ad12d7dddd56c0198fa70cedc3fdad7ac395b2'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': '3e9a2204fcfc6f7dde250e61ca35353411880024102cba14a0bd45f05f1e74'
        }]
    """

    # Adding the new entities
    me.addListOfEntities(newEntities)

    # Returning the output text...
    me.returnOutput()
def uriToI3visioEntities(argv, platform='all'):
    ''' 
        Method that obtains all the entities in a given profile.

        :param argv:    the uri to be received.
        :param platform:    a platform string representing the regular expression to be used.

        :return:    Nothing is returned but the code of the entities is created.
    '''
    me = MaltegoTransform(argv)

    # Recovering the Uri value
    try:
        uri = argv
    except:
        uri = me.getVar("@value")

    #print uri
    newEntities = []

    # Defining the main entity
    aux = {}
    aux["type"] = "i3visio.uri"
    aux["value"] = uri
    aux["attributes"] = []
    newEntities.append(aux)

    # Using i3visio browser to avoid certain issues...
    i3Browser = browser.Browser()
    # Accessing the resources
    data = i3Browser.recoverURL(uri)

    # Getting the list of <RegExp> objects from entify
    lRegexp = regexp_selection.getRegexpsByName([platform])

    newEntities = entify.getEntitiesByRegexp(data=data, listRegexp=lRegexp)
    # This returns a dictionary like the following:
    """
        [{
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'a9b8c5d848205db514d4097d2b78f4528d01a79f39601e0f9c5c40ed689471'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'b28b896e6eeb8d651cacd5f4a4d1490fbe9d05dbc92221609350b0ce7a68e9'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'd727fed4d969b14b28165c75ad12d7dddd56c0198fa70cedc3fdad7ac395b2'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': '3e9a2204fcfc6f7dde250e61ca35353411880024102cba14a0bd45f05f1e74'
        }]
    """
    # Adding list of entities to be displayed
    me.addListOfEntities(newEntities)
    #print json.dumps(entities, indent=2)
    #for elem in entities:
    #    newEnt = me.addEntity(elem["type"],elem["value"])
    #    newEnt.setDisplayInformation("<h3>" + elem["value"] +"</h3><p>"+str(elem["attributes"])+"</p>")
    #    for extraAtt in elem["attributes"]:
    #        newEnt.addAdditionalFields(str(extraAtt['type']), str(extraAtt['type']), True, str(extraAtt['value']))

    # Returning the output text...
    me.returnOutput()
Esempio n. 3
0
def uriToI3visioEntities(argv, platform="all"):
    """ 
        Method that obtains all the entities in a given profile.

        :param argv:    the uri to be received.
        :param platform:    a platform string representing the regular expression to be used.

        :return:    Nothing is returned but the code of the entities is created.
    """
    me = MaltegoTransform(argv)

    # Recovering the Uri value
    try:
        uri = argv
    except:
        uri = me.getVar("@value")

    # print uri
    newEntities = []

    # Defining the main entity
    aux = {}
    aux["type"] = "i3visio.uri"
    aux["value"] = uri
    aux["attributes"] = []
    newEntities.append(aux)

    # Using i3visio browser to avoid certain issues...
    i3Browser = browser.Browser()
    # Accessing the resources
    data = i3Browser.recoverURL(uri)

    # Getting the list of <RegExp> objects from entify
    lRegexp = regexp_selection.getRegexpsByName([platform])

    newEntities = entify.getEntitiesByRegexp(data=data, listRegexp=lRegexp)
    # This returns a dictionary like the following:
    """
        [{
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'a9b8c5d848205db514d4097d2b78f4528d01a79f39601e0f9c5c40ed689471'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'b28b896e6eeb8d651cacd5f4a4d1490fbe9d05dbc92221609350b0ce7a68e9'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': 'd727fed4d969b14b28165c75ad12d7dddd56c0198fa70cedc3fdad7ac395b2'
        }, {
        'attributes': [],
        'type': 'i3visio.sha256',
        'value': '3e9a2204fcfc6f7dde250e61ca35353411880024102cba14a0bd45f05f1e74'
        }]
    """
    # Adding list of entities to be displayed
    me.addListOfEntities(newEntities)
    # print json.dumps(entities, indent=2)
    # for elem in entities:
    #    newEnt = me.addEntity(elem["type"],elem["value"])
    #    newEnt.setDisplayInformation("<h3>" + elem["value"] +"</h3><p>"+str(elem["attributes"])+"</p>")
    #    for extraAtt in elem["attributes"]:
    #        newEnt.addAdditionalFields(str(extraAtt['type']), str(extraAtt['type']), True, str(extraAtt['value']))

    # Returning the output text...
    me.returnOutput()