Created
July 20, 2015 13:32
-
-
Save keithmccammon/9315babfe886e5dd5f28 to your computer and use it in GitHub Desktop.
Extracting historical network events (netconns) given a list of domains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Dump a comma-separated list of domain,ipaddr pairings where the domain | |
| includes at least one element from the list (domains). | |
| Useful for dumping historical name resolution data, compiling lists of | |
| endpoints that have talked to a domain, etc. | |
| Depends on https://github.com/redcanaryco/cbapi2. | |
| """ | |
| from cbapi2 import CbApi2 | |
| domains = ['no-ip.org', | |
| 'no-ip.biz', | |
| 'no-ip.info'] | |
| CB_URL = '' | |
| CB_API_TOKEN = '' | |
| if __name__ == '__main__': | |
| c = CbApi2(CB_URL, CB_API_TOKEN, ssl_verify=False) | |
| result = c.process_search(' or '.join(domains)) | |
| for proc in result: | |
| for netconn in proc.netconns: | |
| if any(domain in netconn.dns for domain in domains): | |
| print '%s,%s' % (netconn.dns, netconn.ipaddr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment