Az - Unauthenticated Enum & Initial Entry

HackTricks 지원

Azure 테넌트

테넌트 열거

테넌트의 도메인을 알고 있는 공격자는 일부 공개 Azure API를 쿼리하여 해당 테넌트에 대한 자세한 정보를 수집할 수 있습니다. API를 직접 쿼리하거나 PowerShell 라이브러리 AADInternals를 사용할 수 있습니다:

API정보AADInternals 함수

login.microsoftonline.com/<domain>/.well-known/openid-configuration

테넌트 ID를 포함한 로그인 정보

Get-AADIntTenantID -Domain <domain>

autodiscover-s.outlook.com/autodiscover/autodiscover.svc

테넌트의 모든 도메인

Get-AADIntTenantDomains -Domain <domain>

login.microsoftonline.com/GetUserRealm.srf?login=<UserName>

테넌트의 로그인 정보, 테넌트 이름 및 도메인을 포함한 인증 유형. If NameSpaceTypeManaged이면 AzureAD가 사용됨.

Get-AADIntLoginInformation -UserName <UserName>

login.microsoftonline.com/common/GetCredentialType

데스크톱 SSO 정보를 포함한 로그인 정보

Get-AADIntLoginInformation -UserName <UserName>

AADInternals 라이브러리의 한 명령어로 Azure 테넌트의 모든 정보를 쿼리할 수 있습니다:

Invoke-AADIntReconAsOutsider -DomainName corp.onmicrosoft.com | Format-Table

Azure 테넌트 정보의 출력 예시:

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

테넌트의 이름, ID 및 "브랜드" 이름에 대한 세부 정보를 관찰할 수 있습니다. 또한 데스크톱 단일 로그인(SSO)의 상태, 일명 Seamless SSO도 표시됩니다. 이 기능이 활성화되면 이 기능을 통해 특정 사용자의 존재(열거)를 대상 조직 내에서 확인할 수 있습니다.

또한 출력에는 대상 테넌트와 관련된 모든 확인된 도메인의 이름과 해당 식별 유형이 표시됩니다. 연합 도메인의 경우 사용 중인 식별 공급자의 완전한 도메인 이름(FQDN)(일반적으로 ADFS 서버)도 공개됩니다. "MX" 열은 이메일이 Exchange Online으로 라우팅되는지 여부를 지정하며, "SPF" 열은 Exchange Online이 이메일 발신자로 나열되어 있는지를 나타냅니다. 현재의 정찰 기능은 SPF 레코드 내의 "include" 문을 구문 분석하지 않으므로 잘못된 부정적 결과가 발생할 수 있음에 유의해야 합니다.

사용자 열거

테넌트 내에서 사용자 이름이 존재하는지 확인할 수 있습니다. 이는 게스트 사용자를 포함하며, 게스트 사용자의 사용자 이름 형식은 다음과 같습니다:

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

이메일은 사용자의 이메일 주소이며 "@"가 밑줄 "_"로 대체됩니다.

AADInternals를 사용하면 사용자가 존재하는지 여부를 쉽게 확인할 수 있습니다:

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

Azure Unauthenticated Enumeration and Initial Entry

Introduction

In this section, we will cover the techniques used to perform unauthenticated enumeration and gain initial access in Azure environments. Unauthenticated enumeration involves gathering information from publicly available sources without the need for valid credentials. This information can then be used to identify potential entry points and security weaknesses in the Azure environment.

Tools and Techniques

1. Cloud Metadata API

Azure provides a metadata service that can be accessed without authentication. This service can be used to retrieve valuable information about the Azure instance, such as its location, resource group, and network configuration. By querying the metadata service, an attacker can gather intelligence to aid in further exploitation.

2. DNS Enumeration

Performing DNS enumeration can reveal subdomains and other domain-related information that may be useful for identifying targets within the Azure environment. Tools like dnsrecon and dnsenum can be used to gather this information without authentication.

3. Service Principal Enumeration

Service principals in Azure are used to authenticate applications and services. Enumerating service principals can provide insights into the permissions and roles assigned to different applications, potentially revealing misconfigurations that could be exploited by an attacker.

4. Storage Account Enumeration

Azure storage accounts may contain sensitive data or misconfigured access controls that could lead to unauthorized access. Enumerating storage accounts can help identify such vulnerabilities and assist in gaining initial entry into the Azure environment.

Conclusion

Unauthenticated enumeration is a critical phase in the reconnaissance process of a penetration test. By leveraging publicly available information and tools, attackers can gather valuable intelligence to identify potential attack vectors and security gaps in Azure environments. It is essential for organizations to regularly assess and secure their Azure environments to prevent unauthorized access and data breaches.

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

당신은 또한 한 줄에 하나의 이메일 주소가 포함된 텍스트 파일을 사용할 수 있습니다:

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

세 가지 다른 열거 방법을 선택할 수 있습니다:

방법설명

Normal

이는 위에서 언급한 GetCredentialType API를 가리킵니다. 기본 방법입니다.

Login

이 방법은 사용자로 로그인을 시도합니다. 참고: 쿼리는 로그인 로그에 기록됩니다.

Autologon

이 방법은 사용자로 자동 로그인 엔드포인트를 통해 로그인을 시도합니다. 쿼리는 로그인 로그에 기록되지 않습니다! 따라서, 패스워드 스프레이 및 브루트포스 공격에도 잘 작동합니다.

유효한 사용자 이름을 발견한 후 사용자에 대한 정보를 얻을 수 있습니다:

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

스크립트 o365creeper를 사용하면 이메일이 유효한지 확인할 수도 있습니다.

# Put in emails.txt emails such as:
# - root@corp.onmicrosoft.com
python.exe .\o365creeper\o365creeper.py -f .\emails.txt -o validemails.txt

Microsoft Teams를 통한 사용자 열거

Microsoft Teams는 정보를 얻기 좋은 소스입니다.

Microsoft Teams의 API를 사용하면 사용자를 검색할 수 있습니다. 특히 externalsearchv3searchUsers와 같은 "사용자 검색" 엔드포인트를 사용하여 Teams에 등록된 사용자 계정에 대한 일반 정보를 요청할 수 있습니다.

API 응답에 따라 존재하지 않는 사용자와 유효한 Teams 구독을 가진 기존 사용자를 구별할 수 있습니다.

TeamsEnum 스크립트를 사용하여 주어진 사용자 이름 집합을 Teams API에 대해 유효성을 검사할 수 있습니다.

python3 TeamsEnum.py -a password -u <username> -f inputlist.txt -o teamsenum-output.json

Azure Unauthenticated Enumeration and Initial Entry

Introduction

In this section, we will cover the techniques used to perform unauthenticated enumeration and gain initial access in Azure environments. Unauthenticated enumeration involves gathering information from publicly available sources without the need for valid credentials. This information can then be used to identify potential entry points and vulnerabilities that can be exploited to gain initial access to the Azure environment.

Tools and Techniques

1. Enumerating Azure Subdomains

One common technique is to use tools like Sublist3r or Amass to discover subdomains associated with the target Azure environment. By identifying subdomains, an attacker can uncover additional entry points that may have weaker security controls compared to the main domain.

2. Identifying Azure Storage Accounts

Another important aspect is identifying Azure storage accounts that may be publicly accessible. Tools like azurite or manual inspection can help in identifying storage accounts that have misconfigured access controls, allowing an attacker to view, modify, or delete data stored in the account.

3. Discovering Azure Web Applications

Using tools like dirb or Gobuster, an attacker can discover web applications hosted within the Azure environment. By identifying these applications, the attacker can look for common vulnerabilities such as misconfigured permissions, outdated software, or known security issues that can be exploited to gain access.

Conclusion

Unauthenticated enumeration is a critical phase in the reconnaissance process, allowing attackers to gather valuable information without alerting the target organization. By leveraging tools and techniques to identify potential entry points and vulnerabilities, an attacker can increase their chances of successfully gaining initial access to Azure environments.

[-] 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)

또한 다음과 같은 기존 사용자의 가용성 정보를 열람할 수 있습니다:

  • 사용 가능

  • 자리 비움

  • 방해 금지

  • 바쁨

  • 오프라인

업무 외 메시지가 구성되어 있는 경우 TeamsEnum을 사용하여 메시지를 검색할 수도 있습니다. 출력 파일이 지정된 경우, 업무 외 메시지는 자동으로 JSON 파일 내에 저장됩니다:

jq . teamsenum-output.json

Azure Unauthenticated Enumeration and Initial Entry

Introduction

In this section, we will cover the techniques to perform unauthenticated enumeration and gain initial access in Azure environments. By leveraging publicly available information and tools, an attacker can gather valuable information about the target Azure environment without the need for authentication. This information can then be used to identify potential entry points and security weaknesses that can be exploited to gain initial access.

Enumeration Techniques

1. DNS Enumeration

DNS enumeration involves querying DNS servers to gather information about the target domain, such as subdomains, mail servers, and other DNS records. Tools like dnsrecon and dnsenum can be used to perform DNS enumeration and gather valuable information that can be used in further attacks.

2. Service Enumeration

Service enumeration involves identifying services running in the Azure environment, such as web servers, databases, and other applications. Tools like nmap and Masscan can be used to scan for open ports and identify services running on those ports.

3. Storage Account Enumeration

Azure storage accounts can often contain sensitive data such as configuration files, backups, and other valuable information. Tools like azcopy and Azure Storage Explorer can be used to enumerate storage accounts and identify potentially sensitive data that can be accessed without authentication.

Initial Entry Points

Once valuable information has been gathered through enumeration, the attacker can identify potential entry points to gain initial access to the Azure environment. Common entry points include:

  • Weak or default credentials on services such as web servers, databases, and storage accounts.

  • Misconfigurations that allow unauthorized access to sensitive data or resources.

  • Vulnerabilities in applications or services running in the Azure environment that can be exploited to gain unauthorized access.

By leveraging the information gathered during enumeration and identifying these entry points, an attacker can gain initial access to the Azure environment and further compromise the security of the target organization.

{
"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
}
]
}

Azure Services

Azure 테넌트가 사용하는 도메인을 알았으므로 이제 노출된 Azure 서비스를 찾아보는 것이 중요합니다.

이러한 목표를 달성하기 위해 MicroBust에서 제공하는 방법을 사용할 수 있습니다. 이 기능은 여러 Azure 서비스 도메인에서 기본 도메인 이름(및 몇 가지 순열)을 검색할 것입니다:

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

오픈 스토리지

InvokeEnumerateAzureBlobs.ps1와 같은 도구를 사용하여 오픈 스토리지를 발견할 수 있습니다. 이 도구는 Microburst/Misc/permitations.txt 파일을 사용하여 순열을 생성하여 오픈 스토리지 계정을 찾으려고 시도합니다.

Import-Module .\MicroBurst\MicroBurst.psm1
Invoke-EnumerateAzureBlobs -Base corp
[...]
https://corpcommon.blob.core.windows.net/secrets?restype=container&comp=list
[...]

# Access https://corpcommon.blob.core.windows.net/secrets?restype=container&comp=list
# Check: <Name>ssh_info.json</Name>
# Access then https://corpcommon.blob.core.windows.net/secrets/ssh_info.json

SAS URLs

공유 액세스 서명 (SAS) URL은 특정 스토리지 계정의 일부 (전체 컨테이너, 파일 등)에 대한 액세스를 제공하는 URL이며 일부 특정 권한 (읽기, 쓰기 등)을 가지고 있습니다. 유출된 것을 발견하면 민감한 정보에 액세스할 수 있습니다. 다음과 같이 보입니다 (이것은 컨테이너에 액세스하기 위한 것이며, 파일에 대한 액세스를 부여하는 경우 URL의 경로에도 해당 파일이 포함될 것입니다):

https://<storage_account_name>.blob.core.windows.net/newcontainer?sp=r&st=2021-09-26T18:15:21Z&se=2021-10-27T02:14:21Z&spr=https&sv=2021-07-08&sr=c&sig=7S%2BZySOgy4aA3Dk0V1cJyTSIf1cW%2Fu3WFkhHV32%2B4PE%3D

Storage Explorer를 사용하여 데이터에 액세스합니다

자격 증명 침해

피싱

비밀번호 스프레이 / 브루트 포스

Az - Password Spraying

참고 자료

HackTricks 지원

Last updated