红队战术 – Windows 持久性恶意挂载

admin 2024年2月7日23:38:59评论13 views字数 1185阅读3分57秒阅读模式

红队战术 – Windows 持久性恶意挂载

通过全新安装或升级安装 Windows 操作系统时,将执行 Windows 安装程序二进制文件。Windows 安装程序允许执行自定义脚本,例如SetupComplete.cmd和ErrorHandler.cmd,以便在Windows 安装过程完成期间或之后安装应用程序或执行其他任务。这些脚本存储在以下位置:

%WINDIR%SetupScriptsSetupComplete.cmd%WINDIR%SetupScriptsErrorHandler.cmd

使用ErrorHandler.cmd脚本可以在Windows操作系统升级时执行任意代码。尽管它可以被视为一种非常规策略,但它可以与计划任务相结合,例如运行 Windows 安装程序并建立持久性。以下代码可用作代码执行的概念证明,该代码执行将在启动 Windows 安装程序二进制文件时显示一个消息框:

using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms; namespace Windows_setup1{    internal static class Program    {        [STAThread]        static void Main()        {            string message = "Visit pentestlab.blog";            string title = "Pentestlaboratories";            MessageBox.Show(message, title);        }    }}

红队战术 – Windows 持久性恶意挂载

Windows 安装脚本 – 消息框代码

由于 Windows 安装程序会在执行期间以及安装过程中发生错误时检查Scripts文件夹中是否存在ErrorHandler.cmd,因此可以使用此脚本执行任意代码。

红队战术 – Windows 持久性恶意挂载

Windows 安装脚本路径

运行setup.exe将导致错误,从而强制执行ErrorHandler.cmd脚本。

红队战术 – Windows 持久性恶意挂载

Windows 安装脚本 – 消息框

用植入程序替换消息框可执行文件将允许建立命令和控制会话。

红队战术 – Windows 持久性恶意挂载

Windows 安装脚本 – C2

植入程序的进程树指定如下:

Setup.exe --> cmd.exe --> demon.x64.exe

红队战术 – Windows 持久性恶意挂载

Windows 安装脚本 – 进程树


参考:

https://www.hexacorn.com/blog/2022/01/16/beyond-good-ol-run-key-part-135/


恶意软件开发:持久性 - 第 22 部分。Windows 设置。简单的 C++ 示例。

https://cocomelonc.github.io/persistence/2023/07/16/malware-pers-22.html




感谢您抽出

红队战术 – Windows 持久性恶意挂载

.

红队战术 – Windows 持久性恶意挂载

.

红队战术 – Windows 持久性恶意挂载

来阅读本文

红队战术 – Windows 持久性恶意挂载

点它,分享点赞在看都在这

原文始发于微信公众号(Ots安全):红队战术 – Windows 持久性恶意挂载

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年2月7日23:38:59
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   红队战术 – Windows 持久性恶意挂载https://cn-sec.com/archives/2474867.html

发表评论

匿名网友 填写信息