pymisp 2.5.7.1__py3-none-any.whl → 2.5.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pymisp might be problematic. Click here for more details.
- pymisp/api.py +1 -0
- {pymisp-2.5.7.1.dist-info → pymisp-2.5.8.dist-info}/METADATA +4 -4
- {pymisp-2.5.7.1.dist-info → pymisp-2.5.8.dist-info}/RECORD +5 -68
- CHANGELOG.txt +0 -5393
- examples/__init__.py +0 -0
- examples/add_attributes_from_csv.py +0 -74
- examples/add_email_object.py +0 -29
- examples/add_fail2ban_object.py +0 -86
- examples/add_feed.py +0 -25
- examples/add_file_object.py +0 -47
- examples/add_filetype_object_from_csv.py +0 -53
- examples/add_generic_object.py +0 -26
- examples/add_github_user.py +0 -65
- examples/add_gitlab_user.py +0 -56
- examples/add_named_attribute.py +0 -25
- examples/add_organisations.py +0 -57
- examples/add_ssh_authorized_keys.py +0 -29
- examples/add_user.py +0 -22
- examples/add_vehicle_object.py +0 -22
- examples/addtag2.py +0 -45
- examples/asciidoc_generator.py +0 -114
- examples/cache_all.py +0 -10
- examples/copyTagsFromAttributesToEvent.py +0 -68
- examples/copy_list.py +0 -93
- examples/create_events.py +0 -26
- examples/cytomic_orion.py +0 -549
- examples/del.py +0 -22
- examples/delete_user.py +0 -16
- examples/edit_organisation.py +0 -20
- examples/edit_user.py +0 -20
- examples/falsepositive_disabletoids.py +0 -136
- examples/fetch_events_feed.py +0 -15
- examples/fetch_warninglist_hits.py +0 -38
- examples/freetext.py +0 -22
- examples/generate_file_objects.py +0 -78
- examples/generate_meta_feed.py +0 -15
- examples/get.py +0 -37
- examples/get_csv.py +0 -37
- examples/get_network_activity.py +0 -187
- examples/last.py +0 -48
- examples/load_csv.py +0 -94
- examples/lookup.py +0 -28
- examples/misp2cef.py +0 -71
- examples/misp2clamav.py +0 -52
- examples/openioc_to_misp.py +0 -27
- examples/proofpoint_tap.py +0 -203
- examples/proofpoint_vap.py +0 -65
- examples/search.py +0 -48
- examples/search_attributes_yara.py +0 -40
- examples/search_sighting.py +0 -42
- examples/server_sync_check_conn.py +0 -32
- examples/sharing_groups.py +0 -15
- examples/show_sightings.py +0 -168
- examples/stats_report.py +0 -405
- examples/sync_sighting.py +0 -171
- examples/tags.py +0 -25
- examples/test_sign.py +0 -19
- examples/trustar_misp.py +0 -59
- examples/up.py +0 -21
- examples/upload.py +0 -60
- examples/users_list.py +0 -15
- examples/vmray_automation.py +0 -281
- examples/vt_to_misp.py +0 -182
- examples/warninglists.py +0 -22
- examples/yara.py +0 -38
- examples/yara_dump.py +0 -98
- {pymisp-2.5.7.1.dist-info → pymisp-2.5.8.dist-info}/LICENSE +0 -0
- {pymisp-2.5.7.1.dist-info → pymisp-2.5.8.dist-info}/WHEEL +0 -0
examples/addtag2.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
from pymisp import PyMISP
|
|
4
|
-
from keys import misp_url, misp_key, misp_verifycert
|
|
5
|
-
import argparse
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def init(url, key):
|
|
9
|
-
return PyMISP(url, key, misp_verifycert, 'json')
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if __name__ == '__main__':
|
|
13
|
-
parser = argparse.ArgumentParser(description='Tag something.')
|
|
14
|
-
parser.add_argument("-u", "--uuid", help="UUID to tag.")
|
|
15
|
-
parser.add_argument("-e", "--event", help="Event ID to tag.")
|
|
16
|
-
parser.add_argument("-a", "--attribute", help="Attribute ID to tag")
|
|
17
|
-
parser.add_argument("-t", "--tag", required=True, help="Tag ID.")
|
|
18
|
-
args = parser.parse_args()
|
|
19
|
-
|
|
20
|
-
if not args.event and not args.uuid and not args.attribute:
|
|
21
|
-
print("Please provide at least one of the following : uuid, eventID or attribute ID, see --help")
|
|
22
|
-
exit()
|
|
23
|
-
|
|
24
|
-
misp = init(misp_url, misp_key)
|
|
25
|
-
|
|
26
|
-
if args.event and not args.attribute:
|
|
27
|
-
result = misp.search(eventid=args.event)
|
|
28
|
-
for event in result:
|
|
29
|
-
uuid = event['Event']['uuid']
|
|
30
|
-
|
|
31
|
-
if args.attribute:
|
|
32
|
-
if not args.event:
|
|
33
|
-
print("Please provide event ID also")
|
|
34
|
-
exit()
|
|
35
|
-
result = misp.search(eventid=args.event)
|
|
36
|
-
for event in result:
|
|
37
|
-
for attribute in event['Event']['Attribute']:
|
|
38
|
-
if attribute["id"] == args.attribute:
|
|
39
|
-
uuid = attribute["uuid"]
|
|
40
|
-
|
|
41
|
-
if args.uuid:
|
|
42
|
-
uuid = args.uuid
|
|
43
|
-
|
|
44
|
-
print("UUID tagged: %s" % uuid)
|
|
45
|
-
misp.tag(uuid, args.tag)
|
examples/asciidoc_generator.py
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
from datetime import date
|
|
6
|
-
import importlib
|
|
7
|
-
|
|
8
|
-
from pymisp import MISPEvent
|
|
9
|
-
from defang import defang
|
|
10
|
-
from pytaxonomies import Taxonomies
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class ReportGenerator():
|
|
14
|
-
def __init__(self, profile="daily_report"):
|
|
15
|
-
self.taxonomies = Taxonomies()
|
|
16
|
-
self.report = ''
|
|
17
|
-
profile_name = "profiles.{}".format(profile)
|
|
18
|
-
self.template = importlib.import_module(name=profile_name)
|
|
19
|
-
|
|
20
|
-
def from_remote(self, event_id):
|
|
21
|
-
from pymisp import PyMISP
|
|
22
|
-
from keys import misp_url, misp_key, misp_verifycert
|
|
23
|
-
misp = PyMISP(misp_url, misp_key, misp_verifycert)
|
|
24
|
-
result = misp.get(event_id)
|
|
25
|
-
self.misp_event = MISPEvent()
|
|
26
|
-
self.misp_event.load(result)
|
|
27
|
-
|
|
28
|
-
def from_file(self, path):
|
|
29
|
-
self.misp_event = MISPEvent()
|
|
30
|
-
self.misp_event.load_file(path)
|
|
31
|
-
|
|
32
|
-
def attributes(self):
|
|
33
|
-
if not self.misp_event.attributes:
|
|
34
|
-
return ''
|
|
35
|
-
list_attributes = []
|
|
36
|
-
for attribute in self.misp_event.attributes:
|
|
37
|
-
if attribute.type in self.template.types_to_attach:
|
|
38
|
-
list_attributes.append("* {}".format(defang(attribute.value)))
|
|
39
|
-
for obj in self.misp_event.Object:
|
|
40
|
-
if obj.name in self.template.objects_to_attach:
|
|
41
|
-
for attribute in obj.Attribute:
|
|
42
|
-
if attribute.type in self.template.types_to_attach:
|
|
43
|
-
list_attributes.append("* {}".format(defang(attribute.value)))
|
|
44
|
-
return self.template.attributes.format(list_attributes="\n".join(list_attributes))
|
|
45
|
-
|
|
46
|
-
def _get_tag_info(self, machinetag):
|
|
47
|
-
return self.taxonomies.revert_machinetag(machinetag)
|
|
48
|
-
|
|
49
|
-
def report_headers(self):
|
|
50
|
-
content = {'org_name': 'name',
|
|
51
|
-
'date': date.today().isoformat()}
|
|
52
|
-
self.report += self.template.headers.format(**content)
|
|
53
|
-
|
|
54
|
-
def event_level_tags(self):
|
|
55
|
-
if not self.misp_event.Tag:
|
|
56
|
-
return ''
|
|
57
|
-
for tag in self.misp_event.Tag:
|
|
58
|
-
# Only look for TLP for now
|
|
59
|
-
if tag['name'].startswith('tlp'):
|
|
60
|
-
tax, predicate = self._get_tag_info(tag['name'])
|
|
61
|
-
return self.template.event_level_tags.format(value=predicate.predicate.upper(), expanded=predicate.expanded)
|
|
62
|
-
|
|
63
|
-
def title(self):
|
|
64
|
-
internal_id = ''
|
|
65
|
-
summary = ''
|
|
66
|
-
# Get internal refs for report
|
|
67
|
-
for obj in self.misp_event.Object:
|
|
68
|
-
if obj.name != 'report':
|
|
69
|
-
continue
|
|
70
|
-
for a in obj.Attribute:
|
|
71
|
-
if a.object_relation == 'case-number':
|
|
72
|
-
internal_id = a.value
|
|
73
|
-
if a.object_relation == 'summary':
|
|
74
|
-
summary = a.value
|
|
75
|
-
|
|
76
|
-
return self.template.title.format(internal_id=internal_id, title=self.misp_event.info,
|
|
77
|
-
summary=summary)
|
|
78
|
-
|
|
79
|
-
def asciidoc(self, lang='en'):
|
|
80
|
-
self.report += self.title()
|
|
81
|
-
self.report += self.event_level_tags()
|
|
82
|
-
self.report += self.attributes()
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if __name__ == '__main__':
|
|
86
|
-
try:
|
|
87
|
-
parser = argparse.ArgumentParser(description='Create a human-readable report out of a MISP event')
|
|
88
|
-
parser.add_argument("--profile", default="daily_report", help="Profile template to use")
|
|
89
|
-
parser.add_argument("-o", "--output", help="Output file to write to (generally ends in .adoc)")
|
|
90
|
-
group = parser.add_mutually_exclusive_group(required=True)
|
|
91
|
-
group.add_argument("-e", "--event", default=[], nargs='+', help="Event ID to get.")
|
|
92
|
-
group.add_argument("-p", "--path", default=[], nargs='+', help="Path to the JSON dump.")
|
|
93
|
-
|
|
94
|
-
args = parser.parse_args()
|
|
95
|
-
|
|
96
|
-
report = ReportGenerator(args.profile)
|
|
97
|
-
report.report_headers()
|
|
98
|
-
|
|
99
|
-
if args.event:
|
|
100
|
-
for eid in args.event:
|
|
101
|
-
report.from_remote(eid)
|
|
102
|
-
report.asciidoc()
|
|
103
|
-
else:
|
|
104
|
-
for f in args.path:
|
|
105
|
-
report.from_file(f)
|
|
106
|
-
report.asciidoc()
|
|
107
|
-
|
|
108
|
-
if args.output:
|
|
109
|
-
with open(args.output, "w") as ofile:
|
|
110
|
-
ofile.write(report.report)
|
|
111
|
-
else:
|
|
112
|
-
print(report.report)
|
|
113
|
-
except ModuleNotFoundError as err:
|
|
114
|
-
print(err)
|
examples/cache_all.py
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
from pymisp import PyMISP
|
|
5
|
-
from keys import misp_url, misp_key, misp_verifycert
|
|
6
|
-
import argparse
|
|
7
|
-
import os
|
|
8
|
-
|
|
9
|
-
SILENT = False
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def getTagToApplyToEvent(event):
|
|
13
|
-
tags_to_apply = set()
|
|
14
|
-
|
|
15
|
-
event_tags = { tag.name for tag in event.tags }
|
|
16
|
-
for galaxy in event.galaxies:
|
|
17
|
-
for cluster in galaxy.clusters:
|
|
18
|
-
event_tags.add(cluster.tag_name)
|
|
19
|
-
|
|
20
|
-
for attribute in event.attributes:
|
|
21
|
-
for attribute_tag in attribute.tags:
|
|
22
|
-
if attribute_tag.name not in event_tags:
|
|
23
|
-
tags_to_apply.add(attribute_tag.name)
|
|
24
|
-
|
|
25
|
-
return tags_to_apply
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def TagEvent(event, tags_to_apply):
|
|
29
|
-
for tag in tags_to_apply:
|
|
30
|
-
event.add_tag(tag)
|
|
31
|
-
return event
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def condPrint(text):
|
|
35
|
-
if not SILENT:
|
|
36
|
-
print(text)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if __name__ == '__main__':
|
|
40
|
-
parser = argparse.ArgumentParser(description='Get an event from a MISP instance.')
|
|
41
|
-
parser.add_argument("-e", "--event", required=True, help="Event ID to get.")
|
|
42
|
-
parser.add_argument("-y", "--yes", required=False, default=False, action='store_true', help="Automatically accept prompt.")
|
|
43
|
-
parser.add_argument("-s", "--silent", required=False, default=False, action='store_true', help="No output to stdin.")
|
|
44
|
-
|
|
45
|
-
args = parser.parse_args()
|
|
46
|
-
SILENT = args.silent
|
|
47
|
-
|
|
48
|
-
misp = PyMISP(misp_url, misp_key, misp_verifycert)
|
|
49
|
-
|
|
50
|
-
event = misp.get_event(args.event, pythonify=True)
|
|
51
|
-
tags_to_apply = getTagToApplyToEvent(event)
|
|
52
|
-
condPrint('Tag to apply at event level:')
|
|
53
|
-
for tag in tags_to_apply:
|
|
54
|
-
condPrint(f'- {tag}')
|
|
55
|
-
|
|
56
|
-
confirmed = False
|
|
57
|
-
if args.yes:
|
|
58
|
-
confirmed = True
|
|
59
|
-
else:
|
|
60
|
-
confirm = input('Confirm [Y/n]: ')
|
|
61
|
-
confirmed = len(confirm) == 0 or confirm == 'Y' or confirm == 'y'
|
|
62
|
-
if confirmed:
|
|
63
|
-
event = TagEvent(event, tags_to_apply)
|
|
64
|
-
condPrint(f'Updating event {args.event}')
|
|
65
|
-
misp.update_event(event)
|
|
66
|
-
condPrint(f'Event {args.event} tagged with {len(tags_to_apply)} tags')
|
|
67
|
-
else:
|
|
68
|
-
condPrint('Operation cancelled')
|
examples/copy_list.py
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
import sys
|
|
5
|
-
|
|
6
|
-
from pymisp import PyMISP
|
|
7
|
-
|
|
8
|
-
from keys import cert, priv
|
|
9
|
-
|
|
10
|
-
url_cert = 'https://misp.circl.lu'
|
|
11
|
-
url_priv = 'https://misppriv.circl.lu'
|
|
12
|
-
cert_cert = 'misp.circl.lu.crt'
|
|
13
|
-
cert_priv = 'misppriv.circl.lu.crt'
|
|
14
|
-
source = None
|
|
15
|
-
destination = None
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def init(cert_to_priv=True):
|
|
19
|
-
global source
|
|
20
|
-
global destination
|
|
21
|
-
print(cert_to_priv)
|
|
22
|
-
if cert_to_priv:
|
|
23
|
-
source = PyMISP(url_cert, cert, cert_cert, 'xml')
|
|
24
|
-
destination = PyMISP(url_priv, priv, cert_priv, 'xml')
|
|
25
|
-
else:
|
|
26
|
-
source = PyMISP(url_priv, priv, cert_priv, 'xml')
|
|
27
|
-
destination = PyMISP(url_cert, cert, cert_cert, 'xml')
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def copy_event(event_id):
|
|
31
|
-
e = source.get_event(event_id)
|
|
32
|
-
return destination.add_event(e)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def update_event(event_id, event_to_update):
|
|
36
|
-
e = source.get_event(event_id)
|
|
37
|
-
return destination.update_event(event_to_update, e)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def list_copy(filename):
|
|
41
|
-
with open(filename, 'r') as f:
|
|
42
|
-
for l in f:
|
|
43
|
-
copy(l)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def loop_copy():
|
|
47
|
-
while True:
|
|
48
|
-
line = sys.stdin.readline()
|
|
49
|
-
copy(line)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def copy(eventid):
|
|
53
|
-
eventid = eventid.strip()
|
|
54
|
-
if len(eventid) == 0 or not eventid.isdigit():
|
|
55
|
-
print('empty line or NaN.')
|
|
56
|
-
return
|
|
57
|
-
eventid = int(eventid)
|
|
58
|
-
print(eventid, 'copying...')
|
|
59
|
-
r = copy_event(eventid)
|
|
60
|
-
if r.status_code >= 400:
|
|
61
|
-
loc = r.headers['location']
|
|
62
|
-
if loc is not None:
|
|
63
|
-
event_to_update = loc.split('/')[-1]
|
|
64
|
-
print('updating', event_to_update)
|
|
65
|
-
r = update_event(eventid, event_to_update)
|
|
66
|
-
if r.status_code >= 400:
|
|
67
|
-
print(r.status_code, r.headers)
|
|
68
|
-
else:
|
|
69
|
-
print(r.status_code, r.headers)
|
|
70
|
-
print(eventid, 'done.')
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def export_our_org():
|
|
74
|
-
circl = source.search(org='CIRCL')
|
|
75
|
-
return circl
|
|
76
|
-
|
|
77
|
-
if __name__ == '__main__':
|
|
78
|
-
import argparse
|
|
79
|
-
parser = argparse.ArgumentParser(
|
|
80
|
-
description='Copy the events from one MISP instance to an other.')
|
|
81
|
-
parser.add_argument('-f', '--filename', type=str,
|
|
82
|
-
help='File containing a list of event id.')
|
|
83
|
-
parser.add_argument(
|
|
84
|
-
'-l', '--loop', action='store_true',
|
|
85
|
-
help='Endless loop: eventid in the terminal and it will be copied.')
|
|
86
|
-
parser.add_argument('--priv_to_cert', action='store_false', default=True,
|
|
87
|
-
help='Copy from MISP priv to MISP CERT.')
|
|
88
|
-
args = parser.parse_args()
|
|
89
|
-
init(args.priv_to_cert)
|
|
90
|
-
if args.filename is not None:
|
|
91
|
-
list_copy(args.filename)
|
|
92
|
-
else:
|
|
93
|
-
loop_copy()
|
examples/create_events.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
from pymisp import ExpandedPyMISP, MISPEvent
|
|
5
|
-
from keys import misp_url, misp_key, misp_verifycert
|
|
6
|
-
import argparse
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if __name__ == '__main__':
|
|
10
|
-
parser = argparse.ArgumentParser(description='Create an event on MISP.')
|
|
11
|
-
parser.add_argument("-d", "--distrib", type=int, help="The distribution setting used for the attributes and for the newly created event, if relevant. [0-3].")
|
|
12
|
-
parser.add_argument("-i", "--info", help="Used to populate the event info field if no event ID supplied.")
|
|
13
|
-
parser.add_argument("-a", "--analysis", type=int, help="The analysis level of the newly created event, if applicable. [0-2]")
|
|
14
|
-
parser.add_argument("-t", "--threat", type=int, help="The threat level ID of the newly created event, if applicable. [1-4]")
|
|
15
|
-
args = parser.parse_args()
|
|
16
|
-
|
|
17
|
-
misp = ExpandedPyMISP(misp_url, misp_key, misp_verifycert)
|
|
18
|
-
|
|
19
|
-
event = MISPEvent()
|
|
20
|
-
event.distribution = args.distrib
|
|
21
|
-
event.threat_level_id = args.threat
|
|
22
|
-
event.analysis = args.analysis
|
|
23
|
-
event.info = args.info
|
|
24
|
-
|
|
25
|
-
event = misp.add_event(event, pythonify=True)
|
|
26
|
-
print(event)
|