/
extract_SS7_GT.py
38 lines (30 loc) · 1.48 KB
/
extract_SS7_GT.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from pymisp import ExpandedPyMISP
from keys import misp_url, misp_key, misp_verifycert
# This script is a really simple example on how to extract GTs from SS7 Objects in Telecom MISP events
# I then create a csv file with the following template:
# Source GT, Event URL
f = open('misp.csv','w')
f.write('id,url\n')
if __name__ == '__main__':
misp = ExpandedPyMISP(misp_url, misp_key, misp_verifycert)
result = misp.search(tags=['SS7 Attack', 'SS7-Attack'], return_format='json')
if not result:
print('No results for this query')
exit(0)
for r in result:
for o in r['Event']['Object']:
for a in o['Attribute']:
if a['object_relation'] == 'SccpCgGT':
# Handle when several GT with ',' or ';' have been inserted in the SccpCgGT attribute
if ',' in a['value']:
l_value = a['value'].split(",")
for v in l_value:
f.write(v.strip()+",https://misp.gsma.com/events/view/"+r['Event']['id']+"\n")
elif ';' in a['value']:
l_value = a['value'].split(";")
for v in l_value:
f.write(v.strip()+",https://misp.gsma.com/events/view/"+r['Event']['id']+"\n")
else:
f.write(a['value'].strip()+",https://misp.gsma.com/events/view/"+r['Event']['id']+"\n")