-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMISP-GetValue.py
39 lines (31 loc) · 1.45 KB
/
MISP-GetValue.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
38
39
from pymisp import ExpandedPyMISP
import os
def main():
# Get environment variables
path = os.environ.get('path')
misp_url = os.environ.get('misp_url')
misp_key = os.environ.get('misp_key')
verify_ssl = False # Set to True if you want to verify SSL certificate
# Initialize MISP connection
misp = ExpandedPyMISP(misp_url, misp_key, verify_ssl)
# Define attribute types to search for
attribute_types = ['domain']
# Iterate through attribute types
for attribute_type in attribute_types:
try:
# Search for attributes of the specified type with warning list enforcement
search_result = misp.search(controller='attributes', enforce_warninglist=True, type_attribute=attribute_type)
# Write search results to a file
output_file_path = f'/var/ossec/etc/lists/enforced_warninglist_{attribute_type}_values_wazuh'
write_search_results_to_file(search_result, output_file_path)
except Exception as e:
# Handle exceptions and print error message
print(f"Error occurred for attribute type '{attribute_type}': {e}")
break
def write_search_results_to_file(search_result, output_file_path):
# Write search results to a file
with open(output_file_path, 'w') as file:
for attribute in search_result['Attribute']:
file.writelines(attribute['value'] + ':\n')
if __name__ == "__main__":
main()