Skip to content

Instantly share code, notes, and snippets.

@chrisdoman
Created September 17, 2019 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdoman/7daffe5a8dabbd1fd0ab641e2ec84776 to your computer and use it in GitHub Desktop.
Save chrisdoman/7daffe5a8dabbd1fd0ab641e2ec84776 to your computer and use it in GitHub Desktop.
get_otx_domains_to_rpz.py
# 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