Data pilferage
Introduction
Once access to an RDS instance is obtained, either through a standard terminal due to the availability of a password or through a vulnerability in an application that talks to an RDS, it is almost second nature for an attacker to dump data from the database.
Multiple tools are available that allow you to pilfer data through an application via a vulnerbaility like SQL Injection. The AWS console and cli also provide the ability to find and mount RDS snapshots. A password reset on these snapshots can then be used to obtain access to the data they store.
What are we going to cover?
In this chapter we shall see how we can use tools like SQLmap to dump data from a vulnerable application. We shall also see how we can use the aws cli and the Amazon API to restore an RDS snapshot into an instance and then gain access to the data that it contains.
Steps to attack
Attack 1 - Dumping entire RDS database using SQLMap
We will dump all the data from the vulnerable application using SQLMap
First let's confirm if the application is reachable
Next we fire up SQLMap and attack the vulnerable parameter. Remember this data is coming from the RDS which is a different asset than the AWS EC2 instance running the web application
Attack 2 - Stealing from RDS Snapshots
RDS snapshots can be made public. If the full snapshot identifier is available, this snapshot can be mounted in your own instance.
Partial snapshot identifiers can be searched from the AWS console
Once the snapshot is found, let's restore the snapshot as a new instance
Once the snapshot is restored, we will check if the instance has been created so that we can connect to it
You may have to wait for sometime as the instance is backed up after creation. The status when you run describe-db-instances tells you whether the instance is available or backing-up. The value of "DBInstanceStatus" should read "available".
Finally, we will reset the credentials of the MasterUsername and login into the instance
This operation also takes some time. You can check the status of the RDS instance by running the aws rds describe-db-instances
covered above
Run the following command from the cloudhacker machine to see if the MySQL RDS is up and accesible
If the endpoint is not visible, then the port 3306 will have to be opened on the Security Group for the instance.
In RDS console, click on the recoverdb instance
Click on the Security Group
Add an Inbound rule for port 3306 TCP for Cloudhacker IP
Connect to the endpoint using the mysql client command
Once you are connected using the mysql client, you can pilferage data
Additional references
Last updated