Skip to content

Instantly share code, notes, and snippets.

Created September 17, 2019 09:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# 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:
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:
with open('otx_blocklist.rpz','w') as f:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment