Menu and Error Checking updated

This commit is contained in:
=
2025-08-25 09:13:16 -04:00
parent d7e6b43e39
commit 81e2f7f7d1
4 changed files with 65 additions and 55 deletions
+16 -10
View File
@@ -58,17 +58,23 @@ def devicehistory(url, outputjson: bool):
}
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
if outputjson == True:
if outputjson:
return response
parse_text = json.loads(response.text)
for block in parse_text['response']['exechistory']:
print(ct.colorText(f"Command: {block['commandline']}","green"))
print(ct.colorText(f"Date: {block['datetime']}","green"))
print(ct.colorText(f"Filename: {block['filename']}","green"))
print(ct.colorText(f"Policy Name: {block['policyname']}","green"))
print(ct.colorText(f"Hostname: {block['hostname']}","green"))
print(ct.colorText(f"Hash: {block['sha256']}","green"))
print("\n")
# Safely get exechistory
exechistory = parse_text.get('response', {}).get('exechistory')
if isinstance(exechistory, list):
for block in exechistory:
print(ct.colorText(f"Command: {block.get('commandline', 'N/A')}", "green"))
print(ct.colorText(f"Date: {block.get('datetime', 'N/A')}", "green"))
print(ct.colorText(f"Filename: {block.get('filename', 'N/A')}", "green"))
print(ct.colorText(f"Policy Name: {block.get('policyname', 'N/A')}", "green"))
print(ct.colorText(f"Hostname: {block.get('hostname', 'N/A')}", "green"))
print(ct.colorText(f"Hash: {block.get('sha256', 'N/A')}", "green"))
print("\n")
else:
print(ct.colorText("No execution history found or data is not in expected format.", "red"))