Questions tagged [netcat]

netcat is a command for performing read/write operations on TCP or UDP network connections.

From the official GNU netcat project page:

It is designed to be a reliable "back-end" tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built-in capabilities.

It provides access to the following main features:

  • Outbound and inbound connections, TCP or UDP, to or from any ports.
  • Featured tunneling mode which allows also special tunneling such as UDP to TCP, with the possibility of specifying all network parameters (source port/interface, listening port/interface, and the remote host allowed to connect to the tunnel.
  • Built-in port-scanning capabilities, with randomizer.
  • Advanced usage options, such as buffered send-mode (one line every N seconds), and hexdump (to stderr or to a specified file) of trasmitted and received data.
  • Optional RFC854 telnet codes parser and responder.

SANS has produced a netcat cheat sheet (PDF) with various tips on usage.

911 questions
25
votes
3 answers

nc command: inverse host lookup failed: Unknown host

nc works fine when i execute it on a VM. Connection to 10.0.0.10 22 port [tcp/ssh] succeeded! But when I execute the same command inside my docker container, it gives the below UNKNOWN error/exception. 10.0.0.10: inverse host lookup failed: Unknown…
Rohith
  • 1,077
  • 5
  • 16
  • 36
25
votes
5 answers

Issue with netcat timeout

Why does the following netcat command not time out if the attempt to connect takes longer than 3 seconds (ie: when the port isn't open)? I assumed that the -w flag would be what I needed. OS is OSX 10.9. nc -v -z -w 3 127.0.0.1 5050 Assuming that…
anditpainsme
  • 601
  • 1
  • 7
  • 14
24
votes
2 answers

Send POST request with netcat

I have found this little script in PHP that send a simple request to twitter for update your status, I have tried this: http://pratham.name/twitter-php-script-without-curl.html, and it work. Now, I want send this request with netcat, but this…
fixo2020
  • 266
  • 1
  • 2
  • 7
21
votes
5 answers

Scripting an HTTP header request with netcat

I'm trying to play around with netcat to learn more about how HTTP works. I'd like to script some of it in bash or Perl, but I've hit upon a stumbling block early on in my testing. If I run netcat straight from the prompt and type in a HEAD request,…
romandas
  • 4,086
  • 7
  • 29
  • 33
21
votes
3 answers

CentOS 7 and Puppet unable to install nc

I am having a weird issue with having puppet enforce the package nc. I installed it manually in the end via: yum install nc I see puppet does it via: /usr/bin/yum -d 0 -e 0 -y list nc Returns: Error: No matching Packages to list I have tested this…
Werner
  • 791
  • 1
  • 6
  • 23
20
votes
1 answer

How to start REPL for slimv with MIT-Scheme

My operating system is Debian Squeeze. Here's the vim version: VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 12 2010 02:29:33) I read a tutorial on http://kovisoft.bitbucket.org/tutorial.html and tried to start REPL for MIT-Scheme. Unfortunately,…
Yai0Phah
  • 433
  • 4
  • 14
19
votes
3 answers

nc: invalid option -- 'z'

On RHEL 7.2 OS, I get following error when trying to run nc commnad nc -z -v -w1 host port nc: invalid option -- 'z' Ncat: Try `--help' or man(1) ncat for more information, usage options and help. QUITTING. Is there any alternative to it
Patan
  • 17,073
  • 36
  • 124
  • 198
16
votes
1 answer

Send Commands to socket using netcat

I am sending text commands to a custom protocol TCP server. In the example below I send 2 commands and receive a response written back. It works as expected in telnet and netcat: $ nc 192.168.1.186 9760 command1 command2 theresponse not working…
Shiva
  • 531
  • 4
  • 6
  • 14
15
votes
1 answer

Using BusyBox version of netcat for listening tcp port

I need to listen some arbitrary port inside the Linux embedded box. I chose port 6660 because it is meant for uncrypted connections anyway and since the Linux box running customized Linux OS there are not many ports open. I found out that netcat (nc…
arapEST
  • 491
  • 1
  • 4
  • 16
15
votes
2 answers

What are .sock files and how to communicate with them

What are .sock files? How can I communicate with a .sock file? Elaborating on the 2nd bullet, I understand that .sock files are for Inter-process communication. How can I 'communicate' with them? Let us say a sock file is designed to respond in a…
Julian Simpson
  • 161
  • 1
  • 1
  • 4
15
votes
2 answers

Sending a hex string to a remote via netcat

I've got some binary commands (which I'm representing as hex) that I need to send to a remote device (it's an embedded data collection device) and observe the reply. It's easy to connect to it with netcat nc -v 192.168.200.34 19000 and it sits…
fl4r3
  • 161
  • 1
  • 2
  • 7
14
votes
2 answers

Emulating netcat -e

How can I emulate netcat -e with a version of netcat that does not have the -e option ? I need to trigger a command remotely. I can do it with netcat - without -e: #!/bin/bash netcat -l 8080 ; myCommand.sh That would do the trick, but I would…
user787935
  • 141
  • 1
  • 1
  • 3
14
votes
2 answers

Continuously listen to tcp port via terminal

Is it possible to listen to a port continuously? I listen for incoming tcp notifications with following command sudo nc -l -p 999 But as soon as notification arrives I have to restart listen with same command. Is it possible to listen to port…
S4M11R
  • 399
  • 2
  • 5
  • 14
14
votes
1 answer

Starting a TCP server from terminal

How do I start a TCP server from the terminal on port 13370 using nc? I was following a tutorial that required starting up a TCP server on 13370 and send requests through it. The tut advised me to open the TCP server using "nc" How do I go on…
ritvik1512
  • 303
  • 1
  • 3
  • 10
14
votes
1 answer

How can I send a byte (or bytes) to test a socket listening in my application?

How can I send a byte (or bytes) to test a TCP socket that's listening on a port in my application? My application receives a single byte that tells it what to do. Some operations will receive additional bytes to further instruct it. I tried using…
Imme22009
  • 3,992
  • 7
  • 31
  • 47
1
2
3
60 61