title: Decrypt pcap RC4 encryption with pycrypto
body: <p>Part of a training exercise I'm doing I need to <strong>decrypt data transmitted and saved in a pcap</strong>. </p>
  
  <p>I know the encryption is <b>RC4</b> and I have the key which I know is correct</p>
  
  <p>I wrote a really basic python script using pycrypto which I thought would do it but for some reason the output is still gibberish</p>
  
  <p>Got the data from the pcap file by running this:</p>
  
  <pre>tshark -nr file.pcapng -q -z follow,tcp,ascii,5 > output</pre>
  
  <p>The script I wrote using pycrypto:</p>
  
  <pre><code>from Crypto.Cipher import ARC4
  
  key = ARC4.new('my_key')
  content = open('output','r')
  text = content.read()
  msg = key.decrypt(text)
  print(msg)
  </code></pre>
  
  <p>Output, although different, does not seem to correctly decrypt the TCP stream. Any suggestions? Have I done anything wrong?</p>