Continued Colorization, pushed it to utils and colorized other helper scripts
This commit is contained in:
+19
-18
@@ -16,16 +16,17 @@ import datetime
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
import utils.colortext as ct
|
||||
|
||||
def devicehistory(url, outputjson: bool):
|
||||
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: ")
|
||||
print(ct.colorText("1. Today", "yellow"))
|
||||
print(ct.colorText("2. Last 24 Hours", "yellow"))
|
||||
print(ct.colorText("3. Past 7 Days", "yellow"))
|
||||
print(ct.colorText("4. Past 30 Days", "yellow"))
|
||||
print(ct.colorText("5. Custom Date Range","yellow"))
|
||||
choice = input(ct.colorText("\nSelect Date Range: ", "white"))
|
||||
today = datetime.date.today()
|
||||
today = today.strftime("%Y-%m-%d")
|
||||
if choice == '1':
|
||||
@@ -40,18 +41,18 @@ def devicehistory(url, outputjson: bool):
|
||||
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: ")
|
||||
print(ct.colorText("Please Input Dates as YYYY-MM-DD", "cyan"))
|
||||
date_selected = input(ct.colorText("From: ", "white"))
|
||||
today = input(ct.colorText("Date To: ", "white"))
|
||||
print(ct.colorText("WARNING: Device Name is Case Sensitive", "red"))
|
||||
device = input(ct.colorText("Enter Device Name: ", "white"))
|
||||
payload_dict = {
|
||||
"datefrom": date_selected,
|
||||
"dateto": today,
|
||||
"hostname": device
|
||||
}
|
||||
payload = json.dumps(payload_dict)
|
||||
print(payload)
|
||||
print(ct.colorText(payload, "green"))
|
||||
headers = {
|
||||
"X-APIKey": os.getenv('APIKEY')
|
||||
}
|
||||
@@ -64,10 +65,10 @@ def devicehistory(url, outputjson: bool):
|
||||
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(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")
|
||||
Reference in New Issue
Block a user