# Hunting - Movimentação Lateral
> [!warning] Aviso Importante
> Este playbook é para uso por threat hunters com experiência em DFIR. As queries podem gerar alto volume de resultados — aplique critérios de filtragem e baseie-se em baselines do ambiente antes de escalar.
---
## Visão Geral
Movimentação lateral é a fase em que um atacante expande o acesso de um sistema comprometido inicial para outros sistemas na rede, buscando atingir objetivos de alto valor como Domain Controllers, servidores de backup, sistemas financeiros ou repositórios de código.
**Por que caçar movimentação lateral:**
- É o indicador mais confiável de um ataque em progresso
- A janela de detecção é relativamente curta - o atacante ainda está no ambiente
- Comprometimento de um único endpoint não justifica resposta completa; movimentação lateral eleva drasticamente o risco
**Técnicas mais comuns:**
| Técnica | Método | Ferramenta típica |
|---------|--------|------------------|
| Pass the Hash | NTLM com hash roubado | Mimikatz, Impacket |
| Pass the Ticket | Kerberos ticket forjado | Mimikatz, Rubeus |
| Remote Services | WMI, WinRM, SMB, RDP | PSExec, Impacket wmiexec |
| Remote Desktop | RDP com credenciais válidas | mstsc.exe nativo |
| Living off the Land | Ferramentas nativas Windows | net.exe, sc.exe, schtasks |
| Token Manipulation | Impersonation de token de processo | Incognito, Cobalt Strike |
---
## Hipóteses de Hunting
```mermaid
mindmap
root((Movimentação\nLateral))
Pass the Hash
NTLM Type 3 sem Type 2
Autenticação de conta\nde máquina em serviço de usuário
EventID 4624 LogonType 3\nNTLM de IP interno
Pass the Ticket
TGS com lifetime incomum
Ticket para serviço\nnão esperado
Golden Ticket\nlifetime > 10h
Remote Services
PSExec PSEXECSVC pipe
WMI excutando em remote host
WinRM 5985/5986\nconexões incomuns
Beaconing e C2
Named pipes Cobalt Strike
Processos com conexões\na múltiplos hosts internos
cmd.exe / powershell.exe\ncomo filho de serviço remoto
Credential Dumping
LSASS access GrantedAccess 0x1010
Volume Shadow Copy access
SAM/NTDS.dit access
```
---
## Ferramentas Recomendadas
### DFIR e Hunting
| Ferramenta | Uso | Comando Chave |
|------------|-----|---------------|
| **Velociraptor** | Hunting em escala - autenticações, processos, conexões | `velociraptor artifacts collect Windows.EventLogs.LoginActivity` |
| **Sysmon** | Telemetria de processos, rede, pipes nomeados | Config: Eventos 1, 3, 10, 17, 18 |
| **BloodHound / SharpHound** | Mapeamento de caminhos de ataque no AD | `SharpHound.exe -c All` (em ambiente autorizado) |
| **PingCastle** | Auditoria de segurança do Active Directory | `PingCastle.exe --healthcheck` |
| **Impacket** (para válidação) | Entender técnicas de ataque para criar detecções | `python3 wmiexec.py domain/user:pass@target` |
### Análise de Logs
| Ferramenta | Uso | Foco |
|------------|-----|------|
| **Chainsaw** | Análise rápida de Windows Event Logs | `chainsaw hunt evtx/ --rules sigma/` |
| **Hayabusa** | Detecção de ameaças em Event Logs com regras Sigma | `hayabusa.exe -d evtx/ -r rules/ -o results.csv` |
| **LogonTracer** | Visualização de eventos de logon - detectar lateral movement | Interface web, importa EVTX |
### SIEM Queries
| Plataforma | Cobertura |
|------------|-----------|
| **Splunk** | Queries SPL para EventID críticos de autenticação |
| **Microsoft Sentinel** | KQL queries para Sign-in Logs, Identity Protection |
| **Elastic SIEM** | EQL e Detection Rules para lateral movement |
---
## Hipótese 1 - Pass the Hash (PtH)
**Hipótese:** Um atacante está usando o hash NTLM de uma credencial comprometida para autenticar em outros sistemas sem conhecer a senha em texto claro.
**Por que funciona:** O protocolo NTLM autentica com base no hash, não na senha. Uma conta com hash roubado pode ser usada lateralmente sem triggerar políticas de senha complexa.
### Query Splunk - PtH (EventID 4624 LogonType 3 via NTLM)
```spl
EventCode=4624 LogonType=3 AuthenticationPackageName=NTLM
| where NOT match(WorkstationName, "(?i)(workstation|desktop|laptop)")
| stats count values(TargetUserName) as users values(WorkstationName) as sources by IpAddress
| where count > 3
| sort -count
```
### Query KQL - Sentinel - Pass the Hash
```kql
SecurityEvent
| where EventID == 4624
| where LogonType == 3
| where AuthenticationPackageName == "NTLM"
| where isnotempty(IpAddress) and IpAddress != "-"
| where IpAddress !startswith "127." and IpAddress !startswith "::1"
| summarize LogonCount = count(), TargetAccounts = make_set(TargetUserName),
SourceMachines = make_set(WorkstationName) by IpAddress, bin(TimeGenerated, 1h)
| where LogonCount > 5
| order by LogonCount desc
```
---
## Hipótese 2 - Pass the Ticket / Kerberos Abuse
**Hipótese:** Um atacante está usando tickets Kerberos forjados (Golden Ticket, Silver Ticket, Overpass-the-Hash) para obter acesso a serviços sem credenciais válidas.
### Golden Ticket - Indicadores
- Ticket TGT com lifetime > 10 horas (padrão é 10h, Golden Tickets costumam usar 10 anos)
- Autenticação para `krbtgt` com encryption type RC4 (downgrade de AES)
- TGS request para serviço em DC sem TGT correspondente no log
### Query Splunk - Detecção de Golden Ticket
```spl
EventCode=4769 TicketEncryptionType=0x17
| stats count by TargetUserName, ServiceName, ClientAddress
| where count > 5
| sort -count
```
```spl
EventCode=4768 TicketEncryptionType=0x17
| stats count by TargetUserName, IpAddress
| eval possible_rc4_downgrade=if(count>3,"YES","check")
| sort -count
```
### Query KQL - Sentinel - Kerberos Anomaly
```kql
SecurityEvent
| where EventID == 4769
| where TicketEncryptionType == "0x17" // RC4-HMAC (indicador de downgrade)
| summarize Count = count(), Services = make_set(ServiceName) by TargetUserName, IpAddress, bin(TimeGenerated, 1h)
| where Count > 3
| order by Count desc
```
---
## Hipótese 3 - Remote Services (SMB/WMI/WinRM)
**Hipótese:** Um atacante está usando ferramentas de administração remota legítimas (PSExec, WMI, WinRM) para executar comandos em outros sistemas.
### Query Splunk - PSExec via Named Pipe
```spl
index=sysmon EventCode=17 OR EventCode=18
PipeName="\\PSEXECSVC"
| stats count by Computer, process_name, PipeName
| sort -count
```
### Query Splunk - WMI Execução Remota
```spl
index=sysmon EventCode=1
ParentImage="C:\\Windows\\System32\\wbem\\WmiPrvSE.exe"
| where NOT match(Image, "(?i)(wmiprvse|wmiapsrv|scrcons)")
| stats count by Computer, User, Image, CommandLine
| sort -count
```
### Query Splunk - WinRM Conexões Incomuns
```spl
index=sysmon EventCode=3
DestinationPort IN (5985, 5986)
| stats count by SourceIp, DestinationIp, User, Computer
| where count > 3
| sort -count
```
### Query KQL - Sentinel - Lateral Movement via SMB Admin Shares
```kql
DeviceNetworkEvents
| where RemotePort == 445
| where RemoteIPType == "Private"
| where InitiatingProcessFileName !in~ ("System", "lsass.exe", "svchost.exe")
| summarize ConnectedHosts = dcount(RemoteIP), HostList = make_set(RemoteIP)
by DeviceName, InitiatingProcessFileName, bin(Timestamp, 1h)
| where ConnectedHosts > 3
| order by ConnectedHosts desc
```
---
## Hipótese 4 - Credential Dumping (Pré-Lateral Movement)
**Hipótese:** Um atacante acessou o processo LSASS para extrair credenciais antes de mover lateralmente.
### Query Splunk - Acesso ao LSASS
```spl
index=sysmon EventCode=10
TargetImage="C:\\Windows\\system32\\lsass.exe"
| where NOT match(Image, "(?i)(MsMpEng|svchost|csrss|wininit|services|SecurityHealthService|SenseIR|AMonSvc)")
| stats count by Computer, User, Image, GrantedAccess
| sort -count
```
### Query Splunk - Volume Shadow Copy Deletion
```spl
index=windows EventCode=4688
(CommandLine="*vssadmin*delete*" OR CommandLine="*shadowcopy*delete*")
| table _time, Computer, User, CommandLine
```
### Query KQL - Sentinel - LSASS Memory Read
```kql
DeviceEvents
| where ActionType == "OpenProcessApiCall"
| where FileName =~ "lsass.exe"
| where ProcessCommandLine !contains "lsass"
| where not(InitiatingProcessFileName in~
("MsMpEng.exe", "SenseIR.exe", "csrss.exe", "wininit.exe", "services.exe"))
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, InitiatingProcessCommandLine
```
---
## Hipótese 5 - Movimento Lateral via RDP
**Hipótese:** Um atacante está usando RDP para se conectar a múltiplos sistemas internos a partir de uma máquina comprometida.
### Query Splunk - RDP de Máquina para Máquina (Interno)
```spl
index=windows EventCode=4624 LogonType=10
| stats count dc(Computer) as unique_targets values(Computer) as targets by SourceNetworkAddress
| where unique_targets > 3
| sort -unique_targets
```
### Query Splunk - Shadow Copy RDP (Acesso Sem Tela)
```spl
index=windows EventCode=4624 LogonType=10
| where NOT match(SourceNetworkAddress, "10\.0\.|192\.168\.|172\.")
| table _time, SourceNetworkAddress, TargetUserName, Computer
```
### Sigma Rule - Lateral Movement via WMI
```yaml
title: Lateral Movement via WMI Remote Execution
status: experimental
description: Detects processes spawned by WmiPrvSE that are commonly used for lateral movement
logsource:
category: process_creation
product: windows
detection:
selection:
ParentImage|endswith: '\wbem\WmiPrvSE.exe'
Image|endswith:
- '\cmd.exe'
- '\powershell.exe'
- '\net.exe'
- '\net1.exe'
- '\ipconfig.exe'
- '\whoami.exe'
condition: selection
level: high
tags:
```
---
## Gantt de Hunting Semanal
```mermaid
gantt
title Ciclo de Threat Hunting — Movimentação Lateral
dateFormat YYYY-MM-DD
section Segunda
Coletar baseline de autenticações :2026-03-23, 1d
Executar hipótese Pass the Hash :2026-03-23, 1d
section Terça
Analisar Kerberos anomalies :2026-03-24, 1d
Mapear top talkers RDP interno :2026-03-24, 1d
section Quarta
Hunting WMI/WinRM/PSExec :2026-03-25, 1d
Verificar named pipes suspeitos :2026-03-25, 1d
section Quinta
Revisão de LSASS access logs :2026-03-26, 1d
Correlacionar achados da semana :2026-03-26, 1d
section Sexta
Documentar hipóteses válidadas :2026-03-27, 1d
Atualizar detection rules :2026-03-27, 1d
```
---
## Checklist de Hunting
### Preparação
- [ ] Confirmar que Sysmon está instalado e configurado em todos os endpoints (eventos 1,3,10,17,18)
- [ ] Confirmar retenção de logs de autenticação: mínimo 90 dias no SIEM
- [ ] Estabelecer baseline de autenticações normais (top usuários, top hosts de origem)
- [ ] Mapear quais sistemas têm RDP habilitado internamente
- [ ] Identificar contas de serviço com privilégios elevados (potenciais alvos de PtH)
### Execução
- [ ] Executar hipótese 1 (Pass the Hash) e analisar resultados
- [ ] Executar hipótese 2 (Kerberos abuse) - verificar RC4 downgrades e ticket lifetimes
- [ ] Executar hipótese 3 (Remote services) - PSExec, WMI, WinRM
- [ ] Executar hipótese 4 (Credential dumping) - LSASS, shadow copies
- [ ] Executar hipótese 5 (RDP lateral) - múltiplos destinos internos
### Documentação
- [ ] Documentar cada hipótese testada com resultado (TP/FP/Inconclusivo)
- [ ] Escalar qualquer True Positive para IR imediatamente
- [ ] Atualizar detection rules com novos padrões identificados
- [ ] Registrar falsos positivos para refinar queries futuras
---
## Lições Aprendidas e Melhorias
### Após Cada Sessão de Hunting
1. Quantas hipóteses foram testadas?
2. Algum True Positive foi identificado? Escalonado?
3. Quais fontes de dados faltaram para a análise?
4. Alguma detection rule foi adicionada ao SIEM como resultado?
### Melhorias Estruturais
- [ ] Implementar Sysmon em 100% dos endpoints com configuração Olaf Hartong
- [ ] Habilitar auditoria de objetos AD (EventID 4662, 4768, 4769, 4771)
- [ ] Implementar solução PAM para credenciais privilegiadas (CyberArk/Delinea)
- [ ] Segmentar rede - impedir SMB lateral entre workstations
- [ ] Bloquear WinRM (5985/5986) entre workstations (apenas workstation → servidor)
- [ ] Implementar LAPS (Local Administrator Password Solution) para senhas locais únicas
---
## Referências
- [[t1021-remote-services|T1021 - Remote Services]] - técnica MITRE ATT&CK
- [[t1550-002-pass-the-hash|T1550.002 - Pass the Hash]] - técnica MITRE ATT&CK
- [[t1550-002-pass-the-hash|T1550.003 - Pass the Ticket]] - técnica MITRE ATT&CK
- [[t1558-steal-or-forge-kerberos-tickets|T1558 - Steal or Forge Kerberos Tickets]] - técnica MITRE ATT&CK
- [[hunting-supply-chain-compromise]] - playbook relacionado
- [[g0016-apt29]] - grupo que usa extensivamente movimentação lateral via LSASS e WMI
- [[ta0008-lateral-movement|MITRE ATT&CK - Lateral Movement Tactic]]
- [Microsoft - Detecting Pass-the-Hash with Audit Policies](https://docs.microsoft.com/en-us/windows-server/identity/securing-privileged-access/securing-privileged-access-reference-material)
- [JPCERT - Detecting Lateral Movement Tools](https://www.jpcert.or.jp/english/pub/sr/20170612ac-ir_research_en.pdf)
- [Specterops - BloodHound](https://github.com/BloodHoundAD/BloodHound)
---
*Última revisão: 2026-03-23 | Próxima revisão recomendada: 2026-09-23*