Repository navigation
SQL Injections
SQL Injection... if you are on this page you probably heard or even used MySQL, it's a great tool to save everything you need to save on your web application. Of course, life comes at risk, you could be robbed, you could be mugged, you could be victim of a home invasion ! It's also the case for your web application, if you leave the door of your house, unlocked, while you're away, someone might try and get inside and steal your stuff, again; this is the same with your web application, if you don't put any protection on it, somebody will find a way to get in your web application and steal sensitive info such as passwords, email, or even your bank account information. With all of this, the question still persists, how dangerous is an SQL injection ?. In this document I will answer your question, first I am going to explain to you what is an SQL Injection and in the second part of the document I will show you the potential damages a hacker could do to your app using an Injection.
SQL injections are one of the most common form of attacks on the web.
An SQL injection is pretty similar to an XSS attack except that, this time, the hacker enters SQL statements that could delete your whole database, or show sensitive information. SQL injections are extremelly dangerous for your web application and could cost you alot if one of them manages to make their way onto your website.
here's an example of a javascript system that handles a login page
txtUserId = getRequestString("UserId");
txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;now here's what a user could do to trick your web application into spilling sensitive info
Imagine this is your login page
Username: myUser
Password: myPass
but what if the hacker decided to enter this instead ?
Username: myUser
Password: " or ""="
Then the SQL query just executed looks like this:
SELECT * FROM Users WHERE Name ="" or ""="" AND Pass ="" or ""=""This statement returns all the rows inside the users table, since or ""="" is always TRUE Now, that's scary not to say the least !, and it only takes a minute or so to execute this attack, anybody can execute this, imagine what a senior hacker with bad intentions could do to your application ! you, your employees and your customers' privacy are at risk, And as I mentioned before, if your customers cannot trust your website they will not make business with you ! First impression is something really important when it comes to your web application.
imagine you have a form, in which you can enter a specific ID, as an example we will take an "Item Return" Form
Item Id:340 (Hint: This can be found printed on the back of the item)
Reason for returning the product: bla bla bla, the item is not functioning correctly.....
Now that's what a normal user would type, but if a hacker wanted to delete some tables inside your database he could do:
Item Id:340; DROP TABLE Debts
This translates to this in sql:
SELECT * FROM Items WHERE ItemId = 340; DROP TABLE Debts;The hacker would've successfully dropped the Debts table, no more debts.. Yay !
For the hacker of course...
Based on my evidence, protecting yourself against these types of attacks is extremely important, although, it might seem hard to protect yourself against these type of attacks, it is not as hard as you think ! I hope you enjoyed reading my page, in the future, I hope people become more aware of SQL injections and invest more into securing their applications against these types of attacks. Without Further Redo, if you want to protect yourself against these types of attacks you can read my article