This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
sql_injection [2019/10/01 11:23] acm |
sql_injection [2019/10/05 18:51] (current) acm |
||
---|---|---|---|
Line 11: | Line 11: | ||
SELECT password FROM users WHERE username=' | SELECT password FROM users WHERE username=' | ||
</ | </ | ||
- | Now let's say I'm a hacker who wants to get the passwords of all the users in the system, but I'm not quite sure what their usernames are. | + | Now let's say I'm a hacker who wants to get the passwords of all the users in the system, but I'm not quite sure what their usernames are. As a hacker I could type in something like: |
< | < | ||
- | OR ' | + | //Ignore the '/' |
+ | OR ' | ||
</ | </ | ||
+ | changing the query that retrieves the password to: | ||
+ | < | ||
+ | SELECT password FROM users WHERE username='' | ||
+ | </ | ||
+ | Since 1 = 1 is always true, and any OR statement with a clause that is always true will also always be true, this statement will return every password in the database. | ||
+ | === Batched SQL Statements === | ||
+ | Another more powerful form of SQL Injection is using Batched SQL Statements. This allows us to write full SQL statements that are then executed by the server, rather than being limited to just modifying an existing statement. This works by closing out all open and expected inputs in the existing statement, ending it with a ';', | ||
+ | {{ : | ||
+ | The SQL statement on the school' | ||
+ | < | ||
+ | “INSERT INTO Students VALUES (‘“ + firstName “‘, | ||
+ | </ | ||
+ | Thanks to the specific nature of little Bobby' | ||
+ | < | ||
+ | INSERT INTO Students VALUES(‘Robert’); | ||
+ | </ | ||
+ | This causes the software to delete the entire student table after inserting Robert into the table. This works as putting a semicolon into a SQL statement allows us to execute more than one statement per line. | ||
+ | |||
+ | === References === | ||
+ | https:// | ||
+ | https:// | ||
+ | https:// | ||
+ | https:// | ||
+ |