Tag Info

Hot answers tagged

8

I used the -r and -p switch to xxd: $ echo '0006303030304e43' | xxd -r -p | nc -l localhost 8181 Thanks to inspiration from @Gilles answer, here's a perl version: $ echo '0006303030304e43' | perl -e 'print pack "H*", <STDIN>' | nc -l localhost 8181


7

Unfortunately it's impossible to do with just bash. /dev/tcp/<ip>/<port> virtual files are implemented in the way that bash tries to connect to the specified <ip>:<port> using connect(2) function. In order to create listening socket, it would have to call bind(2) function. You can check this by downloading bash sources and looking at ...


7

you want tcpdump not nc, and the syntax would be tcpdump -i eth0 netcat is only for basic TCP/IP testing. tcpdump utilizes the libpcap library which allows for lowlevel interactions with packets and the likes


6

Netcat is not a specialized HTTP client. Connecting through a proxy server for Netcat thus means creating a TCP connection through the server, which is why it expects a SOCKS or HTTPS proxy with the -x argument, specified by -X: -X proxy_protocol Requests that nc should use the specified protocol when talking to the proxy server. ...


6

As perl will be installed. perl -MIO::Socket::INET -ne 'BEGIN{$l=IO::Socket::INET->new( LocalPort=>1234,Proto=>"tcp",Listen=>5,ReuseAddr=>1); $l=$l->accept}print $l $_' < ~/.bashrc would work, unless a local firewall doesn't allow incoming connections to 1234. If socat is installed: socat -u - tcp-listen:1234,reuseaddr < ...


5

Here a solution without xxd or perl: If the echo builtin of your shell supports it (bash and zsh do, but not dash), you just need to use the right backslash escapes: echo -ne '\x00\x06\x30\x30\x30\x30\x4e\x43' | nc -l localhost 8181 If you have /bin/echo from GNU coreutils (nearly standard on Linux systems) or from busybox you can use it, too. With sed ...


5

pv, which is available as a NetBSD package, lets you limit the rate of a pipe. <large_file pv -L 1k | netcat …


5

You could use something like this: while true; do nc -lvp 1337 -c "echo -n 'Your IP is: '; grep connect my.ip | cut -d'[' -f 3 | cut -d']' -f 1" 2> my.ip; done nc will be executed in endless loop listening on port 1337 with verbose option that will write information about remote host to stderr. stderr is redirected to file my.ip. Option -c for nc ...


5

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 sure the remote TCP received the ...


4

Just put the redirection outside the loop. while true; do read_folder process_data sleep 10 done | netcat $ip $port If you need to output to the loop's standard output from inside the loop, divert it through another file descriptor. { while true; do read_folder echo tick >&3 process_data sleep 10 done | ...


4

If you have xxd, that's easy: it can convert to and from hexadecimal. echo '0006303030304e43' | xxd -r -p | nc -l localhost 8181 I don't think there's a reasonable (and reasonably fast) way to convert hexadecimal to binary using only POSIX tools. It can be done fairly easy in Perl. The following script converts hexadecimal to binary, ignoring any input ...


4

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 which will read from stdin as long as it's ...


4

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 plus the record terminator fed to ...


3

Can you try doing the second step without doing the nc? That is - do the VNC with just the -L and -R. I believe the issue is that your netcat session is connecting back to an already open. So when doing the VNC stuff don't use netcat.


3

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 to D: ssh -o ProxyCommand='socat - ...


3

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" option, for "zero I/O". Try nc -z -w 3 ...


3

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 the file isn't truncated until after the ...


3

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 man page for more info.


3

When connecting to an IPv6 link-local address you need to specify through which link to reach it, as seen from the client system. The same link-local addresses are used on every link, so the client needs to be told explicitly which link (interface) to use. So if the system you want to reach is connected through eth0 of the client system, you need to connect ...


2

Two separate processes: One that copies result.txt to netcat. Result.txt is fed via another process. echo -n >result.txt tail -f result.txt | nc ip port & while true do read_folder() process_data() > result.txt wait 10 sec done


2

I had faced with this problem too. The main problem is netcat. It is a great tool, but it closes the connection when one of its connected input or output file descriptors are closed. It doesn't do anything when server is not listening and it exits when the other peer is closed. As long as you setup the server correctly and keep your file descriptors open, it ...


2

cat out | netcat foo.bar.org 4000 > in & I think the problem is that cat will exit as soon as it receives an EOF from the out pipe. And when cat exits, the rest of the pipeline (including netcat) gets terminated as well. Try something like this instead: while true; do cat out; done | netcat foo.bar.org 4000 > in & Thus, cat gets restarted ...


2

I use tsocks for this purpose. It's a wrapper that catches all connects and forwards them according to your tsocks.conf file. For instance: server = 127.0.0.1 server_type = 5 server_port = 1338 Where as you already have a ssh-proxy set on localhost port 1338. Using this method, you can nest connections since the next ssh session running in the tsocks ...


2

Take a look at socat: http://www.dest-unreach.org/socat/doc/README


2

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.


2

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-openbsd netcat implemention


2

You should use tcpdump with the -w switch. tcpdump -i INTERFACE -w FILENAME Replace INTERFACE with the interface you want to listen and FILENAME with the location of the file to which you need to capture the output.


1

You have to run the command in its own shell instance. nohup sh -c 'nc -l -p 4000 | dd of=/home/myname/test.txt 2>/run/user/myname/stderr 1>/run/user/myname/stdout' &


1

vlc has a stream feature to redirect video by network. You need execute this command on server: vlc -vvv zzx.rmvb --sout '#std{access=mmsh,mux=asfh,dst=:8080}' And then,you can execute this command on client: mms://server_ip_address:8080 As the above,I use mms/mmsh to redirect video by network. Vlc support other stream methods.For ...


1

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 -d. Otherwise, you could replace the ...



Only top voted, non community-wiki answers of a minimum length are eligible