68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
# Copyright (C) 2025 James Brotosky, Brandon Wickline
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
import requests
|
|
import json
|
|
import os
|
|
import utils.pretty as ct
|
|
|
|
def addHash(policy, hash):
|
|
print(f"Adding the following hashes to {policy}:")
|
|
print(hash)
|
|
|
|
def addPath(policy, hash):
|
|
print(f"Adding the following Path Exclusions to {policy}:")
|
|
print(hash)
|
|
|
|
|
|
|
|
|
|
def addHashReal(url, allowlistID, hashlist):
|
|
endpoint = url + '/v1/hash/application/add'
|
|
print(ct.colorText("[+] Grabbing All Categories", "cyan"))
|
|
payload = {
|
|
"applicationid" : allowlistID,
|
|
"hashes" : hashlist
|
|
}
|
|
headers = {
|
|
"X-APIKey": os.getenv('APIKEY')
|
|
}
|
|
try:
|
|
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
|
response.raise_for_status() # Raise an error for bad status codes
|
|
parse_text = json.loads(response.text)
|
|
print(parse_text)
|
|
except requests.exceptions.RequestException as e:
|
|
return {"error": str(e)}
|
|
|
|
def addPathReal(url, grouplistID, pathlist):
|
|
endpoint = url + '/v1/group/path/add'
|
|
print(ct.colorText("[+] Grabbing All Categories", "cyan"))
|
|
payload = {
|
|
"applicationid" : grouplistID,
|
|
"hashes" : pathlist
|
|
}
|
|
headers = {
|
|
"X-APIKey": os.getenv('APIKEY')
|
|
}
|
|
try:
|
|
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
|
response.raise_for_status() # Raise an error for bad status codes
|
|
parse_text = json.loads(response.text)
|
|
print(parse_text)
|
|
except requests.exceptions.RequestException as e:
|
|
return {"error": str(e)}
|
|
|