def trx_getstastuscode(data): trx = MaltegoTransform() website = data.Value url = 'http://{0}'.format(website) try: r = requests.get(url) trx.addEntity('maltego.Phrase', str(r.status_code)) except: trx.addUIMessage( 'Whoops, that doesn\'t look like a valid website address') return trx.returnOutput()
def handler(event, context): response = MaltegoTransform() # Maltego XML Response Object if ("body" in event): request = MaltegoMsg( event["body"]) # Maltego XML Request Object (what we got in) sampleTransform(request, response) xmlResponse = response.returnOutput() else: xmlResponse = get_exception_message() # We didnt get a body? yikes! return { 'body': '{}'.format(xmlResponse), 'headers': { 'Content-Type': 'text/xml' }, 'statusCode': 200 }
from APIManagement import Tacyt from maltego.Entities import TacytEntities as te api = TacytApp.TacytApp(Tacyt.APP_ID, Tacyt.SECRET_KEY) m = MaltegoTransform() field = sys.argv[1] try: query = "certificateFingerprint:%s"%field result = api.search_apps(query=query,maxResults=100) data = result.get_data() if 'result' in data and data['result'] is not None and 'applications' in data['result'] and data['result']['applications']: for data in data['result']['applications']: if 'key' in data and data['key'] is not None: application = data['key'] m.addEntity(te.KEY, application.encode('utf-8')) else: m.addUIMessage("The key is not found in the results") else: m.addUIMessage("The search returns null results") except Exception as e: m.addException(str(e)) m.throwExceptions() m.returnOutput()