Skip to content

FRP魔改:去除非 TLS 流量特征 / 配置文件写入源码,通过参数传递加密后的 IP 和端口 / 添加钉钉上线提醒 / 域前置

Notifications You must be signed in to change notification settings

M1r0ku/frp-Modify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

frp-Modify

使用说明

  • cmd/frpc/sub/root.go#getFileContent()函数中,按需修改 FRPC 配置和key(默认testkey
func getFileContent(ip string, port string) {
	key := "testkey"
	ip = str2xor(ip, key)
	port = str2xor(port, key)

	var configContent string = `[common]
        server_addr = ` + ip + `
        server_port = ` + port + `
	tls_enable = true 
	[plugin_socks]
	type = tcp
	remote_port = 7788
	plugin = socks5
	#plugin_user = ""
	#plugin_passwd = ""
	`
	fileContent = configContent
}
  • 确保安装 Go-1.16+ 和 GCC 环境,然后运行package.sh进行交叉编译
$ go env -w GOPROXY=https://goproxy.cn,direct  # 设置代理
$ ./package.sh
  • FRPS正常运行,FRPC则需要传入异或后的字符串。可通过xor.py脚本进行异或,异或后的字符串可能存在特殊字符\,因此建议使用双引号包裹
$ ./frpc -t <IP> -p <端口>
$ ./frpc -t "E\AZZSAZTBEET" -p "CUCD"  # 192.168.111.1:7000

钉钉提醒

  • 需要在client/control.go#HandleNewProxyResp()函数中配置钉钉机器人AccessTokenSecret,然后在前面的配置部分添加相关plugin_userplugin_passwd即可
func (ctl *Control) HandleNewProxyResp(inMsg *msg.NewProxyResp) {
    // ...

	if err != nil {
		xl.Warn("[%s] start error: %v", inMsg.ProxyName, err)
	} else {
		// 配置钉钉机器人
		dingAccessToken := ""
		dingSecret := ""
        
        // ...
	}

    // ...
}

域前置

  • 修改依赖包 go/pkg/mod/golang.org/x/[email protected]/websocket/client.go#NewConfig() 方法,添加回源 Host
func NewConfig(server, origin string) (config *Config, err error) {
	config = new(Config)
	config.Version = ProtocolVersionHybi13
	config.Location, err = url.ParseRequestURI(server)
	if err != nil {
		return
	}
	config.Origin, err = url.ParseRequestURI(origin)
	if err != nil {
		return
	}
	config.Header = http.Header(make(map[string][]string))
+	config.Header.Set("Host", "test.baidu.local")
	return
}
  • 然后修改 go/pkg/mod/golang.org/x/[email protected]/websocket/hybi.go#hybiClientHandshake() 方法
func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (err error) {
	bw.WriteString("GET " + config.Location.RequestURI() + " HTTP/1.1\r\n")

	// According to RFC 6874, an HTTP client, proxy, or other
	// intermediary must remove any IPv6 zone identifier attached
	// to an outgoing URI.

+	// FRP Websocket Host
+	host := config.Location.Host
+	if tmpHost := config.Header.Get("Host"); tmpHost != "" {
+		host = tmpHost
+	}
+	bw.WriteString("Host: " + removeZone(host) + "\r\n")
+	// bw.WriteString("Host: " + removeZone(config.Location.Host) + "\r\n")
 
    // ...
}
  • 最后在cmd/frpc/sub/root.go#getFileContent()中配置开启 Websocket 协议
protocol = websocket

参考文章

About

FRP魔改:去除非 TLS 流量特征 / 配置文件写入源码,通过参数传递加密后的 IP 和端口 / 添加钉钉上线提醒 / 域前置

Resources

Stars

Watchers

Forks