Concepts / Web injection and scripting

Web injection and scripting

SQL injection

Also called SQLi

Changing what a database query does by sending input that is pasted into the query as code, not data.

The input becomes part of the query
The input becomes part of the query

The app pastes the input into the SQL text, so its quote ends the string and -- turns the password check into a comment.

SQL injection is input that changes a query because the app pastes it into the SQL text: ... WHERE username = '<you>'. A quote closes the string and -- comments the rest away, so admin' -- logs in with no password and ' OR 1=1 -- matches every row. One field can read a whole table. The fix is a [[parameterised-query]]: fixed SQL, input bound as a value.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab