1

I have some packets that are encrypted with Cryptcat tool and I want to decrypt them. I have the encryption password. I tried to use netcat with cryptcat, but every time I'm connecting from netcat to cryptcat and try to send something the connection closes.

I tried the following:

cryptcat -vv -k p@ssword -l -p 1337 > decryptedfile

and from another terminal:

cat encrypted | nc localhost 1337

When I hit enter the connection closes!

  • For other reason than reaching the end of file? Was anything written? Does sending work if you use cryptcat instead nc to send the data (and why aren't you using cryptcat for sending)? – sebasth Nov 24 '17 at 0:48
  • Are you sure you've not got your decrypted content in decryptedfile? – roaima Nov 24 '17 at 18:23
0

Works for me. Note that encryption and decryption are paired on the basis that sending encrypts and receiving decrypts. (You can't use cryptcat to send an encrypted file in order to decrypt it.)

You might want to check that your encrypted source file contains plausible data (i.e. it's non-zero length), and using tshark or an equivalent check that the data really is transmitted across the wire.

First, generate an encrypted file

We start listening on System 2 before we transmit the message on System 1.

System 2

nc -vv -l -p 1337 >message.enc

hex message.enc
   0000 14 fd 25 da c3 5e 36 81  b2 7b e7 b0 13 4b b5 8b  ..%..^6. .{...K..
   0010 cc 13 4c 60 bd 54 1e e2  5b 01 7f ac bc 93 27 6b  ..L`.T.. [.....'k
   0020 c3 a3 90 30 44 76 e1 61  f5 42 2d 04 f2 13 eb d4  ...0Dv.a .B-.....
   0030 9c d9 9c 75 95 10 b2 55  42 bf 0d cb cb           ...u...U B....

System 1

date | cryptcat -vv -k p@ssword -w 1 system2 1337

Now, resend the encrypted file

As before, we start listening on the receiver before transmitting the message

System 1

cryptcat -vv -k p@ssword -l -p 1337    # → Thu 25 Oct 15:07:24 BST 2018

System 2

nc -vv -w 1 system1 1337 <message.enc

Alternative recommendation

In general terms, the original author of netcat stated that they preferred to keep it purely as a network tool, and for encryption to be added using external tools. Taking this approach one could use mcrypt and build a pair of tool chains like this:

generate_data | mcrypt -z | nc ...

... nc -l | mcrypt -d -z | produce_data

An advantage here is that standalone decryption is possible, and does not require using nc ... cryptcat -l between two servers. It also decouples the direction of the transfer from the implied encryption or decryption of the message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.