14139

Sql Injection is basically an attack that relies on adding some content to any input ( user input) in any query so as to manipluate the input in such a way that that it breaks or modifies the syntax ( in a way which admin of website did not intent to).

Even if you are a bit confused with the above statement don’t worry take is easy you will get it as you go through the answer.

Well i will take a basic example to explain you how it works.

Below diagram is result of logical OR

a     | b     | a OR b
-----------------------
false | false | false
false | true  | true
true  | false | true
true  | true  | true

If you see carefully what it means is if any of the two statements is true then result will be true. what i mean is if there is any statement say A OR B such either of the two ( i mean A or B) is true then result will be TRUE .

Now lets move to the SQL part.

Suppose you have a website and it has a table Users ( name of table) which has Name ( name here is username) and password(s) ( as usually we do have ). So people can sign up and sign in.

When someone logins the query that is handling the input is say this :

SELECT Id FROM Users WHERE Name = $name AND Password = $password;

So in normal cases what will happen is say i m a user lovepreetsingh and i create a passwords techandsecurity. When i will sign in the command goes like this :

SELECT Id FROM Users WHERE Name = lovepreetsingh AND Password = techandsecurity;

which is fine. I will get my login access as there is a user lovepreetsingh with password techandsecurity in the table.

Join Our Whatsapp Group: https://chat.whatsapp.com/22Vw2xAbKYs2yIyrbX4iCN

But the id passwords are dependent on users so they could choose anything. Suppose a user goes to login form page and enters say in the username column : ‘ OR 1 = 1;–and in the password column say password itself ( or anything you can take here or even leave it blank).

Now the query has become

SELECT Id FROM Users WHERE Name = 1 OR 1 = 1; -- AND Password = password;

So lets now first understand what it means. If you are not in SQL ( practice any other language) in all languages you use something to denote the comment section. Say in PHP we use // to denote comment or say in C it starts with/* and ends with */ . The –is the SQL does the same purpose means everything followed after it will be considered as comment ( so won’t be executed as a command , in way will be ignored).

I already told you about OR logic and you can see well that 1=1 is always true. So because one of the two values ( a OR b) is true means the results will be true. And the result is followed by – – means it mentions that comment section starts from there ( ignore the part that is ahead).

Now this is how SQL works. What i mean is you gave an input for username which became a command here ( true command).

When i used my real credentials that is lovepreetsingh and techandsecurity for login i logged into the account corresponding to these credentials. But here i just asked for access of True ( and true is valid on all id). Depending upon the complete structure of website ( the other part of coding) it will be executed. Most probably ( considering normal scenerio) i will get logged into User id that is the first id ( first column and first row) .

Well now you can well imagine what all could be done with it. You could simply create queries to login into some specific user or get entire database even or even delete some columns or rows ( say drop them).

Say if i use this to drop the table itself :

"SELECT * FROM Users WHERE Name = ''; DROP TABLE `users`";--";

The above query can delete entire users database ( see carefully the second half of query).

You can use different queries for different results.

What hackers do is they will first try some queries and check how is your website dealing with the special characters. Some websites don’t even allow chacters like “=” as a part of id or password. Some do allow but they sanitize or parse them well and know how to handle them ( at the date you can do a lot many things to prevent it , even placeholders are enough and if you want to discuss more on its prevention raise a question on its prevention or say on FIEO – filter input escape output and invite me there). Anyways what hackers do is they check by sending queries how your website is handling these queries ( from the errors they are getting). If errors show that the database side is accepting these queries than they go for SQL ( now things depend upon the website).

Buy Me A Coffee

Dude If You Liked My Content Please Share It.

Part 2 SQL Injection :- https://techandsecurity.net/sql-injection-vulnerabilities-and-how-to-prevent-them.html


Lovepreet Singh
CEO & FOUNDER OF" FIVE RIVERS INCORPORATION - LEADING SOFTWARE & CYBER SECURITY DEVELOPMENT COMPANY" || CERTIFIED ETHICAL HACKER || FUTURE TRILLIONAIRE || FUTURISTIC || "DULL SCHOOL STUDENT" || (Follow this link to message me on WhatsApp: https://wa.me/13018426470)

How do I learn ethical hacking in India?

Previous article

What is hairpinning? When should one use it on his network?

Next article

You may also like

14,139 Comments

  1. [url=http://lending.us.org/]direct payday loan lenders[/url]

  2. Wonderful data. Appreciate it!
    viagra online diagnosis generic viagra online

  3. You said it nicely.!
    take viagra and then penis pump

  4. thank you web site admin

  5. Quality content is the key to be a focus for the
    users to pay a visit the website, that’s what this web page
    is providing.

  6. I reckon something genuinely special in this site.

  7. I pay a quick visit each day a few sites and information sites
    to read content, except this weblog offers quality based content.

  8. Point effectively regarded..
    viagra plus something else generic viagra online

  9. Thank you, Awesome information.
    viagra explained

  10. It’s an amazing post for all the online visitors; they will get advantage from it I am sure.

  11. Amazing blog layout here. Was it hard creating a nice looking website like this?

  12. She got off it on the 3rd of February, or the 4th. I dont quite remember but she hasn’t had it since and
    it’s March 2nd. I read a lot about this and people say it completely messes up the cycle
    and im sure it does.
    나비 바이브레이터 팬티 바이브레이터 팬티 바이브레이터

  13. [url=https://xenical120mg.com/]xenical orlistat[/url] [url=https://lisinoprilbuy.com/]lisinopril[/url] [url=https://femaleviagra24.com/]female viagra online[/url] [url=https://levitrasale.com/]buy levitra online[/url] [url=https://azithromycin100.com/]azithromycin tablets 250 mg[/url] [url=https://vardenafilbuy.com/]where to buy vardenafil[/url] [url=https://zoviraxacyclovir.com/]acyclovir herpes[/url] [url=https://wellbutrin300.com/]wellbutrin 300mg[/url] [url=https://doxycycline02.com/]doxycycline generic[/url] [url=https://buydiflucan.com/]where can i buy diflucan online[/url]

  14. [url=https://femaleviagra24.com/]female viagra[/url] [url=https://zoviraxacyclovir.com/]generic zovirax[/url] [url=https://allopurinolzyloprim.com/]allopurinol[/url] [url=https://hydrochlorothiazide25.com/]hydrochlorothiazide triamterene[/url] [url=https://levitrasale.com/]brand levitra[/url] [url=https://generictadalafil20mg.com/]generic cialis tadalafil[/url] [url=https://cafergot100.com/]cheap cafergot[/url] [url=https://lisinoprilbuy.com/]lisinopril buy[/url] [url=https://buydiflucan.com/]cost of diflucan[/url] [url=https://doxycycline02.com/]doxycycline 500mg[/url]

  15. [url=http://hydrochlorothiazide25.com/]hydrochlorothiazide 12.5[/url] [url=http://buydiflucan.com/]buy diflucan online without prescription[/url] [url=http://femaleviagra24.com/]female viagra[/url] [url=http://allopurinolzyloprim.com/]allipurinol online[/url] [url=http://atarax10.com/]atarax 10mg[/url] [url=http://tetracycline365.com/]tetracycline[/url] [url=http://vardenafilbuy.com/]buy vardenafil cheap[/url] [url=http://doxycycline02.com/]buy online doxycycline[/url] [url=http://sildenafil1000.com/]sildenafil for sale[/url] [url=http://azithromycin100.com/]azithromycin 500 dosage online pharmacy[/url] [url=http://generictadalafil20mg.com/]tadalafil 10[/url] [url=http://wellbutrin300.com/]wellbutrin prescription[/url] [url=http://lisinoprilbuy.com/]lisinopril 10mg tablets[/url] [url=http://levitrasale.com/]online levitra sales[/url] [url=http://sildalis120.com/]generic sildalis[/url]

  16. You actually expressed it wonderfully!
    india generic viagra buy one viagra generic

  17. Attractive component to content. I simply stumbled upon your
    website and in accession capital to claim that
    I acquire in fact loved account your weblog posts. Anyway I’ll
    be subscribing in your feeds and even I success you get admission to consistently fast.

  18. Appreciate it, Loads of tips!

    10mg vs 20mg viagra experiance

  19. Hey there! I just want to offer you a big thumbs up
    for the great info you have here on this post. I am coming back
    to your web site for more soon.

  20. I enjoy examining and I believe this website got some really
    useful stuff on it!

  21. Hey very interesting blog!

Leave a reply

Your email address will not be published. Required fields are marked *