Wireshark Decryption

From SambaWiki
Jump to: navigation, search

Using the session key (SMB3)

Starting from Wireshark 2.5.0 (released Feb 2018) you can pass a list of SessionId -> SessionKey mappings via a table in the SMB2 preferences or command-line.

The session key in this context refers to the cryptographic session keys used in authentication and message signing. It is not the same as the CIFS SessionKey.

From MS-SMB2:

Session.SessionKey: The first 16 bytes of the cryptographic key for this authenticated context. If the cryptographic key is less than 16 bytes, it is right-padded with zero bytes.

Known limitations

As of Wireshark 2.6.5 (December 2018):

  • only supports SMB3.0. Decryption of SMB3.1.1 will be in the next release.
  • only supports AES-128-CCM
  • Due to how the dissector works, the trace requires a Tree Connect packet to be present in the trace being decrypted (done using the right session id).

Obtaining the session key

Linux kernel client

The linux kernel client (cifs.ko) can be configured to dump the cryptographic keys it generates (visible in dmesg output) via the build time option CONFIG_CIFS_DEBUG_DUMP_KEYS. Keep in mind this is a debugging option and it should not be set on a production system.

You can set this option in your .config file or find it in make menuconfig by going in:

  • File systems
    • Network File Systems
      • SMB3 and CIFS support (advanced network filesystem)
        • Enable CIFS debugging routines > Dump encryption keys for offline decryption (Unsafe).

Once enabled, you can mount a share and pass the mount options vers=3 or vers=3.11 to make sure the connection uses SMB3 and seal to require encryption.

If the connection reaches the Tree Connect stage you should be able to see this in the kernel console (via dmesg) for each session established:

CIFS VFS: generate_smb3signingkey: dumping generated AES session keys
CIFS VFS: Session Id    bc 1a fc 0d 00 00 00 00
CIFS VFS: Session Key   34 57 e1 90 4b 94 3a 0d 09 be 22 b9 b9 cf c7 4c
CIFS VFS: Signing Key   28 bf a3 71 39 e5 05 71 c6 15 58 f3 cf 42 3f 0e
CIFS VFS: ServerIn Key  79 2a 9a 40 1e cf 16 52 41 a5 ec bd 1c e5 84 17
CIFS VFS: ServerOut Key c0 73 c8 1d 36 f5 74 3e ef 6e c1 9d 5c e5 cb 71


Starting from Samba 4.11, both client and server code can dump the generated keys in the log file using "debug encryption = yes" in smb.conf or via the command line. Note that the option controls both server and client code.


$ smbclient //localhost/scratch --option='debugencryption=yes' -e -mSMB3 -U aaptel%aaptel
debug encryption: dumping generated session keys
Session Id    [0000] F0 38 C7 30 00 00 00 00                             .8.0....
Session Key   [0000] CB 18 C5 26 18 CA 9F 59   44 0A 62 44 63 90 2B BA   ...&...Y D.bDc.+.
Signing Key   [0000] A6 0B B1 50 1B FD 51 1F   8A 06 00 8C 13 7E 7C 4F   ...P..Q. .....~|O
ServerIn Key  [0000] 7D 93 ED 2D E6 54 0C 86   8F 3F B5 AE 63 1D BD E7   }..-.T.. .?..c...
ServerOut Key [0000] 7A D0 18 61 7B E3 E5 2A   33 5E 27 66 D1 6B F9 0E   z..a{..* 3^'f.k..

Setting the key

Setting a key: Edit > Preferences > SMB2, Edit

Note: The kernel prints the Session Id as it is on the wire (little endian). Wireshark decryption expects the Session Id as it is on the wire as well, so you should be able to copy/paste from one to the other (despite showing the Session ID field decoded when dumping packets).

  • Just copy the Session Id and Session Key into wireshark (see screenshot).
  • Alternatively you can pass them via the command line (works with wireshark and tshark):
tshark -ouat:smb2_seskey_list:3d00009400480000,28f2847263c83dc00621f742dd3f2e7b -r smb3-aes-128-ccm.pcap

Using a keytab


You only need to do that once:

  • Open Wireshark
  • Goto: Preferences -> Protocols -> KRB5
  • Select: Try to decrypt encrypted Kerberos blobs

Basic decryption

The easiest way, on a unix-like system is to run


Note: Wireshark for 64-bit Windows (GUI or command-line) doesn't like the -K flag, run the 32-bit Windows version instead.

The other way, is to specify the keytab in Preferences -> Protocols -> KRB5 -> keytab path

How to extract the keytab?

See: How to extract a keytab from a windows domain with Samba

Decrypted AES DCE/RPC

To do this, you will need metze's wireshark branch, and his patched verison of MIT Kerberos

http://gitweb.samba.org/?p=metze/wireshark/wip.git;a=shortlog;h=refs/heads/ws-metze-gssapi git://git.samba.org/metze/wireshark/wip.git ws-metze-gssapi

Also, you will need to apply krb5-1.6-wireshark-hack-01.diff to MIT Kerberos 1.6, and set LD_LIBRARY_PATH to wherever you put the result.