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

learn more… | top users | synonyms

1
vote
0answers
21 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 ...
0
votes
0answers
21 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 ...
1
vote
1answer
34 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 ...
1
vote
1answer
285 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....
0
votes
2answers
2k views

How can I use netcat (nc) for chat client server model?

I am trying to write a daemon using bash. I will enter my partner's IP address and the connection will start using nc partner_ip 2015, likewise on the server I will start the connection using nc -l -p ...
2
votes
1answer
72 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
67 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
2answers
46 views

net cat client and server model

I tried to make server client model as below on one shell nc -l -p 8080 this works as a server and on another nc 127.0.0.1 8080 and this works as a client all of this is fine ... the ...
0
votes
1answer
55 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. ...
3
votes
1answer
66 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
0answers
39 views

netcat output does not write to array if launched from cron

I am able to run this script as a user or root with bash or sh. Doing so gives me the output that I expect (arrayFWS is written to file, then emailed). However, when I run it with crontab with user or ...
0
votes
1answer
19 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 ...
0
votes
0answers
52 views

Testing Remote SMTP Server Port

I am currently working in a lab environment to test a script for my production environment. My environment has several remote firewalls, all of which have an external mail Virtual IP (VIP). Our ...
1
vote
1answer
49 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
0answers
95 views

How to Copy Files through Socks 5 Proxy?

I'm trying to copy files from ubuntu server A to debian server B. Accessing both of them via SSH on win7 laptop C. Because of slow transfers the company running A provided a Socks5 proxy. Now when ...
7
votes
7answers
2k 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 ...
0
votes
0answers
60 views

Netcat missing -z flag

I have a script that checks if a server can connect to another one over port 443, I use the following command in the script: [user@centos6 ~]$ nc -v -w 2 -z 10.3.22.2 443 Connection to 10.3.22.2 443 ...
0
votes
1answer
35 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 ...
1
vote
1answer
107 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
109 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
76 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 ...
0
votes
1answer
54 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 ...
7
votes
3answers
6k 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 ...
0
votes
1answer
39 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 ...
1
vote
0answers
36 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 ...
0
votes
0answers
9 views

Pipe output of netcat -k as soon as something is received [duplicate]

I have a nc command that's supposed to save anything received to a file immediately, yet it only dumps everything once I kill the parent process: nc -kl 9876 > log.txt How can I fix that?
1
vote
0answers
165 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
69 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
107 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
112 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 ...
2
votes
1answer
172 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 ...
2
votes
1answer
45 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 |...
1
vote
1answer
31 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 ...
7
votes
3answers
11k 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 ...
1
vote
2answers
149 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
0answers
31 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 ...
2
votes
0answers
205 views

named pipe proxy over SSH

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 ...
1
vote
2answers
124 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
91 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 -...
1
vote
1answer
184 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@...
1
vote
1answer
358 views

Netcat not working as expected when executed remotely in a non interactive shell

I have observed many unexpected behaviour when trying to start netcat in listen mode remotely. 1. When following command is used : ssh root@198.18.40.13 'nc -l -k 80 &' I observed that the ...
1
vote
1answer
490 views

grep not matching in nc output

I'm using nc to scan for open ports but I'm scanning a wide range and it's displaying too many results. Trying to grep it for the word "succeeded" doesn't work for some reason: $ nc -zv localhost ...
3
votes
1answer
804 views

nc -l in background closes immediately (nc -l 1234 &)

When I put this nc -l 12345 >nc_out in a shell script, run it and then connect from other shell using telnet, it allows me to type some text and have it end up in nc_out. But if I start nc in ...
1
vote
1answer
480 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 ...
1
vote
1answer
68 views

Is there a way to have netcat listen and place incoming files in a destination directory?

I'd like to use netcat to regularly transfer files to a media server on my network. However, I can't figure out how (or if it's possible) to do something like nc -l 5959 > /media/data/, where ...
1
vote
1answer
395 views

Need help using Netcat

I have a file on my server that has HL7 messages spread out by a space. Example below. I am wanting to send one of these messages at a time in a continual loop until stopping the script with ctrl+c. I ...
8
votes
4answers
2k 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 ...
0
votes
1answer
138 views

Can you force netcat to succeed only if all ports in port range succeed?

I use nc as part of a verification script, and check the output of each nc command listed against what the expected output should be. e.g., nc -zvw1 serv1.host.com 443 | gawk '{print $7}' Expected ...
2
votes
1answer
303 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 ...
0
votes
1answer
230 views

Saving from arecord on a raspberry pi across a network to a mac

I've currently got a usb mic plugged into a Raspberry Pi B+ and am using the following code to record data: arecord --buffer-time=5000000 -D plughw:1,0 -f cd -t raw | lame -r - stream.mp3 I then ...