Tuesday, February 17, 2015

SQL Injection Intermediate Level

This is a theoretical post about types of SQL Injection attacks and the concepts behind SQL Injection. I have added this here since so far we had been dealing with URLs, and will continue to do so. For the attacker, there is no direct way to write complete queries and he/she may only make changes to the URL or input form. However, the knowledge of MySQL (or any other DBMS) part of the attack is necessary, since it will be required when you deal with more robust websites where the standard attacks won't work and you need to get creative. Before reading this post, I recommend these 3:-



  • SQL Injection Basics (theoretical yet important)
  • Manual SQL Injection (using web browser only)
  • Automated SQL Injection using SQLMap (Kali Linux needed) 


  • Now we will proceed to the actual content of the post :-

    Types of SQL Injection attacks

    • SQL injection + insufficient authentication
    • SQL injection + DDoS attacks
    • SQL injection + DNS hijacking
    • SQL injection + XSS

    Technical implementations

    Incorrectly filtered escape characters

    This form of SQL injection occurs when user input is not filtered for escape characters and is then passed into a SQL statement. This results in the potential manipulation of the statements performed on the database by the end-user of the application.
    The following line of code illustrates this vulnerability:
    statement = "SELECT * FROM users WHERE name ='" + userName + "';"
    
    This SQL code is designed to pull up the records of the specified username from its table of users. However, if the "userName" variable is crafted in a specific way by a malicious user, the SQL statement may do more than the code author intended. For example, setting the "userName" variable as:
    ' or '1'='1
    
    or using comments to even block the rest of the query (there are three types of SQL comments). All three lines have a space at the end:
    ' or '1'='1' -- 
    ' or '1'='1' ({ 
    ' or '1'='1' /* 
    

    renders one of the following SQL statements by the parent language:
    SELECT * FROM users WHERE name = '' OR '1'='1';
    
    SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
    
    If this code were to be used in an authentication procedure then this example could be used to force the selection of a valid username because the evaluation of '1'='1' is always true.
    The following value of "userName" in the statement below would cause the deletion of the "users" table as well as the selection of all data from the "userinfo" table (in essence revealing the information of every user), using an API that allows multiple statements:
    a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't
    
    This input renders the final SQL statement as follows and specified:
    SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't';
    
    While most SQL server implementations allow multiple statements to be executed with one call in this way, some SQL APIs such as PHP's mysql_query() function do not allow this for security reasons. This prevents attackers from injecting entirely separate queries, but doesn't stop them from modifying queries.

    Incorrect type handling

    This form of SQL injection occurs when a user-supplied field is not strongly typed or is not checked for type constraints. This could take place when a numeric field is to be used in a SQL statement, but the programmer makes no checks to validate that the user supplied input is numeric. For example:
    statement := "SELECT * FROM userinfo WHERE id =" + a_variable + ";"
    
    It is clear from this statement that the author intended a_variable to be a number correlating to the "id" field. However, if it is in fact a string then the end-user may manipulate the statement as they choose, thereby bypassing the need for escape characters. For example, setting a_variable to
    1;DROP TABLE users
    
    will drop (delete) the "users" table from the database, since the SQL becomes:
    SELECT * FROM userinfo WHERE id=1;DROP TABLE users;
    

    Blind SQL injection

    Blind SQL Injection is used when a web application is vulnerable to an SQL injection but the results of the injection are not visible to the attacker. The page with the vulnerability may not be one that displays data but will display differently depending on the results of a logical statement injected into the legitimate SQL statement called for that page. This type of attack can become time-intensive because a new statement must be crafted for each bit recovered. There are several tools that can automate these attacks once the location of the vulnerability and the target information has been established.

    Conditional responses

    One type of blind SQL injection forces the database to evaluate a logical statement on an ordinary application screen. As an example, a book review website uses a query string to determine which book review to display. So the URL http://books.example.com/showReview.php?ID=5 would cause the server to run the query
    SELECT * FROM bookreviews WHERE ID = 'Value(ID)';
    
    from which it would populate the review page with data from the review with ID 5, stored in the table bookreviews. The query happens completely on the server; the user does not know the names of the database, table, or fields, nor does the user know the query string. The user only sees that the above URL returns a book review. A hacker can load the URLs http://books.example.com/showReview.php?ID=5 OR 1=1 and http://books.example.com/showReview.php?ID=5 AND 1=2, which may result in queries
    SELECT * FROM bookreviews WHERE ID = '5' OR '1'='1';
    SELECT * FROM bookreviews WHERE ID = '5' AND '1'='2';
    
    respectively. If the original review loads with the "1=1" URL and a blank or error page is returned from the "1=2" URL, and the returned page has not been created to alert the user the input is invalid, or in other words, has been caught by an input test script, the site is likely vulnerable to a SQL injection attack as the query will likely have passed through successfully in both cases. The hacker may proceed with this query string designed to reveal the version number of MySQL running on the server:
    http://books.example.com/showReview.php?ID=5 AND substring(@@version,1,1)=4
    , which would show the book review on a server running MySQL 4 and a blank or error page otherwise. The hacker can continue to use code within query strings to glean more information from the server until another avenue of attack is discovered or his or her goals are achieved.

    Second Order SQL Injection

    Second order SQL injection occurs when submitted values contain malicious commands that are stored rather than executed immediately. In some cases, the application may correctly encode a SQL statement and store it as valid SQL. Then, another part of that application without controls to protect against SQL injection might execute that stored SQL statement. This attack requires more knowledge of how submitted values are later used. Automated web application security scanners would not easily detect this type of SQL injection and may need to be manually instructed where to check for evidence that it is being attempted.

    This post is licensed under Creative Commons Attribution-ShareAlike 3.0. This license permits sharing, but requires attribution and that the content be shared under same or similar license . The source of the content in this page is -
    https://en.wikipedia.org/wiki/SQL_injection
    License details can be read here https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License

    Blind SQLi Tutorial

    You may read this tutorial if you have gone through the content of this page and are ready to go to the next level.

    27 comments:

    1. a post full of waste...we can this all this stuff on youtube or wikipedia..teach us some real hacks dude..

      ReplyDelete
      Replies
      1. Try this http://www.kalitutorials.net/2015/02/blind-sql-injection.html

        Delete
      2. seriously..a post full of waste..anyone knows about sql injection dude..teach us how to perform that...attack..

        Delete
      3. You sound like a little script kiddie. Go back to trying to hack your grandmothers WEP AP you turd.
        This man is devoting his time to churning out these tutorials for the lowest common denominator.
        Be a little more humble you pissant

        Delete
      4. Hello world
        We Only Make - The boss

        Reseller :- Hacking Tools & Hacking services, Also Teach Hacking Methods Via teem weaver or Anydesk,
        Each Method Take minimum 1 hour to learn with vedio Tutorial And Hacking Tools ,

        How to Make Money With Method & luck ,

        - Spamming & Tools ,
        - Carding & Tools ,
        - Virus with control panal and Spy bot files,
        - Virus With Builder And Crypter ,
        - Scanners with Bruters ,
        - Crypters with Doc Exploits ,pdf Exploits ,TExtfile Exploits ,
        - PHP Exploits with shell and mailer
        - OTP verications Bypass with Bulletproof Scam-page and Otp control
        - Company Ceo or cfo leads Any country
        - Rat virus with builder
        - Cookies Stealers and Builder
        - keyloger and builder
        - Credit card Scam-pages
        - Bank login Scam-pages
        - debit card topup scam page
        - donation scam-page
        - dhl login and tracking scam-page
        - fedax login and tracking scam-page
        - Shipping Tools

        Place & Ground
        learners you will pay cheap $ for demo Tools & Method

        Business grounds

        Credit card Low Interest Services,

        - Credit card with Fullz Information - Minimum Investment 150$ - With 50k Credit limit And balance
        - Debit Card Topup AS per Card limit - Minimum Investment 200$ - With 8000$ balance
        - Dating scam Fresh male female Logins - Minimum Investment 80$ - Dating Login upto 30
        - Tex refund Scam leads - Minimum Investment 200$ - Result upto 5000 in 10 days
        - payments and Bills - Minimum Investment 300$ - upto 7000$
        - Wester union Minimum Transfer 2000$ - Transfer Fess 400$
        -----------------
        ABOUT US :
        Icq :-675452902
        Skype: rushr00t000
        email me:- hackitbackd00r@gmail.com


        Delete
    2. How about hosted pages of Mikrotik system? Does Injection work ?!

      ReplyDelete
      Replies
      1. 🏵PLUG HACKERS🏵
        We are a group of HACKERS dedicated to fish out SPAMMERS❌( fake Hackers) that are stealing from people daily. The are everywhere in the internet, in various Sites and Social Media.

        WHO ARE PLUG HACKERS⁉️
        We are HACKERS registered under the HACKER’s FORUM “HACKERONE”. We have dedicated ourselves to flush out these false HACKERS and also to help their victims recover Every penny💵💶 they have lost to this Thieves.

        If you have been a victim of this SPAMMERS you need to contact us ASAP using the Email provided below
        GLOBALPLUGGERS@gmail.com
        OR
        You can drop a voice note message to the secure line below and we will get back to you
        +1 (808) 600 0773.







        Delete
    3. Very innovative post, thanks
      Regards,
      http://pre-testbd.com

      ReplyDelete
    4. copy paste from wiki xD

      ReplyDelete
    5. good commands. very helpful.

      ReplyDelete

    6. BEST WAY TO HAVE GOOD AMOUNT TO START A GOOD BUSINESS or TO START LIVING A GOOD LIFE..... Hack and take money directly from any ATM Machine Vault with the use of ATM Programmed Card which runs in automatic mode. email (williamshackers@hotmail.com) for how to get it and its cost . .......... EXPLANATION OF HOW THESE CARD WORKS.......... You just slot in these card into any ATM Machine and it will automatically bring up a MENU of 1st VAULT $5,000, 2nd VAULT $10,000, RE-PROGRAMMED, EXIT, CANCEL. Just click on either of the VAULTS, and it will take you to another SUB-MENU of ALL, OTHERS, EXIT, CANCEL. Just click on others and type in the amount you wish to withdraw from the ATM and you have it cashed instantly... Done. ***NOTE: DON'T EVER MAKE THE MISTAKE OF CLICKING THE "ALL" OPTION. BECAUSE IT WILL TAKE OUT ALL THE AMOUNT OF THE SELECTED VAULT. email (williamshackers@hotmail.com). We are located in USA.

      ReplyDelete
    7. Guys it no longer questionable when it comes to (HACKING). I am good in what I do Hacking.

      I am tire of showing you guys list of what I do and good at, no matter what it is you WANT just bring it on I will Hack it for you

      All you need do just Email:- pointekhack@gmail.com and your job shall be done with %100✓ guarantee

      ReplyDelete
    8. i was lost with no hope for my wife was cheating and had always got away with it because i did not know how or always too scared to pin anything on her. with the help a friend IN PERSON OFJOHN who recommended me to who help hack her phone, email, chat, sms and expose her for a cheater she is. I just want to say a big thank you to HACKINTECHNOLOGY@GMAIL.COM . am sure someone out there is looking for how to solve his relationship problems, you can also contact him for all sorts of hacking job..he is fast and reliable. you could also text +1 669 225 2253

      ReplyDelete
    9. contact : elizabethjone146@gmail.com WhatsApp +18573255825 Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
      Do you need to retrieve your stolen bitcoin?
      Do you need to increase your credit score?
      Do you intend to upgrade your school grade?
      Do you need any information concerning any database.
      Do you need to retrieve deleted files?
      Do you need to clear your criminal records or DMV?
      Do you want to remove any site or link from any blog?
      you should contact this hacker, he is reliable and good at the hack jobs..
      contact : elizabethjone146@gmail.com WhatsApp +18573255825

      ReplyDelete
    10. contact : elizabethjone146@gmail.com WhatsApp +18573255825 Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
      Do you need to retrieve your stolen bitcoin?
      Do you need to increase your credit score?
      Do you intend to upgrade your school grade?
      Do you need any information concerning any database.
      Do you need to retrieve deleted files?
      Do you need to clear your criminal records or DMV?
      Do you want to remove any site or link from any blog?
      you should contact this hacker, he is reliable and good at the hack jobs..
      contact : elizabethjone146@gmail.com WhatsApp +18573255825

      ReplyDelete
    11. elizabethjone146@gmail.com WhatsApp +18573255825
      hello everybody if you Need a good hacker? A senior member of ice fog hackers.A professional in the areas mentioned below:
      1. hotmailfacebook,whatsapp,emails,twitter and instagram hack
      2- Hacking computer system
      3- Cloning of phones
      4- Changing DMV records without leaving traces
      5- Changing school grades without leaving traces
      6- Retrieving hacked social media accounts
      7- Credit card hack
      8- Clearing criminal records
      9- Clearing of bad driving records without leaving traces
      10- Website hack
      11- Retrieving hacked social media accounts
      12- P.I – Private investigator like cheating husbands or wives and any other P.I activities and so many other services.
      13- Catch hacker scammers
      14- Wire transfer to any bank
      15- Retrieval of hacked accounts (facebook,twitter,instagram,zoosk,match etc..)
      16- Bank login
      17- Phishing emails. to mention a few..He is at your service if you need him.
      Contact elizabethjone146@gmail.com WhatsApp +18573255825
      is the best of hacker try elizabeth you will happy about your work

      ReplyDelete
    12. best hacker WHAT ARE YOU SEEKING?
      WE ARE GREATER THAN OTHERS IN HACKING PROFESSIONALISM.LETS HELP YOU WITH YOUR HACKING NEEDS. IN THE FOLLOWING AREAS SUCH AS.
      Erasing of criminal records,
      Do you need to hack into any SCHOOL DATABASE server?
      How To Check Someones Text Messages Online
      improve your CREDIT SCORE?
      HACK ANY PHONE without having physical access?
      Hack all kinds of SOCIAL MEDIA ACCOUNTS?
      Hack all EMAIL ACCOUNTS?
      hack b t c
      Hack SOMEONE LOCATION?
      Contact elizabethjone146@gmail.com
      WhatsApp +18573255825

      ReplyDelete
    13. Never settle for a cheating spouse. Contact elizabethjone146@gmail.com
      WhatsApp +18573255825 for any form of hack like
      1-DATABASE HACK.
      2-WHATSAPP HACK
      3-WEBSITE HACK
      4-TRACKING CALLS
      5-PHONE CLONE
      6-FACEBOOK HACK
      7-CHANGE SCHOOL GRADE
      8-ONLINE RECORDS CHANGES
      9-BANK ACCOUNT HACK
      10-ERASE CRIMINAL RECORDS
      11-ONLINE HACKING LECTURES
      12-WORLD PRESS BLOGS HACK
      13-CONTROL DEVICES REMOTELY HACK
      14-SALES OF DUMPS CARDS & CC OF ALL KIND
      15-RETRIVAL OF HACKED SOCIAL MEDIA ACCOUNTS
      16-INCREASE CREDIT SCORE
      i have used this hacker services more than 5 times and it has always worked try him and thank me later. you Contact elizabethjone146@gmail.com
      WhatsApp +18573255825

      ReplyDelete
    14. best hacker A hacker that can do all form of jobs you want is AVAILABLE read till the end for his EMAIL. Contact elizabethjone146@gmail.com
      WhatsApp +18573255825
      1-DATABASE HACK
      2-WHATS-APP HACK
      3-WEBSITE HACK
      4-TRACKING CALLS
      5-PHONE CLONE
      6-FACEBOOK HACK
      7-CHANGE SCHOOL GRADE
      8-ONLINE RECORDS CHANGES
      9-BANK ACCOUNT HACK
      10-ERASE CRIMINAL RECORDS
      11-ONLINE HACKING LECTURES
      12-WORLD PRESS BLOGS HACK
      13-CONTROL DEVICES REMOTELY HACK
      14-SALES OF DUMPS CARDS & CC OF ALL KIND
      15-RETRIVAL OF HACKED SOCIAL MEDIA ACCOUNTS
      16-INCREASE CREDIT SCORE
      17.- CRACK YAHOO! MAIL PASSWORD
      18.- CRACK MSN / HOTMAIL PASSWORD
      19.- CRACK AOL/ AIM PASSWORD
      20.- CRACK GMAIL / GOOGLE PASSWORD
      21.- CRACK MySPACE PASSWORD
      22.- CRACK COMCAST PASSWORD
      23.- CRACK SBCBLOBAL PASSWORD
      24.- CRACK TISCALI PASSWORD
      25.- CRACK FRIENDSTER PASSWORD
      26.- CRACK FACEBOOK PASSWORD
      27.- CRACK MAIL.RU PASSWORD
      28.- CRACK RAMBLER PASSWORD
      29.- CRACK GMX PASSWORD
      30.- CRACK ROGERS PASSWORD
      31.- CRACK BTinternet PASSWORD
      Contact elizabethjone146@gmail.com
      WhatsApp +18573255825

      ReplyDelete
    15. contact : elizabethjone146@gmail.com WhatsApp +18573255825 Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
      Do you need to retrieve your stolen bitcoin?
      Do you need to increase your credit score?
      Do you intend to upgrade your school grade?
      Do you need any information concerning any database.
      Do you need to retrieve deleted files?
      Do you need to clear your criminal records or DMV?
      Do you want to remove any site or link from any blog?
      you should contact this hacker, he is reliable and good at the hack jobs..
      contact : elizabethjone146@gmail.com WhatsApp +18573255825

      ReplyDelete
    16. Hello Everybody,
      My name is Mrs Sharon Sim. I live in Singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of $250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of $250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius, call/whats-App Contact Number +918929509036 via email:(urgentloan22@gmail.com) Thank you.

      ReplyDelete
    17. contact : elizabethjone146@gmail.com WhatsApp +18573255825 Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
      Do you need to retrieve your stolen bitcoin?
      Do you need to increase your credit score?
      Do you intend to upgrade your school grade?
      Do you need any information concerning any database.
      Do you need to retrieve deleted files?
      Do you need to clear your criminal records or DMV?
      Do you want to remove any site or link from any blog?
      you should contact this hacker, he is reliable and good at the hack jobs..
      contact : elizabethjone146@gmail.com WhatsApp +18573255825

      ReplyDelete
    18. Never settle for a cheating spouse. Contact elizabethjone146@gmail.com
      WhatsApp +18573255825 for any form of hack like
      1-DATABASE HACK.
      2-WHATSAPP HACK
      3-WEBSITE HACK
      4-TRACKING CALLS
      5-PHONE CLONE
      6-FACEBOOK HACK
      7-CHANGE SCHOOL GRADE
      8-ONLINE RECORDS CHANGES
      9-BANK ACCOUNT HACK
      10-ERASE CRIMINAL RECORDS
      11-ONLINE HACKING LECTURES
      12-WORLD PRESS BLOGS HACK
      13-CONTROL DEVICES REMOTELY HACK
      14-SALES OF DUMPS CARDS & CC OF ALL KIND
      15-RETRIVAL OF HACKED SOCIAL MEDIA ACCOUNTS
      16-INCREASE CREDIT SCORE
      i have used this hacker services more than 5 times and it has always worked try him and thank me later. Contact elizabethjone146@gmail.com
      WhatsApp +18573255825

      ReplyDelete
    19. contact
      elizabethjone146@gmail.com or text them on Whatsapp +18573255825 Do you suspect your partner of cheating? are you being overly paranoid
      or seeing signs of infidelity?Then he sure is cheating: I was in that
      exact same position when I was referred through my best friend Monique
      who helped me hack into my girlfriend’s phone, it was like a miracle
      when he helped me clone my girlfriend phone and I got first-hand information
      from his phone. Now I get all his incoming and outgoing text messages, emails, call
      logs, web browsing history, photos and videos, instant messengers (facebook,whatsapp,bbm,IG
      etc) GPS locations, phone tap to get live transmissions
      on all phone conversations.You can also contact
      elizabethjone146@gmail.com or text them on Whatsapp +18573255825

      ReplyDelete
    20. I want to testify about United blank atm cards which can withdraw money from any atm machines around the world. I was very poor before and have no job. I saw so many testimony about how United hackers send them the atm blank card and use it to collect money in any atm machine and become rich. I email them also and they sent me the blank atm card. I have use it to get 90,000 dollars. withdraw the maximum of 5,000 USD daily. United hackers  is giving out the card just to help the poor. Hack and take money directly from any atm machine vault with the use of atm programmed card which runs in automatic mode.

      Email: unitedblankatmhackcard@gmail.com

      ReplyDelete

    © 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.
    Bitcoin: 1B5aLqJcMW7zznffTxQwta8JTZsxBDPguC