Example #1
0
def dns_domain():
    if request.body.len > 0:
        incoming = TRX.MaltegoMsg(request.body.getvalue())
        xform = TRX.MaltegoTransform()
        if (incoming.Type == "Domain" or incoming.Type == "DNSName"
                or incoming.Type == "NSRecord") and re.match(
                    ValidHostnameRegex, incoming.Value):
            if 'api' in incoming.TransformSettings:
                s = spyonweb.Spyonweb(incoming.TransformSettings['api'])
                data = s.dns_domain(incoming.Value, limit=incoming.Slider)
                if data is None:
                    xform.addUIMessage("No results found", TRX.UIM_FATAL)
                    return xform.returnOutput()
                for name in data:
                    ent = xform.addEntity("maltego.Domain", name)
                    ent.setLinkLabel(
                        data[name]
                    )  # date domain name was associated with server
                return xform.returnOutput()
            else:
                xform = TRX.MaltegoTransform()
                xform.addException("Must submit an API key")
                return xform.throwExceptions()
        else:
            xform.addException("Must submit a valid host name")
            return xform.throwExceptions()
Example #2
0
 def test_entity_link_style(self):
     entity = TRX.MaltegoEntity()
     entity.setLinkStyle(TRX.LINK_STYLE_DASHED)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(entity.additionalFields['link#maltego.link.style'].value,
                  "1")
     assert_equal(out['Entity']['AdditionalFields']['Field']['#text'], "1")
Example #3
0
 def test_entity_note(self):
     entity = TRX.MaltegoEntity()
     note = "Test Note"
     entity.setNote(note)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(entity.additionalFields['notes#'].value, note)
     assert_equal(out['Entity']['AdditionalFields']['Field']['#text'], note)
Example #4
0
 def test_entity_iconurl(self):
     entity = TRX.MaltegoEntity()
     url = "http://example.com/example.png"
     entity.setIconURL(url)
     assert_equal(entity.iconURL, url)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(out['Entity']['IconURL'], url)
Example #5
0
 def test_entity_link_thickness(self):
     entity = TRX.MaltegoEntity()
     entity.setLinkThickness(42)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(
         entity.additionalFields['link#maltego.link.thickness'].value, "42")
     assert_equal(out['Entity']['AdditionalFields']['Field']['#text'], "42")
Example #6
0
def domain():
    if request.body.len > 0:
        incoming = TRX.MaltegoMsg(request.body.getvalue())
        if (incoming.Type == "Domain" or incoming.Type
                == "DNSName") and re.match(ValidHostnameRegex, incoming.Value):
            if 'api' in incoming.TransformSettings:
                s = spyonweb.Spyonweb(incoming.TransformSettings['api'])
                data = s.domain(incoming.Value)
                return process_domain(data)
            else:
                xform = TRX.MaltegoTransform()
                xform.addException("Must submit an API key")
                return xform.throwExceptions()
        else:
            xform = TRX.MaltegoTransform()
            xform.addException("Must submit a valid host name or domain name")
            return xform.throwExceptions()
Example #7
0
 def test_entity_displayinfo_results(self):
     entity = TRX.MaltegoEntity()
     entity.addDisplayInformation("TestValue", "TestLabel")
     r = xmltodict.parse(entity.returnEntity())
     assert_equal(r['Entity']['DisplayInformation']['Label']['@Name'],
                  "TestLabel")
     assert_equal(r['Entity']['DisplayInformation']['Label']['#text'],
                  "TestValue")
Example #8
0
 def test_entity_strict(self):
     entity = TRX.MaltegoEntity()
     entity.addProperty('test', matchingRule="strict", value="StrictTest")
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(entity.additionalFields['test'].matchingRule, "strict")
     assert_equal(
         out['Entity']['AdditionalFields']['Field']['@MatchingRule'],
         'strict')
Example #9
0
 def test_entity_property_results(self):
     entity = TRX.MaltegoEntity("IPv4Address", "10.0.0.1")
     entity.addProperty("ipaddress.internal", value="True")
     assert_is_instance(entity.additionalFields['ipaddress.internal'],
                        TRX.Property)
     # NOTE: The following tests for the string "True", not the bool True
     assert_equal(entity.additionalFields["ipaddress.internal"].value,
                  "True")
Example #10
0
 def test_entity_link_color(self):
     entity = TRX.MaltegoEntity()
     color = '0xff00ff'
     entity.setLinkColor(color)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(entity.additionalFields['link#maltego.link.color'].value,
                  color)
     assert_equal(out['Entity']['AdditionalFields']['Field']['#text'],
                  color)
Example #11
0
 def test_entity_link_label(self):
     entity = TRX.MaltegoEntity()
     label = "Test Label"
     entity.setLinkLabel(label)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(entity.additionalFields['link#maltego.link.label'].value,
                  label)
     assert_equal(out['Entity']['AdditionalFields']['Field']['#text'],
                  label)
Example #12
0
def analytics():
    if request.body.len > 0:
        incoming = TRX.MaltegoMsg(request.body.getvalue())
        xform = TRX.MaltegoTransform()
        if incoming.Type == "Phrase" and re.match(ValidAnalyticsRegex,
                                                  incoming.Value):
            if 'api' in incoming.TransformSettings:
                s = spyonweb.Spyonweb(incoming.TransformSettings['api'])
                data = s.analytics(incoming.Value, limit=incoming.Slider)
                if data is None:
                    xform.addUIMessage("No results found", TRX.UIM_FATAL)
                    return xform.returnOutput()
                for name in data:
                    ent = xform.addEntity("maltego.Domain", name)
                    ent.setLinkLabel(
                        data[name])  # date ID was associated with domain
                return xform.returnOutput()
            else:
                xform = TRX.MaltegoTransform()
                xform.addException("Must submit an API key")
                return xform.throwExceptions()
        else:
            xform.addException("Must submit a valid Analytics tracking ID")
            return xform.throwExceptions()
Example #13
0
def process_domain(data):
    xform = TRX.MaltegoTransform()
    if data['status'] != 'found':
        xform.addUIMessage("No results found", TRX.UIM_FATAL)
        return xform.returnOutput()
    name = data['result']['domain'].keys()[0]
    for code in data['result']['domain'][name]['items'].get('adsense', ''):
        ent = xform.addEntity("maltego.Phrase", code)
        ent.setWeight(data['result']['domain'][name]['items']['adsense'][code])
    for code in data['result']['domain'][name]['items'].get('analytics', ''):
        ent = xform.addEntity("maltego.Phrase", code)
        ent.setWeight(
            data['result']['domain'][name]['items']['analytics'][code])
    for server in data['result']['domain'][name]['items'].get(
            'dns_servers', ''):
        ent = xform.addEntity("maltego.NSRecord", server)
        # TODO: how to represent IP addresses returned in this API call?
    for ip in data['result']['domain'][name]['items'].get('ip', ''):
        ent = xform.addEntity("maltego.IPv4Address", ip)
        ent.setWeight(data['result']['domain'][name]['items']['ip'][ip])
    return xform.returnOutput()
Example #14
0
 def test_entity_set_value(self):
     entity = TRX.MaltegoEntity()
     entity.setValue("Maltego")
     assert_equal(entity.value, "Maltego")
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(out['Entity']['Value'], "Maltego")
Example #15
0
 def test_entity_weight(self):
     entity = TRX.MaltegoEntity()
     entity.setWeight(100)
     assert_equal(entity.weight, 100)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(out['Entity']['Weight'], "100")
Example #16
0
 def test_entity_set_type(self):
     entity = TRX.MaltegoEntity()
     entity.setType("Location")
     assert_equal(entity.entityType, "Location")
Example #17
0
 def test_entity_init_value(self):
     entity = TRX.MaltegoEntity("IPv4Address", "127.0.0.1")
     # FIXME: the below matches the library but not the documentation!
     assert_equal(entity.value, "127.0.0.1")
Example #18
0
 def test_entity_displayinfo_dict(self):
     entity = TRX.MaltegoEntity()
     entity.addDisplayInformation("TestValue", "TestLabel")
     assert_equal(entity.displayInformation.keys(), ["TestLabel"])
     assert_equal(entity.displayInformation['TestLabel'], "TestValue")
Example #19
0
 def test_entity_bookmark(self):
     entity = TRX.MaltegoEntity()
     entity.setBookmark(TRX.BOOKMARK_COLOR_GREEN)
     out = xmltodict.parse(entity.returnEntity())
     assert_equal(entity.additionalFields['bookmark#'].value, "1")
     assert_equal(out['Entity']['AdditionalFields']['Field']['#text'], "1")
Example #20
0
 def test_entity_default_type(self):
     entity = TRX.MaltegoEntity()
     assert_equal(entity.entityType, "Phrase")
Example #21
0
 def test_entity_property_count(self):
     entity = TRX.MaltegoEntity("IPv4Address", "10.0.0.1")
     entity.addProperty("ipaddress.internal", value="True")
     assert_equal(len(entity.additionalFields), 1)
Example #22
0
 def test_entity_init_type(self):
     entity = TRX.MaltegoEntity("IPv4Address")
     assert_equal(entity.entityType, "IPv4Address")
Example #23
0
 def test_entity_default_value(self):
     entity = TRX.MaltegoEntity()
     assert_equal(entity.value, "")
Example #24
0
 def setUpClass(self):
     self.xform = TRX.MaltegoTransform()
Example #25
0
 def test_entity_property_dict(self):
     entity = TRX.MaltegoEntity("IPv4Address", "10.0.0.1")
     entity.addProperty("ipaddress.internal", value="True")
     assert_is_instance(entity.additionalFields, dict)
     assert_equal(entity.additionalFields.keys(), ["ipaddress.internal"])
Example #26
0
 def test_msg_meta(self):
     m = TRX.MaltegoMsg(self.m_xml)
     assert_equal(m.Value, "127.0.0.1")
     assert_equal(m.Weight, "100")
     assert_equal(m.Slider, 50)
     assert_equal(m.Type, "IPAddress")
Example #27
0
 def test_entity_displayinfo_count(self):
     entity = TRX.MaltegoEntity()
     entity.addDisplayInformation("TestValue", "TestLabel")
     assert_equal(len(entity.displayInformation), 1)
     assert_is_instance(entity.displayInformation, dict)
Example #28
0
 def test_msg_property(self):
     m = TRX.MaltegoMsg(self.m_xml)
     assert_equal(m.getProperty('ipv4-address'), "127.0.0.1")
     assert_equal(m.getProperty('ipaddress.internal'), "true")
     assert_is_none(m.getProperty('nope'))
Example #29
0
 def test_msg_entity(self):
     m = TRX.MaltegoMsg(self.m_xml)
     assert_is_instance(m, TRX.MaltegoMsg)
Example #30
0
 def test_msg_setting(self):
     m = TRX.MaltegoMsg(self.m_xml)
     assert_equal(m.getTransformSetting("api"), "JUSTKIDDING")
     assert_is_none(m.getTransformSetting("nope"))