0

Im going through the beginner hackerone ctfs and Im trying to crack the Micro-CMS v2. There is a login page that is vulnerable to an SQL injection. The query goes like this:

'SELECT password FROM admins WHERE username=\'%s\'' % request.form['username'].replace('%', '%%')

In the username field I input ' UNION SELECT '123' AS password WHERE '1'='1 but then it returns this error

ProgrammingError: (1064, "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 'WHERE '1'='1'' at line 1")

I tried commenting it out with --' or usingg WHERE 1=1' instead but nothing seamed to work

1 Answers1

0

Maybe try to put UNION' or 1=1; -- in the username field.

So the query would become like this:

SELECT password FROM admins WHERE username='UNION' or 1=1; --

The result of this query would output all values in the password field.

Chris Albert
  • 2,462
  • 8
  • 27
  • 31