Integrating Masscan port scanner with Shodan API using Python
Author: Trevor Davenport
Masscan Port Scanner: https://github.com/robertdavidgraham/masscan
Masscan Man Page: http://manpages.ubuntu.com/manpages/vivid/man8/masscan.8.html
Python Dependencies: Requests (http://www.python-requests.org/en/latest/)
BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/)
Shodan API (https://shodan.readthedocs.org/en/latest/)
Other Dependencies: CURL (http://curl.haxx.se/)
1 [*] Masscan initiates port scan
2 [*] Results are generated in XML output
3 [*] Output is pushed to scanhub.shodan.io/repo
4 [*] Data Analysis for Security/Vulnerability Management
Shodan Provides a dictionary of common Ports to known Services, we can use this data to further expand the knowledge of our open port list.
Data Analysis will render the Services and Service Count from the masscan results.
Using BeautifulSoup, we parse the XML File into meaningful data.
Cleaned Up. A Mapping of Host to Port(s).
If I had more time to implement this I would have done some aspects differently.
- Integrate ShodanAPI Exploit search for known/unknown ports
- Parse Banners for each Host, look for any vulnerabilities/verbose information about servers.
- Utilize Amazon instances for MapReduce-esque efficiency
- Input Formatting (IP Address)
- Testing API Key
- Do Away with Python.os() -- Yeah.. I know. Quick, Dirty and Effective was the name of the game
- Integrate ShodanMaps (see screenshot below)