Official Maltego Documentation » Developer Portal » Local Transforms » Python Local Transform Examples

Python Local Transform Examples


These local transform code examples utilise the Basic Python Library found on the and show some basic functionality in an easy to copy and paste way. 

Hello World

This transform merely returns "hello world" as a phrase, it doesn't depend on the input entity at all:

from MaltegoTransform import * 
me = MaltegoTransform()
me.addEntity("maltego.Phrase","hello world");
me.returnOutput()

Reading Input

This is simple transform to show reading input from an entity and returning it to the graph (in this case working with a domain and returning a phrase with that domain in it):

from MaltegoTransform import *
import sys

domain = sys.argv[1]

me = MaltegoTransform()
me.addEntity("maltego.Phrase","hello " + domain)
me.returnOutput()

Reading Entity Properties

This example shows using the library to read the properties of an entity and printing them out. Note this is just a snippet, not a transform!

from MaltegoTransform import *
import sys

me = MaltegoTransform()
me.parseArguments(sys.argv)

longitude = me.getVar("longitude")
latitude = me.getVar("latitude")

print longitude
print latitude

Returning a Complex Entity

This transform example shows reading an entity as well as setting properties, additional fields, a UI message and the weight of the entity (run on a domain):

from MaltegoTransform import *
import sys

me = MaltegoTransform()
domain = sys.argv[1]

thisent = me.addEntity("maltego.Domain","hello " + domain)

thisent.setType("maltego.Domain")
thisent.setValue("Complex." + domain)
thisent.setWeight(200)

thisent.setDisplayInformation("<h3>Heading</h3><p>content here about" + domain + "!</p>");
thisent.addAdditionalFields("variable","Display Value",True,domain)

me.addUIMessage("completed!")
me.returnOutput()

Official Maltego Documentation
-»
Developer Portal
-»
Local Transforms
-»
Python Local Transform Examples

© Copyright 2017, Paterva PTY Limited