Extreme Hacking
Advanced Ethical Hacking Institute in Pune
INTRO!!
In this tutorial, I will demonstrate the infamous MySQL injection in newbie perspective so that all the newbies become able to become successful SQL injector. But, be sure to check various php & mysql functions in various sites which will help you a lot… Now lets begin our walkthrough of SQL injection. WHAT IS DATABASE? WHAT IS SQL INJECTION? |
BYPASSING LOGINS
Suppose, a site has a login form & only the registered users are allowed to enter the site. Now, say u wanted to bypass the login and enter the site as the legitimate user. If the login scriptblock is not properly sanitized by the programmer, u may have luck to enter the site. U might be able to login into the site without knowing the real username and real password by just interacting with the DB server. So, isn’t that the beauty of SQL injection?? Let’s see an example, where the username admin with the password pass123 can login to the site. Suppose, the SQL query for this is carried out as below: SELECT USER from database WHERE username=’admin’ AND password=’pass123′ And if above SELECT command evaluates true, user will be given access to the site otherwise not. Think what we could do if the scriptblock is not sanitized. This opens a door for the hackers to gain illegal access to the site. In this example, the attacker can enter the following user data in the login form: username: a or 1=1– password:blank So, this would make our query as: SELECT USER from database WHERE username=’a’ or 1=1– AND password=” Note that — is the comment operator and anything after it will be ignored as a comment. There exists another comment operator which is /*. So our above query becomes: SELECT USER from database WHERE username=’a’ or 1=1 Now this query evaluates true even if there is no user called ‘a’ bcoz 1=1 is always true and using OR makes the query return true when one of the query is true. And this gives access to the site admin panel. ACCESSING SECRET DATA Sub-section 1: Sub-section 2: Sub-section 3: Sub-section 4: Quick note: Also, you may check for user, database,etc.. by using following: Sub-section 5: This will list all the tables present in the DB. For our purpose, we will be searching for the table containing the user and password information. So we look the probable table with that information. U can even write down the table names for further reference and works. For my example, I would use the tbluser as the table that contains user & password. This returns all the columns present in the DB server. Now from this listing, we will look for the probable columns for username and password. For my injection, there are two columns holding these info. They are username and password respectively. So that’s the column what I wanted. U have to search and check the columns until u get no error. This would display the columns present in the table tbluser. But this may not work always. Sub-section 6: Here, I guessed for the table name as user. But this gave me the error bcoz the table with the name user didn’t exist on the DB. Now I kept on guessing for the table name until I didn’t get error. The page loaded normally. Now again u have to guess the column names present in the tbluser table. U may try these methods so as to get various data such as credit card numbers, social security numbers, etc. and etc. if the database holds. Just what u need to do is figure out the columns and get them displayed on the vulnerable page. That’s all on the injection for accessing secret data. MODIFYING SITE CONTENT: By executing first query, we have set the title value as ‘Hacked By sam207′ in the table article while in second query, we have updated all three fields title, data, & author in the table article. DELETE:As already stated, this deletes the content of one or more fields permanently from the db server. DROP:This is another deadly command u can use. With this, u can delete a table & all its associated data. Finally, I want to say little about ; SHUTTING DOWN MySQL SERVER: LOADFILE: But sometimes, you will have to hex the part & do something like below: MySQL ROOT: Now you will get the usernames & hashes.. The hash is mysqlsha1… Quick note: JTR won’t crack it.. But http://www.insidepro.com has one to do it.. FINALIZING THE INJECTION TUTORIAL: MAJOR MySQL COMMANDS:
Below, I would list some major MySQL commands that might help you a lot… Play with them in different ways by setting up a MySQL server in your computer..
ALTER DATABASE — change a database Disclaimer |
www.extremehacking.org
CEHv8 CHFIv8 ECSAv8 CAST ENSA CCNA CCNA SECURITY MCITP RHCE CHECKPOINT ASA FIREWALL VMWARE CLOUD ANDROID IPHONE NETWORKING HARDWARE TRAINING INSTITUTE IN PUNE,Certified Ethical Hacking, Center For Advanced Security Training in India,IT Security Training Information Security Traning Courses in Pune, ceh certification in pune, Ethical Hacking Course in Pune