pymisp 2.5.7__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.

Files changed (135) hide show
  1. pymisp/api.py +1 -0
  2. pymisp/data/misp-objects/objects/rmm/definition.json +1 -1
  3. {pymisp-2.5.7.dist-info → pymisp-2.5.8.dist-info}/METADATA +4 -4
  4. {pymisp-2.5.7.dist-info → pymisp-2.5.8.dist-info}/RECORD +6 -135
  5. CHANGELOG.txt +0 -5380
  6. examples/__init__.py +0 -0
  7. examples/add_attributes_from_csv.py +0 -74
  8. examples/add_email_object.py +0 -29
  9. examples/add_fail2ban_object.py +0 -86
  10. examples/add_feed.py +0 -25
  11. examples/add_file_object.py +0 -47
  12. examples/add_filetype_object_from_csv.py +0 -53
  13. examples/add_generic_object.py +0 -26
  14. examples/add_github_user.py +0 -65
  15. examples/add_gitlab_user.py +0 -56
  16. examples/add_named_attribute.py +0 -25
  17. examples/add_organisations.py +0 -57
  18. examples/add_ssh_authorized_keys.py +0 -29
  19. examples/add_user.py +0 -22
  20. examples/add_vehicle_object.py +0 -22
  21. examples/addtag2.py +0 -45
  22. examples/asciidoc_generator.py +0 -114
  23. examples/cache_all.py +0 -10
  24. examples/copyTagsFromAttributesToEvent.py +0 -68
  25. examples/copy_list.py +0 -93
  26. examples/create_events.py +0 -26
  27. examples/cytomic_orion.py +0 -549
  28. examples/del.py +0 -22
  29. examples/delete_user.py +0 -16
  30. examples/edit_organisation.py +0 -20
  31. examples/edit_user.py +0 -20
  32. examples/falsepositive_disabletoids.py +0 -136
  33. examples/fetch_events_feed.py +0 -15
  34. examples/fetch_warninglist_hits.py +0 -38
  35. examples/freetext.py +0 -22
  36. examples/generate_file_objects.py +0 -78
  37. examples/generate_meta_feed.py +0 -15
  38. examples/get.py +0 -37
  39. examples/get_csv.py +0 -37
  40. examples/get_network_activity.py +0 -187
  41. examples/last.py +0 -48
  42. examples/load_csv.py +0 -94
  43. examples/lookup.py +0 -28
  44. examples/misp2cef.py +0 -71
  45. examples/misp2clamav.py +0 -52
  46. examples/openioc_to_misp.py +0 -27
  47. examples/proofpoint_tap.py +0 -203
  48. examples/proofpoint_vap.py +0 -65
  49. examples/search.py +0 -48
  50. examples/search_attributes_yara.py +0 -40
  51. examples/search_sighting.py +0 -42
  52. examples/server_sync_check_conn.py +0 -32
  53. examples/sharing_groups.py +0 -15
  54. examples/show_sightings.py +0 -168
  55. examples/stats_report.py +0 -405
  56. examples/sync_sighting.py +0 -171
  57. examples/tags.py +0 -25
  58. examples/test_sign.py +0 -19
  59. examples/trustar_misp.py +0 -59
  60. examples/up.py +0 -21
  61. examples/upload.py +0 -60
  62. examples/users_list.py +0 -15
  63. examples/vmray_automation.py +0 -281
  64. examples/vt_to_misp.py +0 -182
  65. examples/warninglists.py +0 -22
  66. examples/yara.py +0 -38
  67. examples/yara_dump.py +0 -98
  68. tests/57c4445b-c548-4654-af0b-4be3950d210f.json +0 -1
  69. tests/__init__.py +0 -0
  70. tests/csv_testfiles/invalid_fieldnames.csv +0 -11
  71. tests/csv_testfiles/valid_fieldnames.csv +0 -4
  72. tests/email_testfiles/mail_1.eml.zip +0 -0
  73. tests/email_testfiles/mail_1.msg +0 -0
  74. tests/email_testfiles/mail_1_bom.eml +0 -858
  75. tests/email_testfiles/mail_1_headers_only.eml +0 -28
  76. tests/email_testfiles/mail_2.eml +0 -32
  77. tests/email_testfiles/mail_3.eml +0 -170
  78. tests/email_testfiles/mail_3.msg +0 -0
  79. tests/email_testfiles/mail_4.msg +0 -0
  80. tests/email_testfiles/mail_5.msg +0 -0
  81. tests/email_testfiles/mail_multiple_to.eml +0 -15
  82. tests/email_testfiles/source +0 -1
  83. tests/git-vuln-finder-quagga.json +0 -1493
  84. tests/misp_event.json +0 -76
  85. tests/mispevent_testfiles/attribute.json +0 -21
  86. tests/mispevent_testfiles/attribute_del.json +0 -23
  87. tests/mispevent_testfiles/def_param.json +0 -53
  88. tests/mispevent_testfiles/event.json +0 -8
  89. tests/mispevent_testfiles/event_obj_attr_tag.json +0 -57
  90. tests/mispevent_testfiles/event_obj_def_param.json +0 -62
  91. tests/mispevent_testfiles/event_obj_tag.json +0 -29
  92. tests/mispevent_testfiles/event_tags.json +0 -18
  93. tests/mispevent_testfiles/existing_event.json +0 -4599
  94. tests/mispevent_testfiles/existing_event_edited.json +0 -4601
  95. tests/mispevent_testfiles/galaxy.json +0 -25
  96. tests/mispevent_testfiles/malware.json +0 -19
  97. tests/mispevent_testfiles/malware_exist.json +0 -163
  98. tests/mispevent_testfiles/misp_custom_obj.json +0 -38
  99. tests/mispevent_testfiles/overwrite_file/definition.json +0 -457
  100. tests/mispevent_testfiles/proposals.json +0 -35
  101. tests/mispevent_testfiles/shadow.json +0 -148
  102. tests/mispevent_testfiles/sighting.json +0 -5
  103. tests/mispevent_testfiles/simple.json +0 -2
  104. tests/mispevent_testfiles/test_object_template/definition.json +0 -29
  105. tests/new_misp_event.json +0 -34
  106. tests/reportlab_testfiles/HTML_event.json +0 -1
  107. tests/reportlab_testfiles/galaxy_1.json +0 -1250
  108. tests/reportlab_testfiles/image_event.json +0 -2490
  109. tests/reportlab_testfiles/japanese_test.json +0 -156
  110. tests/reportlab_testfiles/japanese_test_heavy.json +0 -318
  111. tests/reportlab_testfiles/long_event.json +0 -3730
  112. tests/reportlab_testfiles/mainly_objects_1.json +0 -1092
  113. tests/reportlab_testfiles/mainly_objects_2.json +0 -977
  114. tests/reportlab_testfiles/sighting_1.json +0 -305
  115. tests/reportlab_testfiles/sighting_2.json +0 -221
  116. tests/reportlab_testfiles/to_delete1.json +0 -804
  117. tests/reportlab_testfiles/to_delete2.json +0 -1
  118. tests/reportlab_testfiles/to_delete3.json +0 -1
  119. tests/reportlab_testfiles/very_long_event.json +0 -1006
  120. tests/reportlab_testoutputs/to_delete1.json.pdf +0 -391
  121. tests/reportlab_testoutputs/to_delete2.json.pdf +0 -506
  122. tests/reportlab_testoutputs/to_delete3.json.pdf +0 -277
  123. tests/search_index_result.json +0 -69
  124. tests/sharing_groups.json +0 -98
  125. tests/stix1.xml-utf8 +0 -110
  126. tests/stix2.json +0 -1
  127. tests/test_analyst_data.py +0 -123
  128. tests/test_emailobject.py +0 -157
  129. tests/test_fileobject.py +0 -20
  130. tests/test_mispevent.py +0 -473
  131. tests/test_reportlab.py +0 -431
  132. tests/testlive_comprehensive.py +0 -3734
  133. tests/testlive_sync.py +0 -474
  134. {pymisp-2.5.7.dist-info → pymisp-2.5.8.dist-info}/LICENSE +0 -0
  135. {pymisp-2.5.7.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)
@@ -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,10 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- from keys import misp_url, misp_key, misp_verifycert
5
- from pymisp import ExpandedPyMISP
6
-
7
-
8
- if __name__ == '__main__':
9
- misp = ExpandedPyMISP(misp_url, misp_key, misp_verifycert)
10
- misp.cache_all_feeds()
@@ -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)