Thursday, March 13, 2014

SQL Injection : How It Works


Lets get started at an apparently unrelated point. Lets assume we create a table in SQL. Now there are three main parts of a database management system, like SQL. They are -
  • Creating structure of table
  • Entering data
  • Making queries (and getting meaningful results from data)
So, when SQL is used to display data on a web page, it is common to let web users input their own queries. For example, if you go to a shopping website to buy a smartphone, you might want to specify what kind of smartphone you want. The site would probably be storing data about phones in table with columns like Name, Price, Company, Screen Size, OS, etc.
Now what they do is that they allow you to create a query using some sort of user friendly drop down based form which lets you select your budget, preferred company, etc. So basically, you, the user, can create queries and request data from their SQL servers without typing any code. 
This automated method of creating queries for you is relatively safe (since it doesn't give you a lot of flexibility in terms of what queries you can create, you are limited by the syntax of queries they have decided). However, there is another method of creating queries which can be exploited by us. 
A url ending in .php is a direct indication that the website/blog uses sql to deliver a lot of it's data, and that you can execute queries directly by changing the url. Usually the data in the SQL tables is protected and can be viewed directly only by certain people (admins etc.). However, when we send some rogue commands to the SQL server, it doesn't understand what to do, and returns an error.
This is a clear indication that with intelligent design of URLs, we can send queries that will make the database 'go berserk' and malfunction, and give us all the otherwise private data of its tables. This attack can be used to obtain confidential data like a list of username and passwords of all users on a website.


  1. We have to find a website which is vulnerable to SQL injection (SQLi) attacks. Vulnerability has 2 criteria. Firstly, it has to allow execution of queries from the url, and secondly, it should show an error for some kind of query or the other. An error is an indication of a SQL vulnerability.
  2. After we know that a site is vulnerable, we need to execute a few queries to know what all makes it act in an unexpected manner. Then we should obtain information about SQL version and the number of tables in database and columns in the tables.
  3. Finally we have to extract the information from the tables.
Vulnerabilities are found using your own creativity along with famous dorks (more on this in a later tutorial)
For the 2nd and 3rd step, there are 2 ways to do them-
  • Manually using some standard codes available online (and if you know SQL then you can figure most of the stuff out yourself). For example, you can instruct the database to give you all the data from a table by executing the command- 
SELECT * FROM Users WHERE UserId = 105 or 1=1
Now, while the first part of the query "UserID=105" may not be true for all user, the condition 1=1 will always be true. Basically the query asks the table to return all details of users for whom either user id = 105 or 1=1 (1 is always equal to 1, irrespective of the userId and all other factors). Effectively, you have the username and passwords and all other information about all the users of the website.

  • Using some tool - Some tools help in making the process easier. You still have to use commands but using tools is much more practical after you have an idea what is actually happening. I don't recommend all the GUI Windows tools which are found on malware filled websites, and never work. All throughout this blog we have used Kali Linux, and if you really are serious about hacking, there is no reason not to have Kali Linux installed. In Kali Linux, there is a great tool called SQLMap that we'll be using.

Quick cool example

Now suppose you develop a web app. Here are the credentials for login-
Username : abcd
Password : xyz

Now, for login, you have the following condition:

if ("abcd" == Username and "xyz" == Password) 

Now if someone enters Username which is different from abcd or password which is different from xyz, then he won't be able to login. Seems to be fine.

But wait, if a person enter username as "pqr" or 1==1 and password as "wxy" or 1==1, your code would check credentials in the following way -
("abcd"=="pqr" or 1==1) and ("xyz" == "wxy" or 1==1)
Let's translate that into boolean. 1==1 is true obviously, abcd==pqr is not true, nor is xyz==wxy. So, we get,
(false or true) and (false or true)
which becomes
true and true
which becomes
So, the person logged into your web app without knowing the username or password.

PS: The example here grossly simplifies a lot of things, but taking care of all details would make this more complicated than it has to be for a first tutorial in SQL injection (coming tutorials are more syntactically correct).
The first command is legit and gives you access to data of srinivas only, and only in the condition where the password is correct. The second statement gives you access to data of all accounts.
That's it for this tutorial, you now know how SQL Injections work. It might be worth your time learning some SQL on W3schools till I come up with some other tutorial. Also, check out the navigation bar at the top of the blog to see if you find something that interests you. We have a lot of tutorials for beginners in the field of hacking.
If you would like to go ahead, then here is the next tutorial in the SQL injection series-

Hacking Websites Using SQL Injection Manually

Also, a tutorial on automated Sql injection is finally here. Take a look

Sql Injection Using sqlmap in kali linux


  1. I Live Your Lessons

    I hope Add video lessons

  2. Great hacker you are!!!

  3. Hi How Are you
    I know that here use linux
    but I happen to have a problem with sqlmap recently installed Windows 8.1 along with Python 2.7, but when you open the cmd and type command -u http: // / store.php? ID = 1 --dbs throws me an error on a notepad
    Link: /// file G: / Error
    I hope you can help me with this problem. Thank you

  4. SELECT * FROM Users WHERE UserId = 105 or 1=1

  5. SELECT * FROM Users WHERE UserId = 105 or 1=1

  6. i just wanna know how do I or where do i type the sql command?

    1. Most of the time, you type it in the URL bar, where you type website address (after the .php in the address). Sometimes some form fields can also be used.

  7. comment je peux pirater un compte facebook

  8. The link 'Sql Injection Using sqlmap in kali linux' redirects to the wrong page.

    Thanks for the tutorials

  9. This is really good blog information thanks for sharing .I am really impressed with your writing abilities

    เว็บไซต์คาสิโนออนไลน์ที่ได้คุณภาพอับดับ 1 ของประเทศ
    เป็นเว็บไซต์การพนันออนไลน์ที่มีคนมา สมัคร Gclub Royal1688
    และยังมีเกมส์สล็อตออนไลน์ 1688 slot อีกมากมายให้คุณได้ลอง
    สมัครสมาชิกที่นี่ >>> Gclub Royal1688

  10. Coolest Quotes. This is one of the best article I have ever read

  11. That a really god article. You blog is awesome.
    funny status

  12. I think your site has one of the cleanest theme I’ve came across. It really helps make reading your blog a lot easier
    wonderful article it is really good.

  13. Cool Te Amo Status. This is one of the best article I have ever read

  14. filmyhit provides an tips and tricks,

    technology,product keys and latest how to guide stuff. While providing all this, we foresee

    ourselves to be known as the best digital marketing. Here you will get 9xmovies etc. are some of the subjects to name that we

    cater our users in bolly4u tricks. We were recently

    recognised as the most reliable and dependable digital marketer for UrgroveMovies , and also voted as the Numero Uno

    assignment provider for the past two years. The Online website have been using their past

    experience and knowledge in order to supply the users with high quality content,essays,

    thesis,reports, journals and technolgy, Cinevood

    reflections, case study analysis, etc. There are many websites in the internet which functioning at

    skyrocketed prices.

  15. hi sir this is information really good really thanks skymovies please please share some information like this information again thanks for share this information.

  16. wow ! What a great content! I found your blog on google and loved reading it greatly. It is a great post indeed. Much obliged to you and good fortunes. keep sharing.
    lws quotes

  17. Writing articles that are very interesting and very neat, at first I did not understand how to write good articles,
    after I saw your website I began to learn and understand how to write the right articles.
    Thank you foWriting articles that are very interesting and very neat, at first I did not understand how to write good articles,
    after I saw your website I began to learn and understand how to write the right articles.
    Thank you for giving a very good example of writing, I will often come to your website to learn how to write like the one on your website.
    Satta king 2019
    r giving a very good example of writing, I will often come to your website to learn how to write like the one on your website.
    Satta king 2019

  18. phir bhi tumko chahunga lyrics Amit Mishra, who is known for popular songs like 'Bulleya', 'Galti Se Mistake', 'Suno Ganpati Bappa Morya' and 'Ding Dang', is happy with the response his new tracks are getting. Amit says, “'Ole Ole 2.0' from 'Jawaani Jaaneman' is one of my favourites. Growing up, I’ve loved this Abhijeet Bhattacharya song and it was an honour to share the Tanishk Bagchi track with him. Both the versions are equally good, mine has different lyrics and antara." He adds, "Progression wise, there are differences when it comes to the chord structure, and mukhre ka start bhi thoda alag hai. Yeh aaj ka EDM hai aur woh uss samay ka EDM tha.” Talking about his songs 'Ajj Mera Yaar' and 'Sachiyaan' in 'Bhangra Paa Le', the singer says, “Both the songs have an EDM-bhangra vibe, and are beautiful. I am happy that I got an opportunity to work with the composers Kaushik-Akash-Guddu (KAG) and Shubham Shirule-Ana Rehman.” Amit has also lent his vocals for the Telugu and Tamil versions of 'Street Dancer 3D’s 'Dua Karo'. “I had to work on getting the pronunciations right for 'O Deva Deva' (Telugu) and 'Maraven Yen Adayaalam' (Tamil). People are appreciating the songs and I am really honoured. It’s a great composition and I’m happy with all the appreciation that’s coming my way.”

  19. phir bhi tumko chahunga lyricsMumbai, March 19 : Popular singer Jasbir Jassi, known for songs like "Dil le gayi kudi Gujarat di" and "Laung da lashkara", says he now rejects offers to sing Bollywood numbers due to their double meaning lyrics. Jassi visited the Hungama office for a special meet-and-greet session called Hungama Spotlight, where he launched and celebrated his latest single with DJ Shaan titled "Bulleya", read a statement.
    On his thoughts about today's music, Jassi said: "I sometimes have a problem with some of the Punjabi songs and videos because they are representing Punjabi music in a wrong way.

    "Today it is difficult to sit with our family and enjoy new Punjabi songs. My problem is people try to copy the West, but I feel there is still more time for people to accept it. That's the only reason that I get so many offers from Bollywood but I have to reject many songs because of their abusive or double meaning lyrics.

    "Of course I feel bad doing so, but I cannot help it".

  20. Khushi Rahman amazing website. I like This Website

  21. It is truly a nice & useful piece of info. I am glad that you just
    shared this useful information with us. Please stay
    us up to date like this.
    Thanks for sharing.

    Dirty Pick Up Lines

    Best Team Names

  22. I am really thankful to you for sharing such a motivational post.
    Bengali Shayari

  23. Nice This Aritecal I red complit
    I'm a blogger anyon like read bangla jokes

  24. What a nice blog! I have enjoyed reading through the article! What a great content! I found your blog on google and loved reading it greatly. It is a great post indeed. Much obliged to you and good fortunes. keep sharing.

  25. Thank you for sharing article.I have a presentation next week on this topic and blockchain related topic like blockchain course for the developers , and I am at the search for such information about that. your blog is very helpful for my presentation.

  26. All University B.COM Result 2020 Roll Number Wise (Annual/Semester)Checking students must have a link to thats university.Here we are providing All university links to Check their all Regular, Private and non-college students

    Now Check Here
    Now Check Here
    Now Check Here

  27. great post... i always come for read your post because of your content. keep posting

    Best Inspirational Quotes ,

    Respect Women Quotes

  28. Hello every one how are you.
    see all offer news in one place.
    if you need to see all offer ditails are here

    Number one internet package provider Banglalink sms package
    Number one internet package provider My gp app

  29. You’d outstanding guidelines there. I did a search about the field and identified that very likely the majority will agree with your web page.
    UOK BCOM 1st Year Result 2020
    UOK BCOM 2nd Year Result 2020
    UOK BCOM 3rd Year Result 2020

  30. Great article well explained. If you do love quotes & sayings please do check our website. Breaking Bad Quotes

  31. Send your friend sweet birthday wishes for the coming year with this birthday card. It's time to celebrate your friend's birthday and wish her the best for the future. birthday wishes and messages for grandma

  32. Satta king can be played in both online and offline modes. For online, users should download the application. The four games in satta king are: satta king Gail, Satta king Desawar, Satta king Faridabad, Satta king Ghaziabad. satta king

  33. I specially thanks for this tutorial of SQL Injection. Specialist

  34. This article is very useful...
    Keep sharing such amazing content...
    Thanks for Sharing...
    Visit for Best gifts for Girlfriend in India...,
    Best Sad Quotes in Hindi and
    Best motivational quotes in hindi

  35. Nice Article Thanks For Sharing With Us.
    To Know More Details And Listen Main Tera Ban Jaunga Song With Lyrics Click Here - Main Tera Ban Jaunga Lyrics

  36. Nice Article. Your Website Is Awesome.
    To Know More Details And Listen Bekhayali Song With Lyrics Click Here - Bekhayali Lyrics

  37. If you are one of those who don’t know how to update the Garmin map, below are some of the ways by which you can update it. You just need to use the Garmin Express application in the matter of getting the Garmin Map updates. With the help of Garmin Express, you will be able to update your Garmin Map by downloading it from the official website of Garmin.

    garmin updates
    garmin map updates
    garmin gps updates
    garmin nuvi updates
    garmin express updates

  38. नफ़रत सी हो गई हैँ इस दुनिया से, एक तुम से मोहब्बत करके love status

  39. When it comes to talking about its features, this Magellan device or Magellan GPS updates are loaded; with various sorts of exciting features. Once you start using this great device, you’ll learn about the traffic alerts, weather conditions, and a lot more. While using it, you’ll get to know which road route you should choose and which you should avoid. As many GPS devices are available in the market, one can opt for Magellan to make traveling easy and smooth. It will happen only just because of this advanced and modified device. But there is the thing about it that it needs updates from time to time. Simply put, you will need to update this device to have a comfortable experience of your journey.

    magellan gps update
    tomtom gps update
    magellan gps updates
    tomtom gps updates

  40. Really nice so lovely thanks such a lot for sharing this post, I appreciate your work.It was an excellent informative post.Go such a large amount of helpful and informative links.Loved your writings also. construct of the subject was well discussed. like to return here again.Bangla Shayari Please find our website content, like- Bangla Kobitafor best satisfied contents.

  41. That's really nice post absolutely fabulous I really liked it and thanks for sharing

  42. Thank You So much for sharing these tips and tricks.
    My Blog

  43. Thank You so much. I am A progammer and it helped em alot.
    Joker Football Gloves

  44. I read this article fully on the topic of the resemblance of most recent and preceding technologies, it’s remarkable article.

    leather sofa set

  45. Thanks for sharing the informative post about.
    I have learned many new information from your post.
    If You want to play online mobile game. Visit now Game Development Kolkata

    Game Development Company in Kolkata,
    Kolkata Game Developers,
    Game development Kolkata,
    List of Game Design Courses,
    Game development company in India

    Other Services :

  46. Try to add only relevant data and information. If you feel that you are stuck, you can take assignment help online to get a proper idea. There are several web services which can help you to find out a suitable solution to your problems Aliexpress Coupon Code This is nice Website

  47. Good Aliexpress Promo Code Thank you for the very informative article.

  48. Great Information English Song Lyrics Thank you for the very informative article.

  49. Thanks to your post I knew how to browse a site without visiting. thank you..

  50. im Angela McLaughlin and i came with good news, you don’t have to fight with your spouse before he/she opens his/her phone for you.
    All you need do is to Email or visit for any form of hack you need,
    i must confess this hacker has really helped me recover a lot from my spouse who left i and my children for 3 years.
    it is easier to reach them faster on telegram @h4ckerspro or call/text 1 646 948 8125

  51. Your article was very good, never read such an article before, and in addition to this I have read many more articles of your website. I want to say again, you wrote very well, Thank you.
    Triund Trek Package
    Ladakh Packages
    Kareri Lake

  52. SQL injection usually comes when you ask a user for input the data , like their username/userid, and instead of a name or id, the user gives you an SQL statement that you will unknowingly run on your database. These all knowledge is comes from the best blogging website Digifybox

  53. Escort Service Noida
    Since Escort Service Noida are solid and dynamic, take them to a separated spot and shoot them outside under the hugeness of the sky. It is agreeable to have sex directly in nature. Provocative bitched from Noida escorts will totally see the value in the scene and give you outrageous pleasure. Kiss her and embrace her, have a stunning foreplay before getting a charge out of hammering her. Escort Service Noida manages each fantasy you have and delightful youngsters from Noida Escorts will satisfy you with no cry.

  54. Hi tһere, You’ve done a great ϳob. I will certainly Dig it and personally recommend it to my friends. I’m sure they’ll be benefited from this site.

    Best Vacuum Cleaners Under 5000 in India

  55. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. Semaglutide

  56. Hello, Thanks for sharing with us. i loved it
    Nazraan Lyrics

  57. Because it is simple to go back to older behaviors, pals that hold to abuse drug or alcohol and settings wherein dependancy can recur, a brand new surroundings may be very advantageous for one's recovery.halfway house near me

  58. That is really an amazing post. Thank you for sharing it.
    Admissiongyan is Study in Germany Consultants that help students to study MS in Germany, MBA in Germany & Free Education in Germany.

  59. Advance Lyrics This is a lyrics website. Advance lyrics for Hindi songs to get this website. not only Hindi Punjabi, English, Hindi, lyrics are available with song details and download links on

    Pyar acha lagta hai lyrics
    Milaa Yunn Lyrics

  60. These are truly fantastic ideas regarding blogging. Great Work editor
    Bhojpuri song lyrics

  61. You have written very useful article for us. Your content is full of
    educational tutorials.

  62. Incredible Info! I Recently Came Across Your Blog And Have Been Reading Along. I Thought I Would Leave My First Comment. I Don't Know What To Say Except That I Have.
    signature generator


  63. This is a good website, I have been reading its articles for a long time. If I do not find a solution to any problem, then I come and search on this website. However, a lot of work has happened that day when I did not get the answer to my question. If you like to travel, then you can book these packages -
    Kareri Lake Trek
    Triund Trek

  64. Thanks for sharing , this was so informative . I have also written some:
    FAStag Kya Hai
    Business Ideas In Hindi With Low Investment

  65. Such a informative article.
    If u are searching for a stylish fancy text generator for Instagram, Facebook or any other social media. Then u should visit us at

  66. This is a good website, I have been reading its articles for a long time. If I do not find a solution to any problem, then I come and search on this website.
    FASTag Kya Hai
    Business Ideas In Hindi With Low Investment
    Web Hosting Kya Hai
    Free Fire Ka Baap Kaun Hai
    PUBG Ka Baap Kaun Hai
    Bharat Me Kul Kitne Jile Hai 2021


  67. I am blogger and content writer. I love traveling to a new place. I have written about many subjects till now.
    Free Fire Ka Baap Kaun Hai
    PUBG Ka Baap Kaun Hai
    Bharat Me Kul Kitne Jile Hai 2021

  68. More than whatever else it's far a shining instance of what the human spirit can acquire withinside the maximum attempting of circumstances. The sheer scale of this motion is testimony to its grand success.AA Meeting Near Me


  69. Techdost services private limited is a leading and renowned digital marketing, website designing, software development and mobile application development company. Delivering its services all over Ghaziabad, Meerut, Delhi, India.
    8+ years of intensive experience in this industry
    Highly committed towards delivering high quality website design and development services all over India.
    Work with a professional team of experts that includes more than 15 members
    Techdost is a trustworthy, reliable and highly committed digital marketing, website designing, software development and mobile application development company delivering its services all over Ghaziabad, Meerut, Delhi, India.

    software development company in Delhi
    Website designing company in Ghaziabad

    software development company in Delhi
    Digital Marketing company in Delhi
    SEO Company in Meerut
    Website designing Company in Meerut

  70. Your search for a leading Digital Marketing company ends here. Meet techdost services private limited a leading and a renowned digital marketing agency delivering high quality results and delivering the best work for the clients.

    Digital Marketing Company in Meerut

    Digital Marketing Company in Delhi

  71. awesome and wonderful post, thanks for sharing. new tech app

  72. Hi there, after reading this remarkable paragraph i am too happy to share my experience here with friends. Feel free to visit my website; 먹튀검증

  73. I want to to thank you for this great read!! I certainly enjoyed every little bit of it. I have you bookmarked to check out new stuff you post…
    횟수 무제한 출장

  74. A model is a person with a role either to promote or advertise commercial products and services or to serve as a visual aid for

    people who are creating works of art or to pose for photography. Though models are predominantly female models, especially to

    model clothing. Models may work professionally or casually.

    Guide in Novotel Aerocity
    Guide in Paharganj
    Guide in Pullman Hotel
    Guide in Red Fox Hotel
    Guide in Aerocity
    Guide in IBIS Hotel
    e^scorts in Aerocity
    e^scorts in Holiday inn
    e^scorts in IBIS Hotel Aerocity
    e^scorts in JW Marriott Hotel


  75. thanks for sharing information.
    Thought in Hindi

  76. The article posted was very enlightening and useful. You people are doing a fantastic job. Keep posting.

    Phone Pe Se Kitna Paisa Bhej Sakte Hai
    Share Bazar Se Paise Kiase Kamay

  77. Admiring the dedication you put into your blog and in depth information you provide.
    It’s awesome to come across a blog every once in a while that
    isn’t the same old rehashed information. Check this out Web Lyrics

  78. Meerut is famous for its well-known education hub.

    People from nearby cities and states came here to study in schools & colleges.

    It has around 400 schools, 75+ professional & technical colleges, more than 150 academic colleges & 4 universities.

    As far as school is concerned, CJDAV PUBLIC SCHOOL is the best school in Meerut.

    It comes under the chart of the Top 10 CBSE schools in Meerut.

    It is an English Medium School affiliated with CBSE Board in 1994 and since then they are climbing the ladder of success.

    Top 10 CBSE Schools in Meerut

    Meerut is famous for

    Meerut is famous for

  79. Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially App development I care for such info a lot.

    Kali linux training courses in malaysia

  80. Your blog is very Nice. I love reading you blog. Your site performance is also very responsive.
    Find out the latest songs lyrics in English and Hindi on this site:
    Lyrics in Hindi


  82. To learn English grammar, first of all it is necessary to learn tense in Hindi, so from here you can easily learn tense in Hindi.

  83. free converter from youtube to mp3 and mp4
    how to download youtube vidoes mp3 mac
    youtube to mp3 multi
    convert mp3 to youtube upload
    youtube to mp3 proxy
    youtube sound to mp3
    youtube to mp3 converter app apple
    where is a safe youtube to mp3
    search and convert youtube videos to mp3


  85. good brother the post is very well written i really like it keep doing more brother.
    want to someone earn big money online then click on a7satta

  86. This technique involves using long, gliding strokes with their hands, forearms, and even their feet to apply pressure on the client's body

  87. I am fortunate to have come across such amazing individuals, who not only touch my body but also my heart with their kindness and professionalism.

  88. Pretty! This has been an extremely wonderful post. Thank you for supplying this info.

  89. Wow, happy to see this awesome post. Thanks for sharing a great information

  90. Fantastic post! Please keep sharing post like this. Thanks, have a good day.

  91. I like it whenever people come together and share thoughts. Great website, continue the good work!

  92. Nonetheless, I found iit and I’ll be bookmarking and checking back frequently!

  93. Hi there to every body, this webpage contains amazing and excellent data.

  94. Great post! We will be linking to this great post on our website. Keep up the great writing.

  95. Great delivery. Great arguments. Keep up the amazing spirit.

  96. Keep up the good work. Check out more posts. Very good starting, goodjob

  97. Well this article is great. I need this article. Thanks. great share for us

  98. We offer customized spa packages to suit your business needs.

  99. Bangalore's body massage centers are a haven for relaxation.

  100. Drink plenty of water before and after your massage to help flush out toxins released from the muscles, always communicate with your therapist about the temperature of the stones and the pressure of the massage to ensure your comfort, allow yourself to fully relax and embrace the experience. Focus on your breathing and let go of any tension or stress


© Kali Tutorials, 2016. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Shashwat Chaudhary and Kali Tutorials with appropriate and specific direction to the original content.