← All hunts high TLP:CLEAR Part 2 of 3

SafePay: Internal Discovery and Lateral Movement

An adversary is using legitimate administrative tools and scripts to enumerate network shares and move laterally via remote management protocols while disabling local security software.

Based on research by CISA 2026-10-22 9 steps · 3 queries T1021.001 T1021.002 T1021.006 T1027.002 T1059.001 T1059.003 T1569.002 T1685

Brief

The Context

SafePay ransomware actors often exploit known vulnerabilities for initial access before beginning a period of internal discovery. CISA recently detailed these tactics in advisory AA26-293A (#StopRansomware: SafePay Ransomware). Once inside, the adversary focuses on identifying high-value targets and moving laterally using tools that frequently blend into legitimate IT operations.

How the Hunt Flows

The hunt starts by examining process execution logs for a specific set of administrative and Remote Monitoring and Management (RMM) tools. It identifies tools like PsExec, AnyDesk, and ScreenConnect. Rather than alerting on every execution, the first phase filters for rare occurrences across the fleet. This identifies hosts where these tools appear outside of their typical administrative footprint.

The second phase runs two queries in parallel to provide context to the identified tools. The first query searches script activity logs for specific functions associated with network share discovery and Active Directory enumeration. It looks for content like ShareFinder or Get-NetShare that attackers use to find sensitive data or backup servers.

The second parallel query examines network connections to remote management ports such as RDP (3389) and WinRM (5985, 5986). It stacks these connections to find rare outbound patterns. If a host identified in the process phase also shows outbound RDP activity to a server it does not usually manage, the confidence of the finding increases.

Finally, the hunt synthesizes these findings. An analyst or automated agent triages the results by correlating the process, script, and network evidence. This multi-surface approach helps separate an IT administrator performing maintenance from an intruder mapping the network.

Blind Spots and Limitations

This hunt relies heavily on endpoint visibility. If the adversary pivots from an unmanaged beachhead host—such as a personal laptop or a legacy server without an agent—the initial share enumeration remains invisible. The hunt only detects the activity when the actor interacts with a managed resource.

Additionally, the script analysis uses string matching for known tools and cmdlets. If the adversary uses Base64 encoding or complex character replacement to obfuscate their PowerShell commands, the string-based filters will not catch the activity.

Why This is a Hunt

Legitimate use of AnyDesk, TeamViewer, or PsExec is common in many enterprises. A standard detection rule for these tools often creates too much noise for a security operations center to handle. This hunt is not a simple alert; it is a structured investigation that requires correlating three different types of evidence to find the signal in the noise.

How to Run the Hunt

This hunt is available as an open hunt.md playbook. You can import it into Huntbase or any other runtime that supports the hunt.md format. The playbook contains the logic to automate the initial data gathering and provide a structured interface for triage.

In this series

Steps

  1. Identify administrative and RMM tools

    Query · detection candidate

    Find the execution of tools SafePay uses for lateral movement and host enumeration, filtering for rare occurrences.

    reads hb_process_activitysql
    SELECT device_hostname, process_name, process_path, parent_process_name, process_cmd_line, user_name, time FROM hb_process_activity WHERE (instr(',' || '{{discovery_tools}}' || ',', ',' || LOWER(process_name) || ',') > 0 OR instr(',' || '{{discovery_tools}}' || ',', ',' || LOWER(process_original_file_name) || ',') > 0) AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days') GROUP BY process_name, process_path, parent_process_name, process_cmd_line, device_hostname HAVING COUNT(DISTINCT device_hostname) <= 3

    What a hit looks like. Rows show legitimate tools running in unusual contexts, such as from user profiles or by unauthorized users, limited to rare sightings across the fleet.

  2. Search for share discovery and enumeration scripts

    Query · enrichment

    Locate PowerShell activity targeting network shares or performing Active Directory enumeration to identify valuable assets.

    reads hb_script_activitysql
    SELECT device_hostname, script_name, script_content, actor_user_name, time FROM hb_script_activity WHERE (LOWER(script_content) LIKE '%sharefinder%' OR LOWER(script_content) LIKE '%get-netshare%' OR LOWER(script_content) LIKE '%invoke-sharefinder%' OR LOWER(script_content) LIKE '%netshareenum%' OR LOWER(script_content) LIKE '%get-adcomputer%' OR LOWER(script_content) LIKE '%ldap://%') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days')

    What a hit looks like. Script blocks containing ShareFinder functions or AD query commands. Silence suggests no such scripts were executed within the window.

  3. Identify remote service connections

    Query · baseline

    Stack-count network connections to remote management ports used for lateral movement.

    reads hb_network_connectionsql
    SELECT device_hostname, process_name, dst_endpoint_port, COUNT(*) AS connections, MIN(time) AS first_seen FROM hb_network_connection WHERE (dst_endpoint_port IN (3389, 5985, 5986) OR LOWER(process_name) LIKE '%anydesk%' OR LOWER(process_name) LIKE '%teamviewer%') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days') GROUP BY device_hostname, process_name, dst_endpoint_port HAVING COUNT(DISTINCT device_hostname) <= 3

    What a hit looks like. A small number of hosts connecting to RDP or WinRM ports, or using RMM software. Rare connections stand out from normal administrative baseline.

  4. Triage lateral movement evidence

    Agent triage

    Synthesize the findings from process, script, and network surfaces to determine if a host is being used for lateral pivots.

  5. Evaluate threat presence

    Decision

    Route the hunt based on the agent verdict.

  6. Isolate compromised host

    Response action

    Halt lateral movement by containing the affected hosts.

  7. Analyst investigation

    Analyst task

    Verify the agent's findings and identify additional lateral movement paths.

  8. Reporting and cleanup

    Analyst task

    Finalize the hunt and record findings.

Coverage

Scenario coverage

StageCoveredHow, or why not
Active Directory and Share Discovery
T1059.001 · T1059.003
Yes identify-living-off-land-tools, hunt-malicious-scripting
Lateral Movement and Remote Management
T1021.001 · T1021.002 · T1021.006 · T1569.002
Yes identify-living-off-land-tools, examine-remote-service-traffic
Defense Impairment and Stealth
T1685 · T1027.002
Existing rule The 'defender_tamper_script_block' rule already monitors for Set-MpPreference and DisableRealtimeMonitoring commands.
Edge Device Exploitation and Brute Force
T1190 · T1110 · T1133
Out of scope Belongs to another part of the '#StopRansomware: SafePay Ransomware' series.
Account Persistence and Privilege Gain
T1098 · T1136
Out of scope Belongs to another part of the '#StopRansomware: SafePay Ransomware' series.
Local Privilege Escalation
T1548.002 · T1134.001
Out of scope Belongs to another part of the '#StopRansomware: SafePay Ransomware' series.
Data Collection and Exfiltration
T1560.001 · T1048 · T1567 · T1567.002
Out of scope Belongs to another part of the '#StopRansomware: SafePay Ransomware' series.
Encryption and Recovery Inhibition
T1486 · T1490 · T1070.004
Out of scope Belongs to another part of the '#StopRansomware: SafePay Ransomware' series.

Blind spots

  • Needs endpoint agent coverage on all domain-joined hosts. Adversaries may pivot from an unmanaged beachhead to managed servers, remaining invisible until they touch a managed resource. It would answer Are there domain-joined hosts not running an agent that are performing share enumeration?.
  • Needs hb_script_activity with full block reconstruction. A simple string match on common cmdlets can be bypassed by character replacement or encoding. It would answer Are the enumeration scripts using base64 or other obfuscation that avoids the LIKE filters?.

Parameters & data

Parameters

ParameterTypeDefaultWhat it is
discovery_toolslist[string]psexec.exe, psexec64.exe, winrm.exe, anydesk.exe, teamviewer.exe, sharpshares.exe, netexec.exe, screenconnect.exe, b2.exe, acronisdiskdirector.exeProcess names of tools used by SafePay for discovery and movement.
lookback_daysnumber14Days of history to examine.
scope_hostslist[host]—Specific hosts to narrow the hunt; leave empty for the entire estate.

Telemetry

SourceCategoryTelemetry
Endpoint telemetry (hb_ surfaces)endpointendpoint
Network telemetrynetworknetwork

Source

Download hunt.md Definition (JSON) An open hunt.md file; it runs anywhere that reads the format.
---
analysis: A single detection rule for PsExec or AnyDesk creates excessive noise in
  environments where these are used legitimately. This hunt provides the necessary
  context by correlating tool execution with share discovery scripts and rare network
  patterns, allowing an analyst to distinguish between administrative work and an
  active intrusion.
blind_spots:
- id: missing-endpoint-visibility
  question: Are there domain-joined hosts not running an agent that are performing
    share enumeration?
  requires: endpoint agent coverage on all domain-joined hosts
  risk: Adversaries may pivot from an unmanaged beachhead to managed servers, remaining
    invisible until they touch a managed resource.
  stage: discovery-share-enumeration
- id: obfuscated-scripts
  question: Are the enumeration scripts using base64 or other obfuscation that avoids
    the LIKE filters?
  requires: hb_script_activity with full block reconstruction
  risk: A simple string match on common cmdlets can be bypassed by character replacement
    or encoding.
  stage: defense-evasion-security-impairment
coverage:
- stage: discovery-share-enumeration
  status: covered
  steps:
  - identify-living-off-land-tools
  - hunt-malicious-scripting
- stage: lateral-movement-rmm-psexec
  status: covered
  steps:
  - identify-living-off-land-tools
  - examine-remote-service-traffic
- reason: The 'defender_tamper_script_block' rule already monitors for Set-MpPreference
    and DisableRealtimeMonitoring commands.
  stage: defense-evasion-security-impairment
  status: existing_rule
- reason: 'Belongs to another part of the ''#StopRansomware: SafePay Ransomware''
    series.'
  stage: initial-access-exploitation-and-brute-force
  status: out_of_scope
- reason: 'Belongs to another part of the ''#StopRansomware: SafePay Ransomware''
    series.'
  stage: persistence-account-manipulation
  status: out_of_scope
- reason: 'Belongs to another part of the ''#StopRansomware: SafePay Ransomware''
    series.'
  stage: privilege-escalation-uac-bypass
  status: out_of_scope
- reason: 'Belongs to another part of the ''#StopRansomware: SafePay Ransomware''
    series.'
  stage: collection-exfiltration-utilities
  status: out_of_scope
- reason: 'Belongs to another part of the ''#StopRansomware: SafePay Ransomware''
    series.'
  stage: impact-encryption-recovery-inhibition
  status: out_of_scope
guardrails:
  claims: no_unsupported
  evidence: citation_required
  missing_data: not_benign
  telemetry: untrusted
hunt:
  applicability: campaign-specific
  handoff: promote-to-detection
  justification: SafePay is a highly active ransomware variant targeting critical
    infrastructure. Identifying lateral movement before the impact stage (encryption)
    is the only way to prevent large-scale data loss and operational downtime.
  methodology: model-assisted
  trigger: intel-report
hypothesis: An adversary is using legitimate administrative tools and scripts to enumerate
  network shares and move laterally via remote management protocols while disabling
  local security software.
labels:
- hunt
- attack.t1059.001
- attack.t1059.003
- attack.t1021.001
- attack.t1021.002
- attack.t1021.006
- attack.t1569.002
- attack.t1685
- attack.t1027.002
- defense evasion
- discovery
- exfiltration
- impact
- initial access
- lateral movement
- persistence
- privilege escalation
name: 'SafePay: Internal Discovery and Lateral Movement'
parameters:
  discovery_tools:
    default:
    - psexec.exe
    - psexec64.exe
    - winrm.exe
    - anydesk.exe
    - teamviewer.exe
    - sharpshares.exe
    - netexec.exe
    - screenconnect.exe
    - b2.exe
    - acronisdiskdirector.exe
    description: Process names of tools used by SafePay for discovery and movement.
    from:
      kind: article
      observed: '2026-10-20'
      ref: AA26-293A
    type: list[string]
  lookback_days:
    default: '14'
    description: Days of history to examine.
    type: number
  scope_hosts:
    default: []
    description: Specific hosts to narrow the hunt; leave empty for the entire estate.
    type: list[host]
provenance:
  authors:
  - name: Huntbase hunt generation
    org: huntbase.io
  generated:
    by: huntbase-hunt-generation
    from: https://www.cisa.gov/news-events/cybersecurity-advisories/aa26-293a
    gates:
    - dry-run
    - lint
    model: hb_google/gemini-3-flash-preview
rationale: Start with workstations exhibiting unusual outbound RDP or WinRM traffic.
  Focus on systems where Windows Defender alerts have recently cleared or where 'Real-time
  monitoring' is reported as disabled.
references:
- name: 'CISA AA26-293A: #StopRansomware: SafePay Ransomware'
  url: https://www.cisa.gov/news-events/cybersecurity-advisories/aa26-293a
related:
- hunt: safepay-initial-access-exploitation
  reason: This hunt assumes the attacker has already gained a foothold via VPN or
    edge vulnerability exploitation.
  relation: precedes
- hunt: safepay-exfiltration-encryption
  reason: Once lateral movement is complete, the attacker will proceed to data collection
    and encryption.
  relation: follows
- hunt: safepay-external-access-identity-consolidation
  relation: follows
scenario:
  stages:
  - name: Edge Device Exploitation and Brute Force
    observables:
    - CVE-2020-3259
    - CVE-2023-20269
    - CVE-2023-27532
    - CVE-2024-40711
    - CVE-2024-40766
    - Mullvad VPN IP addresses
    - VPN authentication failures
    slug: initial-access-exploitation-and-brute-force
    tactic: initial-access
    techniques:
    - T1190
    - T1110
    - T1133
  - name: Account Persistence and Privilege Gain
    observables:
    - net user /add
    - Password changes for existing system users
    - Creation of new administrative accounts
    slug: persistence-account-manipulation
    tactic: persistence
    techniques:
    - T1098
    - T1136
  - name: Local Privilege Escalation
    observables:
    - UAC bypass via COM component objects
    - Token impersonation activity
    slug: privilege-escalation-uac-bypass
    tactic: privilege-escalation
    techniques:
    - T1548.002
    - T1134.001
  - name: Active Directory and Share Discovery
    observables:
    - ShareFinder.ps1
    - SharpShares.exe
    - NetExec
    slug: discovery-share-enumeration
    tactic: discovery
    techniques:
    - T1059.001
    - T1059.003
  - name: Lateral Movement and Remote Management
    observables:
    - psexec.exe
    - winrm.exe
    - AnyDesk.exe
    - TeamViewer.exe
    - ScreenConnect
    - RDP connections
    slug: lateral-movement-rmm-psexec
    tactic: lateral-movement
    techniques:
    - T1021.001
    - T1021.002
    - T1021.006
    - T1569.002
  - name: Defense Impairment and Stealth
    observables:
    - Set-MpPreference -DisableRealtimeMonitoring
    - Disabling security software
    - Software packing or VM protection
    slug: defense-evasion-security-impairment
    tactic: defense-evasion
    techniques:
    - T1685
    - T1027.002
  - name: Data Collection and Exfiltration
    observables:
    - 7z.exe
    - WinRAR.exe
    - rclone.exe
    - FileZilla.exe
    - WinSCP.exe
    - b2.exe (Backblaze)
    - OneDrive exfiltration
    slug: collection-exfiltration-utilities
    tactic: exfiltration
    techniques:
    - T1560.001
    - T1048
    - T1567
    - T1567.002
  - name: Encryption and Recovery Inhibition
    observables:
    - .SafePay extension
    - vssadmin.exe delete shadows
    - Resetting NAS to factory settings
    - Self-deletion of ransomware binary
    slug: impact-encryption-recovery-inhibition
    tactic: impact
    techniques:
    - T1486
    - T1490
    - T1070.004
  summary: SafePay ransomware actors gain initial access through credential harvesting,
    brute-force attacks, and exploitation of vulnerabilities in VPN and edge devices
    like Cisco and Veeam. Once inside, they escalate privileges via UAC bypass, move
    laterally using RDP and PsExec, and utilize RMM tools for persistence before exfiltrating
    data and deploying encryption.
series:
  index: 2
  slug: stopransomware-safepay-ransomware
  title: '#StopRansomware: SafePay Ransomware'
  total: 3
severity: high
targets:
  analyst:
    name: Tier-2 analyst
    role: analyst
  endpoint:
    category: endpoint
    name: Endpoint telemetry (hb_ surfaces)
    telemetry:
    - endpoint
  hunter:
    agent: true
    name: Hunt agent
  network:
    category: network
    name: Network telemetry
    telemetry:
    - network
tlp: clear
type: investigation
---


# SafePay: Internal Discovery and Lateral Movement

This hunt focuses on the middle phase of a SafePay ransomware intrusion. SafePay actors use living-off-the-land binaries (LOLBins) like PsExec and WinRM alongside legitimate RMM tools such as AnyDesk and ScreenConnect to pivot through the network. They concurrently use PowerShell scripts like ShareFinder to identify valuable assets and modify Windows Defender settings to avoid detection. The hunt identifies the execution of these tools, correlates them with suspicious script content, and examines network traffic to remote management ports.

## identify-living-off-land-tools
<!-- Identify administrative and RMM tools -->
Find the execution of tools SafePay uses for lateral movement and host enumeration, filtering for rare occurrences.

```sqlite target=endpoint role=detection-candidate params=(discovery_tools=discovery_tools, scope_hosts=scope_hosts, lookback_days=lookback_days)
~~~yaml
expected: Rows show legitimate tools running in unusual contexts, such as from user
  profiles or by unauthorized users, limited to rare sightings across the fleet.
prevalence:
  by: device_hostname
  key:
  - process_name
  - process_cmd_line
  rare_below: 4
reads:
- device_hostname
- parent_process_name
- process_cmd_line
- process_name
- process_original_file_name
- process_path
- time
- user_name
silence: not_evidence_of_absence
source: hb_process_activity
verified: dry-run
verified_at: '2026-10-22'
~~~
SELECT device_hostname, process_name, process_path, parent_process_name, process_cmd_line, user_name, time FROM hb_process_activity WHERE (instr(',' || '{{discovery_tools}}' || ',', ',' || LOWER(process_name) || ',') > 0 OR instr(',' || '{{discovery_tools}}' || ',', ',' || LOWER(process_original_file_name) || ',') > 0) AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days') GROUP BY process_name, process_path, parent_process_name, process_cmd_line, device_hostname HAVING COUNT(DISTINCT device_hostname) <= 3
```

## correlate-discovery-and-evasion
<!-- Correlate with script and network activity -->
parallel:
- → hunt-malicious-scripting
- → examine-remote-service-traffic
join: → triage-lateral-movement

## hunt-malicious-scripting
<!-- Search for share discovery and enumeration scripts -->
Locate PowerShell activity targeting network shares or performing Active Directory enumeration to identify valuable assets.

```sqlite target=endpoint role=enrichment params=(scope_hosts=scope_hosts, lookback_days=lookback_days)
~~~yaml
expected: Script blocks containing ShareFinder functions or AD query commands. Silence
  suggests no such scripts were executed within the window.
reads:
- actor_user_name
- device_hostname
- script_content
- script_name
- time
silence: not_evidence_of_absence
source: hb_script_activity
verified: dry-run
verified_at: '2026-10-22'
~~~
SELECT device_hostname, script_name, script_content, actor_user_name, time FROM hb_script_activity WHERE (LOWER(script_content) LIKE '%sharefinder%' OR LOWER(script_content) LIKE '%get-netshare%' OR LOWER(script_content) LIKE '%invoke-sharefinder%' OR LOWER(script_content) LIKE '%netshareenum%' OR LOWER(script_content) LIKE '%get-adcomputer%' OR LOWER(script_content) LIKE '%ldap://%') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days')
```

## examine-remote-service-traffic
<!-- Identify remote service connections -->
Stack-count network connections to remote management ports used for lateral movement.

```sqlite target=network role=baseline params=(scope_hosts=scope_hosts, lookback_days=lookback_days)
~~~yaml
baseline:
  compare: first_seen
  window: '{{lookback_days}}d'
expected: A small number of hosts connecting to RDP or WinRM ports, or using RMM software.
  Rare connections stand out from normal administrative baseline.
prevalence:
  by: device_hostname
  key:
  - process_name
  - dst_endpoint_port
  rare_below: 4
reads:
- device_hostname
- dst_endpoint_port
- process_name
- time
silence: not_evidence_of_absence
source: hb_network_connection
verified: dry-run
verified_at: '2026-10-22'
~~~
SELECT device_hostname, process_name, dst_endpoint_port, COUNT(*) AS connections, MIN(time) AS first_seen FROM hb_network_connection WHERE (dst_endpoint_port IN (3389, 5985, 5986) OR LOWER(process_name) LIKE '%anydesk%' OR LOWER(process_name) LIKE '%teamviewer%') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days') GROUP BY device_hostname, process_name, dst_endpoint_port HAVING COUNT(DISTINCT device_hostname) <= 3
```

## triage-lateral-movement
<!-- Triage lateral movement evidence -->
```agent target=hunter
cite: required
context:
- identify-living-off-land-tools
- hunt-malicious-scripting
- examine-remote-service-traffic
max_iterations: 5
objective: Identify hosts used for lateral pivots.
success_criteria: A verdict of malicious, suspicious, or benign per host with cited
  evidence.
tools:
- endpoint
- network
```

## evaluate-threat-presence
<!-- Evaluate threat presence -->
if~: "the triage verdict is malicious for at least one host" (confidence: high, judge=hunter)
then: → isolate-compromised-host
indeterminate: → analyst-investigation
unavailable: → analyst-investigation (blind_spot: missing-endpoint-visibility)
else: → reporting-and-cleanup

## isolate-compromised-host
<!-- Isolate compromised host -->
```action target=endpoint
~~~yaml
approval: required
~~~
Isolate the host and initiate a full forensic review of the user sessions active during the detected window.
```
→ analyst-investigation

## analyst-investigation
<!-- Analyst investigation -->
```manual target=analyst
Review the cited process command lines and script content. Cross-reference with hb_auth_signin to identify the originating source IP of the lateral movement attempts.
```
→ reporting-and-cleanup

## reporting-and-cleanup
<!-- Reporting and cleanup -->
```manual target=analyst
Document all discovered lateral movement paths and recommend tuning for the RMM tool detection candidate if the findings were verified.
```
→ end

Run it

Take this hunt into your environment.

Open it in Huntbase to run every step against your own connections, with Scout weighing the evidence and your analysts in command. Or take the open hunt.md file anywhere that reads the format.

Machine-drafted by huntbase-hunt-generation using hb_google/gemini-3-flash-preview, gated by dry-run, lint, then reviewed by a person.