What is the FRP

To put it simply, FRP is a reverse proxy software. It is lightweight but powerful. It enables devices on the Intranet or behind the firewall to provide services to the outside world and supports many protocols such as HTTP, TCP and UDP. We will only talk about TCP and UDP today. As of the completion of this article, the latest version of FRP is V0.22.0, which is used in this article.

Server Settings

After SSH connection to VPS, run the following command to check the processor architecture, and download different versions of FRP arch according to the architecture to check the result. If “X86_64” can select “AMD64”, run the following command to select the corresponding version according to the architecture and download it

https://github.com/fatedier/frp/releases

Then extract tar -zxvf frp_0.22.0_linux_amd64.tar.gz

Change the folder name to make it easier to use CP -r FRP_0.22.0 _linux_AMD64 FRP

Copy the decompressed folder to the directory you want. For convenience, I put it directly in the user directory. Enter the directory CD FRP

Take a look at the file ls -A

We just need to focus on the following files

  • frps
  • frps.ini
  • frpc
  • frpc.ini

The first two files (s-ending for server) are the server program and the server configuration file respectively, and the last two files (C-ending for client) are the client program and the client configuration file respectively. Since we are configuring the server, we can delete the two files rm FRPC rm frpc.ini on the client

Then modify the frps.ini file vim frps.ini

This file should have the following format

[common]
bind_port = 7000
dashboard_port = 7500
token = 12345678
dashboard_user = admin
dashboard_pwd = admin
vhost_http_port = 10080
vhost_https_port = 10443
Copy the code
  • “Bind_port” indicates the port used to connect the client to the server. This port number will be used later when configuring the client.
  • Dashboard_port is the dashboard port on the server. If port 7500 is used, log in to the web browser to view the running information about the FRP service after the service is configured and started, where X.X.X.X is the IP address of the VPS.
  • Token is the password used for the connection between the client and server. Set and record the token for later use.
  • Dashboard_user and dashboard_pwd indicate the username and password for logging in to the dashboard. Set the username and password accordingly.
  • Vhost_http_port and vhost_https_port are used for reverse proxy HTTP hosts. This document does not involve HTTP. Therefore, copy or delete them.

Save after editing (vim save if not please search yourself). After that we can run the FRPS server./frps -c frps.iniIf such a message is displayed, it indicates that the system is running properly. If an error message is displayed, check the preceding steps.

2019/01/12 15:22:39 [I] [service.go:130] frps tcp listen on 0.0. 0. 0:7000
2019/01/12 15:22:39 [I] [service.go:172] http service listen on 0.0. 0. 0:10080
2019/01/12 15:22:39 [I] [service.go:193] https service listen on 0.0. 0. 0:10443
2019/01/12 15:22:39 [I] [service.go:216] Dashboard listen on 0.0. 0. 0:7500
2019/01/12 15:22:39 [I] [root.go:210] Start frps success
Copy the code

In this case, access X.X.X.X :7500 and log in to the dashboard using the user name and password you have set

Server running in the background

So far, our server is only running in the foreground, if Ctrl+C stops or if you close the SSH window, FRPS will stop running, so we use nohup to run it in the background.

nohup ./frps -c frps.ini &

Client Setup

Similarly, select the appropriate FRP program to download based on the client device. In Windows, download and decompress are not described. If you download frp_0.22.0_windows_amd64.zip, unzip it in the root directory of drive C, and rename the folder to “FRP”, you can delete the FRPS and frps.ini files in it. Open frpc.ini in a text editor, similar to the server side, with the following content.

[common]
server_addr = x.x.x.x
server_port = 7000
token = won517574356
[rdp]
type = tcp
local_ip = 127.0.0.1           
local_port = 3389
remote_port = 7001  
Copy the code

The three items under the common field are the Settings of the server.

  • Set server_ADDR to the server IP address.
  • Server_port indicates the server port number. Enter the port number you set. If the port number is not changed, it is 7000
  • “Token” is the connection password you set on the server, just fill it in as is.

Custom rules

When FRP is used, it is forwarded based on the port number. The following figure shows the working principle.

In the preceding frPC. ini, the RDP and SMB fields are user-defined rules. The format of the user-defined ports is as follows.

  • [XXX] indicates a rule name. You can define the rule name for easy query.
  • Type indicates the forwarding protocol type. You can select TCP or UDP. Consult the FRP manual if necessary.
  • Local_port is the port number of the local application. Set this parameter based on the port number of the local application.
  • Remote_port is the port number opened by this rule on the server. The server accesses the service of port local_port by listening on this port.

The default PORT of Windows RDP is 3389 and the protocol is TCP. It is recommended that you test the Remote connection using FRP on the LOCAL area network before using FRP to connect the Remote connection successfully and then use FRP to Pierce the connection.

SMB is the protocol used for Windows file sharing. The default port number is 445 and the protocol is TCP. This rule enables remote file access.

After frpc.ini is configured, you can run FRPC

Use the command prompt or Powershell to go to CD C:\ FRP

Run the./ FRPC -c frpc.ini command to run the FRPC program. If the following information is displayed, the FRPC program is running properly.

2019/01/12 16:14:56 [I] [service.go:205] login to server success, get run id [2b65b4e58a5917ac], server udp port [0]
2019/01/12 16:14:56 [I] [proxy_manager.go:136] [2b65b4e58a5917ac] proxy added: [rdp smb]
2019/01/12 16:14:56 [I] [control.go:143] [smb] start proxy success
2019/01/12 16:14:56 [I] [control.go:143] [rdp] start proxy success
Copy the code

Do not close the command line window. In this case, you can run a program outside the LAN to access X.X.X.X: XXXX (IP is the IP address of the VPS, and the port is the customized remote_port) to access the corresponding service.

The client runs in the background and starts automatically

When FRPC is running, there is always a command line window running in the foreground, which affects the appearance. We can use a batch file to run it in the background, and we can double click to execute it. Every time we open FRPC, we do not need to input commands by ourselves. Create a text file in any directory, rename it frpc.bat, edit, paste the following content, and save it.

@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM
cd C:\frp
frpc -c frpc.ini
exit
Copy the code

Then run the.bat file directly to start FRPC and hide the window (you can exit in Task Manager). For boot, just throw the.bat file directly into the Windows boot folder. At this point, the client configuration is complete, and then you can append the rules to frpc.ini as needed. It is strongly recommended that you test related functions on the LAN and configure the Windows firewall that may be affected before using FRP to test Intranet penetration. After the Intranet debugging passes, you can use FRP to test Intranet penetration.