Skip to content

Commit 8a079b3

Browse files
committed
Update
1 parent d63e2fb commit 8a079b3

182 files changed

Lines changed: 34371 additions & 19 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
.idea
22
idea
33

4-
cmd
5-
pkg
64
release
75

8-
*.go
96
*.exe
107
*.7z
11-
*.ini
12-
build.bat
8+
*.ini

README.md

Lines changed: 93 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Erfrp-[frp](https://github.com/fatedier/frp)二开-免杀与隐藏
1+
# Erfrp-frp二开-免杀与隐藏
22

3-
本项目是frp的二开项目。frp是fatedier开发的一款优秀的快速反向代理工具,可以将NAT或防火墙后面的本地服务器暴露在互联网上。但原程序对攻击队而言并不优雅,希望本项目可以为攻击队贡献完美的FRP二开项目!
3+
本项目是frp的二开项目。[frp](https://github.com/fatedier/frp)是fatedier开发的一款优秀的反向代理工具,可以将本地服务器暴露在互联网上。但原程序对攻击队而言并不优雅,希望本项目可以为攻击队贡献一个完美的FRP二开项目!作者:[0e0w](https://github.com/0e0w)
44

5-
目前程序和代码未发布,敬请期待!
6-
7-
本项目创建于2022年4月18日,最近的更新时间为2022年11月16日。
5+
本项目创建于2022年4月18日,最近的更新时间为2022年11月18日。
86

97
- [01-项目结构修改](https://github.com/Goqi/Erfrp#01-%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84%E4%BF%AE%E6%94%B9)
108
- [02-项目功能修改](https://github.com/Goqi/Erfrp#02-%E9%A1%B9%E7%9B%AE%E5%8A%9F%E8%83%BD%E4%BF%AE%E6%94%B9)
@@ -15,6 +13,8 @@
1513

1614
## 01-项目结构修改
1715

16+
本项目基于frp-0.45.0。对项目结构进行了调整,调整后的项目结构如下:
17+
1818
```
1919
│ frpc.go
2020
│ frps.go
@@ -94,10 +94,8 @@
9494
│ ├─consts
9595
│ │ consts.go
9696
│ │
97-
│ ├─crypto
97+
│ ├─dscrypto
9898
│ │ aes.go
99-
│ │ aes1.go
100-
│ │ aes2.go
10199
│ │ des.go
102100
│ │ md5.go
103101
│ │ rsa.go
@@ -249,25 +247,106 @@
249247
## 02-项目功能修改
250248

251249
- [x] 程序运行判断是否存在frpc.ini或frps.ini文件,不存在则自动创建。
252-
- [ ] 加入命令执行模块
253-
- [ ] 全部的参数都从ini文件获取?or 全部的参数都写到go文件中?
250+
251+
```
252+
// 自动生成frpc.ini和frps.ini
253+
func init() {
254+
frpcini := "frpc.ini"
255+
if _, errFileExist := os.Stat(frpcini); errFileExist != nil {
256+
f, err := os.Create(frpcini)
257+
if err != nil {
258+
os.Exit(1)
259+
}
260+
_, err = f.Write(config.DefaultiniBytefrpc)
261+
}
262+
263+
}
264+
```
265+
266+
- [ ] 全部的参数都从ini文件获取?or 全部的参数都写到go文件中?#Todo
267+
268+
- [ ] 加入命令执行模块#Todo
254269

255270
## 03-静态特征修改
256271

257-
- [ ] 去除日志打印相关内容
272+
- [ ] 去除日志打印相关内容#Todo
273+
- [ ] 去除FRP相关的字段内容#Todo
258274

259275
## 04-流量特征修改
260276

261277
- [x] 0x17特征修改
278+
- [x] 默认开启TLS
262279

263280
## 05-敏感信息隐藏
264281

265-
- [ ] 服务端IP地址加密
266-
- [x] [程序运行后删除配置文件](https://github.com/Goqi/Erfrp/blob/main/pkg/cmd/frpc/root.go):例子:frpc.exe --delini
267-
- [x] [远程加载配置文件](https://github.com/Goqi/Erfrp/blob/main/pkg/config/value.go):例子:frpc.exe -c http://127.0.0.1/frpc.ini
282+
- [x] [配置文件自动删除](https://github.com/Goqi/Erfrp/blob/main/pkg/cmd/frpc/root.go):frpc.exe --delini
283+
284+
```
285+
// 删除配置文件
286+
// 程序运行时添加--delini命令
287+
if delEnable == true {
288+
err := os.Remove(cfgFile)
289+
if err != nil {
290+
return err
291+
}
292+
}
293+
```
294+
295+
- [x] [远程加载配置文件](https://github.com/Goqi/Erfrp/blob/main/pkg/config/value.go):frpc.exe -c http://127.0.0.1/frpc.ini
296+
297+
```
298+
func GetRenderedConfFromFile(path string) (out []byte, err error) {
299+
var b []byte
300+
rawUrl := path
301+
if strings.Contains(rawUrl, "http") {
302+
log.Info("Remote load ini file")
303+
response, _err1 := http.Get(path)
304+
if _err1 != nil {
305+
return
306+
}
307+
defer response.Body.Close()
308+
body, _err := io.ReadAll(response.Body)
309+
if _err != nil {
310+
return
311+
}
312+
httpContent := string(body)
313+
var content = []byte(httpContent)
314+
out, err = RenderContent(content)
315+
return
316+
317+
} else {
318+
log.Info("Local load ini file")
319+
b, err = os.ReadFile(path)
320+
if err != nil {
321+
return
322+
}
323+
localContent := string(b)
324+
var content = []byte(localContent)
325+
out, err = RenderContent(content)
326+
return
327+
}
328+
}
329+
```
330+
331+
- [x] [服务端IP地址加密](https://github.com/Goqi/Erfrp/blob/main/pkg/client/service.go):需要在代码上面修改aes的key和加密后的字符
332+
333+
```
334+
package dscrypto
335+
336+
// 对服务器IP进行隐藏需要修改此处的AESKey和AESencryptCode。
337+
// 同时需要对frpc.ini中的server_addr进行修改,修改成AESencryptCode。
338+
// server_addr支持正常的ip和加密之后的ip,2种形式。
339+
var (
340+
VpsIP = "192.168.1.22"
341+
AESKey = "9d9d14b5f6650726afe17e1af4052632" //Erfrp
342+
AESencryptCode = "J6X+PfMnVldSaM1tpjaNKw=="
343+
//AESencryptCode = "2HrQDAPV5JgjckfYkO9u4g=="
344+
)
345+
```
268346

269347
## 06-参考项目资源
270348

349+
- [frp代码分析报告](https://github.com/Goqi/ErKai/tree/main/0x04/frp)
271350
- https://github.com/atsud0/frp-modify
272351
- https://github.com/OrangeWatermelon/frp_cmd
273352
- https://github.com/baibaicloud/frp

build.bat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@echo off
2+
go build -ldflags "-w -s" -o release/frpc.exe frpc.go
3+
go build -ldflags "-w -s" -o release/frps.exe frps.go
4+
5+
@echo off
6+
SET CGO_ENABLED=0
7+
SET GOOS=windows
8+
SET GOARCH=386
9+
go build -ldflags "-w -s" -o release/frpc32.exe frpc.go
10+
go build -ldflags "-w -s" -o release/frps32.exe frps.go
11+
12+
@echo off
13+
SET CGO_ENABLED=0
14+
SET GOOS=linux
15+
SET GOARCH=amd64
16+
go build -ldflags "-w -s" -o release/frpc frpc.go
17+
go build -ldflags "-w -s" -o release/frps frps.go

cmd/frpc/http.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright 2018 fatedier, fatedier@gmail.com
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package frpc
16+
17+
import (
18+
"Erfrp/pkg/config"
19+
"Erfrp/pkg/consts"
20+
"fmt"
21+
"os"
22+
"strings"
23+
24+
"github.com/Gogods/cobra"
25+
)
26+
27+
func init() {
28+
RegisterCommonFlags(httpCmd)
29+
30+
httpCmd.PersistentFlags().StringVarP(&proxyName, "proxy_name", "n", "", "proxy name")
31+
httpCmd.PersistentFlags().StringVarP(&localIP, "local_ip", "i", "127.0.0.1", "local ip")
32+
httpCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
33+
httpCmd.PersistentFlags().StringVarP(&customDomains, "custom_domain", "d", "", "custom domain")
34+
httpCmd.PersistentFlags().StringVarP(&subDomain, "sd", "", "", "sub domain")
35+
httpCmd.PersistentFlags().StringVarP(&locations, "locations", "", "", "locations")
36+
httpCmd.PersistentFlags().StringVarP(&httpUser, "http_user", "", "", "http auth user")
37+
httpCmd.PersistentFlags().StringVarP(&httpPwd, "http_pwd", "", "", "http auth password")
38+
httpCmd.PersistentFlags().StringVarP(&hostHeaderRewrite, "host_header_rewrite", "", "", "host header rewrite")
39+
httpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
40+
httpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")
41+
42+
rootCmd.AddCommand(httpCmd)
43+
}
44+
45+
var httpCmd = &cobra.Command{
46+
Use: "http",
47+
Short: "Run frpc with a single http proxy",
48+
RunE: func(cmd *cobra.Command, args []string) error {
49+
clientCfg, err := parseClientCommonCfgFromCmd()
50+
if err != nil {
51+
fmt.Println(err)
52+
os.Exit(1)
53+
}
54+
55+
cfg := &config.HTTPProxyConf{}
56+
var prefix string
57+
if user != "" {
58+
prefix = user + "."
59+
}
60+
cfg.ProxyName = prefix + proxyName
61+
cfg.ProxyType = consts.HTTPProxy
62+
cfg.LocalIP = localIP
63+
cfg.LocalPort = localPort
64+
cfg.CustomDomains = strings.Split(customDomains, ",")
65+
cfg.SubDomain = subDomain
66+
cfg.Locations = strings.Split(locations, ",")
67+
cfg.HTTPUser = httpUser
68+
cfg.HTTPPwd = httpPwd
69+
cfg.HostHeaderRewrite = hostHeaderRewrite
70+
cfg.UseEncryption = useEncryption
71+
cfg.UseCompression = useCompression
72+
73+
err = cfg.CheckForCli()
74+
if err != nil {
75+
fmt.Println(err)
76+
os.Exit(1)
77+
}
78+
79+
proxyConfs := map[string]config.ProxyConf{
80+
cfg.ProxyName: cfg,
81+
}
82+
err = startService(clientCfg, proxyConfs, nil, "")
83+
if err != nil {
84+
fmt.Println(err)
85+
os.Exit(1)
86+
}
87+
return nil
88+
},
89+
}

cmd/frpc/https.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright 2018 fatedier, fatedier@gmail.com
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package frpc
16+
17+
import (
18+
"Erfrp/pkg/config"
19+
"Erfrp/pkg/consts"
20+
"fmt"
21+
"os"
22+
"strings"
23+
24+
"github.com/Gogods/cobra"
25+
)
26+
27+
func init() {
28+
RegisterCommonFlags(httpsCmd)
29+
30+
httpsCmd.PersistentFlags().StringVarP(&proxyName, "proxy_name", "n", "", "proxy name")
31+
httpsCmd.PersistentFlags().StringVarP(&localIP, "local_ip", "i", "127.0.0.1", "local ip")
32+
httpsCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
33+
httpsCmd.PersistentFlags().StringVarP(&customDomains, "custom_domain", "d", "", "custom domain")
34+
httpsCmd.PersistentFlags().StringVarP(&subDomain, "sd", "", "", "sub domain")
35+
httpsCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
36+
httpsCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")
37+
38+
rootCmd.AddCommand(httpsCmd)
39+
}
40+
41+
var httpsCmd = &cobra.Command{
42+
Use: "https",
43+
Short: "Run frpc with a single https proxy",
44+
RunE: func(cmd *cobra.Command, args []string) error {
45+
clientCfg, err := parseClientCommonCfgFromCmd()
46+
if err != nil {
47+
fmt.Println(err)
48+
os.Exit(1)
49+
}
50+
51+
cfg := &config.HTTPSProxyConf{}
52+
var prefix string
53+
if user != "" {
54+
prefix = user + "."
55+
}
56+
cfg.ProxyName = prefix + proxyName
57+
cfg.ProxyType = consts.HTTPSProxy
58+
cfg.LocalIP = localIP
59+
cfg.LocalPort = localPort
60+
cfg.CustomDomains = strings.Split(customDomains, ",")
61+
cfg.SubDomain = subDomain
62+
cfg.UseEncryption = useEncryption
63+
cfg.UseCompression = useCompression
64+
65+
err = cfg.CheckForCli()
66+
if err != nil {
67+
fmt.Println(err)
68+
os.Exit(1)
69+
}
70+
71+
proxyConfs := map[string]config.ProxyConf{
72+
cfg.ProxyName: cfg,
73+
}
74+
err = startService(clientCfg, proxyConfs, nil, "")
75+
if err != nil {
76+
fmt.Println(err)
77+
os.Exit(1)
78+
}
79+
return nil
80+
},
81+
}

0 commit comments

Comments
 (0)