Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Ncat

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use Ncat", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use Ncat" this article.

Ncat is a general command line tool for reading, writing, redirecting and encrypting data on the network. It is designed to be your Swiss Army knife network, handling a variety of security testing and management tasks. Ncat is suitable for interactive use or as a network connection back-end for other tools.

System environment

Centos8

How to install ncat

On the Centos7/8 system, the ncat installation package is called nmap-ncat

[root@server1 ~] # yum-y install nmap-ncat 1. Check the connection of port 80 of TCP

For this example, we will examine the port 80 connection with the hostname DCserver.

[root@server1] # nc-vz DCserver 80Ncat: Version 7.70 (https://nmap.org/ncat) Ncat: Connected to 192.168.0.6:80.Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.

The-z option is "Zero-Imax O mode" and is used to check the connection status.

Create a listening port

The following command creates a tcp listening port:

[root@server1] # nc-vl 1234Ncat: Version 7.70 (https://nmap.org/ncat) Ncat: Listening on:: 1234Ncat: Listening on 0.0.0.0 nc 1234

Use netstat-tlunp to see:

On another host, use the nc command to test the connection to that port:

[root@server1] # nc-vz 192.168.43.131 1234Ncat: Version 7.70 (https://nmap.org/ncat) Ncat: Connected to 192.168.43.131:1234.Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.

Then go back to the listening side and you can see that port 45568 from 192.168.43.131 connects to port 1234 on the listening side.

[root@server1] # nc-vl 1234Ncat: Version 7.70 (https://nmap.org/ncat) Ncat: Listening on:: 1234Ncat: Listening on 0.0.0.0:1234Ncat: Connection from 192.168.43.131.Ncat: Connection from 192.168.43.131 nc 45568.

You can use the-k option to keep the listening side open.

Third, as a chat tool

Ncat can be used as a chat tool, we configure the server to listen on the port, and the remote host connects to the same port on the server and sends messages. On the server side, run the following command to open the listening port:

[root@qdzabbix ~] # ncat-l 8080

Run the following command on the remote host, and enter the chat below, press enter to send, and you can see the message content on the server.

[root@server1 ~] # ncat 192.168.0.12 8080Hello qdzabbix

Below, the contents of the message can be seen on both the server side and the remote host.

To quit, just press Ctrl + c.

4. Check the version of SSH software

You can use the nc command to check the server software version by sending the EXIT command to port 22 of ssh, as follows:

[root@server1 ~] # echo "EXIT" | nc 192.168.43.131 22SSH-2.0-OpenSSH_7.8Protocol mismatch. Use ncat to create a back door

You can use the ncat command to create a backdoor. This feature is mainly used by hackers. You can run the command like this and execute the following command on the server side:

[root@qdzabbix] # nc-l 5566-e / bin/bash

The command to run is specified after the-e option. Now the client can connect to port 5566 on the server and can fully access our system through bash by running the following command:

[root@server1 ~] # nc qdzabbix 5566lsanaconda-ks.cfga.txtbatchCustomer_Supplied_Ticketscustom_resolv.conf

The red line in the following picture shows the executed command.

Use ncat to run a Web server with static pages

You can start the Web server using the ncat command on the local host, which opens the static network page sample.html. You can run the following command:

First save the following to the / root/sample.html file.

[root@qdzabbix ~] # vim / root/sample.html Test Page Level 1 header Subheading Normal text here

Then execute the following command:

[root@qdzabbix] # while true; do nc-l-p 80

In the above command, the-p 88 option specifies that the source port is 80.

If you visit it in the browser, you can see the contents of the page.

The above is all the contents of this article "how to use Ncat". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 201

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report