This post is an introduction to D2 Elliot, the Web Exploitation Framework, and will focus on its SQL injection capabilities.
As a short disclaimer, for the rest of the article, the keyword "target" defines your lab VM or pentest training instance. The vulnerable application has been taken as a random example from the current landscape of vulnerabilities.
Let's start with a simple use, by exploiting GENU CMS. We will see how a simple SQL injection vulnerability is handled by the framework and is exploited in a matter of seconds.
The vulnerable code is present in the articles/read.php file:
This is easily exploited by reaching the following URL:
How do we implement this exploitation in Elliot?
We create a new exploit and select the appropriate type of exploit, here it's an SQL exploit. The web exploits often share the common attribute of being directed to a particular vulnerable webpage. The vulnerable URL is given and we mark the injection point with the "
The <WRAPPER> tag specifies that we want Elliot to determine how to inject; it will therefore detect if we need a quote in before the injection string, a comment at the end, etc; overall, the injection details.
Let's now run some different payloads:
That's as simple as that. Let's now spawn a session to run several SQL queries.
How does that work?
First, the exploit needs to determine what kind of DBMS is running. The vulnerability is tried in different ways to determine which one of the known DBMS (see here) is the best match. Then, according to the DBMS, it computes some additional parameters, like the way to encode strings to bypass filters.
Then, an injection method must be determined. From the number of injection methods it knows on MySQL (see here as well), Elliot determines the union method would fit the most on this simple case.
It therefore configures its parameters.
Let's break down these four parameters one by one:
First, we need to know how much fields are in the first query, so that the number of fields in our injection matches it.
Then Elliot determines one field that is displayed in the page, in order to fetch injection results.
Now comes another important information, which is whether or not every row of the SQL query will be displayed in the web page. Often we encounter code that simply fetches the first result, and throws the other away. If it is the case,Elliot will fetch every result one by one, using in this case the LIMIT operator of MySQL.
Elliot then verifies if a row stacking method is available; if it is, it will greatly improve performance by reducing HTTP exchanges. Some of you might think about the GROUP_CONCAT() function, which allows to obtain several rows as if they were only one. The main problem of this function is that it is limited to 1024 characters, which is not much when we need to obtain, for instance, the content of a whole table.
Elliot uses an homebrew extraction method, developed for several DBMS, which allows to obtain every single row of a query as one. This method has no limit of size whatsoever, and fetching thousand of rows only takes a single HTTP exchange.
Every parameter can be specified by the user, in the exploit or at runtime, or simply determined by Elliot.
As this article comes to an end, hopefully you can see how easy it is to design and use an exploit with Elliot. The SQL injection engine has been designed to support all kinds of injection, even the most peculiar, and the most advanced. Posts about more advanced exploits will follow, still in the SQL series. Stay posted on twitter