mirror of https://github.com/MISP/misp-modules
Modules for expansion services, import and export in MISP
http://misp.github.io/misp-modules
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
# -*- coding: utf-8 -*- |
|
|
|
import json |
|
from datetime import date, timedelta |
|
from pybgpranking import BGPRanking |
|
|
|
misperrors = {'error': 'Error'} |
|
mispattributes = {'input': ['AS'], 'output': ['freetext']} |
|
moduleinfo = {'version': '0.1', 'author': 'Raphaël Vinot', |
|
'description': 'Query an ASN Description history service (https://github.com/CIRCL/ASN-Description-History.git)', |
|
'module-type': ['expansion', 'hover']} |
|
|
|
|
|
def handler(q=False): |
|
if q is False: |
|
return False |
|
request = json.loads(q) |
|
if request.get('AS'): |
|
toquery = request['AS'] |
|
else: |
|
misperrors['error'] = "Unsupported attributes type" |
|
return misperrors |
|
|
|
bgpranking = BGPRanking() |
|
values = bgpranking.query(toquery, date=(date.today() - timedelta(1)).isoformat()) |
|
|
|
if not values: |
|
misperrors['error'] = 'Unable to find the ASN in BGP Ranking' |
|
return misperrors |
|
return {'results': [{'types': mispattributes['output'], 'values': values}]} |
|
|
|
|
|
def introspection(): |
|
return mispattributes |
|
|
|
|
|
def version(): |
|
return moduleinfo
|
|
|