当前位置:网站首页>SQL注入漏洞(繞過篇)
SQL注入漏洞(繞過篇)
2022-06-25 11:18:00 【errorr0】
在學習完了SQL注入的原理、SQL注入的類型後那麼可以說SQL注入已經大致了解了,但事實是現實中開發人員不可能讓你這麼簡單就攻擊到數據庫,他們一般會對已輸入或可輸入的數據做一定限制,這篇文章我主要對SQL注入中代碼或者waf過濾的繞過做一次總結。
大小寫繞過
這是最簡單也是最雞肋的繞過方式,可以利用的原因有兩個:SQL語句對大小寫不敏感、開發人員做的黑名單過濾過於簡單。

雙寫繞過
雙寫繞過的原理是後臺利用正則匹配到敏感詞將其替換為空。即如果過濾了select,我們輸入123select456 後會被檢測出敏感詞,最後替換得到的字符串由123select456 ---> 123456。這種過濾的繞過也很簡單即雙寫select即可,如:selselectect ---> select ,進行一次這樣的過濾就雙寫,兩次就三寫以此類推。看下面例子:

這裏很清楚的看到錯誤的信息,or應該是被過濾了,我們利用上面講的繞過方式,

成功了,這也就是雙寫繞過的方法,挺簡單的。
空格過濾
如果遇到空格被過濾了,主要的幾個思路都是想辦法找一個代替品,能代替空格的有幾個:
注釋繞過 /**/ :正常情况下只要這個沒有被過濾就一定能代替。
括號過濾 () :將所有的關鍵字都用括號括起來就可以達到替代空格分隔的作用如下,
正常:select * from user
括號:(select)*(from)(user)
url編碼:這種遇到可以試試。用%20代替空格或者用其他的url編碼
%09、%0a、%0b、%0c、%0d 、%a0、%00
回車換行替代:回車換行也可以用做分隔功能替代空格。
Tab替代:Tab可以做分隔功能。
注釋過濾
遇到我們平常用的 --+ 注釋過濾,我們可以用以下幾種注釋代替:
#、;%00、-- (兩個减號一個空格)
用其他數據閉合:
select * from user where id='1'
||
V
select * from user where id='1' or '1' ='1'
引號過濾
引號過濾有兩種全款,一種是不能出現引號、一種是會被轉義,轉義的處理方法上一篇已經說過了就是寬字節注入的繞過,如果是無法出現引號又必修得用引號,可以將參數的值和單引號或者雙引號綁定在一起然後轉換為16進制最後在輸入時在前加0x*****。
逗號過濾
有函數或者指令在使用時需要用到逗號,因此繞過逗號的方法因函數或指令的不同而不同。
substring()

不用在意函數,substr與substring差不多。可以看到從上面本應用逗號的情况到下面直接用from……for代替。
如果需要用到mid()函數,其中也有逗號繞過的方法與substring()相同,用from……for替代逗號。
limit 0,1
limit 0,1中存在逗號,那麼如果逗號被過濾了我們替代的方法是用offset,即

這裏要注意一下,如果使用了offset,原本逗號前後的數據要相互交換一下。
union
聯合注入中我們需要select 1,2,3,4……,而如果過濾了逗號這裏又該如何繞呢?這裏其實挺有意思的,聯合查詢select 1,2,3,4……經過測試可以單獨寫如下

括號後面的a、b、c是隨意命名的是省略了as的寫法,為什麼我要這麼寫?這樣寫就可以把逗號過濾,我們使用offset代替可以得到,

所以聯合查詢的逗號繞過是利用join代替。
等於號過濾
如果只過濾了等於號可以用以下代替
<> :不等於的意思 !=
regexp、like、rlike

邏輯運算符過濾
過濾了or、and、xor、not可以用相對應的字符代替:&&、||、| 、!

如果都不能用則可以考慮使用笛卡爾積(^),

這種可以直接不使用and or這些連接符。
編碼繞過
編碼繞過說實話傳統很少用上,但是有時他的利用真的就會出其不意,所以還是了解一下。
十六進制繞過


相似函數的互相替代
1)sleep() <-->benchmark()
2)ascii() <-–>hex()、bin(),替代之後再使用對應的進制轉string即可
3)group_concat() <–->concat_ws()
4)substr() <--> substring() <--> mid()
5)user() <--> @@user、datadir–>@@datadir
6)ord() <-–> ascii():這兩個函數在處理英文時作用相同,但是處理中文等時不一致。
參考:SQL注入繞過的姿勢_真的强啊!的博客-CSDN博客_sql注入from繞過
SQL注入時當and、or等字符被過濾了怎麼辦_litchi125的博客-CSDN博客_sql注入過濾and
SQL注入過濾的繞過_12622800的技術博客_51CTO博客
https://www.csdn.net/tags/MtTaEgwsMTY0OTk1LWJsb2cO0O0O.html#2_12
边栏推荐
- ZABBIX distributed system monitoring
- Ladder Side-Tuning:预训练模型的“过墙梯”
- 某APP中模拟器检测分析
- 撸一个随机数生成器
- 1-7snapshots and clones in VMWare
- [shangyun boutique] energy saving and efficiency improvement! Accelerating the transformation of "intelligent manufacturing" in the textile industry
- Kingbasees plug-in DBMS of Jincang database_ UTILITY
- Network remote access using raspberry pie
- 3 Questions par jour (3) - vérifier l'existence d'entiers et de leurs doubles
- SystemVerilog(十三)-枚举数据类型
猜你喜欢

Open source invites you to participate in the openssf Open Source Security Online Seminar

基于Minifilter框架的双缓冲透明加解密驱动 课程论文+项目源码

网络远程访问的方式使用树莓派

A difficult mathematical problem baffles two mathematicians

Chinese translation of IMA Lazarus' the new giant, the goddess of Liberty

金仓KFS数据级联场景部署

Technical practice and development trend of video conference all in one machine

c盘使用100%清理方法

Geographic location system based on openstreetmap+postgis paper documents + reference papers + project source code and database files

C disk uses 100% cleaning method
随机推荐
Software testing to avoid being dismissed during the probation period
Android: generic mapping analysis of gson and JSON in kotlin
[shangyun boutique] energy saving and efficiency improvement! Accelerating the transformation of "intelligent manufacturing" in the textile industry
Garbage collection mechanism
Technical practice and development trend of video conference all in one machine
CMU提出NLP新范式—重构预训练,高考英语交出134高分
从GEE中免费获取全球人类住区层 (GHSL) 数据集
Five types of questions about network planning
Detection and analysis of simulator in an app
Checking whether the double value is an integer - Swift - checking if a double value is an integer - swift
Arrays.asList()
At 16:00 today, Mr. sunxiaoming, a researcher of the Institute of computing, Chinese Academy of Sciences, took you into the quantum world
Upload and modify the use of avatars
Application of global route guard
Sign up to open the third session of the "flying oar hacker marathon". It's been a long time
Introduction to socket UDP and TCP
Continuous delivery jenkinsfile syntax
2022 PMP project management examination agile knowledge points (2)
撸一个随机数生成器
中国信通院沈滢:字体开源协议——OFL V1.1介绍及合规要点分析