Questions tagged [nc]

`nc` is the "network `cat`" program, connecting Unix pipe I/O to TCP and UDP sockets.

nc is like cat for TCP/IP networking. It is often used with Unix processes that do not have built-in networking but which can do regular Unix pipe style I/O, allowing them to talk to the network instead.

There is no standard version of nc, so your system might have a competing variant of the program. Common names are netcat, ncat, and socat.

84 questions
52
votes
3 answers

What are the differences between ncat, nc and netcat?

I'm not sure about when to use nc, netcat or ncat. If one is the deprecated version of another? If one is only available on one distribution? If it is the same command but with different names? In fact I'm a bit confused. My question comes from…
Pozinux
  • 1,305
  • 5
  • 16
  • 27
43
votes
3 answers

Using netcat for port forwarding

I have a process that listens on an IP:port - in fact it is spark streaming which connects to a socket. The issue is that I wish to somehow create a server that connects to spark on one port and data is streamed into this server from another port.…
disruptive
  • 531
  • 1
  • 5
  • 5
13
votes
1 answer

What is `nc -z` used for?

In a solution of an exercise I found this: nc -z [serverip] [port] What does it do? On nc man page I found -z zero-I/O mode [used for scanning] not very explanatory... Searching on the web I found the Netcat Cheat Sheet which says: -z:…
Francesco
  • 808
  • 7
  • 24
7
votes
2 answers

Any way to send just "\n" in Telnet?

I'm wondering if there's any way to get telnet to send only a \n, not a \r\n. For example, if one process is listening on a port like this, to print the bytes of any traffic received: nc -l 1234 | xxd -c 1 Connecting to it from netcat with nc…
shelly
  • 81
  • 1
  • 1
  • 3
6
votes
1 answer

How does this command work? mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc -l 1234 > /tmp/f

Today I was reading the nc man page and stumbled on this command. I know that: mkfifo /tmp/f is creating a named pipe at /tmp/f. cat /tmp/f is printing whatever is written to that named pipe and the output of cat /tmp/f is been piped to…
6
votes
2 answers

Is nc (netcat) on MacOS missing the "-e" flag?

When I try to run nc -l 1337 -e /bin/bash, it says: nc: invalid option -- e usage: nc [-46AacCDdEFhklMnOortUuvz] [-K tc] [-b boundif] [-i interval] [-p source_port] [--apple-delegate-pid pid] [--apple-delegate-uuid uuid] [-s…
anonymous
  • 253
  • 3
  • 16
6
votes
1 answer

How to filter the success message when using nc port scan

I used following command for port scanning of my machine nc -zv 192.168.1.1 1-100 but I want to filter only succeeded message from following output.Hence i used the following command nc -zv 192.168.1.1 1-100|grep succeeded But no use, still it…
SuperKrish
  • 775
  • 1
  • 12
  • 22
6
votes
1 answer

How can I repeatedly send the contents of a file via socat / ncat to a socket

I'm running some performance testing, and I'm trying to send the same file repeatedly to a socket. If I do something like: $ socat -b1048576 -u OPEN:/dev/zero TCP4-LISTEN:9899,reuseaddr,fork $ socat -b1048576 -u TCP:127.0.0.1:9899…
Alun
  • 409
  • 1
  • 4
  • 7
6
votes
3 answers

How do I get a URL over HTTP with netcat?

Can anybody tell me why I am getting bad request while executing this command echo -e "GET http://www.yellowpages.com.eg/Mjg3NF9VUkxfMTEwX2h0dHA6Ly93d3cubG90dXMtYWlyLmNvbV8=/Lotus-Air/profile.html HTTP/1.1\n\n" | nc www.yellowpages.com 80 The same…
Madhur Ahuja
  • 1,501
  • 3
  • 12
  • 14
5
votes
4 answers

One way communication over UDP using Netcat

I have a situation where many "smart" devices are sending me data via UDP. I can't change anything on the sending end. I'm testing nc (or netcat) but can't get past the following: Receiving end command: nc -l -u 8123 Test sending command: echo…
Scott May
  • 73
  • 1
  • 5
4
votes
3 answers

convert one line values to multiple lines with numbering order

The following variable include for example this values echo $SERVERS server1,server2,server3,server4,server5 and when I want to pipe them on different lines then I do the following echo $SERVERS | tr ','…
yael
  • 12,598
  • 51
  • 169
  • 303
4
votes
1 answer

How to create a public unix domain socket?

Consider /var/run/acpid.socket. At any point I can connect to it and disconnect from it. Compare that with nc: $ nc -l -U ./myunixsocket.sock Ncat: bind to ./myunixsocket.sock: Address already in use. QUITTING. nc apparently allows only single-use…
Sergiy Kolodyazhnyy
  • 16,187
  • 11
  • 53
  • 104
4
votes
1 answer

What's the difference between using netcat (nc) and curl for HTTP requests?

I'm using curl to request a specific URL and getting 200 OK response: curl -v www.youtypeitwepostit.com * About to connect() to www.youtypeitwepostit.com port 80 (#0) * Trying 54.197.246.21... * Connected to www.youtypeitwepostit.com…
heytar
  • 43
  • 1
  • 1
  • 5
3
votes
3 answers

'Reversed shell' - pull shell commands from remote host with human-controlled input?

I would like to connect to a remote machine, ideally over SSH, and then pull the commands from there. To be precise, I would like make a remote machine connect to my local machine, where I would have an interactive console, send commands and see the…
Ondra Žižka
  • 879
  • 9
  • 16
3
votes
2 answers

Connecting with sftp using a proxy server

I am trying to connect to an external server using a proxy with the below command: sftp -v -o "ProxyCommand /usr/bin/nc -X connect -x proxyserver.com:8080 %h %p" [email protected] This isn't working. I get the below output: debug1: Reading…
R.Smith
  • 31
  • 1
  • 1
  • 3
1
2 3 4 5 6