Skip to content

Instantly share code, notes, and snippets.

Created April 5, 2016 15:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/321844f3b3d5631baaa0bf73da20b847 to your computer and use it in GitHub Desktop.
Save anonymous/321844f3b3d5631baaa0bf73da20b847 to your computer and use it in GitHub Desktop.
Powershell Maltego Local Transform Example
Param(
$IP ##IP we will look up
)
#Define XML Header
$MaltegoHeader = @"
<MaltegoMessage>
<MaltegoTransformResponseMessage>
<Entities>
"@
#Define XML Footer
$MaltegoFooter = @"
</Entities>
</MaltegoTransformResponseMessage>
</MaltegoMessage>
"@
#Example Query:
#Invoke-RestMethod -Method GET -Uri "http://ip-api.com/json/4.2.2.2"
#Example Results:
#as : AS3356 Level 3 Communications, Inc.
#city : New York
#country : United States
#countryCode : US
#isp : Level 3 Communications
#lat : 40.7128
#lon : -74.0059
#org : Level 3 Communications
#uery : 4.2.2.2
#egion : NY
#regionName : New York
#status : success
#timezone : America/Chicago
#zip :
#Invoke the API and store the response
$response = Invoke-RestMethod -Method GET -Uri "http://ip-api.com/json/$($IP)"
#Build the XML Container around the values
$MaltegoLocation = "<Entity Type='Location'><Value>$($response.Country)</Value></Entity>"
$MaltegoOrganization = "<Entity Type='Organization'><Value>$($response.org)</Value></Entity>"
#Output
Write-Host "$MaltegoHeader$MaltegoLocation$MaltegoOrganization$MaltegoFooter"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment