Az - Services
Wspieraj HackTricks
Sprawdź plany subskrypcji!
Dołącz do 💬 grupy Discord lub grupy telegram lub śledź nas na Twitterze 🐦 @hacktricks_live.
Dziel się trikami hakerskimi, przesyłając PR-y do HackTricks i HackTricks Cloud na GitHubie.
Portale
Listę portali Microsoft znajdziesz na https://msportals.io/
Surowe żądania
Azure API za pomocą Powershell
Uzyskaj access_token z IDENTITY_HEADER i IDENTITY_ENDPOINT: system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:$IDENTITY_HEADER');
.
Następnie zapytaj Azure REST API, aby uzyskać subscription ID i więcej.
$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
Instalacja
pip install azure
pip install azure-mgmt
pip install azure-mgmt-resource
pip install azure-mgmt-compute
pip install azure-mgmt-network
pip install azure-mgmt-storage
pip install azure-mgmt-web
pip install azure-mgmt-sql
pip install azure-mgmt-keyvault
pip install azure-mgmt-dns
pip install azure-mgmt-rdbms
pip install azure-mgmt-cosmosdb
pip install azure-mgmt-containerregistry
pip install azure-mgmt-containerservice
pip install azure-mgmt-redis
pip install azure-mgmt-eventhub
pip install azure-mgmt-iothub
pip install azure-mgmt-servicebus
pip install azure-mgmt-trafficmanager
pip install azure-mgmt-cdn
pip install azure-mgmt-search
pip install azure-mgmt-monitor
pip install azure-mgmt-loganalytics
pip install azure-mgmt-automation
pip install azure-mgmt-devtestlabs
pip install azure-mgmt-batch
pip install azure-mgmt-datalake-store
pip install azure-mgmt-datalake-analytics
pip install azure-mgmt-datamigration
pip install azure-mgmt-hdinsight
pip install azure-mgmt-machinelearningcompute
pip install azure-mgmt-recoveryservices
pip install azure-mgmt-recoveryservicesbackup
pip install azure-mgmt-scheduler
pip install azure-mgmt-servicefabric
pip install azure-mgmt-signalr
pip install azure-mgmt-sqlvirtualmachine
pip install azure-mgmt-storageimportexport
pip install azure-mgmt-subscription
pip install azure-mgmt-synapse
pip install azure-mgmt-timeseriesinsights
pip install azure-mgmt-virtualwan
pip install azure-mgmt-policyinsights
pip install azure-mgmt-managedservices
pip install azure-mgmt-managementgroups
pip install azure-mgmt-marketplaceordering
pip install azure-mgmt-mixedreality
pip install azure-mgmt-netapp
pip install azure-mgmt-security
pip install azure-mgmt-serialconsole
pip install azure-mgmt-signalr
pip install azure-mgmt-sqlvirtualmachine
pip install azure-mgmt-storageimportexport
pip install azure-mgmt-subscription
pip install azure-mgmt-synapse
pip install azure-mgmt-timeseriesinsights
pip install azure-mgmt-virtualwan
pip install azure-mgmt-policyinsights
pip install azure-mgmt-managedservices
pip install azure-mgmt-managementgroups
pip install azure-mgmt-marketplaceordering
pip install azure-mgmt-mixedreality
pip install azure-mgmt-netapp
pip install azure-mgmt-security
pip install azure-mgmt-serialconsole
Użycie
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient
from azure.mgmt.storage import StorageManagementClient
from azure.mgmt.web import WebSiteManagementClient
from azure.mgmt.sql import SqlManagementClient
from azure.mgmt.keyvault import KeyVaultManagementClient
from azure.mgmt.dns import DnsManagementClient
from azure.mgmt.rdbms import mysql, postgresql
from azure.mgmt.cosmosdb import CosmosDBManagementClient
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
from azure.mgmt.containerservice import ContainerServiceClient
from azure.mgmt.redis import RedisManagementClient
from azure.mgmt.eventhub import EventHubManagementClient
from azure.mgmt.iothub import IotHubClient
from azure.mgmt.servicebus import ServiceBusManagementClient
from azure.mgmt.trafficmanager import TrafficManagerManagementClient
from azure.mgmt.cdn import CdnManagementClient
from azure.mgmt.search import SearchManagementClient
from azure.mgmt.monitor import MonitorManagementClient
from azure.mgmt.loganalytics import LogAnalyticsManagementClient
from azure.mgmt.automation import AutomationClient
from azure.mgmt.devtestlabs import DevTestLabsClient
from azure.mgmt.batch import BatchManagementClient
from azure.mgmt.datalake.store import DataLakeStoreAccountManagementClient
from azure.mgmt.datalake.analytics import DataLakeAnalyticsAccountManagementClient
from azure.mgmt.datamigration import DataMigrationManagementClient
from azure.mgmt.hdinsight import HDInsightManagementClient
from azure.mgmt.machinelearningcompute import MachineLearningComputeManagementClient
from azure.mgmt.recoveryservices import RecoveryServicesClient
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
from azure.mgmt.scheduler import SchedulerManagementClient
from azure.mgmt.servicefabric import ServiceFabricManagementClient
from azure.mgmt.signalr import SignalRManagementClient
from azure.mgmt.sqlvirtualmachine import SqlVirtualMachineManagementClient
from azure.mgmt.storageimportexport import StorageImportExportManagementClient
from azure.mgmt.subscription import SubscriptionClient
from azure.mgmt.synapse import SynapseManagementClient
from azure.mgmt.timeseriesinsights import TimeSeriesInsightsManagementClient
from azure.mgmt.virtualwan import VirtualWANManagementClient
from azure.mgmt.policyinsights import PolicyInsightsClient
from azure.mgmt.managedservices import ManagedServicesClient
from azure.mgmt.managementgroups import ManagementGroupsAPI
from azure.mgmt.marketplaceordering import MarketplaceOrderingAgreements
from azure.mgmt.mixedreality import MixedRealityClient
from azure.mgmt.netapp import NetAppManagementClient
from azure.mgmt.security import SecurityCenter
from azure.mgmt.serialconsole import SerialConsoleClient
# Uwierzytelnianie
credentials = ServicePrincipalCredentials(
client_id='YOUR_CLIENT_ID',
secret='YOUR_SECRET',
tenant='YOUR_TENANT_ID'
)
# Klient zarządzania zasobami
resource_client = ResourceManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania obliczeniami
compute_client = ComputeManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania siecią
network_client = NetworkManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania magazynem
storage_client = StorageManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania stronami internetowymi
web_client = WebSiteManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania SQL
sql_client = SqlManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Key Vault
keyvault_client = KeyVaultManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania DNS
dns_client = DnsManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania MySQL
mysql_client = mysql.MySQLManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania PostgreSQL
postgresql_client = postgresql.PostgreSQLManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania CosmosDB
cosmosdb_client = CosmosDBManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania rejestrami kontenerów
containerregistry_client = ContainerRegistryManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania usługami kontenerowymi
containerservice_client = ContainerServiceClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Redis
redis_client = RedisManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Event Hub
eventhub_client = EventHubManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania IoT Hub
iothub_client = IotHubClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Service Bus
servicebus_client = ServiceBusManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Traffic Manager
trafficmanager_client = TrafficManagerManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania CDN
cdn_client = CdnManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania wyszukiwaniem
search_client = SearchManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania monitorowaniem
monitor_client = MonitorManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania logami analitycznymi
loganalytics_client = LogAnalyticsManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania automatyzacją
automation_client = AutomationClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania laboratoriami testowymi
devtestlabs_client = DevTestLabsClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania zadaniami wsadowymi
batch_client = BatchManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Data Lake Store
datalake_store_client = DataLakeStoreAccountManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Data Lake Analytics
datalake_analytics_client = DataLakeAnalyticsAccountManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania migracją danych
datamigration_client = DataMigrationManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania HDInsight
hdinsight_client = HDInsightManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania obliczeniami uczenia maszynowego
machinelearningcompute_client = MachineLearningComputeManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania usługami odzyskiwania
recoveryservices_client = RecoveryServicesClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania kopią zapasową usług odzyskiwania
recoveryservicesbackup_client = RecoveryServicesBackupClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania harmonogramem
scheduler_client = SchedulerManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Service Fabric
servicefabric_client = ServiceFabricManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania SignalR
signalr_client = SignalRManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania maszynami wirtualnymi SQL
sqlvirtualmachine_client = SqlVirtualMachineManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania importem/eksportem magazynu
storageimportexport_client = StorageImportExportManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania subskrypcjami
subscription_client = SubscriptionClient(credentials)
# Klient zarządzania Synapse
synapse_client = SynapseManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Time Series Insights
timeseriesinsights_client = TimeSeriesInsightsManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Virtual WAN
virtualwan_client = VirtualWANManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Policy Insights
policyinsights_client = PolicyInsightsClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania usługami zarządzanymi
managedservices_client = ManagedServicesClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania grupami zarządzania
managementgroups_client = ManagementGroupsAPI(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania zamówieniami Marketplace
marketplaceordering_client = MarketplaceOrderingAgreements(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania Mixed Reality
mixedreality_client = MixedRealityClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania NetApp
netapp_client = NetAppManagementClient(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania bezpieczeństwem
security_client = SecurityCenter(credentials, 'YOUR_SUBSCRIPTION_ID')
# Klient zarządzania konsolą szeregową
serialconsole_client = SerialConsoleClient(credentials, 'YOUR_SUBSCRIPTION_ID')
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"])
lub wewnątrz funkcji Python:
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)
Lista Usług
Strony w tej sekcji są uporządkowane według usług Azure. Znajdziesz tam informacje o usłudze (jak działa i jakie ma możliwości) oraz jak enumerować każdą usługę.
Wspieraj HackTricks
Sprawdź plany subskrypcji!
Dołącz do 💬 grupy Discord lub grupy telegram albo śledź nas na Twitterze 🐦 @hacktricks_live.
Dziel się trikami hackingowymi, przesyłając PR-y do HackTricks i HackTricks Cloud repozytoriów na githubie.
Last updated