ttp_windows_suspicious_filewrites_to_sharepoint_layouts
Description
Detects a command-line interpreter (cmd.exe or powershell.exe) writing a file to a SharePoint (\TEMPLATE\LAYOUTS) directory.
Query · yara_l
events:
(
$e.metadata.event_type = "FILE_CREATION" or
$e.metadata.event_type = "FILE_MODIFICATION" or
$e.metadata.event_type = "FILE_MOVE"
)
$e.target.file.full_path = /\\\d{1,2}\\TEMPLATE\\LAYOUTS\\[^\\]+$/ nocase
$e.principal.process.file.full_path = /(^|\\)(pwsh|cmd|powershell)\.exe$/ nocase
not $e.principal.process.command_line = /C:\\SP\\Automation\\\\AutoSPInstallerMain.ps1\s+C:\\SP\\Automation\\\\AutoSPInstallerInput.xml/ nocase
outcome:
$principal_hostname = $e.principal.hostname
$risk_score = 85
$vendor_name = array($e.metadata.vendor_name)
$product_name = $e.metadata.product_name
$victim_uid = $e.principal.asset.asset_id
$victim_name = $e.principal.asset.hostname
$victim_netid = array($e.principal.ip)
$adversary_uid = $e.principal.user.userid
$adversary_name = $e.principal.user.user_display_name
$adversary_netid = $e.principal.user.windows_sid
$tmp1 = max(
if($e.security_result.action != "BLOCK" and $e.security_result.action != "UNKNOWN_ACTION", 2)
)
$tmp2 = max(
if($e.security_result.action = "BLOCK", 1)
)
$result = arrays.index_to_str(strings.split("attempted,failed,succeeded,succeeded"), $tmp1 + $tmp2)
$result_time = $e.metadata.event_timestamp.seconds
$event_count = 1
condition:
$e