Shodan -- used by pentesters, researchers and data scientists everywhere to analyze information about computers on the Internet. From webcams to SCADA to looking at where various SSL information in certificates can tie organisations together. It is a common tool used by many different people. We really wanted to get some Maltego goodness on that!
TL;DR -- You can get the Shodan transforms in the transform hub right now. To use all of the different transform options (or you can stick with the free options) you can simply click on settings in the transform hub after installing to add your API key.There have been transforms written for Shodan before, but we really felt like they needed refreshing. So we took it upon ourselves to look at the information provided by Shodan and decide how we could integrate it into the needs of Maltego users. We first started by looking at what information was readily and easily available and then if it was useful in an n-th order graph. This is what we came up with.
Taking an IP address, you can identify various pieces of information for that IP address, these are broken down into the following:
- Service - A service is an application running on a particular port and is represented as <port>:<banner> in a new maltego.Service entity. If the banner is unknown the text "<unknown>" is displayed.
- Hostnames - Any hostnames enumerated by Shodan will be displayed. Most often this is the reverse DNS for the IP address.
- Owner Details - This will return two phrases (unless they are the same), one for the ISP and one for the organisation identified by Shodan.
- Location - If GPS and Location variables have been identified these will be returned as one or two different entities.
- AS - Returns the AS number for the IP address in question.
With this kind of information and the power of Maltego it means you can easily do link analysis across a large number of IP addresses (and later networks!) ... fantastically. Graphing information such as common services, owners or locations means that even if the machines you are investigating/targeting are on disparate networks you can find connection between them. It is of course still up to the analyst to identify if the connections are valid or not.
An example of this could be something like looking at the infrastructure of the NSA (starting with nsa.gov) and performing a simple footprint with Maltego ( Domain -> DNS -> IP Addresses). Once we have the IP addresses we can run the "To Shodan Details" transform and see the following:
From here we can switch to 'bubble view' (replaced in M4) to get an idea of the most common nodes, and we see the usual suspects, Layer 3 communications (a T1 provider ), the AS used and a number of machines running what looks like webservers:
Above example shows the ability to correlate - however it may be even more interesting to look at machines that did not match the more common nodes. Looking at these you can quickly identify 'the odd one out':
The ability to send a netblock to Shodan and have it return IP Addresses it has found within a particular range is phenomenally useful. As such we have included this transforms within the pack! What it gives you is the ability to take a large network space (think multiple Class A/B's) and have only a small subset of that returned. This is usually interesting as the results returned show only the populated space in the netblock -- Shodan does the pre-scanning for you!Keeping with our previous example of the NSA, if we take a handful of IP addresses within the 8.44.101.x network space found previously:220.127.116.11 - remoteoffice1.nsa.gov18.104.22.168 - smtp.nsa.gov22.214.171.124 - smtp.nsa.gov126.96.36.199 - dsdn-gh1-uea05.nsa.gov
188.8.131.52 - remoteoffice.nsa.gov
184.108.40.206 - dsdn-gh1-uea06.nsa.gov
220.127.116.11 - remoteoffice2.nsa.gov
If we now run the transform "To Netblock [Using natural boundaries]" to get the class C those are in (or do it manually), which returns 18.104.22.168-255.
From here you can run to "toIPs [Shodan]" and you will see the following in the ouput window:
As you can see from this example we're using a free API key and our results are limited to 100 but you can use your own paid-for key to get all the results available! Even with just the first 100 results (of 198) it means we have already managed to narrow down our space further.
Now we can look at the results and perform tasks such as looking at the reverse DNS names (with the transform "To DNS Name [Reverse DNS]") and already get new DNS names we previously did not find such as emvm-gh1-uea08.nsa.govand eas.nsa.gov.
One thing you might notice about the first example is that there is a service entity returned that contains the details in the format of <port> : <service> . There are two additional transforms included in the Shodan transform hub item that will break these apart into the various ports and services. This allows you to quickly visualize which ports and applications are more commonly used.If we look at an example quickly mapping defense.gouv.fr to DNS, then to IP addresses as we did above we see something like the following:
From here however it becomes more interesting as we can take each of the services to a port and banner and within bubble view examine the common infrastructure on a port and service level:
Typically you would see something like the graph above where there are a lot of port 80's running an HTTPd of some kind, but it is interesting to see things like port 81,82,83 and 84 as well. In this case these all seem to be a standard webmail configuration. A graph like the one above however is filled with additional interesting artifacts...
Further Port Manipulation
From a port entity (either in your existing graph or dragging it in from the palette) you can also run transforms that identify other IP addresses running services on that port. For example if we look at S7 devices (from https://icsmap.shodan.io/) we can see that they generally run on port 102.In Maltego we add the port to our graph and run the transform to IPs From Port [via Shodan]. This gives us the option of adding additional terms in the query (that might be found in the response) as well as the country code as seen below:
From here we get a number of results back for IP addresses that have services running on port 102. We can then take each of these services to the details for those IP addresses and visualize the results to identify commonality between them. Here we can see that a lot of the machines running the Siemens S7 devices on port 80 also have VNC listening on port 5900.
Native Shodan Queries
In addition to the above queries we have also included the ability to search for your own custom terms or use a more guided version of the transform.
The first is the advanced search - this transform will send the terms you specify in a phrase entity directly and unmodified to Shodan. For example if you started with the phrase "National Security Agency" and wanted to see all results that contained that exact string you could run the "to IPs via Shodan [Advanced Search]" transform. This would return the following:
You can also see in the detail view that the text Basic realm="National Security Agency" is seen within the IP address highlighted. You can view additional key terms used by exploring the Shodan API documentation at https://developer.shodan.io/api and viewing the keywords available under the /Shodan/Host/Search heading.
If you would prefer to be guided through the four terms we use (ssl, hostname, org and isp) you can run the transform "to IPs via Shodan [Basic]" which will allow you to specify the terms you want. You can use a space ( " " ) for terms you wish to exclude.
PLEASE NOTE: The free API will only allow you to use one term at a time. To use more terms you need your own API key.
Let's see how this works. If you used the phrase "NSA Search" (remember this can be anything as we are doing the basic search), and you filled in the terms as shown below when running the transform "to IPs via Shodan [Basic]":
You would receive the following in your response:
Here you can now run the standard IP to Shodan details to get the details of each of these IP addresses, and as we were searching for any DNS Name containing nsa.gov we get the following out:
Keep in mind that Shodan returns *anything* that contains the word nsa.gov - so entries like nsaoa.nsa.gov.cn are also returned!
The last two transforms are more an incorporation of the previous ones where we will use two specific Shodan keywords (namely 'ssl' and 'hostname') to search through any results found for additional DNS records that we might not have seen before using the other DNS transforms. These are uber useful, especially with certificates (the ssl keyword) to find specific machines on the Internet.
If we run the two transforms we get a nice subset of DNS names (that we had also seen before) with just two simple transforms (To DNS Names [Via Shodan]and To DNS Names SSL [Via Shodan]) -- Abracadabra!
Adding Shodan Transforms:
To add the Shodan transforms it's as simple as going to the transform hub item and clicking on "Install":
API Keys:Shodan API keys are free with limitations for any user on the Shodan website and registration is completely free. The limitations of the free API key are as follows:
- Only the first 100 results per query
- Advanced keywords can only be used one at a time (ie you cannot search for a dns name within a particular country)
Registered users (a once off fee) do not have these limitations (apart from a certain number of lookups per month on a registered key) and the project is really useful so we would encourage you to signup.
To add your API key you can simply click on "settings" within the transform hub and enter your key.
May your english be fluid and your dancing be premium. Use responsibly!