Skip to content

Instantly share code, notes, and snippets.

@chrisdoman
Last active August 6, 2018 14:46
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/ddfd34affaa3e1d3993c6390a3a930bc to your computer and use it in GitHub Desktop.
Save chrisdoman/ddfd34affaa3e1d3993c6390a3a930bc to your computer and use it in GitHub Desktop.
Quick example to pull reports from OTX with tagged Adversaries (i.e. probably APT)
'''
Quick example to pull reports with tagged Adversaries (i.e. probably APT)
'''
from OTXv2 import OTXv2, IndicatorTypes
# This is the API key for the user "api_example"
otx = OTXv2('766ba1df3ab54db9c0fcbf62ef048c3a04c260e8ca65b6c25346084b7b4719ad')
pulses = otx.getall()
print 'title,reference,created'
def clean(s):
return s.replace(',','')
def cleanDate(s):
return s.split('T')[0]
for i in range(0,len(pulses)-1):
try:
pulse = pulses[i]
url = "https://otx.alienvault.com/pulse/" + pulse["id"]
indicators = pulse["indicators"]
references = pulse["references"]
adversary = pulse["adversary"]
title = clean(pulse["name"])
created = cleanDate(pulse["created"])
if references != None and adversary != None:
if len(references) > 0 and len(adversary) > 0:
reference = references[0]
print title + ',' + reference + ',' + created
except Exception as ex:
pass
#sprint str(ex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment