Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
1 vote
0 answers
35 views

Basic webserver supporting post+get (using curl and netcat)

Sorry if the question's title isn't clear about the objective of this question. I was able to make a respond-only webserver using Bash only; when it gets a curl post request, it returns results no ...
user avatar
0 votes
2 answers
53 views

netcat in systemd service resets

I am using netcat to connect to a server over TCP and continuously pipe the data received to file. nc 10.0.2.2 3456 > file.data When running this from terminal or a script it stays connected I want ...
user avatar
1 vote
0 answers
190 views

nc -lvnp (port) Non-responsive w/ PHP Reverse Shell til closed

I am currently working on Machine's on HackTheBox. I've used nc -lvnp (port) quite a bit and i've never ran into this issue: $nc -lvnp 4444 listening on [any] 4444 .... connect to [my IP] from (...
user avatar
0 votes
0 answers
63 views

Is there any way to send request via authenticated proxy in OpenBSD netcat (nc)?

I am using following command using the nc to connect to my server via proxy (localhost:8080). But this proxy is authenticated. I am not sure how to pass the auth details. Pls. note this is older ...
user avatar
0 votes
0 answers
30 views

how to respond server challenge with netcat/socat/telnet

I need to authenticate with SAFECOOKIE on tor's control port. https://stem.torproject.org/faq.html#i-m-using-safe-cookie-authentication https://gitweb.torproject.org/torspec.git/tree/control-spec.txt#...
user avatar
  • 1
-1 votes
1 answer
395 views

How to make nc listen for remote connections

I'm trying to listen for a remote connection but nc keeps giving me this error: Error: Couldn't setup listening socket (err=-3) This is the command I used: nc -lvnp port_number -s my_public_ip
user avatar
0 votes
0 answers
17 views

Userspace solution to use store data and create a UDP server

I'm trying to come up with a good way manage an intermittently connected device that I'm using for a research project. It's a sensor that goes in and out of the water. While under water, of course, ...
user avatar
  • 111
0 votes
1 answer
27 views

Add reponse to the Listening port created with nc -l localhost <some port>

How can I setup a functionality to a listening port created using the nc -l command. I want my server to respond with a pass after connection
user avatar
0 votes
3 answers
67 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 &&...
user avatar
  • 550
0 votes
1 answer
336 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 ...
user avatar
0 votes
1 answer
75 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&...
user avatar
  • 237
0 votes
1 answer
80 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 ...
user avatar
0 votes
1 answer
84 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 ...
user avatar
0 votes
2 answers
465 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 ...
user avatar
0 votes
1 answer
104 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 --...
user avatar
  • 121
0 votes
1 answer
167 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 ...
user avatar
  • 111
8 votes
1 answer
4k 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 ...
user avatar
0 votes
1 answer
2k 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 ...
user avatar
  • 2,281
0 votes
1 answer
4k 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 ...
user avatar
1 vote
1 answer
360 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 ...
user avatar
0 votes
1 answer
41 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 ...
user avatar
  • 2,819
2 votes
3 answers
621 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 ...
user avatar
  • 2,819
2 votes
1 answer
423 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 ...
user avatar
0 votes
1 answer
64 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/...
user avatar
  • 301
3 votes
3 answers
1k 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 | ...
user avatar
  • 11k
1 vote
1 answer
447 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 - ...
user avatar
  • 147
2 votes
0 answers
577 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. ...
user avatar
  • 129
0 votes
2 answers
391 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 &...
user avatar
  • 89.9k
0 votes
1 answer
167 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 ...
user avatar
0 votes
1 answer
359 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: ...
user avatar
  • 3,939
1 vote
1 answer
307 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
user avatar
0 votes
0 answers
657 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 ...
user avatar
  • 3
0 votes
1 answer
308 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-; ...
user avatar
  • 3,317
0 votes
1 answer
472 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":...
user avatar
0 votes
1 answer
600 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 -...
user avatar
0 votes
1 answer
104 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 ...
user avatar
  • 137
1 vote
1 answer
2k 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 ...
user avatar
  • 113
-2 votes
1 answer
73 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 ...
user avatar
  • 89.9k
-1 votes
1 answer
123 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....
user avatar
  • 11k
0 votes
1 answer
313 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: ...
user avatar
  • 2,195
1 vote
2 answers
10k 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 ...
user avatar
2 votes
2 answers
3k 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 (...
user avatar
  • 33
0 votes
1 answer
2k 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 ...
user avatar
  • 26.1k
1 vote
2 answers
1k 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 ...
user avatar
3 votes
1 answer
8k 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....
user avatar
0 votes
2 answers
2k 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 ...
user avatar
  • 11
1 vote
3 answers
836 views

Failing IF in a WHILE loop in BASH script that checks for open 22 ports

Im trying to create a rather basic script to run through a list of servers and check if the SSH port is open using nc. I've tried a few different ways, but can't seem to get this to work. I am ...
user avatar
  • 550
0 votes
1 answer
229 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?
user avatar
  • 111
-1 votes
7 answers
30k 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 ...
user avatar
3 votes
3 answers
71 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 ...
user avatar