Az - Unauthenticated Enum & Initial Entry

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin

Azure Kiracı

Kiracı Keşfi

Bazı herkese açık Azure API’leri vardır; saldırgan sadece kiracının alan adını bilerek daha fazla bilgi toplamak için bu API’leri sorgulayabilir.
API’yi doğrudan sorgulayabilir veya PowerShell kütüphanesi AADInternals (Install-Module AADInternals) kullanabilirsiniz:

  • Tenant ID dahil oturum açma bilgileri
  • Get-AADIntTenantID -Domain <domain> (main API login.microsoftonline.com/<domain>/.well-known/openid-configuration)
  • Kiracıdaki tüm geçerli alan adları
  • Get-AADIntTenantDomains -Domain <domain> (main API autodiscover-s.outlook.com/autodiscover/autodiscover.svc)
  • Kullanıcının oturum bilgileri. Eğer NameSpaceType Managed ise, bu EntraID kullanıldığı anlamına gelir
  • Get-AADIntLoginInformation -UserName <UserName> (main API login.microsoftonline.com/GetUserRealm.srf?login=<UserName>)

Bir Azure kiracısının tüm bilgilerini AADInternals içinden sadece bir komutla sorgulayabilirsiniz:

# Doesn't work in macos because 'Resolve-DnsName' doesn't exist
Invoke-AADIntReconAsOutsider -DomainName corp.onmicrosoft.com | Format-Table

## Output Example of the Azure tenant info:

Tenant brand:       Company Ltd
Tenant name:        company
Tenant id:          1937e3ab-38de-a735-a830-3075ea7e5b39
DesktopSSO enabled: True

Name                           DNS   MX    SPF  Type      STS
----                           ---   --    ---  ----      ---
company.com                   True  True  True  Federated sts.company.com
company.mail.onmicrosoft.com  True  True  True  Managed
company.onmicrosoft.com       True  True  True  Managed
int.company.com              False False False  Managed

It’s possible to observe details about the tenant’s name, ID, and “brand” name. Additionally, the status of the Desktop Single Sign-On (SSO), also known as Seamless SSO, is displayed. When enabled, this feature facilitates the determination of the presence (enumeration) of a specific user within the target organization.

Moreover, the output presents the names of all verified domains associated with the target tenant, along with their respective identity types. In the case of federated domains, the Fully Qualified Domain Name (FQDN) of the identity provider in use, typically an ADFS server, is also disclosed. The “MX” column specifies whether emails are routed to Exchange Online, while the “SPF” column denotes the listing of Exchange Online as an email sender. It is important to note that the current reconnaissance function does not parse the “include” statements within SPF records, which may result in false negatives.

User Enumeration

Tip

Note that even if a tenant is using several emails for the same user, the kullanıcı adı benzersizdir. This means that it’ll only work with the domain the user has associated and not with the other domains.

It’s possible to bir tenant içinde bir kullanıcı adının mevcut olup olmadığını kontrol etmek. This includes also misafir kullanıcıları, whose username is in the format:

<email>#EXT#@<tenant name>.onmicrosoft.com

E-posta, kullanıcı e-posta adresidir; “@” yerine alt çizgi “_” kullanılır.

With AADInternals, kullanıcının var olup olmadığını kolayca kontrol edebilirsiniz:

# Check does the user exist
Invoke-AADIntUserEnumerationAsOutsider -UserName "user@company.com"

Çevirmemi istediğiniz README.md içeriğini buraya yapıştırın. Kod blokları, linkler, yollar, tag’ler ve teknik terimler (pentesting, leak, bulut/SaaS platform isimleri vb.) çevrilmeyecek; geri kalan metni Türkçeye çevirip orijinal markdown/html yapısını koruyacağım.

UserName         Exists
--------         ------
user@company.com True

Ayrıca her satırda bir e-posta adresi bulunan bir metin dosyası da kullanabilirsiniz:

user@company.com
user2@company.com
admin@company.com
admin2@company.com
external.user_gmail.com#EXT#@company.onmicrosoft.com
external.user_outlook.com#EXT#@company.onmicrosoft.com
# Invoke user enumeration
Get-Content .\users.txt | Invoke-AADIntUserEnumerationAsOutsider -Method Normal

Şu anda seçilebilecek 4 farklı enumeration yöntemi var. Bilgiyi Get-Help Invoke-AADIntUserEnumerationAsOutsider içinde bulabilirsiniz:

Aşağıdaki enumeration yöntemlerini destekler: Normal, Login, Autologon ve RST2.

  • Normal yöntemi şu anda görünüşe göre tüm tenant’larda çalışıyor. Önceden en az bir domain için Desktop SSO (aka Seamless SSO) etkinleştirilmiş olmasını gerektiriyordu.

  • Login yöntemi herhangi bir tenant ile çalışır, ancak enumeration sorguları Azure AD sign-in log’una başarısız login olayları olarak kaydedilecektir!

  • Autologon yöntemi artık tüm tenant’larda çalışıyor gibi görünmüyor. Muhtemelen DesktopSSO veya directory sync’in etkinleştirilmiş olmasını gerektirir.

Geçerli kullanıcı adlarını keşfettikten sonra bir kullanıcı hakkında bilgi almak için:

Get-AADIntLoginInformation -UserName root@corp.onmicrosoft.com

Bu script o365spray ayrıca bir email’in geçerli olup olmadığını tespit etmenizi sağlar.

git clone https://github.com/0xZDH/o365spray
cd o365spray
python3 -m pip install -r requirements.txt

# Check 1 email
python3 ./o365spray.py --enum -d carloshacktricks.onmicrosoft.com -u carlos
# Check a list of emails
python3 ./o365spray.py --enum -d carloshacktricks.onmicrosoft.com -U /tmp/users.txt

User Enumeration via Microsoft Teams

Başka iyi bir bilgi kaynağı Microsoft Teams.

Microsoft Teams’in API’si kullanıcı aramaya izin verir. Özellikle “user search” endpoint’leri externalsearchv3 ve searchUsers, Teams’e kayıtlı kullanıcı hesapları hakkında genel bilgi talep etmek için kullanılabilir.

API yanıtına bağlı olarak var olmayan kullanıcılar ile geçerli bir Teams aboneliğine sahip mevcut kullanıcılar ayırt edilebilir.

Script TeamsEnum belirli bir kullanıcı adı setini Teams API’ye karşı doğrulamak için kullanılabilir; ancak bunu kullanmak için Teams erişimi olan bir kullanıcı hesabına erişiminiz olması gerekir.

# Install
git clone https://github.com/lucidra-security/TeamsEnum
cd TeamsEnum
python3 -m pip install -r requirements.txt

# Login and ask for password
python3 ./TeamsEnum.py -a password -u <username> -f inputlist.txt -o teamsenum-output.json

Çevirmem için src/pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/README.md dosyasının içeriğini gönderin.

[-] user1@domain - Target user not found. Either the user does not exist, is not Teams-enrolled or is configured to not appear in search results (personal accounts only)
[+] user2@domain - User2 | Company (Away, Mobile)
[+] user3@domain - User3 | Company (Available, Desktop)

Ayrıca mevcut kullanıcıların aşağıdaki gibi kullanılabilirlik bilgilerini listelemek mümkündür:

  • Available
  • Away
  • DoNotDisturb
  • Busy
  • Offline

Bir ofis dışı mesajı yapılandırılmışsa, mesajı TeamsEnum kullanarak almak da mümkündür. Bir çıktı dosyası belirtilmişse, ofis dışı mesajlar otomatik olarak JSON dosyasına kaydedilir:

jq . teamsenum-output.json

Bu dosyanın içeriğine erişimim yok. Lütfen src/pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/README.md dosyasının içeriğini buraya yapıştırın; verilen kurallara uygun olarak Türkçeye çevireyim.

{
"email": "user2@domain",
"exists": true,
"info": [
{
"tenantId": "[REDACTED]",
"isShortProfile": false,
"accountEnabled": true,
"featureSettings": {
"coExistenceMode": "TeamsOnly"
},
"userPrincipalName": "user2@domain",
"givenName": "user2@domain",
"surname": "",
"email": "user2@domain",
"tenantName": "Company",
"displayName": "User2",
"type": "Federated",
"mri": "8:orgid:[REDACTED]",
"objectId": "[REDACTED]"
}
],
"presence": [
{
"mri": "8:orgid:[REDACTED]",
"presence": {
"sourceNetwork": "Federated",
"calendarData": {
"outOfOfficeNote": {
"message": "Dear sender. I am out of the office until March 23rd with limited access to my email. I will respond after my return.Kind regards, User2",
"publishTime": "2023-03-15T21:44:42.0649385Z",
"expiry": "2023-04-05T14:00:00Z"
},
"isOutOfOffice": true
},
"capabilities": ["Audio", "Video"],
"availability": "Away",
"activity": "Away",
"deviceType": "Mobile"
},
"etagMatch": false,
"etag": "[REDACTED]",
"status": 20000
}
]
}

Password Spraying / Brute-Force

Az - Password Spraying

Domain kullanan Azure Servisleri

Ayrıca, bu post: içinde belgelenenlere benzer yaygın azure alt alanlarında Azure services exposed aramayı deneyebilirsiniz.

  • App Services: azurewebsites.net
  • App Services – Management: scm.azurewebsites.net
  • App Services: p.azurewebsites.net
  • App Services: cloudapp.net
  • Storage Accounts-Files: file.core.windows.net
  • Storage Accounts-Blobs: blob.core.windows.net
  • Storage Accounts-Queues: queue.core.windows.net
  • Storage Accounts-Tables: table.core.windows.net
  • Databases-Redis: redis.cache.windows.net
  • Databases-Cosmos DB: documents.azure.com
  • Databases-MSSQL: database.windows.net
  • Key Vaults: vault.azure.net
  • Microsoft Hosted Domain: onmicrosoft.com
  • Email: mail.protection.outlook.com
  • SharePoint: sharepoint.com
  • CDN: azureedge.net
  • Search Appliance: search.windows.net
  • API Services: azure-api.net

Böyle bir amaç için MicroBurst içindeki bir yöntemi kullanabilirsiniz. Bu fonksiyon, temel domain adını (ve birkaç permutasyonu) birkaç azure domains: içinde arayacaktır:

Import-Module .\MicroBurst\MicroBurst.psm1 -Verbose
Invoke-EnumerateAzureSubDomains -Base corp -Verbose

Phishing

Dosya Sistemi Credentials

az cli birçok ilginç bilgiyi <HOME>/.Azure içinde saklar:

  • azureProfile.json geçmişte oturum açmış kullanıcılar hakkında bilgi içerir
  • clouds.config abonelikler hakkında bilgi içerir
  • service_principal_entries.json uygulamaların credentials (tenant id, clients and secret) içerir
  • msal_token_cache.json access tokens and refresh tokens içerir

macOS ve linux’ta bu dosyalar korunmasız olarak düz metin halinde saklanır.

Referanslar

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin