Use SQLMAP SQL Injection To Hack A Website and Database in Kali Linux
Use SQLMAP SQL Injection To Hack A Website and Database in Kali Linux
SQL injection is a code injection technique, used to attack data driven applications, in which malicious SQL statements
are inserted into an entry field for execution (e.g. to Hackdumpwebsitethe passworddatabaseusingcontents to the
attacker). SQL injection must exploit a security vulnerability in an WireSharkapplication’s software, for example,
Did you knew every time you
when user input is either incorrectly filtered for string literal escape characters embedded in SQL fill in your username and
password on a website …
statements or user input is not strongly typed and unexpectedly executed. SQL injection is mostly known as
an attack vector for websites but can be used to attack any type of SQL databases. In this guide I will show
you how to SQLMAP SQL Injection on Kali Linux to hack a website (more specifically Database) and
What is SQLMAP
sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL
injection flaws and taking over of database servers. It comes with a powerful detection engine, many niche
features for the ultimate penetration tester and a broad range of switches lasting from database
fingerprinting, over data fetching from the database, to accessing the underlying file system and executing
Features
1. Full support for MySQL, Oracle, PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite,
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 1/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
2. Full support for six SQL injection techniques: boolean-based blind, time-based blind, error-based,
3. Support to directly connect to the database without passing via a SQL injection, by providing DBMS
4. Support to enumerate users, password hashes, privileges, roles, databases, tables and columns.
5. Automatic recognition of password hash formats and support for cracking them using a dictionary-based
attack.
6. Support to dump database tables entirely, a range of entries or specific columns as per user’s choice.
The user can also choose to dump only a range of characters from each column’s entry.
7. Support to search for specific database names, specific tables across all databases or specific columns
across all databases’ tables. This is useful, for instance, to identify tables containing custom application
credentials where relevant columns’ names contain string like name and pass.
8. Support to download and upload any file from the database server underlying file system when the
9. Support to execute arbitrary commands and retrieve their standard output on the database server
underlying operating system when the database software is MySQL, PostgreSQL or Microsoft SQL Server.
10. Support to establish an out-of-band stateful TCP connection between the attacker machine and the
database server underlying operating system. This channel can be an interactive command prompt, a
Meterpreter session or a graphical user interface (VNC) session as per user’s choice.
11. Support for database process’ user privilege escalation via Metasploit’s Meterpreter getsystem
command.
[Source: www.sqlmap.org]
Be considerate to the user who spends time and effort to put up a website and possibly depends on it to
make his days end. Your actions might impact someone is a way you never wished for. I think I can’t make it
anymore clearer.
So here goes:
Contents [hide]
What is SQLMAP
Features
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 2/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
Step 1.a: Google Dorks strings to find Vulnerable SQLMAP SQL injectable website
Step 1.b: Initial check to confirm if website is vulnerable to SQLMAP SQL Injection
MySQL Errors
Oracle Errors
PostgreSQL Errors
Step 4: List columns on target table of selected database using SQLMAP SQL Injection
Step 5: List usernames from target columns of target table of selected database using SQLMAP SQL Injection
Step 6: Extract password from target columns of target table of selected database using SQLMAP SQL
Injection
Conclusion
Dorks knows this already, but in case you don’t I have put together a number of strings that you can search
in Google. Just copy paste any of the lines in Google and Google will show you a number of search results.
Step 1.a: Google Dorks strings to find Vulnerable SQLMAP SQL injectable website
This list a really long.. Took me a long time to collect them. If you know SQL, then you can add more here..
Google Dork string Column 1 Google Dork string Column 2 Google Dork string Column 3
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 3/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
decl_id=
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 4/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
inurl:communique_detail.php?
inurl:article.php?id= inurl:memberInfo.php?id=
id=
id=
ID=
inurl:Stray-Questions-View.php?
inurl:loadpsb.php?id= inurl:transcript.php?id=
num=
inurl:news.php?id= inurl:participant.php?id=
inurl:avd_start.php?avd= inurl:download.php?id=
inurl:event.php?id= inurl:main.php?id=
inurl:product-item.php?id= inurl:review.php?id=
inurl:sql.php?id= inurl:chappies.php?id=
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 5/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
inurl:material.php?id= inurl:read.php?id=
inurl:clanek.php4?id= inurl:prod_detail.php?id=
inurl:announce.php?id= inurl:viewphoto.php?id=
inurl:chappies.php?id= inurl:article.php?id=
inurl:read.php?id= inurl:person.php?id=
inurl:viewapp.php?id= inurl:productinfo.php?id=
inurl:viewphoto.php?id= inurl:showimg.php?id=
inurl:rub.php?idr= inurl:view.php?id=
inurl:galeri_info.php?l= inurl:website.php?id=
Step 1.b: Initial check to confirm if website is vulnerable to SQLMAP SQL Injection
For every string show above, you will get huundreds of search results. How do you know which is really
vulnerable to SQLMAP SQL Injection. There’s multiple ways and I am sure people would argue which one
http://www.sqldummywebsite.com/cgi-bin/item.cgi?item_id=15
http://www.sqldummywebsite.com/cgi-bin/item.cgi?item_id=15'
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 6/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
If the page returns an SQL error, the page is vulnerable to SQLMAP SQL Injection. If it loads or redirect you
to a different page, move on to the next site in your Google search results page.
See example error below in the screenshot. I’ve obscured everything including URL and page design for
obvious reasons.
Description: An unhanded exception occurred during the execution of the current web request. Please
review the stack trace for more information about the error where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark before the character string ‘attack;’.
MySQL Errors
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/myawesomestore.com/buystuff.php on
line 12
Error: You have an error in your SQL syntax: check the manual that corresponds to your MySQL server version for the right syntax to use
near ‘’’ at line 12
Oracle Errors
java.sql.SQLException: ORA-00933: SQL command not properly ended at oracle.jdbc.dbaaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 7/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
PostgreSQL Errors
Query failed: ERROR: unterminated quoted string at or near “‘’’”
need to list all the databases in that Vulnerable database. (this is also called enumerating number of
In here:
sqlmap
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 8/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
is a standard database for almost every MYSQL database. So our interest would be on
sqldummywebsite
database.
database got and what are their names. To find out that information, use the following command:
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 9/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
table using SQLMAP SQL Injection as that table probably contains username and passwords.
of
sqldummywebsite
database using SQLMAP SQL Injection. SQLMAP SQL Injection makes it really easy, run the following
command:
of
sqldummywebsite
database.
and
user_password
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 11/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 12/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
Almost there, we now only need the password to for this user.. Next shows just that..
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/
13/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
+--------------- +
| 24iYBc17xK0e. |
+--------------- +
But hang on, this password looks funny. This can’t be someone’s password.. Someone who leaves their
website vulnerable like that just can’t have a password like that.
That is exactly right. This is a hashed password. What that means, the password is encrypted and now we
I have covered how to decrypt password extensively on this Cracking MD5, phpBB, MySQL and SHA1 passwords with Hashcat on
Kali Linux post. If you’ve missed it, you’re missing out a lot.
I will cover it in short here but you should really learn how to use hashcat.
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 14/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
command line type in the following command and on prompt paste the hash value:
hash-identifier
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 15/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
So it’s either 1500 or 3100. But it was a MYSQL Database, so it must be 1500.
I am running a Computer thats got NVIDIA Graphics card. That means I will be using cudaHashcat. On my
laptop, I got an AMD ATI Graphics cards, so I will be using oclHashcat on my laptop. If you’re on VirtualBox
or VMWare, neither cudahashcat nor oclhashcat will work. You must install Kali in either a persisitent USB or
in
DES.hash
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 16/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
Interesting find: Usuaul Hashcat was unable to determine the code for DES hash. (not in it’s help menu).
Howeverm both cudaHashcat and oclHashcat found and cracked the key.
Conclusion
Thanks for reading and visiting my website.
There’s many other ways to get into a Database or obtain user information. You should practice such
Please share and let everyone know how to test their websites using this technique.
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 17/18
9/24/2015 Use SQLMAP SQL Injection to hack a website and database in Kali Linux darkMORE Ops
http://www.darkmoreops.com/2014/08/28/usesqlmapsqlinjectionhackwebsitedatabase/ 18/18