Hot answers tagged

23

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


23

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 ...


21

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 ...


16

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 ...


12

I ran into the same issue. You can solve it this way: # Removes the old package yum erase nc # Manually downloads the working package from the Official Repository wget http://vault.centos.org/6.6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm # Installs the package rpm -iUv nc-1.84-22.el6.x86_64.rpm Please note that the package is for x86_64 (64-bit). If ...


11

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 ...


10

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


10

This particular version of netcat has a bug. Until there's a fix out for it, the only thing you can do is to downgrade to a previous version - sudo yum remove nc-1.84-24.el6.x86_64; sudo yum install nc-1.84-22.el6.x86_64 should do the trick.


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 ...


9

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


9

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).


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

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

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 ...


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 ...


7

ncat --ssl from the nmap package worked well for me: printf 'GET / HTTP/1.1\r\nHost: github.com\r\n\r\n' | ncat --ssl github.com 443 Same on Super User: http://superuser.com/questions/346958/can-the-telnet-or-netcat-clients-communicate-over-ssl


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

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.


6

Just use: echo -e '\x80' | nc host port


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

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 = ...


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

What is the purpose of that -w 3 in the original solution It avoids leaving orphaned nc processes running on the remote host when the ssh session is closed improperly. and why is it causing a Broken pipe error when I use it? Try increasing the timeout for nc to 90 and setting ServerAliveInterval to 30 to see if your problem go away: host foo ...


5

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


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 ...


4

It is not a standard program, but "socat tcp:your-host:1234 exec:bash,pty" will do the work. You can also secure your communication with OpenSSL with socat: # Your side: openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem socat `tty`,raw,echo=0 openssl-listen:1237,reuseaddr,cert=cert.pem,verify=0 # Their side: socat ...



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