Questions tagged [nc]

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

Filter by
Sorted by
Tagged with
0
votes
3answers
61 views

Conditional `if` with command that doesn't respond in else

I have the following command line, which should return the value 1 in case of, by means of nc, check communication with the IP and Port in question: /bin/nc -z 10.102.10.22 10003 > /dev/null &&...
0
votes
1answer
33 views

netcat / nc / telnet perform math on received data then output

I am not an expert on bash so sorry in advance. For my high school CTF competition, I have to read in 3 numbers, perform some arithmetic on them, then output the value back to the server. In ...
0
votes
1answer
40 views

Infinite number of process spawns despite wait and kill (bash)

This code should be a daemon that keeps alive nc command. If nc instance is dead then the daemon should respawn it. #!/bin/sh if [ "$1" != "__forked__" ]; then setsid "$0&...
27
votes
3answers
48k 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 ...
0
votes
1answer
1k 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 ...
1
vote
1answer
1k 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 ...
0
votes
1answer
22 views

nc: run command upon connection

When doing CTFs, I often run nc -lnvp $PORT and do something else while waiting for a connection. I want to be alerted when said connection is established and I get a shell. Since nc is not terminated ...
0
votes
1answer
19 views

Changing port when using netcat

The manual instructs to use -p option for entering port. When I tried to use it, 'no port to connect' was displayed. I was connecting to localhost. But the connection went through when nc localhost ...
0
votes
1answer
86 views

How do I write a simple request/response tcp server using `nc`?

I’m trying to write a request/response TCP server to handle a small number of very simple commands. I'm using a shell script to be as portable as possible, avoiding compilation or requiring specific ...
0
votes
1answer
24 views

Can't ncat some ports after opening them in the router and with firewall-cmd

I want to open some ports, both UDP and TCP, on a Fedora 32 server. First, I've opened them on the router and then restarted the router: Then, I've opened them in firewalld: sudo firewall-cmd --...
-1
votes
7answers
22k 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 ...
2
votes
1answer
18k 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
108 views

Keep track of successful pin in Bandit CTF 24 to 25 [duplicate]

I am doing the bandit wargame of OverTheWire and am trying to pass level 24 -> 25. I successfully got the password with the script below but I'd like to recover the successful pin. I tried ...
6
votes
1answer
1k views

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

Ping works, but I get 'No route to host' even though my firewall is off

I want to check if I can connect to Rspamd's Fuzzy port and have a very strange problem - I can ping a the host and get an answer (0% packet loss). But when I try to telnet him, I get "No route to ...
0
votes
1answer
2k views

vsftp server returning 500 Illegal PORT command when tried to run raw ftp commands in telnet

Currently, I am trying to run ftp commands from telnet client. I was successful with USER, PASS, PASV, LIST and when tried PORT vsftp server is throwing 500 Illegal PORT command. I am following the ...
5
votes
2answers
5k 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
1answer
215 views

How to decrypt Cryptcat with key?

I have a Pcapng (Wireshark) encrypted file with Cryptcat and I also have the Password, how can I decrypt the file? Can't find anything relevant. Only things like: "Is it Really Secure? Not if your ...
2
votes
3answers
275 views

How to understand the action of nc -l

I've read the manual of nc, it tells me that nc -l means Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use ...
0
votes
1answer
23 views

How to use nc to send message consecutively per second

I'm learning the Apache Flink. Here is the Hello World of Flink: https://ci.apache.org/projects/flink/flink-docs-stable/getting-started/tutorials/local_setup.html This example is a program, which ...
1
vote
1answer
113 views

How to setup simple netcat server which sleeps before it returns a HTTP response

Scenario Whenever the netcat server receives a connection, I want it to sleep for 2s before returning a HTTP response. I know we can turn netcat into a simple HTTP server by something like nc -lp ...
0
votes
1answer
44 views

What is this code actually doing?

While doing a CTF challenge on a platform, I needed a reverse shell but couldn't get one working so I looked at the processes and found one reverse shell code: rm /tmp/m;mkfifo /tmp/m;cat /tmp/m|/bin/...
2
votes
3answers
807 views

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

netcat with ssh

every time that I'll send a thing from computer A to computer B with nc, I to use these commands, Computer A tar cfp - film.mp4 | nc -w 3 192.168.xxx.xx 1234 Computer B nc -l -p 1234 | tar xvfp - ...
3
votes
0answers
243 views

netcat -s switch does not work or do anything at all

I have a computer with a NIC with two ports and a switch between them, and I'm trying to send data from one port to the other using netcat. I thought I could simply specify the source address (i.e. ...
1
vote
2answers
1k 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 ...
0
votes
2answers
190 views

How does this nc command work as a HTTP server?

There is an answer that serves a file over HTTP using nc { echo -ne "HTTP/1.0 200 OK\r\n\r\n"; cat some.file; } | nc -l -p 8080 { echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c &...
0
votes
1answer
101 views

How to configure stderr from nc?

I would like to check port connections with nc and forward the result to a text file. stdout works fine. stderr is empty, if you don't use -v (which I dont want), so I would like to configure the ...
0
votes
1answer
221 views

http server with ssl does not work with nc

If run: cat index.html | nc --ssl --broker --keep-open -l 443 on the client side browser keeps on trying to connect with no success. I mean, the html page does not load. Besides, curl output is: ...
1
vote
1answer
127 views

How to send new lines from file to a tcp port?

Wait for file changes and send new lines to a TCP port server. I've tried nc 127.0.0.1 1234 -c "tail -F /var/log/changes.log" & But get broken pipe
0
votes
0answers
326 views

netcat is timing out before timeout has reached

I am trying to test a port on a remote machine. The connection is over satellite, so latency is quite high. I am testing with NC with the -w option to set the timeout. Ex: nc -w 300 address port ...
0
votes
1answer
231 views

Redirecting all primary file descriptors using `exec` causes the shell to exit after program exists depending on which end closes the connection?

I've been practicing my Bash skills by creating reverse shells using various redirection operators. After having set up a nc listener: nc -lvp 4444 I run the following command: 0<&116-; ...
0
votes
1answer
295 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
372 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 -...
0
votes
1answer
54 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
1k 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
3k 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 ...
-2
votes
1answer
63 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
91 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
227 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
6k 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
314 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 ...
2
votes
2answers
2k 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
1k 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
948 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 ...
3
votes
1answer
5k 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
3answers
5k 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
239 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
63 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
119 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?