Tag Info

Hot answers tagged

20

nc doesn't do https. openssl s_client is as close as you'll get. Do something like this: $ cat request.txt | openssl s_client -connect server:443


18

Copying from source to target where target has sshd running: dd if=/dev/sda | gzip | ssh root@target 'gzip -d | dd of=/dev/sda' Copying from source to target via sshd_host when target is not running sshd. Target: nc -l -p 62222 | dd of=/dev/sda bs=$((16 * 1024 * 1024)) Source: ssh -L 62222:target:62222 sshd_host & Source: dd if=/dev/sda | nc ...


14

To quote the nc man page: -l 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 this option in conjunction with the -p, -s, or -z options. Additionally, any timeouts specified with the -w option are ignored. The key here is that -p cannot be combined ...


11

The -k option should do the trick. From the manpage of nc(1): -k Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option. Alternatively, use socat, which is more targeted to your usecase of a proxy server. A random TCP-forwarder example ...


9

My understanding is that a TCP socket consists of the IP+port number, so changing the IP breaks that connection. nc has no way of knowing the IP changed, so it continues sending data to the original IP until the session times out. See RFC 793 (Transmission Control Protocol), specifically section 2.7: 2.7. Connection Establishment and Clearing To identify ...


8

Ick. You're going to have to base64 encode the attachment and create the MIME headers. Rather than generating a new message "on the fly" each time, it would probably be easier just to email yourself a very short example message from a "real" email program (leveraging the work that the people who wrote it did to put the attachment into the proper encoding ...


8

Okay, so using everyone's comments as a starting point I came up with this silly mess :-) ... { sleep 5; echo 'ehlo'; sleep 3; echo 'MAIL FROM:<Test@test.com>'; sleep 3; echo 'RCPT TO: <kyle@test_dest.com>'; sleep 3; echo 'DATA'; sleep 3; echo -e 'To:kyle@testdest.com\nMIME-Version: 1.0 (mime-construct ...


8

Send the dd process a USR1 signal: $ dd if=/dev/urandom of=/dev/null & [1] 977 $ $ kill -USR1 977 274647+0 records in 274646+0 records out 140618752 bytes (141 MB) copied, 17.3286 s, 8.1 MB/s $


8

You should use openssl s_client -connect server:port to debug applications over SSL connections.


8

Don't bother with sniffing the network connection; as @voretaq7 explained, you can't. Instead, have postfix log the connection by adding the IP address of the remote SMTP server to debug_peer_list. And if that doesn't get you enough detail to understand what's going on, you can set smtp_tls_loglevel 4 to get a complete dump of everything that went over the ...


8

Another netcat-like tool is the nmap version, ncat, that has lots of built in goodies to simplify things like this. This would work: ncat -e /bin/cat -k -u -l 1235 -e means it executes /bin/cat (to echo back what you type) -k means keep-alive, that it keeps listening after each connection -u means udp -l 1235 means that it listens on port 1235


8

For me this very simple solution works: nc -l 192.168.2.1 3000 And -p does not work with -l (according to my man page and testing).


7

-p might be wrong.. This will work on redhat based distros.. nc -u -l 2115


6

While hand testing SMTP servers by hand is possible and viable, using a tool designed for this will be much easier. This article explains SWAKS. swaks is designed for smtp server testing. Supports attachments, authentication and encryption!


6

This appears to be a bug in nc. The nc command uses the poll system call to wait until input is received from either stdin or the socket. When a UDP packet has been send to a closed UDP port on the receiving end, an error message is send back. The poll call will return this status to the nc command, but nc does not actually process the error. Instead nc ...


5

Apache docs: http://httpd.apache.org/docs/2.2/logs.html#piped Apache will start the piped-log process when the server starts, and will restart it if it crashes while the server is running. (This last feature is why we can refer to this technique as "reliable piped logging".) NC docs: man nc -w timeout Connections which cannot be ...


5

Allow me to rephrase your question: I want to stick something in the middle of an TLS-encrypted connection that shows me the cleartext that's being sent. . . . Well it wouldn't be very secure now, would it? I mean the whole point of TLS is to prevent exactly what you're trying to do! -- So no, what you're asking for is NOT possible, nor is it ...


5

Try it like this: nc -u -l 7777 > newfile.jpg #on the destination machine cat file.jpg | nc -u 192.168.x.x 7777 #on the source machine Usually you want the machine getting the file to "listen" (run that first), and when it's listening, send the data over udp. UDP does not have a 'handshake' sequence, and packets are sent immediately, even if noone is ...


5

To open a port 12345 on your local machine that, when connected to, will connect to a port 54321 on remotemachine (the machine you're SSH'd into): ssh -L 12345:localhost:54321 remotemachine


5

┬┐have you tried pv? http://www.ivarch.com/programs/pv.shtml dd bs=16M if=/dev/sda|bzip2 -c| pv | nc serverB.example.net 19000 nc -l -p 19000| pv | bzip2 -d| dd bs=16M of=/dev/sdb good luck!


5

That is part of the header. "The Priority value is calculated by first multiplying the Facility number by 8 and then adding the numerical value of the Severity." So 134 / 8 = 16 (facility local0) remainder 6 (severity Informational: informational messages). SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG] HEADER = PRI... PRI = ...


4

The author of the ncat tool, in his page for netcat users notes that: By default, Ncat will accept 100 simultaneous connections, instead of 1 like the original netcat. Use -m to specify the maximum number of simultaneous connections. I rather suspect this means that netcat won't do what you want, but there's a simple drop-in replacement tool ...


4

socat can do serial line stuff, netcat cannot. socat can do fairly advanced functionality, like having multiple clients listen on a port, or reusing connections.


4

There are actually two implementations of netcat, the original implementation by *Hobbit* (called netcat-traditional in Debian/Ubuntu) and the OpenBSD implementation (called netcat-openbsd in Debian/Ubuntu). In Debian/Ubuntu the binaries are called nc.traditional and nc.openbsd respectively (and nc is a link to one of those via the alternatives system). The ...


4

It seems that GELF TCP input needs a null character at the end of each Gelf message. So you should send: echo -e '{"version": "1.1","host":"example.org","short_message":"Short message","full_message":"Backtrace here\n\nmore stuff","level":1,"_user_id":9001,"_some_info":"foo","_some_env_var":"bar"}\0' | nc -w 1 my.graylog.server 12201 This answer was ...


4

I ended up fixing the problem by switching to socat: while read line; do printf "folder.counter:value|1c" | socat -t 0 - UDP:$host:$port done


3

$ nc --listen --keep-open --send-only --exec "/usr/bin/cat /path/to/myfile" 0.0.0.0 5800 $ nc 127.0.0.1 5800 > recvfile


3

What you are seeing is not a time out. What you are seeing is the result of using the wrong protocol for the purpose. TCP will perform flow control, which means it will adjust the transmission speed to the capacity of network and receiver. Additionally TCP will retransmit lost packets. UDP does neither of those. The nc command you used will transmit ...


3

you can use PuTTY for this, select the raw connection option. Telnet may also work for you telnet server port


3

I am using -w 1 below to limit timeouts to 1 second. I also use -v for the reasons mentioned in comments. I used -n to refuse delays for reverse DNS lookups... [mpenning@tsunami ~]$ for i in $(echo "172.16.1.1,172.16.1.5"|tr "," "\n"); do echo -e "22\n80\n443\n8080" | xargs -i nc -w 1 -zvn $i {}; done (UNKNOWN) [172.16.1.1] 22 (ssh) open (UNKNOWN) ...



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