Task 1: Get Familiar With SQL Statements: Docker PS' Showing The Two Containers
Task 1: Get Familiar With SQL Statements: Docker PS' Showing The Two Containers
‘docker exec -it 790 /bin/bash’ gives a shell inside the container, then by using mysql client we have
connected to sqllab_users database.
‘show tables’ will show all the tables in the sqllab_users database.
We are going login into the webpage which is vulnerable to sql injection.
We have successfully logged in and got all data stored in the database.
Task 2.2: SQL Injection Attack from command line
Now we are using command-line tool which is curl ,it will send HTTP GET request to the URL.
We can see that we have got the same results here as well, all the data from database is showing.
The discovery failed because of a special protection mechanism implemented in MySQL, mysq_query
does not allow submitting multiple requests, Causing two consecutive requests for us to report an
error.
As we can see that Alice has 199901 salary, mean our code is successfully injected.
Here we are changing the password for the boby profile ,now the new password for the boby profile
is “hacked”
Username=Boby, Password=hacked
We have successfully logged into the boby account with the above credentials.
In the previous tasks, we learned how to attack database by the SQL injection code. In this task, you
are asked to defend against the previous SQL injection attack you performed.
as task 2.1. to see whether you can login in without password. Figure 17 shows modifying the code.
Figure 18 shows the result after you have executed the counter measurement.
Here we can see that after applying prepared statements into the webpage,
Now its not looking vulnerable to the simple sql injection commands.