natapp intranet penetration-make locally running programs/servers accessible to others through public IP

Article directory

  • 1. Several basic concepts
    • 1.1 LAN
    • 1.2 Intranet
    • 1.3 Intranet penetration
    • 1.4 Natapp
  • 2. Build an intranet penetration environment
  • 3. Local service testing

1. Several basic concepts

1.1 LAN

LAN (Local Area Network) is a computer network that connects computers in a limited area such as a home, school, laboratory, university campus, or office building.

1.2 Intranet

Intranet refers to the internal LAN, which means that the intranet is generally used for communication between computers within the LAN and does not communicate with external network connections.

Some functions that are not developed externally are only accessible within the internal network, which can improve security and access speed. For example, some databases only allow servers to connect through the intranet.

It can be composed of two computers or hundreds or thousands of computers. The transmission speed of the intranet is faster. The latency is relatively low and the supported transmission media are relatively abundant.

1.3 Intranet penetration

Intranet penetration, that is, NAT (Network Address Translation, Network Address Translation) penetration, is a term used when connecting to a network. When the computer is in a local area network, the computer nodes of the external network and the internal network need to connect and communicate. Sometimes, the internal network is not supported. penetrate. That is to say, port mapping can let computers on the external network find computers on the internal network and improve download speeds. Whether it is intranet penetration or other types of network penetration, network penetration is a unified method to study and solve.

image-20231013162647817

1.4 Natapp

Natapp is a commercial intranet penetration tool. It provides a simple and easy-to-use interface and functions, which can help users expose services in the internal network to public network access.

Natapp provides a cross-platform client and server. Users can map internal services to a temporary domain name on the public network by configuring mapping rules on the client, thereby achieving remote access to internal services.

image-20231013163757401

2. Build an intranet penetration environment

During the project development stage, we can deploy the project on a cloud server accessible from the public network, or we can use intranet penetration tools to access the test interface running on our own computer. Here we use natapp as the intranet penetration tool.

  • ?First register an account on this site: https://natapp.cn/register;

  • After logging in, click “Buy Tunnel” on the left, either free or paid;

    image-20231013164340769

  • Select the tunnel protocol as needed. Use web to demonstrate and purchase the tunnel;

    image-20231013164642110

  • Establish a web service locally, use IDEA to start the springboot project, and ensure that the port number monitored by the service is the port number set by the purchased free tunnel;

  • Download the corresponding client according to the local operating system;

    image-20231002215030758

  • After downloading, unzip it to any directory to get natapp.exe (no need to unzip under Linux, just wget).

    image-20231013164957568

  • Copy the authtoken value. This authtoken is your tunnel login credentials.

    image-20231013165150255

  • Under Linux/Mac, you need to use the sudo chmod a + x natapp command to give execution permission first. If you are under Windows, no need to do anything.

  • Run natapp;

    • Windows: Enter the directory of natapp.exe in the cmd command console window and run it.

      natapp -authtoken=f2c62f86f2a3b0a6
      

      image-20231013170404073

    • Linux: After also giving executable permissions, run.

      ./natapp -authtoken=f2c62f86f2a3b0a6
      
  • If your luck is successful, you will get the following rewards:

    image-20231013170518550

So here, others can access the local service through http://adw7qv.natappfree.cc.

It is worth noting that the assigned domain name changes randomly, that is, the domain name assigned to natapp.exe is different each time it is run.

3. Local service testing

Here I start a simple SpringBoot project with the following simple configurations:

  • maven dependencies

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    
    <properties>
        <java.version>17</java.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
    
  • application.yml

    server:
      port: 8090
    
  • access path

    @Controller
    public class TestController {<!-- -->
        @GetMapping("/fox")
        public void fox(HttpServletResponse response) throws IOException {<!-- -->
            response.setContentType("text/html;charset=utf-8");
            PrintWriter out = response.getWriter();
            out.print("Welcome to <a href="https://www.zhulang.love" target="_blank">Fox Banmiantian’s Inn</a >, continuous practical development technology sharing and programming guide.");
            out.flush();
            out.close();
        }
    
        @GetMapping("/")
        public void root(HttpServletResponse response) throws IOException {<!-- -->
            response.setContentType("text/html;charset=utf-8");
            PrintWriter out = response.getWriter();
            out.print("Welcome to follow <a href="https://blog.csdn.net/qq_62982856" target="_blank">My CSDN</a> , continuous practical development technology sharing and programming guide.");
            out.flush();
            out.close();
        }
    }
    

Start the service. After it can be successfully accessed locally through http://localhost:8090 and http://localhost:8090/fox, test it in an external network environment. The easiest way is to let others access it through the random domain name you obtained. Then I access my two interfaces through the following two paths:

  • http://adw7qv.natappfree.cc/fox

    image-20231013174631816

  • http://adw7qv.natappfree.cc

    image-20231013174521887