Created
May 4, 2021 17:22
-
-
Save ashishsecdev/31a02af02525fc4370929dc4672cc588 to your computer and use it in GitHub Desktop.
Wazuh_Automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://github.com/ashishsecdev/Wazuh-Inventory-Automation/blob/main/Wazuh_Automation.py | |
import requests | |
import json | |
import csv | |
url = "http://Wazuh-Endpoint.com:PortNumber" | |
agentNames = "/agents" | |
URL = url + agentNames | |
user = '<UserName>' | |
password= '<PassWord>' | |
response = requests.get(URL, verify=False, auth=(user, password)) | |
r = json.loads(response.text) | |
for i in r["data"]["items"]: | |
agentlist = i["id"] | |
endpoint = "/syscollector/" + agentlist + "/processes" | |
second = url + endpoint | |
response = requests.get(second, verify=False, auth=(user, password)) | |
r = json.loads(response.text) | |
for i in r["data"]["items"]: | |
with open('Wazuh_Inventory.csv', mode='a') as csv_file: | |
fieldnames = ['Process Name', 'PID', "Agent Name"] | |
writer = csv.DictWriter(csv_file, fieldnames=fieldnames) | |
writer.writerow({'Process Name': i["name"], 'PID': i["pid"], 'Agent Name':agentlist}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment