First Commit
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,54 @@
|
||||
import datetime
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
|
||||
def devicehistory(url):
|
||||
endpoint = url + '/v1/getexechistory'
|
||||
print("\n")
|
||||
print("1. Today")
|
||||
print("2. Last 24 Hours")
|
||||
print("3. Past 7 Days")
|
||||
print("4. Past 30 Days")
|
||||
print("5. Custom Date Range")
|
||||
choice = input("\nSelect Date Range: ")
|
||||
today = datetime.date.today()
|
||||
today = today.strftime("%Y-%m-%d")
|
||||
if choice == '1':
|
||||
date_selected = today
|
||||
elif choice == '2':
|
||||
date_selected = datetime.date.today() - datetime.timedelta(days=1)
|
||||
date_selected = date_selected.strftime('%Y-%m-%d')
|
||||
elif choice == '3':
|
||||
date_selected = datetime.date.today() - datetime.timedelta(days=7)
|
||||
date_selected = date_selected.strftime('%Y-%m-%d')
|
||||
elif choice == '4':
|
||||
date_selected = datetime.date.today() - datetime.timedelta(days=30)
|
||||
date_selected = date_selected.strftime('%Y-%m-%d')
|
||||
elif choice == "5":
|
||||
print("Please Input Dates as YYYY-MM-DD")
|
||||
date_selected = input("From: ")
|
||||
today = input("Date To: ")
|
||||
print("WARNING: Device Name is Case Sensitive")
|
||||
device = input("Enter Device Name: ")
|
||||
payload_dict = {
|
||||
"datefrom": date_selected,
|
||||
"dateto": today,
|
||||
"hostname": device
|
||||
}
|
||||
payload = json.dumps(payload_dict)
|
||||
print(payload)
|
||||
headers = {
|
||||
"X-APIKey": os.getenv('APIKEY')
|
||||
}
|
||||
|
||||
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
||||
parse_text = json.loads(response.text)
|
||||
for block in parse_text['response']['exechistory']:
|
||||
print(f"Command: {block['commandline']}")
|
||||
print(f"Date: {block['datetime']}")
|
||||
print(f"Filename: {block['filename']}")
|
||||
print(f"Policy Name: {block['policyname']}")
|
||||
print(f"Hostname: {block['hostname']}")
|
||||
print(f"Hash: {block['sha256']}")
|
||||
print("\n")
|
||||
Reference in New Issue
Block a user