diff --git a/utils/allowlist.py b/utils/allowlist.py index 1731b27..7325799 100644 --- a/utils/allowlist.py +++ b/utils/allowlist.py @@ -142,4 +142,3 @@ def listCategories(url): choice = int(choice) - 1 return choice, policiesnames - diff --git a/utils/policyfunctions.py b/utils/policyfunctions.py index 3b00496..287fa5b 100644 --- a/utils/policyfunctions.py +++ b/utils/policyfunctions.py @@ -13,7 +13,9 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - +import requests +import json +import utils.pretty as ct def addHash(policy, hash): print(f"Adding the following hashes to {policy}:") @@ -21,4 +23,44 @@ def addHash(policy, hash): def addPath(policy, hash): print(f"Adding the following Path Exclusions to {policy}:") - print(hash) \ No newline at end of file + 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)} +