Local Code Snippets

These local transform Code snippets utilise the default libraries and show some basic functionality in an easy to copy and paste way. Please make sure you are familiar with how the libraries and transforms work. If you are not sure we recommend taking a look at our getting started guide.
These samples use the local Python library:


 

Local transfrom Code Snippets

 

Hello World [Back to Top]
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 [Back to Top]
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 [Back to Top]
This example simply illustrates 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 [Back to Top]
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("

Heading

content here about" + domain + "!

"); thisent.addAdditionalFields("variable","Display Value",True,domain) me.addUIMessage("completed!") me.returnOutput()