SQL INJECTION UNION BASED (BEGINNER LEVEL)

SQL injection is kind of code injection. we can compromise our victim database by exploiting SQL injection.

How to find SQL injection vulnerability on a website?
there are lots of tools on the internet and also we can use google dorks to find SQL injection vulnerability.
google dork examples

  • inurl:php?id= (this is common search)
  • inurl:php?id=  facebook (this is specific domain or related thing )


NOTE: THIS SEARCH RESULT IS NOT 100 ACCURACY 

How to check the SQL injection vulnerability?
just put a single quote in the targeted URL. after putting single quotes in the URL. if you get an SQL related error on your victim website, then you can confirm your assumption. the below image shows an error message.

How to exploit?
first, we have to find the vulnerable table total columns number. so I used ORDER BY statement at the end of the url.
NOTE: I ALREADY KNOW THE ACTUAL NUMBER OF COLUMN THAT'S WHY I USED 5 HERE. IF YOU USE INVALID COLUMN NUMBER YOU WILL GET ERROR ON THIS PAGE.

after finding the total number of columns we have to find the vulnerable columns from that. so we can use "union+all+select" statement and find vulnerable columns.
NOTE: I had found 2 and 3 as the vulnerable column in my example.

then we have to check identified vulnerable columns are working or not. so I use @@version command to check the column.
the vulnerable column display the sql version information so we can make sure the command status.

NOTE: WE SHOULD WRITE THE COMMAND WITHIN VULNERABLE COLUMN ONLY OTHERWISE IT IS NOT WORKING.
now we have to find all table from our victim so im going to use "group_concat(table_name),5,6+from+information_schema.tables+where+table_schema=database()" this command and find the table names from our victim.

now, we need column names from respective tables. so i use this command "UNION+SELECT+1,2,3,group_concat(column_name),5,6+from+information_schema.columns+where+table_name=char(10,10,10,10)"
NOTE: WE SHOULD CHANGE THE TABLE NAME TO CHAR CHARACTORS

likewise, we can get the data as well
"UNION+SELECT+1,2,3,group_concat(aaa,bb),5,6+from+TABLENAME"

Comments

Post a Comment

Popular posts from this blog

Install android studio on the parrot os

How to do simple brute force attack with burp suite

PoC video of How to Hack Gmail and Bitcoin Wallet using SS7 flaw