Windows 间接命令执行方式总结
2021-10-09 22:53:24 Author: mp.weixin.qq.com(查看原文) 阅读量:122 收藏

0x00 前言

    最近学习看到了关于 Windows 系统下实现间接命令执行的文章。某些情况下,可以使用非 cmd.exe 的一些自带的程序文件来执行命令,常见的场景就是逃避检测,绕过一些 HIDS,看到国外的文章讲的是可以绕过应用程序白名单产品。具体可利用于哪些场景还得靠表哥们研究下。

这里直接就用找到的一些例子来测试下。

0x01 操作

1.forfiles

    forfiles 是一款 windows 平台的软件工具,其中选择文件并运行一个命令来操作文件。

实际需要执行的命令是通过 /c 参数后的内容。

  • forfiles /c c:\windows\system32\calc.exe

打开进程的父进程为 forfiles.exe

2.pcalua

在 Windows 7 以上的版本可以尝试使用 pcalua 执行命令。不过实测 Windows 08R2 没有找到这个程序。

使用 -a 参数执行命令。

  • pcalua.exe -a C:\Users\keefe\Desktop\1.exe

主进程即为运行的进程。

3.SyncAppvPublishingServer

通过 powershell 执行 SyncAppvPublishingServer.vbs

测试的时候发现在 Powershell V2 版本不能执行。Windows 7 和 Windows 2008 R2 默认是 V2 版本。

Windows 10 测试可以。

通过查询 Powershell 版本,来验证是否可以使用。

  • powershell $PSVersionTable.PSVersion

在 Powershell 命令行下执行。

SyncAppvPublishingServer 将执行双引号内的全部内容。

  • powershell SyncAppvPublishingServer.vbs "n; Start-Process C:\Users\keefe\Desktop\1.exe"

这里也可以通过执行进行上线,据说效果还不错,Tide 团队有讲,就不多测试了。

主进程即为运行的进程。

4. 路径遍历 / 参数混乱

利用:

在同个盘符下,通过欺骗 cmd 执行任意程序。

  • cmd.exe /c "ping 127.0.0.1/../../../../../../../windows/system32/calc.exe"

为什么可以这么使用呢?

在国外大佬的某篇博客中看到以下解释。

简单的理解也就是可以通过构造这种形式,来尝试执行任意程序。

5.conhost

conhost.exe 是在 windows 7 和 Windows server 2008 中引进的新的控制台应用程序处理机制。同样可以命令执行。

在 Windows 10 下测试:

  • conhost C:\Windows\System32\calc.exe

6.explorer

explorer.exe 是 Windows 系统的文件资源管理器,通过 explorer 可以执行程序,其实就是平常我们使用的桌面或者从我的电脑中启动程序都是通过 explorer.exe

  • explorer.exe C:\Users\keefe\desktop\1.exe

  • explorer.exe /root,"C:\Users\keefe\desktop\1.exe"

  • explorer.exe test, "C:\Users\keefe\desktop\1.exe"

7.waitfor

Windows 还有一个 waitfor 命令,用于在系统上发送或等待信号。

通过发送信号或者使用等待信号,可以执行任意命令。

  • waitfor test && C:\Users\keefe\desktop\1.exe

  • // test为信号的名称

  • waitfor /s 127.0.0.1 /si test

0x02 参考文章

Indirect Command Execution, Technique T1202 - Enterprise | MITRE ATT&CKT1202 - Indirect Command ExecutionIndirect Command Execution远控免杀专题 (54)- 白名单 SyncAppvPublishingServer.vbs 执行 payloadCmd Hijack - a command/argument confusion with path traversal in cmd.exe

作者:Keefe   

来源:http://www.aiyuanzhen.com

查看更多精彩内容,还请关注橘猫学安全

每日坚持学习与分享,麻烦各位师傅文章底部给点个“再看”,感激不尽


文章来源: https://mp.weixin.qq.com/s/1GV2ru3G4jOMyXZOx1QDYg
如有侵权请联系:admin#unsafe.sh