date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,373,493,602,000
At the beginning, I created a small server with netcat and it worked well: #!/bin/bash PORT="1234"; startServer(){ fifo="fifo/$1"; mkfifo "$fifo"; connected="0"; netcat -q 0 -l -p "$PORT" < "$fifo" | while read -r line; do if [ "$connected" == "0" ];then #listen for a new connec...
You cannot set and use fd in the same command; you are effectively doing exec {fd}> ... >&$fd. What can work is creating the bash fifo/pipe first, using some simple command like :. Eg: startServer(){ local connected=0 fd exec {fd}<> <(:) nc -q 0 -l -p "$PORT" <&$fd | while read -r line do if [ "...
Bash - Use automatic file descriptor creation instead of fifo
1,373,493,602,000
I got a great answer for my previous question about connecting from Machine A to Machine C via Socks proxy located on Machine B. Say Machine B Ip is 218.62.97.105 and it is listening on port 1080 The command for that: ssh -o ProxyCommand='socat - socks:218.62.97.105:HOST_C:21,socksport=1080' I wonder if it is possible...
With: socat tcp-listen:12345,reuseaddr,fork,bind=127.1 socks:218.62.97.105:11.11.11.11:3128,socksport=1080 you will have a socat waiting for TCP connections on port 12345 on the loopback interface, and forward them to 11.11.11.11:3128 by way of the socks server on 218.62.97.105:1080 You can then use that to connect t...
SSH jumping over socks(4/5) proxy chain. Host -> socks proxy -> socks proxy -> destination
1,373,493,602,000
I'm using nc in a Debian environment: # dpkg -l | grep netcat ii netcat-traditional 1.10-41+b1 # cat /etc/debian_version 9.4 Its help page describe the behavior of the -w flag: -w secs timeout for connects and final net reads So it seems it's accept seconds only (as integer). I ne...
I don't think it is possible with nc alone. But you can additionally use the timeout tool (GNU coreutils package) which allows you to run a command with a timelimit specified as a floating point number, e.g. like so. echo -n read_input | timeout 0.5 nc 192.168.1.185 8800
Usage of nc with timeouts in ms
1,373,493,602,000
I'm trying to connect directly (without 3rd party server) my computer to a friend's computer. We are both behind a ISP router, and would like (as a challenge!) to connect without modifying the router configuration. As suggested here and here, we tried both TCP hole punching: myself$ nc -p 7777 public-ip-friend 8888 fr...
Sometimes the commands given in the question will work, but sometimes it won't. Here is the reason. Let's say: my computer IP on my local network: 192.168.1.10 my home public IP: 203.0.113.10 my friend's public IP: 198.51.100.27 When doing this on my computer: myself$ nc -u -p 7777 198.51.100.27 8888 we have, bef...
UDP or TCP hole punching to connect two peers (each one behind a router)
1,373,493,602,000
If I run these NetCat below commands (no error messages at all) during a WireShark capture running (capture filter= udp dst port 4000) : luis@Zarzamoro:~$ echo "Hello" | nc -w1 -4u 255.255.255.255 4000 luis@Zarzamoro:~$ echo "Hello" | nc -w1 -4u 255.255.255.1 4000 luis@Zarzamoro:~$ echo "Hello" | nc -w1 -4u 192.168.11...
I assume you are using netcat-openbsd because you specify -4. It has -b to enable broadcast address, but it's known that UDP broadcast is not supported by this version of netcat even with -b. Debian Bug#702204 suggests a patch to fix that. You can install an alternative package netcat-traditional which seems to corr...
NetCat ignoring (not sending) network data to broadcast addresses
1,373,493,602,000
I am trying to execute nc command from a script , my script is executing nc command on different ports of Destination using the same source port. e.g: nc -p 8140 -z -v -n 10.X.X.9 9090 nc -p 8140 -z -v -n 10.X.X.9 9091 nc -p 8140 -z -v -n 10.X.X.9 9092 nc -p 8140 -z -v -n 10.X.X.9 9093 and so on ... After the 1st nc ...
Background When you're attempting to use nc in this manner it's continuing to keep the TCP port open, waiting for the destination to acknowledge the receiving of the done request. This is highlighted in the TCP article on Wikipedia. TIME-WAIT (either server or client) represents waiting for enough time to pass to be ...
nc: bind failed: Address already in use
1,408,506,600,000
I have a second monitor that I'd like to use for a text-based debugging log and/or console. I don't want to have it as part of my GUI / "desktop" / main system. I have this display connected to an old linux box that doesn't have much processing power. When it boots up it sits ready at the login: prompt. It is connecte...
netcat springs to mind; it may be the more sensible choice (given the no-overhead, no compression approach to network communications) on your low-spec receiving machine. A nice usage example can be found here: https://stackoverflow.com/questions/4113986/example-of-using-named-pipes-in-linux-bash
How can I pipe data over network or serial to the display of another linux machine?
1,408,506,600,000
I want to let netcat on my server execute a script that works on a file that has just been sent and have the output of this script be sent as the response to the client. My approach is: On the receiving site: nc.traditional -l -p 2030 -e "./execute.sh" > file.iso On the sending site: cat file.iso - | nc.traditional -...
You need some way for the receiving end to recognize the end of the transferred file. With cat file - | nc in the sending side, the data stream through the pipe will make no separation between the contents of the file, and whatever the user types on the terminal (cat - reads the terminal). Also, by default, netcat doe...
How to let Netcat execute command after file transfer is complete?
1,408,506,600,000
I have run into a problem where I have a ncat server with the command ncat -l [port] -k -c "cat > foo; cat > bar". When I connect to this server through netcat, it allows me to write to the file foo, and after that, bar. The problem is that when the client connecting wants to stop writing foo by sending a ^D, it close...
If what you want to do is transfer 2 files with only 1 connection, you will have to somehow use a marker to separate the files in the data stream, as end-of-file is a read of length 0 that netcat will use to close the socket. Control-D may be what you can type in a terminal to signify end-of-file, but it does not gene...
How could I EOF `cat` through `netcat` without closing connection?
1,408,506,600,000
I have a netcat udp connection listening with nc -l -u .... I've been trying to do a per packet manipulation of the incoming data with just command line, but it doesn't look like there is a flag in netcat to indicate a new packet. First, is it possible to just apply a new line to the end of each packet coming in from ...
Server side: # nc -l -u -p 666 > /tmp/666.txt Other server side's shell: # tail -F /tmp/666.txt | while IFS= read -r line; do echo "$line"; # do what you want. done; Client side: # nc -uv 127.0.0.1 666 #### Print your commands.
Command line streaming string manipulation from netcat
1,408,506,600,000
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... * Connected to www.youtypeitwepostit.com (54.197.246.21) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: www...
The relevant RFC, Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing contains the answer to your question: that each line of a HTTP request should end with CR/LF. The grammar for the HTTP Message Format specifies that each header line should end with a Carriage Return character (0x0d in ASCII) followe...
What's the difference between using netcat (nc) and curl for HTTP requests?
1,408,506,600,000
How can I have a netcat connection terminate the sending half of a TCP connection if its input reaches EOF? I have a (non-standard) TCP service which reads all its input (i.e. until the client sends its FIN), and only then starts processing the data and sending back a reply. I would like to use nc to interact with thi...
The comment by @meuh suggested using socat for this purpose. Based on that I've successfully used some command | socat -t30 - TCP:localhost:1234 To transfer data including EOF and then still receive the response.
Half-close netcat connection
1,408,506,600,000
I'm trying to use netcat on Linux server to stream video to my windows client using VLC I started running netcat on Linux: cat /media/HD1/myMovie.mkv | nc -l 8668 In VLC Windows Client I tried to: Open VLC > Open network stream vlc > rtp://@serverIP:8668 Without success.
I had been looking for such a solution this weekend. Since i found one i thought to share it for future researchers. PC 1 = Server. The PC in my lan having my movie stored $ netcat -l -p 8111 <mymovie.mp4 # -p 8111 :port 8111. Can be any port #OR $ cat mymovie.mp4 |netcat -l -p 8111 # -l : listening mode PC 2...
Stream Video using Netcat and VLC
1,408,506,600,000
I'm using nc to scan for open ports but I'm scanning a wide range and it's displaying too many results. Trying to grep it for the word "succeeded" doesn't work for some reason: $ nc -zv localhost 31000-32000 | grep succeeded ... nc: connect to localhost port 31957 (tcp) failed: Connection refused nc: connect to localh...
nc writes its output to standard error, you need: nc -zvv localhost 31000-32000 2>&1 | grep succeeded The 2>&1 will redirect standard error to standard output so you can then pipe it to grep.
grep not matching in nc output
1,408,506,600,000
When I try to redirect the output of cut it always seems to be empty. If don't redirect it, the output shows in terminal as expected. This is true for OS X 10.10 and Linux 4.1.6. This works: root@karla:~# nc 10.0.2.56 30003 [...] lots of lines [...] This works: root@karla:~# nc 10.0.2.56 30003 | cat [...] lots of lin...
It's not that much that there's no output as that it's coming in chunks. Like many programs, when its output is no longer a terminal, cut buffers its output. That is, it only writes data when it has accumulated a buffer-full of it. Typically, something like 4 or 8 KiB though YMMV. You can easily verify it by comparing...
Can't redirect cut output
1,408,506,600,000
I'm trying to use the nc command on SuSE Linux Enterprise Desktop 11. I executed this line: nc ­-4ul 192.0.2.2 50000 But I got this.- bash: nc: command not found This is the first time that I have the problem. I have used the command for other tests without difficulty. I'll appreciate any help to solve this.
It seems that you don't have netcat-openbsd installed in your machine. Try: zypper search netcat-openbsd Then: sudo zypper install netcat-openbsd Maybe your package name will be different, so change it to what ever zypper search command return. This will install netcat version implemented by OpenBSD. Note zypper nc...
nc command not found on SuSE
1,408,506,600,000
Ι am nc-listening on localhost:2500 ▶ nc -l 2500 _ On another terminal I am trying to connect to this listening end ▶ nc -zv localhost 2500 nc: connectx to localhost port 2500 (tcp) failed: Connection refused Connection to localhost port 2500 [tcp/rtsserv] succeeded! Why does it seem like the first attempt is failin...
There are many different implementations of netcat. I'll assume you are not using the traditional implementation but a more modern one, which can handle IPv6, because 1st issue looks related to IPv6. Here I'm using the OpenBSD variant of nc (version 1.217, on Debian 11 as 1.217-3). First issue: double connection nc ...
netcat closing connection on localhost listening end after connection attempt
1,408,506,600,000
In trying to trace a simple HTTP GET request and its response with nc, I'm running into something strange. This, for example, works fine: the in file ends up containing the HTTP GET request and the out file the response. $ mkfifo p $ (nc -l 4000 < p | tee in | nc web-server 80 | tee out p)& [1] 8299 $ echo "GET /sampl...
The problem is that you're using shell redirects to read from and write to the same file. Check p afterwards, it will be empty as well. The shell opens it in read mode, truncating the file, while it's setting up the pipeline before it runs the commands. However, using tee, since it opens the file itself, means that ...
Different redirection styles with netcat and tee giving different results
1,408,506,600,000
I have set-up an ELK server in testing environment. I intend to send log messages from different clients to ELK, but first i want to test it from localhost to verify it running properly. Previously i had directly , used a python library to interact with elastic-search (since there was a problem in using urllib2 , 400...
You could use logger with the -P switch to set your port to 5514. Check man logger for other suitable switches, eg -t. echo "access denied" | logger -t myservice -P 5514 To check if port 5514 is currently associated with logstash, lsof -i :5514, or check logstash startup logs (meta!). Are you certain your logstash is...
How to pipe a sample log message manually to logstash for processing
1,408,506,600,000
I am using Ubuntu server 16.04.3, it comes with the OpenBSD version of netcat. I have used the OpenBSD version of netcat before in Fedora, and in Fedora I can't use the -p option with the -l option, for example the following is illegal: nc -l -p 12345 But in Ubuntu server 16.04.3, the above command worked (by "worked...
This is happening because the Debian/Ubuntu version of "netcat-openbsd" is not in fact the OpenBSD code. It is the OpenBSD code significantly patched with Debian/Ubuntu changes, which have not been sent back to the maintainers of the original software. One of those changes, written by Debian person Aron Xu, makes it ...
Weird netcat (OpenBSD version) behavior
1,408,506,600,000
I am used to forwarding a remote service port on localhost using ssh like: ssh -L 2181:localhost:2182 user@server (forward remote host port 2182 to local port 2181) now, from the machine I ssh to, I am trying to reach a tcp service and forward the response to my local machine: local-machine:2181 <-- SSH --> remote-ma...
as pointed by @ysdx the simple solution is: ssh -L 2181:service:2182 user@server
named pipe proxy over SSH [closed]
1,408,506,600,000
I want to pipe and live play the sound recorded on my raspberry to my MacBook. I've tried the following: On My raspberry: I tried to establish a data stream on a port 3333 arecord -D plughw:3,0 -f S16_LE 44100 -t raw | nc -l -p 3333 On my MacBook: nc 10.10.1.1 3333 | play -t raw -b 16 -e signed-integer -r 44100 -c 1 ...
I can't really tell you what goes wrong with your setup in your specific case; you'd want to check whether your nc actually receives data (e.g. by writing to a file, or by piping through pv), and whether your arecord actually captures sound (by writing to a file instead of piping to nc). Also, not sure that 44100 Hz i...
Piping live sound from raspberry pi to macOS
1,408,506,600,000
I have 4 programs, will be increased in the future, these programs have to connect to the same ip:port to send and receive messages at the same time. Until now I have the socket opened, I also would like to keep the connection alive between the programs and the server. #!/bin/sh nc -lvk 88.109.110.161 100 > port100.tx...
nc does not handle multiple connected clients in parallel and is the wrong tool for this job. There are quite a few right tools for this job, including: Bernstein tcpserver (original or djbwares) or Hoffman tcpserver:tcpserver -v -R -H -l 0 88.109.110.161 100 sh -c 'exec cat 1>&2' 2>&1 | cyclog port100/ my tcpserver ...
How to use bash to create a socket server and allow multiple clients in the same port?
1,408,506,600,000
I want to store the output from an netcat function into a variable. I tried a lot of different ways, but it doesn't work to me. Can someone help me? The whole scripting thing is whole new for me! #! /bin/sh while true;do var = "$(echo "RDTEMP1" | netcat -q2 sanderpi 5033)" echo &(var) echo "$...
In shell, setting variables would be done with: var1=toto var2="$(echo toto | othercommand)" You can't have spaces between your variable name, the equal character and the value you're assigning your variable with. Then, to echo a variable, you would do: echo $var echo "$var" echo "${var}" The & character, in bash/sh...
Store netcat output into variable
1,408,506,600,000
I can't find the list of commands for GNU Netcat. But they say on their official website the following: Goals of this project are full compatibility with the original nc 1.10 that is widely used, and portability. So this means that their commands are the same as nc 1.10, right? But is nc 1.10 considered to be netc...
nc 1.10 is netcat-traditional, which was released by Avian Research and last updated “officially” in 1996. It’s been extensively patched since then, and GNU Netcat was started as a development branch of Avian Netcat. (This is based on information contained in the Debian package.) GNU Netcat doesn’t appear to have been...
Are the GNU Netcat commands the same as netcat-openbsd or netcat-traditional?
1,408,506,600,000
I want to create an echo server without specifying any of my commands inside strings. I want all commands to be connected by pipes. This doesn't appear possible because the response gets returned before the request can be passed to the response generating logic. It seems I could use ncat but I also would prefer to avo...
This does what I want: Server: mkfifo fifo cat fifo | nc -k -l 4458 -v | cat > fifo Client: echo "45" | nc localhost 4458
netcat echo server - possible with pipes instead of commands as strings?
1,408,506,600,000
How can I upgrade a primitive Netcat shell to a fully-featured login shell with tab-completion and line editing? Suppose I start a remote (reverse) shell using Netcat as follows: nc -lvp $port nc $ip $port -e '/bin/bash' Now, what I get is a shell without TTY, tab-completion, line-editing, or history. That is, the le...
You cannot "upgrade" an already running shell. You can however a) create a pty and run another shell in it with script /dev/null b) fiddle with your local terminal so it doesn't intepret the intr, eof, eol and other keys specially, but pass them through. $ nc -lvp 9999 Listening on [0.0.0.0] (family 0, port 9999) [...
How can I upgrade a primitive Netcat shell to a fully-featured login shell with tab-completion and line editing?
1,408,506,600,000
I have opened a service: nc -l -p 1234 -e service.sh If someone connects to this service. nc xxx.xxx.xxx.xxx 1234 Can this connection be found in any Linux log file?
No, network connections are not logged by Linux by default. You can view current connections with a variety of tools, e.g. sudo lsof -P -n -i, but the system does not keep a history of network connections--that's up to the application. Web servers, ssh, mail servers, etc. all do this in their own ways, but nc is desig...
Are netcat connections stored to any log file in Linux?
1,408,506,600,000
Yesterday I asked a question about catting a file over a UDP socket in bash. The solution we came up was netcat -c -w 1 -v -u -s 127.0.0.1 239.255.0.1 30001 < test.txt. This worked in the sense that it sent the packets, but there's a problem. The source file isn't strictly a text file. It's actually a binary file -...
gawk -v 'RS=\03' -v cmd=' socat -u - udp-datagram:239.255.0.1:30001,bind=127.0.0.1' ' {print $0 RT| cmd; close(cmd)}' < file should work as long as there's not more than 8k in between two ^Cs. That runs one socat command per record (records being ^C delimited via the record separator variable), with the record pl...
cat file to udp, pt 2: send 1 udp packet per ^C-delimited line
1,408,506,600,000
Q: Why does the second iteration exits after 10.175.192.16? Can someone explain that? Or I just found a "while/netcat" bug? a.txt's content: $ cat a.txt 10.175.192.14 10.175.192.16 10.175.192.17 $ First iteration, this is ok, just outputs the file content: $ while read oneline; do echo $oneline; done < a.txt 10.1...
I think I have an answer: when nc tries an IP address that has a server listening on port 22 (which is typically SSH server), it reads the rest of the input and passes it to the server on port 22. The SSH server I have running on my home machines just eats the input. The nc I have (Slackware 13.1 system) has a "-z" o...
Why does this shell snippet to check if hosts are up using netcat stop prematurely?
1,408,506,600,000
nc -l -u 6666 on the receiving machine gets no messages from netconsole. tested by doing "echo test > /dev/kmsg" i am able to connect with netcat by doing "nc -u 10.0.0.192 6666" on the netconsole machine "sudo tcpdump -i wlp170s0 -n -e port 6666" outputs nothing on the listening machine netconsole options: modprobe n...
Turns out you have to increase the verbosity with dmesg -n 8
Unable to get output from netconsole
1,408,506,600,000
I have a volume with client data that is encrypted using ZFS native encryption. I was trying to send this from a Ubuntu server to a Debian server. It is not possible to receive zfs send data into encrypted volumes, so the target volume is a new one. But now the transfer failed after a small outage, and the new contain...
I don't know if it is possible with included encryption (I assume it would be), but normally you can resume failed sends with special flags send -t | recv -s, if your pool supports it (the documentation is from illumos, I assume it is the same with ZoL): zfs send [-Penv] -t receive_resume_token Creates a send s...
Can I resume a failed (ZoL) ZFS send over netcat?
1,408,506,600,000
I'm copying dd output through netcat with the following command $dd if=/dev/zero bs=1024K count=1 | nc <IP_ADDR> <PORT> -q 0 1+0 enregistrements lus 1+0 enregistrements écrits 1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,0590934 s, 17,7 MB/s However when I try to parse the output nothing happens $ dd if=/dev/zero bs=102...
In dd if=/dev/zero bs=1024K count=1 | nc <IP_ADDR> <PORT> -q 0 | grep copied there's no way that dd status output could go to grep. grep is reading the output of nc, not dd. If dd wrote that output on its stdout, it would go to nc, not grep. Thankfully dd does not write that status message to its stdout (otherwise it...
Separate dd data from output through netcat to parse output
1,408,506,600,000
I'm trying to open a port on remote system using ssh & netcat like this: ssh [email protected] 'netcat -l 7777 &' but it waits to show output and doesn't go to background! I tried nohup before netcat but got same result; How can I run netcat in background using ssh on remote system?
You can use this: ssh -f [email protected] "sh -c 'netcat -l 7777 > /dev/null 2>&1 &'" Check this thread.
How send a command to background using ssh on remote system
1,408,506,600,000
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: netcat localhost 1234 script.py is a simple loop that reads input, saves it to a file, and then prints it back. Now whatever...
Your writes to stdout are being buffered by python, and only written when the buffer is full. There are 2 simple fixes: Add the -u option to your python command to ask for unbuffered output ('python -u /script.py'). Alternatively, flush the output after each write. In your example, after the line sys.stdout.write( '...
'netcat -e' not relaying stdout
1,408,506,600,000
I'm trying to leave netcat running and close the ssh session (even stop the ssh daemon). But it then exits before all of the data is written. I'm testing in a non-ssh (local) console: nohup nc -l -p 4000 | dd of=/home/myname/test.txt 2>/run/user/myname/stderr 1>/run/user/myname/stdout & To test it, I close the cons...
OK, I dug it down: nohup runs the program with standard input redirected from /dev/null. So the dd command won't get anything from nc and nc probably will fail to write & close itself on first write tried. So first we need to create a named pipe to route the I/O via: mkfifo my.pipe then run dd with input file from th...
netcat doesn't work as expected when detached from console with nohup (Ubuntu/Debian 64bit)
1,408,506,600,000
I have to transfer a 400Gb database consisting of a single file over the Internet from a server where I have full control to an other computer at the opposite border of the ocean (but which uses a slow connection). The transfer should take a full week and in order to reduce all protocol overhead (even using ftp would ...
If your command, as stated in the comments is: socat -u FILE:somedatabase.raw TCP-LISTEN:4443,keepalive,tos=36 you can, on the sending side, do a seek and start serving from there: socat -u gopen:somedatabase.raw,seek=1024 TCP-LISTEN:4443,keepalive,tos=36 on the receiving side you also need to seek: socat tcp:exampl...
How to resume a file transfer using netcat or socat or curl?
1,408,506,600,000
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 possible, to pass each chunk of data (single lines of text) to script.sh as argument. How do I do that? Thanks in advance. ...
This below is the entry point to a multi-input script. #!/bin/bash [ $# -ge 1 -a -f "$1" ] && input="$1" || input="-" # your script's payload here The #! line is self explanatory I hope on the second line $# -ge 1 and is testing for at least one command line argument -a is the boolean and operator -f "$1" is tes...
How to pass received data from netcat to another script as argument?
1,408,506,600,000
I'm currently writing a program that prints to a Zebra printer. Because my office doesn't have a zebra printer, we print to a linux VM running netcat with nc -k -l -p 9100 | tee labels.txt so that we can view the output to the printer and verify correctness. Unfortunately, this file gets pretty big and takes up a lot ...
Answering your question, there is no feature in either netcat or tee to achieve this. Maybe you could write a cron job, which runs every minute and checks the size of the label.txt, and when it reaches 20MB, clears the first 10MB.
How to write to a file with netcat? And set it to grow to a certain size and begin overwriting itself?
1,408,506,600,000
A couple of comments on Hacker News suggest that, on FreeBSD, you can: use cat to send a file ( a .wav file for instance ) to the audio speaker (/dev/dsp). record from the mic using a similar method. send a live stream across the network (using netcat?) I can nearly do the first one. I do cat /dev/random > /dev/dsp ...
cat somefile.wav > /dev/dsp cat /dev/dsp > record_from_mic.wav cat /dev/dsp | nc -l 1234
Playing, recording, and streaming sound with cat and /dev/dsp
1,408,506,600,000
I'm using Ubuntu and I switched to netcat-traditional version but when I try to make simple HTTP requests it always failing, any cases, any servers giving 400 Bad request: (Apache Ubuntu is running on port 80) nc localhost 80 I sent plain: GET / HTTP/1.1 Host: localhost Simple or complex requests, always giving th...
I catched the problem is all about of EOL. I must use the EOL of MS-DOS (changing "\n" by "\r\n") systems even the server is running in a Linux/Unix. On save, in case of gedit, it's all solved just by choosing "Windows" on "Line ending" option in "Save As" screen of gedit.
Netcat Bad Request [closed]
1,495,187,909,000
netcat is wonderful, let me count the ways -- is to much let me sum up -- tcp/ip4, udp/ip4, tcp/ip6, udp/ip6, but what I need is stream/unix. I could write it in half a day, but If someone has already scratched this itch...
On Ubuntu I find this in the netcat man page: -U Specifies to use UNIX-domain sockets. So it seems netcat already can do what you are asking for.
Is there a netcat like utility that uses unix sockets?
1,495,187,909,000
I am writing a script that opens a netcat process remotely on a server which listens for input and redirects it to a file: ssh $remote_upload_user@remote_upload_address "nc -l -p $remote_port > $remote_dir/$backup.gz&" The script proceeds to compress the ZFS snapshot through pigz and then sends the data as input to ...
$(...) is command substitution. You don't want the output of zfs send to be taken as a file name for nc to read from. You want to send the output of zfs send as input to pigz while pigz sends its output to netcat, so: zfs send -R "$zpool@label" | pigz | netcat "$remote_upload_address" "$remote_port" Don't use UDP. UD...
ZFS Send to Pigz, to netcat
1,495,187,909,000
I made a simple server using netcat and backpipe: mkfifo backpipe nc -l 8080 < backpipe | parseRequests.sh > backpipe The contents of "parseRequests.sh" is just: #!/bin/sh if [ "$1" = "1+1" ]; then echo "2"; else echo "0"; fi When I connected to this server in another machine using nc 10.0.0.2 8080 The connection e...
The program on the left side of a pipe does not receive an EOF (which is not a signal) when the right side of the pipeline ends. It gets a SIGPIPE which tells it to terminate. The problem is that you are not reading anything from the pipeline or reading any data from the pipeline. You probably want a while read loop w...
How to avoid sending EOF from a script parsing requests from and sending answers to netcat
1,495,187,909,000
I'm interested in implementing the advanced content filter example for postfix. socat tcp-listen:10026,reuseaddr,fork tcp:localhost:10025 This is a simple "passthru" that works, but obviously doesn't do any filtering or responding. My goal is to have this socat command work exactly as it does (two-way forwarding betwe...
You could simply add -v to socat and it will copy all i/o to stderr, prefixed by > or < to indicate the direction.
socat forward input to both tcp-connect and exec (script)
1,495,187,909,000
I call Qt Assistant like suggested on stackoverflow: nc -lkU ~/.assistantfifo | assistant -enableRemoteControl & Qt Assistant window is opened, and if I call jobs, it returns: [1] + running nc -lkU ~/.assistantfifo | assistant -enableRemoteControl Then, I close Qt Assistant (just by clicking at "x"). Now, jobs r...
The command you are running (nc a.k.a. netcat) will listen for input when run with the -l flag. Normally, netcat in listen mode will close when it receives the end-of-file character, but the -k flag prevents that. In other words, netcat won't close until you kill it because of the way you invoked the command. See the ...
Output of one command is piped to another one; how to close both?
1,495,187,909,000
I am experimenting with communication over UDP port 6666 (the goal is setting up a listener for netconsole, but that's not really relevant here). On the listening side, nc -luv 6666. On the sending side, nc -uv LISTENER_IP 6666. I can send and receive, life is good. Now I leave the listener running, but kill the sende...
Due to the way that UDP "connections" work, this is expected behaviour. This is discussed in the nc6(1) man page ("UDP"), but is applicable to socat and nc as well: UDP support in netcat6 works very well in both connect and in listen mode. When using UDP in listen mode netcat6 accepts UDP packets from any source...
UDP port unreachable although process is listening
1,495,187,909,000
I want to config a PC with necat or socat to execute a script when I tell the server to do this. I have an old app cappable to send simple message UDP prefered. The message is stored in a playlist. example Let's say I want to send a message to open a macro/script to the PC that is running netcat/socat "C:\Users\xxx\D...
This is a classic use of netcat. But this is unix.SE so my answer will be completely in unix. Note: netcat has different names on different distros: netcat: alias to nc on some distros nc: GNU netcat on linux or BSD netcat on *BSD ncat: Nmap netcat, consistent on most systems Options between different versions of n...
Controling a PC via tcp/udp commands necat/socat
1,495,187,909,000
I don't understand the behaviour of netcat. Let's say that I have one host acting as server: [root@localhost tmp]# nc -u -l -p 670 Then I try to connect from a client: root@debian:/tmp# nc -u 192.168.0.109 670 Meanwhile I try to capture those packages: [root@localhost sergio]# tcpdump -nn -i wlp7s0 port 670 I ...
Because you are using UDP. There is no connection setup in UDP before sending any packets like you have with TCP, which means you only see packets if actual data gets transferred. And netcat sends only the data it gets from stdin.
tcpdump and nc with udp
1,495,187,909,000
I have this command succession: echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567 and let's say it return a string like, for example "Hello...bla". On the 89.196.167.2 system, I have made a server that takes ssh commands, executes them, and returns the result to the client. That ssh program is running OK; it re...
Use backticks. i.e.: var=`echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567`
How to put value of echo pipe netcat commands into variable [duplicate]
1,495,187,909,000
So far I use multicast with ipv4 and it works; all involved computers run linux. I listen on two machines and send on one of those two (in a separate terminal). In the below example 'Hello 1' is received on the sending machine (strawberry) and on the remote machine (ero). ero:~$ sudo ip addr add 224.4.19.42 dev enp4s0...
Introduction For a host system, while sending to a multicast IP address is quite similar to sending to an unicast address, receiving multicast is different and uses additional APIs: an host doesn't assign a multicast address to an interface, instead it joins multicast addresses of interest to receive select multicast ...
ipv6 multicast fails when it should loop back to self
1,495,187,909,000
I'm using netcat on Fedora to test an IPv6 UDP multi-cast address. The command is echo hi | nc -6 -u ff02::777:777:777 7777 netcat responds, "Invalid argument." Running strace yields connect(3, {sa_family=AF_INET6, sin6_port=htons(7777), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "ff02::777:777:777", &sin6_addr), s...
Preliminary note: your IPv4 network is not set up as 192.168.0.0/16 but most probably as 192.168.0.0/24 or any other /24 range: 192.168.255.255 is thus not a broadcast, else echo hi | nc -u 192.168.255.255 7777 would have failed. For broadcast, not supported with IPv6 but only with IPv4, an application must use the SO...
netcat producing EINVAL when sending to UDP IPv6 multicast
1,495,187,909,000
My general question is this: What's the best way (simplest, easiest, quickest, least error-prone, etc.) to verify iptables NAT rules locally on a single host (i.e. without a network connection) at the command-line? What follows are the details of specific (failed) attempts at checking a simple DNAT rule using NetCat. ...
Short Explanation: The dummy interfaces and virtual IP addresses send packets through the loopback interface, which isn't affected by the PREROUTING chain. By using network namespaces with veth interfaces we can send traffic from one IP address to another in a way that more accurately models multi-host network traffic...
Testing iptables DNAT Rule Locally Using NetCat
1,495,187,909,000
I have a local network (doesn't really matter if it's VPN or real local network - I've tried both). One computer running Linux Mint opens a socket with mint$ nc -l 4242 And the second one running OpenSUSE can connect and send messages to the socket: suse$ nc 10.8.0.10 4242 But if I try to open a socket on Suse and c...
use this command: sudo iptables -I INPUT -p tcp --dport 4242 -j ACCEPT the last line of your suse INPUT chain is: 0 0 DROP all -- any any anywhere anywhere that means DROP all INPUT packet, with this command sudo iptables -I INPUT -p tcp --dport 4242 -j ACCEPT we Insert...
TCP: One PC can connect to other's listening port but not vice versa
1,495,187,909,000
I want to use netcat as a TCP-server that reads data from a named pipe. For that I did the following: Step 1. Created a pipe and the server that uses it as a source mkfifo /tmp/all.pipe nc -k -l 8080 < /tmp/all.pipe Step 2. Created a client that reads the data continuously: while true; do sleep 1; echo "Check...
Upon: nc -k -l 8080 < /tmp/all.pipe The shell tries to open /tmp/all.pipe and that hangs as there's no process that has opened the named pipe for writing yet. Since nc has not been started yet, that explains why bash gets a connection refused when trying to connect there. When you do echo "hello" > /tmp/all.pipe ...
Usage of named pipe as data source for netcat
1,495,187,909,000
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 3000 < httprespose. Question How do I simulate the 2s delay?
I know a way with socat: socat TCP-LISTEN:3000,fork SYSTEM:'sleep 2; cat httprespose',pty,echo=0 Roughly based on my another answer.
How to setup simple netcat server which sleeps before it returns a HTTP response
1,495,187,909,000
I'm trying to use socat on two systems in order to send a multivolume tar from one system to the other. Multivolume is an absolute requirement as I'm trying to shift potentially petabytes of data to a mounted tape archive. Ultimately, I'm want to do something like this: # on system1: socat PIPE:/tmp/pipe1 SYSTEM:"ssh...
Your problem is that you have not specified you want unidirectional pipes. The socat man page explains how in this case PIPE: is like an echo. What probably happened is that when you first wrote the date into the fifo 1, your socat read it, wrote it to fifo 2, then noticed there was input on fifo 2 so read it and wro...
socat pipe to pipe for multiple open-write-close and open-read-close operations
1,495,187,909,000
When I query a whois server with something like google.com, I get a whole slew of unrelated results, including things like GOOGLE.COM.SPAMMING.IS.UNETHICAL.PLEASE.STOP.THEM.HUAXUEERBAN.COM. Here I'm doing it manually with netcat, but you get similar results using whois: $ echo google.com | nc whois.internic.net 43 Wh...
I found it, but the solution may vary from whois server to whois server. For whois.internic.net, use the keyword domain in your query: Often, the search finds more records than just the one wanted. Specify both type and full name to look up a specific record (for example, domain ibm.com). So, either of these ...
How do I only get whois data for an exact domain?
1,495,187,909,000
I'm working on a set of scripts to monitor some external services that log to a TCP port. function handleMessage { while read message do # Handle $message done } nc -d $ipadd $port | handleMessage This code works fine when log messages are delimited by new lines like the following Service started ERROR: So...
The problem here is in your while read message line. read by default terminates on a newline, but you can pass it another character with the -d option. The question to ask is in your LOGXXXX lines, how does the script know when the entry is finished? If you can put a special character at the end then you can use read ...
Log from TCP Port breaking messages on characters other than newline
1,495,187,909,000
I want to copy a Windows 7 partition that came installed on my laptop to my desktop computer. I've tried: # bzip2 -c /dev/sda5 | nc 192.168.1.1 2222 # on laptop # nc -l 2222 | bzip2 -d > /dev/sda1 # on desktop But gparted tells me the partition is corrupted with a lot of error messages. I also tried: # dd if=/dev/sda...
I finally copied using a tar pipe. # cd /mnt/sda1/ && tar cf - * | nc 192.168.1.1 2222 # on laptop # cd /mnt/sda5/ && nc -l 2222 | tar x # on desktop Copying was way faster and seemed to work. I wasn't able to boot in Windows 7 thought. I only saw a black screen when booting in it and the recovery partition freezes a...
How to copy a partition over network
1,495,187,909,000
Context : I want to test UDP port with nc command What happens : nc command return nothing on output and 0 when i put echo $? Which command : nc -vzu <ip> <port> echo $? What is the problem : I would like to know if i can trust the result of echo $? Version : netcat : 0.7.1-5.ph3.x86_64 (on vCenter). tcpdump-uw : ve...
Different nc versions or implementations might display different behaviors. You will need to test the specific behavior of your specific nc command in order to understand it and determine if you can trust the results. For instance, with my nc version, when I try to connect to some open UDP port, it writes: $ nc -vzu <...
Can i trust echo result of nc command for UDP?
1,495,187,909,000
Can sombody explain why this happening and how to fix it so that the data sent to stdin behaves the same way as the data typed in to stdin. For those who can't see the .gif Basically i have 3 terminals setup. One is running a netcat server which is the following command. nc -l 127.0.0.1 4000 Terminal 2 is just runn...
If you look at the /proc/$PID/fd/0 link, you'll see it points to the terminal: # ls -l /proc/11962/fd/0 lrwx------ 1 foo users 64 Aug 15 04:30 /proc/11962/fd/0 -> /dev/pts/15 When you output to it, you're not passing input to the nc process, you're outputting to the terminal. Which duly prints what you output. It loo...
Proc stdin weird behaviour
1,495,187,909,000
I am working on a process to send data via a pipe from one server to another for processing. Although this is not the exact command, it might look something like this: tail -f logfile | grep "abc" | grep "def" | grep -v "ghi" | netcat -q 0 n.n.n.n 7777 I would like to wrap all those greps into a script and more impor...
Just do: #! /bin/sh - { printf '%s\n' "${1-default-id}" awk '/abc/ && /def/ && ! /ghi/' } | socat - tcp:n.n.n.n:7777 ${1-default-id} expands to the first positional parameter if specified or default-id otherwise. Replace with ${1?} to exit with an error if not passed any argument instead (or ${1?The error message...
How do I inject a header line into a pipe via a shell script?
1,555,301,253,000
I am trying to compress a folder, encode to base64 and send it over the fly , but I am getting a error tar: Cowardly refusing to create an empty archive tar -czf Pictures | base64 | nc remote_host 443 nc -lvp 443 | base64 -d > secret.tgz # remote host how can I compres my folder and send it over the fly correct...
The command is giving an error of "empty" archive because your are not passing it anything to tar for compressing. When using -f what comes after should be the name of the archive to create and only then archives to compress (on your case, a directory). For sending it to stdout to feed it to pipe, you should use the ...
compressing a folder tgz , encode to base64 and send over the fly
1,555,301,253,000
Say I have an http or tcp server running, which serves tarballs (.tgz files). Is there some way I can receive files individually so I can do something like this: nc localhost 5000 | how can I read multiple files here and save each to disk? to explain further, when I connect to the server, I'd like it to respond with ...
On the server, do: tar c file1 file2 dir1 file3 ... | nc -l 5000 Then, on the client, do: nc server 5000 | tar x Or, slower, but more secure: ssh server tar c file1 file2 dir1 file3 ... | tar x For example: $ ssh localhost 'cd /etc; tar c passwd nsswitch.conf' | (d=$(mktemp -d); tar xv -C "$d"; ls -l "$d"; rm -r "$...
connect to server with netcat and receive *multiple* files with one request/connection
1,555,301,253,000
I just noticed that my server is being blocked for rsync from a firewall outside of my server, so I can't rsync to any target. Now, I would also like to know what are all the ports that are being blocked by that firewall. Is there any way to use nmap to do that? I know I can use nmap to scan the opened ports in a spe...
No, you can not nmap to scan one computer from the same computer. By definition, packets won't travel, and packets traveling is the whole base of the internet. You need a router, printer, light-bulb or external computer that could run some commands and use it to look back to that computer. I believe that you can send...
How to scan outbound closed ports with nmap?
1,555,301,253,000
This to my understanding records mono in wav format for 300 seconds to a named pipe called "mic_rec" rec arecord -D hw:4,0 -d 300 -f cd -t wav -c 1 mic_rec And this sends whatever it finds in the named pipe "mic_rec" via tcp out to port 8111 cat mic_rec |netcat -l -p 8111 UDP cat mic_rec |netcat -u -l -p 8111 recei...
I think using UDP will not necessarily by itself solve the problem with latency. This answer just tries to explain why your attempt with UDP did not work at all. UDP is a connectionless protocol, there is no handshake. This means your netcat that "listens" (netcat -l) does not know where to send data to, until it rece...
send (alsa) audio via network via UDP
1,555,301,253,000
I am facing a problem using netcat in a bash script. I would like to match a specific output after sending a command and continue the script execution as soon as possible (not waiting for a netcat timeout) $> echo 'my_command' | nc -q 10 <IP> <PORT> | grep -m 1 EXPECTED_OUTPUT # ISSUE: Closes the connection quite inst...
You want to set it up so that nc is killed as soon as grep finishes. Here is one way: ( subshell_pid=$BASHPID ; echo 'my_command' | nc $IP $PORT > >(grep -m 1 EXPECTED_OUTPUT ; kill -13 -- -$subshell_pid ; ) ) This all runs in a subshell, and then kills all processes started by the subshell when grep finishes. The >(...
Stop netcat as soon as grep matches something
1,555,301,253,000
I have this pipeline: ( tail -f ${named_pipe} | nc localhost ${port} | ql_conditional_release &> "$HOME/debug.log" & disown; ) &> /dev/null so I am reading from the netcat connection. How can I write to that same connection? It should be two-way. Basically if a condition is met in the ql_conditional_release functio...
Make the script echo into ${named_pipe}.
Read and write to same netcat tcp connection
1,555,301,253,000
I am attempting to send the stats command to memcached via netcat, however, I am not getting anything back from memcached... I have tried echo "stats" > commands.txt nc -u 127.0.0.1 11211 < commands.txt I have also tried echo stats | nc -u 127.0.0.1 11211 From what I have read on the bottom of the Memcached Document...
The following worked, You must specify the frameheader printf '\x00\x00\x00\x00\x00\x01\x00\x00stats\r\n' | nc -u 127.0.0.1 11211
Send UDP Packet to Memcached via Netcat
1,555,301,253,000
how can i monitor netcat transferring from android to my linux machine i used this command on android device ( sender ) to make a full dump for my device : dd if=/dev/block/mmcblk0 | busybox nc -l -p 8888 on receiver side i use this command : nc 127.0.0.1 8888 > device_image.dd i need to watch the progress with ...
Inserting pv in your receive-side pipeline should allow you to observe progress: nc 127.0.0.1 8888 | pv >device_image.dd If you had pv available on the sending side, you could also use it there: dd if=/dev/block/mmcblk0 | pv | busybox nc -l -p 8888 But pv probably won't be available on your Android device unless you...
watch netcat transfer dump from android to pc
1,555,301,253,000
I have two files, client.sh and server.sh, all the necessary data is on the server, which is sent to the client using netcat, the client just get these data and display it to the end user, the problem is when the server send some multiline code, the client just receive it as text and display on screen client.sh ip=127...
You can pipe the output of netcat into the shell nc -l $porta_cliente | sh however, on a socket with no authentication whatsoever, be extremely careful as this could allow anyone to execute arbitrary code on the client machine. This method is extremely bad practice and you should consider different approaches.
How can i execute text as code from server to client on shell script (netcat)
1,555,301,253,000
On Dubian, I can do the following using netcat (aka nc, ncat): michael@pi1:~ $ nc -zv 10.120.11.1 20 21 22 23 24 nc: connect to 10.120.11.1 port 20 (tcp) failed: Connection refused Connection to 10.120.11.1 21 port [tcp/ftp] succeeded! Connection to 10.120.11.1 22 port [tcp/ssh] succeeded! Connection to 10.120.11.1 2...
Yea, I found that out as well that nc didn't support -z. I wonder why they dropped it. You could install an older version of ncat, or just use nmap. Nmap nmap -sT -p <port>
Check if remote port is reachable using Centos [duplicate]
1,555,301,253,000
I have tried using nc to chat and transfer files over my local network. However, I am having trouble doing it over internet (with my friend). While doing it locally, i would be using ifconfig to view my ip address. I see only one ipv4 address. I am pretty sure this address cannot be used to connect to my friend, as I ...
The IP address you see using ifconfig is your IP address for your local network only. It is a private address (192.168, right?) and can not be used to communicate over the internet. Your router performs Network Address Translation to convey data between sites you visit and your computer. What you and your friend would...
Chat with friend using netcat
1,555,301,253,000
I know I can spawn the shell on server side using: nc -l 1111 -e /bin/bash But I want to spawn the shell on the client side. I tried doing: nc 127.0.0.1 1111 | /bin/bash It works but I can't see the output of the executed commands. So the question is, is there any way to spawn the shell on the client side using netc...
Seems to work for me, though depends on the version of netcat. Debian has packaged two: "netcat-traditional" and "netcat-openbsd". The former supports -e in both client and server mode, the latter doesn't support it at all. $ nc.traditional localhost 1234 -e /bin/bash $ nc.openbsd localhost 1234 -e /bin/bash nc.openb...
How to spawn a shell using netcat on the client side?
1,555,301,253,000
I have a squid proxy running in a docker container, started like this: docker run --privileged -d --publish=3128:3128 --name foo squid I want to get some information from it, from another container called bar. docker run --rm -it --name bar ubuntu:trusty bash If I run this in the bar container: nc 172.17.0.1 3128 HE...
Probably because netcat exits shortly after getting an end-of-file on its standard input.  Try (echo 'HEAD /'; sleep 5) | nc 172.17.0.1 3128 to keep netcat's local input open long enough for it to read the network data and write it to the standard output.  The 5 is the number of seconds to delay. Netcat has an option...
Can't pipe into netcat
1,555,301,253,000
Testing a simple HTTP request using nc: $ printf 'GET / HTTP/1.1\r\nHost: mozilla.org\r\nAccept: */*\r\n\r\n' | nc mozilla.org 80 HTTP/1.1 301 Moved Permanently Content-Type: text/html Date: Thu, 10 Mar 2016 23:07:31 GMT Location: https://www.mozilla.org/ Connection: Keep-Alive Content-Length: 0 But most hosts result...
You may want -q 1 (or 2 or 3 or something) as otherwise nc will exit before the remote server has issued its response. -D probably requires root.
Empty response on HTTP request with netcat
1,555,301,253,000
I want (as a first step towards an external mysql proxy) reroute traffic from the local connection of mysql (on a VM) to an external proxy (on the host) which then routes it back to the VM which will then give it to the mysql server. I am using this setup as the only thing I want to manipulate is the mysql configurati...
redir is far more appropriate than nc for redirecting ports. While nc is more lightweight and appropriate for one-shot tests, for more serious use redir is more appropriate; nc also does not lends itself to handle reconnections or errors without the support of auxiliary tools and more complicated setups like having x...
Reroute mysql connection through external machine
1,555,301,253,000
How to make nc client on OS X Mavericks keep socket open and read data until server disconnects the socket? I want to send data to a server through nc and then use the response. Problem is that nc disconnects the socket after the data has been sent, without waiting for the server's response. This will just write the d...
A workaround is to keep writing something to the socket - once data can't be written nc will exit. (echo -ne "GET / HTTP/1.0\r\n\r\n"; (while true; do echo -e "\n"; sleep 1; done)) | nc example.com 80 This will send empty line to nc once every second until nc can't write to socket and nc will exit. Thanks to Steffen U...
nc not waiting for server disconnect on OS X
1,555,301,253,000
I have access to just *nix systems. Either NetBSD and/or bare Linux-based OS. So my question comes from the fact that ADB is not widely available on all platforms, if so is very hard to install or obtain (having access to internet, get super user access, etc). Anyways, RNDIS functionality is already offered by almost ...
On the Android phone, you have typed : busybox nc -v -w3 -l -p 3838 This seems Ok. On Linux, type ip route. You should have something like this : default via 37.59.40.254 dev enp1s0 onlink 37.59.40.0/24 dev enp1s0 proto kernel scope link src 37.59.40.118 The line with the default route indicates the router addres...
How to "talk" to a "parent" IP in a subnet?
1,555,301,253,000
Traceroute has an -i flag, -i interface, --interface=interface Specifies the interface through which traceroute should send packets. By default, the interface is selected according to the routing table. ping also provides this with -I. Netcat has no such flag. Is there an easy work around for nc?
A good workaround for netcat: socat. This tool can do anything netcat can do, and much much more. On Linux socat provides the so-bindtodevice= option matching the SO_BINDTODEVICE socket option. Example, to listen on tcp port 4444 binding to interface veth0 (to force OS to use routes related to this interface), with ot...
Netcat with device or interface flag?
1,555,301,253,000
I have the following lines in a script file to wait until port 1521 is open in server1 AND server2 are open and then execute start_apps.sh script. How can I modify this to wait until port 1521 is open in either one of the servers (server1 OR server2) and then execute the start_apps.sh script? until (nc -z server1 152...
I would use a loop that does non-blocking checks. Something like: #!/bin/sh while [ 1 ]; do if [ $(nc -z server1 1521) ] || [ $(nc -z server2 1521) ]; then break fi sleep 1 # if desired done start_apps.sh This loop will run until either condition is met.
How to use netcat to check ports on more than one remote server?
1,555,301,253,000
I'm continuously sending packets to a UDP server after 1 second. To listen for UDP packets: ncat -klup 1234 --sh-exec "cat > /proc/$$/fd/1" However, after printing 100 packets, nothing else prints. With Wireshark I can see that packets are still being sent but on the server side nothing prints. $ ncat -klup 1234 --sh...
Stated in the ncat(1) man page -m numconns, --max-conns numconns (Specify maximum number of connections) The maximum number of simultaneous connections accepted by an Ncat instance. 100 is the default (60 on Windows). 100 is the default maximum number of connections. It can be modified with the -m ...
ncat stops listening after 100 UDP packets
1,555,301,253,000
I would like to use netcat to listen to data and receive only ONE packet. How does one do this?
You can do nc -ulp 1234 -q1 < /dev/null to receive just the first one. It's not great, as it relies on the timeout, but it should work unless your system is completely overloaded. Good enough for a one-off.
Receive only ONE packet using netcat
1,555,301,253,000
From my Android TV box, I would like to get my public IP and other related info from ifconfig.co, but it does not seem to work. If I try this code, it works fine: adb -s 192.168.1.125:5555 shell netcat icanhazip.com 80 <<< $'GET / HTTP/1.1\nHost: icanhazip.com\n\n' ... while this one returns an empty string: adb -s...
Replace the site ifconfig.co with ipinfo.io
Get my public IP from ifconfig.co using netcat
1,555,301,253,000
I open a terminal window and connect to shell using netcat: Terminal Window 1: nc hostname port Then, I navigate to a directory and open a file,... etc (I would need to be able to do this myself, not automate it). Can I then pipe the output of an executable on my computer to the netcat connection?
You could probably do it with a named pipe. mkfifo ncpipe nc hostname port < ncpipe # --- In a galaxy far, far away (another terminal) --- somecommand > ncpipe However there are some issues with this... like, if you take too long, the connection might time out or whatever. It's also possible to do this bi-directional...
Pipe Output of Executable to Existing Netcat Connection
1,517,332,876,000
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 would I go about doing this?
Hi if you want check connection between server with socat try below command and refer link .. CWsocat [options] <address> <address> CWsocat -V CWsocat -h[h[h]] | -?[?[?]] CWfilan CWprocan try this link for better understanding.. there are other method to check the connectivity..
How to “nc -z <address>” with socat?
1,517,332,876,000
I'm trying to use netcat to server some bash command results via a web interface, that stays running. The page is dynamic and needs to be updated upon loading. Just an example with what I'm using: #!/bin/bash while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo -e "Hello World"; } | nc -k -l -p 8888 done Unfortu...
Debian 7u1 installs netcat with netcat-traditional which appears to have it's own set of problems, my original issue being one of them. Removed netcat-traditional by running apt-get remove netcat-traditional and installing the proper one with apt-get install netcat-openbsd everything works as it should!
NetCat never ending http session
1,517,332,876,000
I am trying to pull temperature and humidity data from Fluke DewK 1620a thermo-hygrometers and write the temp/humidity readings to a log. I can connect to the device via netcat with a simple 'nc 1.2.3.4 10001', run some basic commands and receive output. Now I'd like to construct a command line, I can put in a script ...
I'm not sure I'd call it an "answer" per se, but I was able to approximate what I was looking to do in a completely different way. Instead of nc, I've managed to get further along using a file descriptor on /dev/tcp. exec 3<>/dev/tcp/${host}/${port} echo -e "read?" >&3 cat <&3 | tee -a ${log} exec 3<&- exec 3>&- Ther...
Capturing data from a Fluke 1620a via netcat
1,517,332,876,000
I have this question because I want to know when we use netcat to do the traffic forwarding during 3 machine(A->B->C) ssh tunneling, is it possible for C to know A's IP address?
netcat is an _application layer tool. It operates at the higher layers of the OSI stack (layer 7). So in a naive setup, computer C can not directly see computer A; the source of the IP traffic will appear to be from B. At an IP layer, all traffic will look like it originated from B because the netcat application is ...
Which layer(IP/TCP?) is netcat/socat working on?
1,517,332,876,000
How do I specify source port in socat? In netcat I can simply: nc -u -s 192.168.0.1 -p 8888 192.168.0.2 9999 I tried socat udp4:192.168.0.2:9999 STDIN:192.168.0.1:8888 It's failed STDIN: wrong number of parameters (2 instead of 0) So how do I do it in socat?
To achieve the same behavior of nc -u -s 192.168.0.1 -p 8888 192.168.0.2 9999 using socat: $ socat - UDP4:192.168.0.2:9999,bind=192.168.0.1:8888
Socat specify source port
1,517,332,876,000
I have a Linux based router that I’m trying to “control” with a home automation controller. On my automation controller I’m able to utilize a ‘two way strings’ driver to send a string to the Linux router upon the push of a button on the remote control. I’m wanting the string sent to be executed on the router. I’m ab...
You can use screen to do this. https://www.gnu.org/software/screen/ The steps are: Open ssh session as normal. Install screen. (If not already installed) start a new screen session. (Just type screen and press enter) Run your command as you have it Type in ctrl + 'a' and then release both ctrl and a, and press 'd...
How to let process continue running even after disconnecting ssh?
1,517,332,876,000
If i use netcat to listen to a port like so: nc -l 5555, I can then go to localhost:5555 in my web browser and netcat will print the request. However, if I click refresh in my browser, netcat stops working. What is causing this? I've found that specifying -k forces netcat to listen after the current connection complet...
It closes because the browser opens a TCP connection, performs the HTTP transaction, and then says "I'm done!" which usually will close the connection. As you discovered, the -k switch will keep the listening socket open for further connections.
What is making netcat close when I refresh my browser?
1,517,332,876,000
I'm trying to send a binary packet to a local process, via netcat (nc), like this: nc -w 1 -u localhost 10000 < my_binary_packet.bin The output is: read(net): Connection refused Anyone know what's going on? I get the same result with nc -w 1 -u 127.0.0.1 10000 < my_binary_packet.bin
Summary If your listener is bound to a particular IP (such as 192.168.0.10) and port (such as 10000) instead of to IP INADDR_ANY (Internet Namespace Address Any, which means it listens to all interfaces / IP addresses), do this instead to specify the correct IP: # with netcat nc -w 1 -u 192.168.0.10 10000 < my_binary_...
"Connection refused" when I try to send a UDP packet with netcat on an embedded-linux board
1,517,332,876,000
I want to connect to a port on a specific IP address without the use of netcat. I don't know of any method that would get the same result. Below is me connecting to a port with netcat: The above shows me connecting to port 22 (SSH) to a specific host. I basically want to achieve the same result but without the use of...
The obvious answer would be telnet host.example.com port (e. g. telnet www.example.com 80). Another possibility is /dev/tcp: $ echo "HEAD / HTTP/1.0" >/dev/tcp/www.example.com/80
Connect to a port without use of netcat - alternatives
1,517,332,876,000
I want to connect to instances of netcat through a veth(4) device pair. Thus, I create the veth pair using ip as follows: ip link add eth0 type veth peer name eth1 ip addr add 10.0.0.1/24 dev eth0 ip addr add 10.0.0.2/24 dev eth1 ip addr show eth0 13: eth0@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue...
I see they are meant to be put in different network namespaces, but can you tell me why it doesn’t work in a single namespace, when both veth pairs have been assigned IP addresses? The following things likely all go wrong: An application listening to an address will process any incoming packet for this address, no ...
How to connect two instances of netcat through a veth device pair?
1,517,332,876,000
I'm trying to reverse engineer a wifi webcam that connects to an Android app. I sniffed the traffic and found that the transaction is initiated when the app sends a series of 8 UDP packets, at which point the camera will stream video to the phone as a series of UDP packets. I want to send the 8 initiation packets to t...
This task isn't very well suited for doing via command line utilities - you'd be better off doing it in something like Perl or Python if you can, where the networking APIs are much richer. That being said ... you could certainly use netcat to send your packets, piping the hex data into something like xxd (part of the ...
Sending multiple packets of hex data with UDP
1,517,332,876,000
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 implementing a counter but was unsuccessful. Do you have any idea on how I could proceed ? Code: for i in {0000..9999}; do ech...
Actually this answer lets you to correctly guess the pin. It is currently the only answer in the mentioned page which is useful for your problem. Using that script, every output line from nc generates a new line in file f.txt. The first line of f.txt is I am the pincode checker for user... and it doesn't count. The s...
Keep track of successful pin in Bandit CTF 24 to 25 [duplicate]
1,517,332,876,000
The idea I have is to make a netcat server, and when you connect to it, the server runs a python script with which the user can interact. So for example the script asks for a number, and it outputs that number to the power of 3. How can you do that? How do you run a program and redirect the output to the connected us...
socat TCP-LISTEN:50011,fork EXEC:'/path/to/script',stderr,pty,echo=0 Notes: 50011 is the listening port, you can choose your own. Connect to it later, e.g. nc 127.0.0.1 50011. fork allows socat to serve to many clients (also simultaneously). Without pty it's normal to get Input a number: only after you actually prov...
Making a text based server with netcat or other programs? [closed]
1,517,332,876,000
I've made a small command to send a TCP message to an "IP-relay-unit" that can toggle the outputs. printf "setstate,1:1,1\r" | nc ip.ip.ip.ip port This actually works fine, sometimes. Since the printf worked on both linux and mac, I thought it had to do something with netcat. I noted that using -v on netcat improved ...
You can check if there is an active connection with: nc -v <HOST> <PORT> </dev/null; echo $? If the above command, returns you the value 0, then the connection is successful and you can printf your message, otherwise (value is 1), then you know that your connection is refused or timed-out etc.
Using printf with netcat