CTF Hacking
CTF Hacking
Exploit
When we try to login into the website using the username jim404 with some random
Password like 'Password@123' or 'Password123', we get the response from the website
'Login Faild. Please try again'
Looking at the source code of the Web page, we can see that there is a poor input validation
check implemented for the input that we are giving as the user into the server
<script>
async function login() {
$("#result").fadeOut("fast");
response = await fetch("/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"username": $("#username").val(),
"password": $("#password").val()
}),
});
And because of this, we can try and capture our input in Burpsuite to able to inject some
SQL Queries into the input box for authenticating our self as the user jim404 .
In burpsuite, we can see the username and the Password to be passed in clear text to the
login file which is present in the server's end, send this response to the Repeater, then
send this same request to the server.
Here we can see that in the response section of the repeater, there is the DEBUG Query
being displayed to us, where the username is being passed in the raw format as it was enter
by the user and the Password is undergoing a Hash to be compared to the database.
We can also see that the query is using a single quote ( ' ) for containing our input, so,
append this Query after the user name ' AND '1'='1'; -- (with the space in the end of --
), this will comment out the rest of the code that is being entered and will display everything
related to the user jim404 . Including the Flag.
Video write-ups
Pranava Rao: https://www.youtube.com/watch?v=M0w3-7BQ06Y&t=275s (Cracking ZIP
Files and SQL Injection | METACTF | CyberPranava)