- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
04-30-2023 03:40 PM - edited 04-30-2023 03:43 PM
Hello dear community,
my ps script is ready to upload IOCs with least privilege.
But I want to know, what kind of security risks we have if we don't use the Advanced security level?
Has anybody of you a ps snippet where the api key is hased like it is required?
additionally I found this example, but not in ps, just only python 3:
from datetime import datetime, timezone import secrets import string import hashlib import requests def test_advanced_authentication(api_key_id, api_key): # Generate a 64 bytes random string nonce = "".join([secrets.choice(string.ascii_letters + string.digits) for _ in range(64)]) # Get the current timestamp as milliseconds. timestamp = int(datetime.now(timezone.utc).timestamp()) * 1000 # Generate the auth key: auth_key = "%s%s%s" % (api_key, nonce, timestamp) # Convert to bytes object auth_key = auth_key.encode("utf-8") # Calculate sha256: api_key_hash = hashlib.sha256(auth_key).hexdigest() # Generate HTTP call headers headers = { "x-xdr-timestamp": str(timestamp), "x-xdr-nonce": nonce, "x-xdr-auth-id": str(api_key_id), "Authorization": api_key_hash } parameters = {} res = requests.post(url="https://api-xdr.xdr.de.paloaltonetworks.com/api_keys/validate/", headers=headers, json=parameters) return res
BR
Rob
12-29-2023 10:33 AM
Thank you! I already have the answer to my question. The PS script got all the functions to communicate through advanced.
BR
Rob
05-01-2023 09:24 AM
Hi @RFeyertag,
Thank for reaching out through LIVEcommunity!
If I understand correctly you're wanting to know the security risks for not using the advanced security level and looking for an example of hashing the API as required with powershell.
First, one of the biggest reasons for hashing the API Key is to prevent replay and similar attacks while using the API.
As for how to properly encrypt the API key using powershell this may be a good resource to get you started.
I hope this helps.
12-29-2023 10:33 AM
Thank you! I already have the answer to my question. The PS script got all the functions to communicate through advanced.
BR
Rob
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!