Questions tagged [nc]

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

-3
votes
4answers
5k views

Brute-force 4 digit pin with pass using shell script

I am doing some challenges. This is one them. I am trying to brute-force 4 digit pin with the password to get my desired answer. After connecting to the port It prompts me to enter the password then ...
0
votes
1answer
33 views

How can a client talk to another client using unix domain sockets?

Using bash we might have something like this with netcat: nc -lk -U /my/fifo | while read line; do # line => {"client_id":123} done; clients send data like this: echo '{"client_id":123,"data":...
0
votes
1answer
32 views

Understanding the Netcat properly [closed]

Netcat confuses me a little bit and here are the reasons: when I run: nmap localhost There are some ports listed with the information whether they are open or closed. So if I run the command : nc -l -...
1
vote
1answer
8k views

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" user@server.com This isn't working. ...
0
votes
1answer
16 views

How can I list ONLY open ports in a range with nc [duplicate]

I see many examples for nc, even one in the man page, that says nc -zv 77.77.77.77 10-30 would report the open ports in the range 10-30. However, on my machine all the closed ports are also ...
1
vote
1answer
78 views

Sending data to Unix socket failing unless proxied with socat via UDP

I'm trying to debug why data isn't being sent over a Unix Domain Socket. I have 2 applications which should be communicating over a UDS but aren't. To test I've done the following: Using socat, I ...
0
votes
2answers
1k views

Netcat as Daemon

I'm trying to set up something that telnets into a device and saves the output to file. I can get it working on the CLI, but not running it at boot (using crontab) This works running running on 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 ...
-2
votes
1answer
45 views

Does `inetd` (and `nc`) apply only to programs written as daemons?

When inetd makes several programs run as services, does inetd require the programs necessarily written as daemons (e.g. not having a controlling terminal, no interactive input, ...)? Or caninetd ...
-1
votes
1answer
44 views

how to capture details from nc

by the following command we can identify which ip are using port 2181 and the relevant port echo stat | nc localhost 2181 Zookeeper version: 3.4.6-91--1, built on 01/04/2018 10:34 GMT Clients: /182....
0
votes
1answer
41 views

Networking: port listening but nc fails

I have set up a docker-compose stack on a server. One of its services is jaeger collector and is configured as follows: collector: image: jaegertracing/jaeger-collector:1.8 environment: ...
1
vote
2answers
398 views

Shell Script in netcat listener to talk with client

I have this script on my netcat server which asks for name and some other information: *echo "Tell me your name" read $ln ...
2
votes
1answer
144 views

Why does NetHogs report 0 KB/second while benchmarking lo?

I was curious to know how much traffic the Linux kernel could handle on the loopback network, so I decided to benchmark it. In one terminal, I ran: % nc -l -p 5235 127.0.0.1 > /dev/null And in ...
0
votes
2answers
426 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
439 views

How to decrypt Cryptcat (twofish) data?

I have some packets that are encrypted with Cryptcat tool and I want to decrypt them. I have the encryption password. I tried to use netcat with cryptcat, but every time I'm connecting from netcat to ...
1
vote
2answers
479 views

problem piping data into nc

I've written a small UDP server in PHP which listens on a socket, accepts a command, and performs an action. It's really quite basic. I can connect to it manually like this: % nc -u host port (...
0
votes
1answer
228 views

nc getting stuck unexpectedly

I expected this: nc -l localhost 7000 </dev/null & nc localhost 7000 </etc/profile and this nc -l localhost 7000 </etc/profile & nc localhost 7000 </dev/null to finish after ...
1
vote
2answers
342 views

Print netcat input on terminal

I'm trying to write a script where I cat the content of a file and pipe it into nc: $cat somefile.txt | nc server port The file content is sent to the server as expected but on the terminal I only ...
1
vote
1answer
530 views

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....
0
votes
1answer
438 views

ncat v7.6 UDP -k and -w not working as expected

At work ( BSD nc version ) and on many internet examples ncat can listen to udp and be used with the following options : -k which allows multiple connections -w 0 which terminates the current ...
0
votes
3answers
2k views

ncat command gives Idle timeout expired on using option “-i”

I am using the nc command to upload a file to a device, this is how I am using it: nc -i1 "device ip" "port" < /path/to/file this command works fine on Scientific Linux 6.4 32-bit, but after ...
1
vote
1answer
117 views

How can I overwrite the destination file netcat writes to as opposed to appending?

I have two ubuntu servers and will be using a script (although I have not written it yet) on the sending server to send file abcd.txt whenever it changes using: nc 10.10.10.4 3333 < abcd.txt On ...
3
votes
3answers
49 views

'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 ...
0
votes
1answer
41 views

How can I run this tcp command in Ubuntu? [closed]

I want to run this command in Ubuntu: tcp 0 0 0.0.0.0:50010 0.0.0.0:* LISTEN <pid>/java but tcp is not recognized in Ubuntu. What could be an alternative for this?
0
votes
1answer
3k views

nc to retry on connection refuse

is there any solution for nc 192.168.1.1 1234 to retry till it gets connected and once it gets connected ; it will send an output via "nc 192.168.1.1 1234" on machine 192.168.1.1 where it is ...
3
votes
1answer
861 views

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 ...
1
vote
3answers
6k views

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 ...
1
vote
1answer
997 views

How to stream video with netcat

I'd like to have Raspberry Pi stream video, so I'm doing this: raspivid ... -o - | nc -l -k 4242 But the problem is that the pipe or nc, is caching the data until someone connects. But I don't want ...
3
votes
1answer
2k views

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] [--...
1
vote
0answers
296 views

How to `nc -l 1234 | bash` but send response back to connecter

I have a basic netcat listener on my network that uses this command: nc -l 1234 | bash. This command runs everything it receives in nc into BASh. It works, however, only the listener can see the ...
0
votes
1answer
228 views

VPN Clients only can connect to other machines after ping

I have a weird problem. I have an OpenVPN server up and running. When my VPN clients (10.0.0.x) try to connect to another machines (192.168.0.x), they fail (I tried netcat, telnet and SIP). If I ...
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 ...
0
votes
1answer
96 views

Retrieve file from list as nc input

I'm trying to create a simple script (one liner, actually) that takes the content of the a file, makes it random, and provides the output to netcat as the connection destination. This is what I ...
3
votes
1answer
658 views

'netcat -e' not relaying stdout

I'm using netcat to create a backdoor running a python script with the following command: netcat -l -p 1234 -e 'python /script.py' then I'm connecting to the backdoor with another shell using: ...
3
votes
1answer
78 views

Remote control alarm

I want one of machine have a remote control alarm running that can be triggered by any remote machine. More precisely Machine A is running the service in the background Any remote machine B can send ...
1
vote
1answer
1k views

Port forwarding isn't working on mac osx

I've setup port-forwarding on my mac like this: sudo sysctl net.inet.ip.forwarding=1 echo "rdr pass inet proto tcp from any to any port 445 -> 127.0.0.1 port 5441" | sudo pfctl -ef - To this ...
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 ...
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 | ...
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... * ...
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 ...
1
vote
1answer
315 views

Why nmap closed my connection?

I started new connection on port 3333 typing nc -l 3333. Then in other terminal window I typed nmap -sT -O localhost to check if 3333 port is really open. After this command my connection on port 3333 ...
4
votes
1answer
3k views

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

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 ...
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 $ ...
2
votes
1answer
793 views

Connecting to server on localhost with same source and destination port

Here is simple server listening to port 80 of localhost: nc -4 --listen 127.0.0.1 80 Here is the client to connect to server on localhost using source port same as destination port of server: nc -4 ...
2
votes
1answer
192 views

howto set up network printer (DE-agnostic solution)

I have a network printer. I can send a postscript file to the printer using nc, and the printer prints it: cat tiger.eps | nc 192.168.0.6 9100 If I want to print from my applications (ie from ...