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

0
votes
1answer
63 views

netcat - unable to put CLIENT IP into $VAR

netcat with verbose captures client IP. but I can not put it in a variable. VAR=$(nc -v -l 82) is there a way to get the sender's ip into a $VAR ? Note: Verbose mode only prints extra lines on ...
2
votes
1answer
334 views

ZFS Send to Pigz, to netcat

I am writing a script that opens a netcat process remotely on a server which listens for input and redirects it to a file: ssh $remote_upload_user@remote_upload_address "nc -l -p $remote_port > $...
0
votes
1answer
231 views

Make netcat server timeout over ssh

I am writing a script that ssh's into another machine and opens a netcat server. The server needs to be able to timeout. Using -l ignores -w. The command netcat -w 3 throws the usage back at me. ...
0
votes
1answer
147 views

Redirect from nc & copy server output

I have an output from server: nc 192.168.1.170 10001 Also I have 2 programs which works like clients. I want them to be able to get the same data from server. So I need to create one more server, ...
3
votes
0answers
582 views

Write to stdin of running process on occasion

From time to time I want to send some text to the input of netcat. Netcat will send it then to another netcat process (either on my machine or a local network), but now I am only concerned with the ...
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 ...
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 | ...
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?
2
votes
1answer
107 views

TCP: One PC can connect to other's listening port but not vice versa

I have a local network (doesn't really matter if it's VPN or real local network - I've tried both). One computer running Linux Mint opens a socket with mint$ nc -l 4242 And the second one running ...
2
votes
2answers
4k views

Store netcat output into variable

I want to store the output from an netcat function into a variable. I tried a lot of different ways, but it doesn't work to me. Can someone help me? The whole scripting thing is whole new for me! #! ...
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... * ...
0
votes
1answer
336 views

multi-hop rsync through ssh+netcat fails very quickly: connection unexpectedly closed

I want to rsync a directory from a server to my client. I cannot access the server directly, but need to hop through an ssh gateway. From my '.ssh/config': Host gw User ab123456 HostName gw....
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 ...
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 ...
1
vote
2answers
2k views

Make netcat a “stream”

So, I'm doing a simple experiment with netcat where you can set up a voice call. Here are the commands I'm using. server: arecord | netcat -l 10000 | aplay client: arecord | netcat localhost 10000 | ...
0
votes
1answer
2k views

How to check the log of netcat during ssh tunnel

I use netcat to do the traffic forwarding during 3 machine(A->B->C) ssh tunneling. The proxy command from host A running on host B is like: /usr/bin/ssh host_B nc localhost 19999 And there exists a ...
2
votes
1answer
439 views

Controling a PC via tcp/udp commands necat/socat

I want to config a PC with necat or socat to execute a script when I tell the server to do this. I have an old app cappable to send simple message UDP prefered. The message is stored in a playlist. ...
0
votes
2answers
520 views

Which layer(IP/TCP?) is netcat/socat working on?

I have this question because I want to know when we use netcat to do the traffic forwarding during 3 machine(A->B->C) ssh tunneling, is it possible for C to know A's IP address?
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
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 ...
1
vote
0answers
273 views

Port netcat request info to bash script

I have this super simple TCP server that takes requests and returns the output of handler.sh: #!/bin/bash while true ; do nc -l -p 1234 -e handler.sh; done I'd like to port the requested path to ...
1
vote
0answers
60 views

Ensure that file socket is already opened

I'd like to open a simple file socket that can run in background like: nc -l -k -m 10 -U my_socket -c cat & so other processes can connect into it with nc -U my_socket -c read. After this ...
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 ...
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 ...
3
votes
3answers
960 views

how to get espeak to continuously speak stdout piped from netcat

I have a Raspberry pi 3 that I want to use as a sort of PA system, using espeak to announce stuff piped from netcat, which is getting input from a remote server. On the pi, I initiate the listener ...
0
votes
1answer
2k views

netcat daemon for calling functions in sh script

I'm new to shell programming and I have created a script that opens a connection to a server of mine. I want to have this script listen for an input from a client node and use that to run a function. ...
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 $ ...
0
votes
1answer
147 views

Filter for remote server response from netcat SMTP scan

I am using netcat to test if remote exchange server (lets call it exchange1) is online with this code. nc -w 3 192.168.130.17 25 I want to create a file that has that servers name if and only if the ...
1
vote
1answer
808 views

Can't pipe into netcat

I have a squid proxy running in a docker container, started like this: docker run --privileged -d --publish=3128:3128 --name foo squid I want to get some information from it, from another container ...
0
votes
2answers
415 views

How to “nc -z <address>” with socat?

I want to get the behavior of "nc -z host port ; echo $?" with socat, since my network admins have disabled netcat. The purpose is just to test that a TCP connection is open between two servers. How ...
2
votes
1answer
3k views

How to pass received data from netcat to another script as argument?

I have simple bash nc script: #!/bin/bash nc -k -l 127.0.0.1 4444 > filename.out which listens 4444 port for TCP connection. Instead of redirecting received data to filename.out I would like, if ...
0
votes
2answers
785 views

Bash using netcat, send one command's output to file

I need to know how to grab output and store it in a variable. I don't want to send all the output to the file, just one of the commands output I am sending.. Basically AUTH AUTH LIST <---needs to ...
1
vote
1answer
1k views

Empty response on HTTP request with netcat

Testing a simple HTTP request using nc: $ printf 'GET / HTTP/1.1\r\nHost: mozilla.org\r\nAccept: */*\r\n\r\n' | nc mozilla.org 80 HTTP/1.1 301 Moved Permanently Content-Type: text/html Date: Thu, 10 ...
1
vote
1answer
690 views

Reroute mysql connection through external machine

I want (as a first step towards an external mysql proxy) reroute traffic from the local connection of mysql (on a VM) to an external proxy (on the host) which then routes it back to the VM which will ...
0
votes
1answer
369 views

Convert line of ASCII file to binary packet for NetCat

I have an ASCII file, which looks like this: 36,36,0,1 36,36,0,2 ... What I want to do is to send every row of it as one binary TCP segment's payload with NetCat. To convert the number from file to ...
1
vote
0answers
562 views

How can I temporarily map a remote host and port to a local port?

Say I have a machine A acting as a router with two NICs and the following IP addresses: eth0: 192.168.1.1 (LAN) eth1: 10.0.0.1 (WAN) And I have another machine B on IP address 10.0.0.2 that I want ...
4
votes
1answer
876 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 ...
1
vote
0answers
409 views

Netcat server/client for a social thread

I have been learning nc for a while now, and I decided to make a social thread server for it in bash. Surprisingly, I got it working, but I have a couple problems with it. My main problem I want to ...
1
vote
1answer
3k views

How to have netcat server close after n seconds

I need to use nc in a weird way, where I want the server to first send a file, and then recieve a file, and this repeats. I would like to have every instance of the server server close after some ...
1
vote
0answers
1k views

Pipe Text Into and Out of Netcat Server Using mkfifo

I wanted to make two pipes for a netcat server that inputs text into the server, and one that outputs text from the server. I have the server running in a seperate script with the input and output ...
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 ...
1
vote
1answer
286 views

Replicating growing log files in a near real-time manner over the network

I have a server with a bunch of processes writing log files as they run. I need to enable a client host to get a replica of the server-side log files in a near real-time manner. Is there a better way ...
3
votes
1answer
670 views

tunnel netcat video streams to mplayer

I am sending a video stream over my network and I want to encrypt it with ssh. This solution below works: on machine 1 I run ./capture | nc 192.168.1.65 5001 on machine 2 I run netcat -l -p 5001 | ...
2
votes
2answers
2k views

How can I “man-in-the-middle” a specific port?

When I want to figure out how a certain protocol works (let's say in this case, the HTTP protocol on port 80), I open two terminal windows: nc -l 80 nc google.com 80 I then fire up the program I ...
1
vote
1answer
65 views

What command line tools can be used to manually perform each step of an entire network “conversation”?

I know, I know; the phrase "network conversation" is imprecise almost to the point of meaninglessness. Let's take this specific scenario: I plug in a computer to a DHCP enabled router, open a browser ...
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 ...
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 ...
3
votes
2answers
899 views

How do I only get whois data for an exact domain?

When I query a whois server with something like google.com, I get a whole slew of unrelated results, including things like GOOGLE.COM.SPAMMING.IS.UNETHICAL.PLEASE.STOP.THEM.HUAXUEERBAN.COM. Here I'm ...
0
votes
1answer
633 views

Why netcat says that the host isn't authoritative?

When trying to establish a TCP connection to my IP address, 192.168.1.42, netcat tells me that the host isn't authorative. That is, [~] $ echo "Hello, world"|nc -c -vv 192.168.1.42 8080 & nc -l -...
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@...