Created
September 17, 2019 09:47
-
-
Save chrisdoman/7daffe5a8dabbd1fd0ab641e2ec84776 to your computer and use it in GitHub Desktop.
get_otx_domains_to_rpz.py
This file contains 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
# Short demonstration script to write OTX hostnames to a RPZ format text-file | |
from OTXv2 import OTXv2 | |
import os | |
# This is the API key for the user "api_example" | |
otx = OTXv2('766ba1df3ab54db9c0fcbf62ef048c3a04c260e8ca65b6c25346084b7b4719ad') | |
events = otx.get_all_indicators(author_name='alienvault') | |
output = '' | |
for event in events: | |
try: | |
if event['type'] == 'hostname' or event['type'] == 'domain': | |
indicator = event['indicator'] | |
if '*.' in indicator: | |
indicator = indicator.replace('.*','') | |
output += indicator +' CNAME .' + os.linesep | |
output += '*.' + indicator +' CNAME .' + os.linesep | |
except Exception as e: | |
traceback.print_exc() | |
with open('otx_blocklist.rpz','w') as f: | |
f.write(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment