{"id":37870,"date":"2022-01-25T16:23:51","date_gmt":"2022-01-25T10:53:51","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=37870"},"modified":"2022-01-31T16:30:27","modified_gmt":"2022-01-31T11:00:27","slug":"sql-injection-hacking","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/sql-injection-hacking\/","title":{"rendered":"SQL Injection Hacking"},"content":{"rendered":"<h2 id=\"what-is-sql-injection\" style=\"text-align: justify;\"><strong>What Is SQL Injection ?<\/strong><\/h2>\n<p style=\"text-align: justify;\">SQL Injection is a code-based vulnerability that permits an attacker to read and access complex data from the database. Attackers can bypass security measures of applications and use <a href=\"https:\/\/www.wikitechy.com\/tutorials\/sql\/\">SQL<\/a> queries to modify, add, update, or delete records in a database. A SQL injection attack can affect websites or web applications using relational databases such as MySQL, <a href=\"https:\/\/www.wikitechy.com\/tutorials\/oracle\/\">Oracle<\/a> , or SQL Server. In current years, there have been many security cracks that resulted from SQL injection attacks.<\/p>\n<h2 id=\"types-of-sql-injection\">Types of SQL Injection<\/h2>\n<p><strong>In-band SQLi<\/strong> \u2013 The attackers use the same communication channel to launch their attacks and collect outcomes.<\/p>\n<p>Common types of in-band SQL injections are <strong>Error-based SQL injection<\/strong> and <strong>Union-based SQL injection.<\/strong><\/p>\n<ol>\n<li>Error-based SQL injection \u2013 Here, the attacker executes actions that cause the database to create error messages. Using the error message, you can find what database it uses, the version of the server where the trainers are located, etc.<\/li>\n<li>Union-based SQL injection \u2013 UNION SQL operator is used in combining the results of two or more select statements generated by the database, to get a single HTTP response. You can craft your queries within the URL or combine multiple statements within the input fields and try to create a response.<\/li>\n<\/ol>\n<p><strong>Blind SQLi \u2013<\/strong> Here, it does not transfer the data through the web application. The attacker cannot see the result of an attack in-band.<\/p>\n<ol>\n<li><strong>Boolean-based SQL Injection<\/strong> \u2013 Attacker will send an SQL query to the database asking the application to return a different result depending on whether the query returns True or False.<\/li>\n<li><strong>Time-based SQL Injection<\/strong> \u2013 The attacker sends an SQL query to the database, which makes the database wait for a specific amount of time before sharing the result. The response time helps the attacker to decide whether a query is True or False.<\/li>\n<\/ol>\n<p><strong>Out-of-bound SQL Injection<\/strong> \u2013 It is not popular, as it depends on the features that are enabled on the database server being used by the web applications. It can be like a misconfiguration error by the database administrator.<\/p>\n<h2 id=\"how-does-sql-work-on-a-website\"><strong>How Does SQL Work On a Website ?<\/strong><\/h2>\n<p>A website has three main components \u2013 Frontend, Backend, and Database.<\/p>\n<p>Frontend \u2013 \u00a0A website is designed using <a href=\"https:\/\/www.wikitechy.com\/step-by-step-html-tutorials\/\">HTML<\/a> , <a href=\"https:\/\/www.wikitechy.com\/css\/\">CSS<\/a> , and <a href=\"https:\/\/www.wikitechy.com\/tutorials\/javascript\/javascript-tutorial\">JavaScript<\/a><\/p>\n<p>Backend \u2013 Here you have scripting languages such as <a href=\"https:\/\/www.wikitechy.com\/tutorials\/python\/python-tutorial\">Python<\/a> , <a href=\"https:\/\/www.wikitechy.com\/php\/\">PHP<\/a> , Perl, etc.<\/p>\n<p>Database \u2013 The server side has databases such as MySQL, Oracle, and MS SQL Server, to execute the queries.<\/p>\n<p>When you write a query, you usually send a get request to the website. Then, you receive a response from the website with HTML code.<\/p>\n<p>Using the Postman API tool, you can test the responses that you get from various websites.<\/p>\n<h2 id=\"demo-on-sql-injection\">Demo on SQL Injection<\/h2>\n<ul>\n<li>Go to Google Chrome or any web browser and search for owasp broken web apps<\/li>\n<li>Click on the sourceforge.net link<\/li>\n<li>Select the Download option to download the OWASP Broken Web Applications Project<\/li>\n<\/ul>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-37943 aligncenter\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications.png\" alt=\"\" width=\"1600\" height=\"774\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications.png 1600w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications-300x145.png 300w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications-1024x495.png 1024w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications-768x372.png 768w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications-1536x743.png 1536w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications-990x479.png 990w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/source-forge-web-applications-1320x639.png 1320w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>This application has been established by the Open Web Application Security Project that periodically releases the top 10 risks that an application will face for a specific year. It has a collection of weak web apps that are distributed on a Virtual Machine.<\/p>\n<p>Note: Performing SQL Injection in the real-world on any website is illegal.<\/p>\n<ul>\n<li>After downloading the OWASP Broken Web Apps virtual machine, open it on a VMware workstation.<\/li>\n<li>You can see the IP address of the machine. In this case, it\u2019s 192.168.71.132<\/li>\n<li>Use the IP address mentioned above and open it on a browser<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-37947 aligncenter\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/ip-address.png\" alt=\"\" width=\"664\" height=\"295\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/ip-address.png 664w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/ip-address-300x133.png 300w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/p>\n<p>You will find training applications, and realistic, intentionally vulnerable applications.<\/p>\n<p>You can also find old versions of real applications and much more.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-37944\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/versions-of-real-applications.png\" alt=\"\" width=\"1105\" height=\"359\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/versions-of-real-applications.png 1105w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/versions-of-real-applications-300x97.png 300w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/versions-of-real-applications-1024x333.png 1024w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/versions-of-real-applications-768x250.png 768w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/versions-of-real-applications-990x322.png 990w\" sizes=\"(max-width: 1105px) 100vw, 1105px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37942\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/realistice-applications.png\" alt=\"\" width=\"1104\" height=\"263\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/realistice-applications.png 1104w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/realistice-applications-300x71.png 300w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/realistice-applications-1024x244.png 1024w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/realistice-applications-768x183.png 768w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/realistice-applications-990x236.png 990w\" sizes=\"(max-width: 1104px) 100vw, 1104px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37939\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/old-versions-of-real-applications.png\" alt=\"\" width=\"1101\" height=\"312\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/old-versions-of-real-applications.png 1101w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/old-versions-of-real-applications-300x85.png 300w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/old-versions-of-real-applications-1024x290.png 1024w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/old-versions-of-real-applications-768x218.png 768w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/old-versions-of-real-applications-990x281.png 990w\" sizes=\"(max-width: 1101px) 100vw, 1101px\" \/><\/p>\n<p>For the demonstration, you\u2019ll be using the OWASP Mutillidae II application.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37940\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae.png\" alt=\"\" width=\"1600\" height=\"723\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae.png 1600w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae-300x136.png 300w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae-1024x463.png 1024w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae-768x347.png 768w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae-1536x694.png 1536w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae-990x447.png 990w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/owsap-multidae-1320x596.png 1320w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>On the left, you can see the OWASP top 10 risks for 2013, 2010, and 2007.<\/p>\n<p>Click on SQLi \u2013 Bypass Authentication > Login<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37946 aligncenter\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/bypass-authentication.png\" alt=\"\" width=\"512\" height=\"141\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/bypass-authentication.png 512w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/bypass-authentication-300x83.png 300w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/p>\n<p>You will enter a regular login authentication page that any application may ask for.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37938 aligncenter\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page.png\" alt=\"\" width=\"1600\" height=\"644\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page.png 1600w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page-300x121.png 300w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page-1024x412.png 1024w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page-768x309.png 768w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page-1536x618.png 1536w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page-990x398.png 990w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-authentication-page-1320x531.png 1320w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>Suppose you enter an anonymous username and password, that won\u2019t allow you to log in.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37945 aligncenter\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/anonymous-username-and-password.png\" alt=\"\" width=\"418\" height=\"176\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/anonymous-username-and-password.png 418w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/anonymous-username-and-password-300x126.png 300w\" sizes=\"(max-width: 418px) 100vw, 418px\" \/><\/p>\n<p>Let\u2019s write an SQL statement in the username and try to login again.<\/p>\n<ul>\n<li>My Username will be: \u2018 or 1=1 \u2014<\/li>\n<li>Click on Login<\/li>\n<li>You will log in this will time with a status update saying it has authenticated the user<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37937 aligncenter\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login.png\" alt=\"\" width=\"410\" height=\"181\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login.png 410w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/login-300x132.png 300w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><\/p>\n<p>The single quote (\u2018) is an operator that goes to the database server, selects the default user tables, and compares it to the condition that is given. That condition that you gave was 1=1, which is always true. So, it selected the default user table that was available in the database, and instead of linking it to a password, it compared it to the condition.<\/p>\n<p>If you give a false condition like 1=2, you will get an error message \u201cAccount does not exist\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37949\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update.png\" alt=\"\" width=\"1600\" height=\"578\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update.png 1600w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update-300x108.png 300w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update-1024x370.png 1024w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update-768x277.png 768w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update-1536x555.png 1536w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update-990x358.png 990w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2022\/01\/status-update-1320x477.png 1320w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>Now, that you have looked at a demonstration on how an SQL query can be used to login to an application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What Is SQL Injection ? SQL Injection is a code-based vulnerability that permits an attacker to read and access complex data from the database. Attackers can bypass security measures of applications and use SQL queries to modify, add, update, or delete records in a database. A SQL injection attack can affect websites or web applications [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29859],"tags":[101334,101638,101343,101632,101637,101341,101338,101339,101333,101337,101636,101335,101633,101634,101336,101340,101630,101342,101344,101635,101631],"class_list":["post-37870","post","type-post","status-publish","format-standard","hentry","category-hacking","tag-advanced-sql-injection-hacking-and-guide","tag-blind-sql-injection-hacking","tag-how-sql-injection-works","tag-how-to-prevent-sql-injection","tag-manual-sql-injection-hacking-articles","tag-sql-injection-attack-example","tag-sql-injection-cheat-sheet","tag-sql-injection-commands","tag-sql-injection-hacking","tag-sql-injection-hacking-articles","tag-sql-injection-hacking-bank","tag-sql-injection-hacking-code","tag-sql-injection-hacking-software","tag-sql-injection-hacking-tools","tag-sql-injection-hacking-tutorial","tag-sql-injection-login-bypass","tag-sql-injection-or-11","tag-sql-injection-tutorial","tag-sql-injection-vulnerability","tag-sql-injection-hacking-admin-access","tag-what-is-sql-injection-attack"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/37870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=37870"}],"version-history":[{"count":4,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/37870\/revisions"}],"predecessor-version":[{"id":37950,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/37870\/revisions\/37950"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=37870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=37870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=37870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}