Extracting links from a URL to Maltego

There is another recipe in this book that illustrates how to use the BeautifulSoup library to programmatically get domain names. This recipe will show you how to create a local Maltego transform, which you can then use within Maltego itself to generate information in an easy to use, graphical way. With the links gathered from this transform, this can then also be used as part of a larger spidering or crawling solution.

How to do it…

The following code shows how you can create a script that will output the enumerated information into the correct format for Maltego:

import urllib2 from bs4 import BeautifulSoup import sys tarurl = sys.argv[1] if tarurl[-1] == “/”: tarurl = tarurl[:-1] print”<MaltegoMessage>” print”<MaltegoTransformResponseMessage>” ...

Get Python Web Penetration Testing Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.