Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [netcat]

Netcat is a computer networking service for reading from and writing network connections using TCP or UDP

46
votes
4answers
99k views

How does netcat know if a UDP port is open?

So I can use this netcat command to check if a UDP port is open: $ nc -vz -u 10.1.0.100 53 Connection to 10.1.0.100 53 port [udp/domain] succeeded! Unlike TCP, UDP is connectionless (fire and ...
40
votes
4answers
88k views

convert a hex string to binary and send with netcat

I have a binary file that I can send with netcat: $ nc -l localhost 8181 < my.dat The file contains this: $ xxd my.dat 0000000: 0006 3030 3030 4e43 ..0000NC What I really ...
36
votes
3answers
35k views

/dev/tcp listen instead of nc listen

With a netcat listener like: nc -l <port> < ~/.bashrc I can grab my .bashrc on a new machine (doesn't have nc or LDAP) with: cat < /dev/tcp/<ip>/<port> > ~/.bashrc My ...
16
votes
2answers
22k views

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 ...
14
votes
3answers
4k views

How do I create a UDP packet?

When I perform the following Netcat command and view the packets with Wireshark, it says the UDP packet is malformed. $ echo "this is a test" | nc -u 127.0.0.1 53 Similarly, using commands like $ ...
14
votes
3answers
19k views

Using in/out named pipes for a TCP connection

I've been fiddling with getting this to work for a while now, so I suspect some sort of fundamental misunderstanding about how pipes work is the root cause of my troubles. My goal is to initiate a ...
13
votes
5answers
13k views

Simplest way to send files over network

What is the simplest and most versatile way to send files over the network to other computers? By that I mean computers that other people are using at the moment. I don't think SSH works if the ...
13
votes
1answer
21k views

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 ...
13
votes
1answer
6k views

What's the gnu-netcat's '-z' equivalent option in nmap-ncat?

I check for a listening port on a service prior to running a script using this : until nc -z $HOST $PORT do echo "waiting for service to be available..." sleep 0.5 done exec "/my/script" It ...
13
votes
2answers
11k views

Remote desktop over SSH reverse tunnel to replace TeamViewer

I want to open a remote desktop session from my laptop to desktop over my SSH (reverse) tunnel. That should be simple (or at least doable), right? Until now I've been using Team Viewer to log in to ...
12
votes
1answer
33k views

No route to host with nc but can ping

I'm trying to connect to port 25 with netcat from one virtual machine to another but It's telling me no route to host although i can ping. I do have my firewall default policy set to drop but I have ...
12
votes
1answer
2k views

SSH speed greatly improved via ProxyCommand - but why?

The TL;DR version Watch this ASCII cast or this video - then come up with any reasons why this is happening. The text description that follows provides more context. Details of the setup Machine 1 ...
11
votes
7answers
12k views

How to grep netcat output

I'm trying to grep live text stream from netcat, but it doesn't work for me: netcat localhost 9090 | grep sender returns nothing, but I'm sure that it should. If I redirect the netcat output to a ...
11
votes
1answer
15k views

netcat in shell script giving invalid connection

I have a shell script that uses netcat to listen to localhost on port 1111 for web requests. Every time I try accessing localhost:1111/index.html for example I get: invalid connection to [127.0.0.1] ...
10
votes
4answers
35k views

Test if telnet port is active within a shell script

I am trying to create a script to test whether it is possible to login via telnet. I do not want to really log in; therefore, expect is not needed. I just want to see if I am able to get a login ...
10
votes
2answers
7k views

Netcat - How to listen on a TCP port using IPv6 address?

I am using the newest version of netcat (v1.10-41.1) which does not seem to have an option for IPv6 addresses (as the -6 was in the older versions of nc). If I type in nc -lvnp 2222 and check ...
10
votes
2answers
34k views

How to make netcat use an existing HTTP proxy

I can access a web page just fine by directly hitting my web server as follows: $ echo "GET /sample" | nc web-server 80 This is contents of /sample... $ Now, I would like netcat to go via a Squid ...
9
votes
3answers
15k views

netcat doesn't print response

I'm trying to send commands to a tcp port using netcat and pipe response when I run netcat and type my command it prints response correctly but when I pass command from a pipe it sends the command ...
8
votes
4answers
10k views

netcat doesn't terminate when stdin closes

I'm trying to send a message through netcat. After sending the message, netcat must terminate. I've tried the following: cat tsmmessage.bin | nc -u localhost 4300 nc -u localhost 4300 < message....
8
votes
1answer
2k views

Does netcat support proxy authentication?

How to deal with this: nc: Proxy error: "HTTP/1.1 407 Proxy Authentication Required" nc has a -P option for proxy username, but what's for password?
7
votes
1answer
7k views

How to know when NC is done transferring a file

Is there a way to know when netcat is done transferring a file between machines? Current commands: Machine #2: nc -lp 5555 > test.txt Machine #1: nc MachineIP Port < test.txt The transfer ...
7
votes
6answers
28k views

netcat: send text to echo service, read reply then exit

I would like to use netcat to send a piece of text to the echo service on my server, get the reply then exit, so that I know the connection is still good. so far I've tried: echo 'test' | netcat ...
7
votes
1answer
12k views

Netcat (nc6) - Minimal IPv6 only TCP Server and Client

I am trying to set up a basic IPv6 only echo-server using netcat (or rather nc6). Client and server are both in the same local network. However, the client quits immediately: IPv6-Server: $ nc6 -6 -...
7
votes
2answers
3k views

is it possible to send the remote connector ip via netcat?

Actually I want to make something like ifconfig.me functionality but only for my internal network. I see it the way something on server listens some port and send ip of connected remote machine. ...
7
votes
2answers
10k views

Howto create a permanent client connection with netcat?

I'm writing a bash script that constantly read a folder in a loop to send data to a server at a defined time interval. I'm using netcat as the tool to connect to the server and send the data. My ...
6
votes
1answer
25k views

Write output from netcat to a file

I'm currently trying to write a scan port result to a text file Here is the command I tried to use: nc -vv -z localhost 1-80 > file.txt This doesn't work (that is, the error messages from nc don'...
6
votes
2answers
7k views

SSH jumping over socks(4/5) proxy chain. Host -> socks proxy -> socks proxy -> destination

I got a great answer for my previous question about connecting from Machine A to Machine C via Socks proxy located on Machine B. Say Machine B Ip is 218.62.97.105 and it is listening on port 1080 ...
5
votes
2answers
6k views

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 | ...
5
votes
2answers
41k views

nc: bind failed: Address already in use

I am trying to execute nc command from a script , my script is executing nc command on different ports of Destination using the same source port. e.g: nc -p 8140 -z -v -n 10.X.X.9 9090 nc -p 8140 -z ...
5
votes
4answers
3k views

How can I read lines at a fixed speed?

I need to read a large log file and send it over a local network using (netbsd) netcat between two VMs on the same host workstation. I know that netcat has an interval, but as far as I can tell, the ...
5
votes
1answer
3k views

NetCat ignoring (not sending) network data to broadcast addresses

If I run these NetCat below commands (no error messages at all) during a WireShark capture running (capture filter= udp dst port 4000) : luis@Zarzamoro:~$ echo "Hello" | nc -w1 -4u 255.255.255.255 ...
5
votes
1answer
784 views

How to let Netcat execute command after file transfer is complete?

I want to let netcat on my server execute a script that works on a file that has just been sent and have the output of this script be sent as the response to the client. My approach is: On the ...
5
votes
3answers
8k views

How can I pipe data over network or serial to the display of another linux machine?

I have a second monitor that I'd like to use for a text-based debugging log and/or console. I don't want to have it as part of my GUI / "desktop" / main system. I have this display connected to an ...
5
votes
1answer
8k views

How to send audit logs with audisp-remote and receive them with netcat

I am trying to configure a CentOS 7 running in VirtualBox to send its audit logs to the host which is FreeBSD 10.3. Ideally, I'd like to receive the logs with FreeBSD's auditdistd(8) but for now I'd ...
4
votes
3answers
4k views

How to know which flavor of netcat I'm using?

There are two flavors of netcat: netcat-openbsd and netcat-traditional. How to know which flavor of netcat I'm using? I've tried man nc but it doesn't say what flavor it is.
4
votes
3answers
10k views

Why netcat doesn't use the right interface associated with the IP?

I have two network interfaces, A 1.2.3.4 and B 1.2.3.99. (in ifconfig) I run nc -l 1.2.3.99 20101 -v to listen on the interface B. I run nc -v 1.2.3.99 20101 -s 1.2.3.4 -4 because I want to use the ...
4
votes
1answer
5k views

How to pipe a sample log message manually to logstash for processing

I have set-up an ELK server in testing environment. I intend to send log messages from different clients to ELK, but first i want to test it from localhost to verify it running properly. Previously ...
4
votes
2answers
901 views

Why does this shell snippet to check if hosts are up using netcat stop prematurely?

Q: Why does the second iteration exits after 10.175.192.16? Can someone explain that? Or I just found a "while/netcat" bug? a.txt's content: $ cat a.txt 10.175.192.14 10.175.192.16 10.175.192.17 $ ...
4
votes
1answer
760 views

Bash - Use automatic file descriptor creation instead of fifo

At the beginning, I created a small server with netcat and it worked well: #!/bin/bash PORT="1234"; startServer(){ fifo="fifo/$1"; mkfifo "$fifo"; connected="0"; netcat -q 0 -l -p ...
4
votes
1answer
1k views

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 $ ...
4
votes
1answer
1k views

Jumping ssh hosts without netcat

I have access to an intermediate server to which I can connect with ssh. From there I can connect to other servers: A→B→C, where A is my laptop, B is an intermediate server accepting connections from ...
4
votes
1answer
6k views

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... * ...
4
votes
1answer
3k views

How could I EOF `cat` through `netcat` without closing connection?

I have run into a problem where I have a ncat server with the command ncat -l [port] -k -c "cat > foo; cat > bar". When I connect to this server through netcat, it allows me to write to the file ...
4
votes
2answers
9k views

Stream Video using Netcat and VLC

I'm trying to use netcat on Linux server to stream video to my windows client using VLC I started running netcat on Linux: cat /media/HD1/myMovie.mkv | nc -l 8668 In VLC Windows Client I tried to: ...
4
votes
1answer
883 views

Half-close netcat connection

How can I have a netcat connection terminate the sending half of a TCP connection if its input reaches EOF? I have a (non-standard) TCP service which reads all its input (i.e. until the client sends ...
4
votes
1answer
1k views

named pipe proxy over SSH [closed]

I am used to forwarding a remote service port on localhost using ssh like: ssh -L 2181:localhost:2182 user@server (forward remote host port 2182 to local port 2181) now, from the machine I ssh to, I ...
4
votes
1answer
1k views

Remote Mouse netcat (/dev/input/mice)

I was playing around with nc and I'm discovering how powerful and versatile this tool is. I was wondering how the file /dev/input/mice works because when I do cat /dev/input/mice you see the output, ...
3
votes
1answer
2k views

Can't redirect cut output

When I try to redirect the output of cut it always seems to be empty. If don't redirect it, the output shows in terminal as expected. This is true for OS X 10.10 and Linux 4.1.6. This works: root@...
3
votes
1answer
6k views

netcat echo server - possible with pipes instead of commands as strings?

I want to create an echo server without specifying any of my commands inside strings. I want all commands to be connected by pipes. This doesn't appear possible because the response gets returned ...
3
votes
3answers
12k views

getting output from netcat, decoding it and returning an output

I have to get an output from netcat, decode it and return it. after typing: nc cs2107.spro.ink 9000 the output i get is this: Welcome to the Proof of work challenge! Rules: i will provide hex ...