-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathotx_tool.py
More file actions
84 lines (76 loc) · 3 KB
/
Copy pathotx_tool.py
File metadata and controls
84 lines (76 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from secrets import otxKey
from OTXv2 import OTXv2
import argparse
import sys
# time = str(datetime.now() - timedelta()) # Time at which script was initiated.
args = argparse.ArgumentParser()
args.add_argument('-d', '--description',
const='description',
action='append_const',
dest='optList',
default=[],
help='returns description of each pulse')
args.add_argument('-t', '--tags',
const='tags',
action='append_const',
dest='optList',
default=[],
help='returns tags for each pulse')
args.add_argument('-m', '--modified',
const='modified',
action='append_const',
dest='optList',
default=[],
help='return date modified for each pulse')
args.add_argument('-i', '--id',
const='id',
action='append_const',
dest='optList',
default=[],
help='return pulse ids')
args.add_argument('-au', '--author_name',
const='author_name',
action='append_const',
dest='optList',
default=[],
help='return author\'s name for each pulse')
args.add_argument('-ad', '--adversary',
const='adversary',
action='append_const',
dest='optList',
default=[],
help='return adversary title for pulses')
args.add_argument('-ref', '--references',
const='references',
action='append_const',
dest='optList',
default=[],
help='return each pulses references')
args.add_argument('-rev', '--revisions',
const='revisions',
action='append_const',
dest='optList',
default=[],
help='return pulse revisions')
args.add_argument('search',
metavar='SEARCH QUERY',
type=str,
help='list search term',
default='crypto')
options = args.parse_args()
print(options.optList)
try:
otx = OTXv2(otxKey) # Initializes session with OTXv2 API using key contained in secrets.py
except:
print("problem with API key")
pulses = otx.search_pulses(options.optList, 40) # Retrieves list (in json format) of top 40 pulses with tag "crypto"
def pulse_print(): # Loops through each individual pulse retrieved from OTX, and prints name & requested fields.
for aPulse in pulses["results"]:
print('[+] '+'Pulse Name: '+aPulse.get('name')+'\n')
for switch in options:
try:
print('[+] '+switch.title()+': '+aPulse.get(switch)+'\n')
except:
print()
print('-'*30)
print()