Intranet penetration using LANproxy

Time:2019-12-2

Intranet penetration

In the article “wechat local debugging”, the editor mentioned using ngrok, natapp and peanut shell for intranet penetration. However, if you want to use a custom domain name, you have to pay for it.

In this paper, we want to build a free intranet penetration server. Intranet penetration server. The optional software includes LANproxy, FRP, n2n, etc. today, we choose LANproxy.

Original address: http://www.voidking.com/2017/

Get ready

1. A public network server (running proxy server).
2. An intranet PC or server (running proxy client).

Server configuration

Install Java

1. Delete the built-in JDK

rpm -e --nodeps `rpm -qa | grep java`

2. Check the JDK versions in the yum library.
yum search java | grep jdk

3. Select java-1.8.0-openjdk-devel.x86_: openjdk development environment to install.
yum install java-1.8.0-openjdk-devel.x86_64

The default installation directory is/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64

4. Configure environment variables
vim /etc/profile

Add at the end:

#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

5. Make the modification effective immediately
source /etc/profile

6. View the installation results
javajavacjava -version

Install LANproxy

1. Visit the download address of LANproxy, Download proxy-server-0.1.zip, and upload it to the public network server.

Or, download directly on the server
wget https://github.com/ffay/lanproxy/files/1274739/proxy-server-0.1.zip

curl -C - -O -L https://github.com/ffay/lanproxy/files/1274739/proxy-server-0.1.zip

2. Unzip and install
unzip proxy-server-0.1.zip

mv proxy-server-0.1 /usr/local/

3. Modify the configuration file
vim /usr/local/proxy-server-0.1/conf/config.properties
Change the user name and password of the administrator.

4. Start service
cd /usr/local/proxy-server-0.1/bin

chmod +x startup.sh

./startup.sh

5. Visit http: / / host_ip: 8090 to see the login interface.

Nginx reverse proxy

1. Add domain name resolutionlocalTo public IP.

2. In the nginx virtual host configuration directory, add local.voidking.com.conf, as follows:

server {
    listen 80;
    server_name local.voidking.com;
    charset utf-8;
    location /{
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        client_max_body_size       1024m;
        client_body_buffer_size    128k;
        client_body_temp_path      data/client_body_temp;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
        proxy_temp_path            data/proxy_temp;
        
        proxy_pass http://127.0.0.1:8090;
    }
}

3. Test nginx
./nginx -t, you may be prompted that the directory is missing. Then create a new directory.
mkdir -p /usr/local/nginx/data/client_body_temp

mkdir -p /usr/local/nginx/data/proxy_temp

4. Restart nginx
./nginx -s reload

5. Visit http://local.voidking.com/ to see the login interface.

Use

Server configuration

1. Log in to LANproxy, add the client, enter the client’s note name, generate a random key, and submit to add.

2. In the client list and configuration management, new clients will appear.

3. Click the client in configuration management to add configuration (each client can add multiple configurations).

  • The name of the agent. It is recommended to enter the port the client wants to proxy out, or the name of the project the client wants to publish to the public network.
  • Public network port, fill in a server free port, which is used to forward requests to clients.
  • Proxy IP port, fill in the client port, and the public network will forward the request to the client port.

Client configuration

1. Visit the download address of LANproxy, Download proxy-client-0.1.zip, and extract it to your favorite directory.

2. Enter the proxy-client-0.1/conf directory, and modify the config.properties to:

#It is consistent with the secret key filled in when creating the client in the proxy server configuration background; no server can log in https://lanproxy.org/ to create the client to obtain the secret key
client.key=7533f855416741d88732954991668715
ssl.enable=true
ssl.jksPath=test.jks
ssl.keyStorePassword=123456

#Fill in the actual proxy server address here. If there is no server, it can be replaced by its own proxy server (IP) address
server.host=local.voidking.com

#The default port of proxy server SSL is 4993, and the default common port is 4900
#Fill in the SSL port here when SSL. Enable = true, and fill in the normal port here when SSL. Enable = false
server.port=4993

3. Enter the proxy-client-0.1/bin directory and double-click startup.bat to start the LANproxy client.

If the startup fails, it is generally because the JDK is not installed and configured successfully. Refer to the installation of JDK in common configuration of idea. After the JDK is installed and configured, it can be started again.

4. Visit the address http://local.voidking.com: 50000 /, and you can see the page with the same port 80 of the local access client.

So far, the agent succeeded!

Advanced configuration

One port one item

Suppose that our local 4000 port has the node service enabled. So, how to provide this service gracefully to the whole Internet?

1. Add configuration to the server

2. Start the local node service

3. The LANproxy client has been started. Visit http://local.voidking.com: 50001/

At this time, the whole Internet can access the node project, but it is not friendly with the port number. Then, we will add a separate domain name to this project.

1. Add domain name resolutionnode.localTo public IP.

2. In the nginx virtual host configuration directory, add node.local.voidking.com.conf, as follows:

server {
    listen 80;
    server_name node.local.voidking.com;
    charset utf-8;
    location /{
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        client_max_body_size       1024m;
        client_body_buffer_size    128k;
        client_body_temp_path      data/client_body_temp;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
        proxy_temp_path            data/proxy_temp;
        
        proxy_pass http://127.0.0.1:50001;
    }
}

3. Restart nginx
./nginx -s reload

4. Visit http://node.local.voidking.com/ to see the local node service.

Multiple items for one port

1. Through port 80, you can access many projects under the web root directory, such as the basic project and the vkphp project mentioned in other articles. Take the vkphp project as an example below.

2. At present, the front page of the vkphp project is a simple text display.

3. The address accessed through the Internet is http://local.voidking.com:500

At this time, the entire Internet can access the vkphp project, but with the port number and project name, it feels like a fraudulent website. So, can we add a separate domain name to this project? Of course, it can.

1. Add domain name resolutionvkphp.localTo public IP.

2. In the configuration directory of nginx virtual host, add vkphp.local.voidking.com.conf, as follows:

server {
    listen 80;
    server_name vkphp.local.voidking.com;
    charset utf-8;
    location /{
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        client_max_body_size       1024m;
        client_body_buffer_size    128k;
        client_body_temp_path      data/client_body_temp;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
        proxy_temp_path            data/proxy_temp;
        
        proxy_pass http://127.0.0.1:50000;
    }
}

3. Restart nginx
./nginx -s reload

4. Open http-vhosts.conf of the local Apache, and add the configuration:

<VirtualHost *:80> #laragon magic!
    DocumentRoot "C:/laragon/www/vkphp/"
    ServerName vkphp.local.voidking.com
    ServerAlias vkphp.local.voidking.com
</VirtualHost>

5. Restart local Apache

6. Visit http://vkphp.local.voidking.com/ to see the local vkphp project.

Interestingly, the address will be automatically added after the accessvkphp, become http://vkphp.local.void king. C

epilogue

From the above configuration, we found that nginx’s reverse proxy is very easy to use. With a little adjustment, you can adapt to most projects. It’s really a magic weapon to beautify the URL. Wow.

bookmark

LANproxy source address

Amateur grass recommends a LAN penetration tool LANproxy

FRP source address

FRP Chinese document

Using FRP to realize intranet penetration

N2n source address

N2n inner network penetration artifact (one command to achieve penetration)

N 2n inner net penetrating artifact

Recommended Today

What is blockchain? A story tells you how bitcoin works

A story tells you how bitcoin worksRecommend:Artificial intelligence: the age of artificial intelligence in the romantic capital of FranceFlowers are not flowers, things are not things, AI is not things in the pool (chapter of artificial intelligence)To our youth, a salute Pictures may be lost. It is recommended to read the original I spent the […]