SQLi

SQL injection in general

SQL Injection is when an attacker enters a malicious or malformed query to either retrieve or tamper data from a database. And in some cases, log into accounts.


Method 1: true statement

In an example navigate yourself to a log in. Intercept the request and edit the login fields like this:

image.png

{“email”:”’ or 1=1--“,”password”:”a”}

Why does this work?

Method 2: do not force to be true

Similar to what we did in Example 1, we will now log into Bender's account! Capture the login request again, but this time we will put:

bender@juice-sh.op'--

as the email.

image.png

Well, as the email address is valid (which will return true), we do not need to force it to be true.
Thus we are able to use '-- to bypass the login system. Note the 1=1 can be used when the email or username is not known or invalid.


Revision #3
Created 9 July 2022 14:52:53 by Togoboi
Updated 10 July 2022 08:30:40 by Togoboi