E
E
Egor2021-03-26 15:01:38
SQL
Egor, 2021-03-26 15:01:38

How to do SQL injection on MY server?

I decided to learn how to protect myself from SQL injections.
I immediately tried to test it on my server. There is a query that gets a user from the database by his id:

SELECT * FROM `users` WHERE `id` = '{$_POST['id']}'
. If you substitute id 1, you get . How can you perform a SQL injection by getting a user with id 2 as well? SELECT * FROM `users` WHERE `id` = '1'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
ayazer, 2021-03-26
@KenKup11

if id is equal to "1' or `id`='2" then you will get
SELECT * FROM `users` WHERE `id` = '1' or `id`='2'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question