epan/dissectors/packet-xml.c no printf
[metze/wireshark/wip.git] / 0001-HACK-This-is-a-patch-to-apply-to-MIT-Kerberos-1.12-i.patch
1 From 8c4419336853395b261c2e380332fef146e39f78 Mon Sep 17 00:00:00 2001
2 From: Matthieu Patou <mat@matws.net>
3 Date: Thu, 19 Feb 2015 16:25:04 +0100
4 Subject: [PATCH] HACK This is a patch to apply to MIT Kerberos 1.12 in order
5  to relax the checks for checksum verification.
6
7 This is needed for wireshark when dealing with DCERPC encrypted with modern
8 encryption when headers are part of the signing.
9
10 Because we relax the checks you don't want to have this as your default library
11
12 The way to get it working is to do
13 * get the library from http://web.mit.edu/kerberos/dist/historic.html#krb5-1.10-src
14   (ie. http://web.mit.edu/kerberos/dist/krb5/1.10/krb5-1.10.5-signed.tar)
15 * do configure --prefix=<PATH_FOR_PATCHED_KERBEROS>
16   ie. ./configure --prefix=/usr/local/krb5
17 * Apply the patch, from the top of the source directory of MIT:
18   patch -p 0 <<PATH_TO_PATCH>
19 * make
20 * sudo make install
21
22 Then you can use this library with wireshark, either by forcing wireshark at
23 build time to link with this particular libary, or at runtime with the command
24 LD_LIBRARY_PATH=<PATH_FOR_PATCHED_KERBEROS>/lib wireshark
25
26 Signed-off-by: Stefan Metzmacher <metze@samba.org>
27 ---
28  src/lib/crypto/krb/decrypt.c | 33 +++++++++++++++++++++++++++++++--
29  1 file changed, 31 insertions(+), 2 deletions(-)
30
31 diff --git a/src/lib/crypto/krb/decrypt.c b/src/lib/crypto/krb/decrypt.c
32 index 496d262..9861812 100644
33 --- a/src/lib/crypto/krb/decrypt.c
34 +++ b/src/lib/crypto/krb/decrypt.c
35 @@ -77,9 +77,38 @@ krb5_k_decrypt(krb5_context context, krb5_key key,
36  
37      ret = ktp->decrypt(ktp, key, usage, cipher_state, iov, 4);
38      if (ret != 0)
39 -        zap(output->data, plain_len);
40 -    else
41 +    {
42 +        unsigned int len = plain_len;
43 +        /*
44 +         * HACK:
45 +         * This is a HACK to allow Wireshark to decrypt DCERPC
46 +         * payload when header signing is used.
47 +         *
48 +         * We know the checksum was wrong, this happens
49 +         * when DCERPC uses header signing as we don't give all the data for
50 +         * the signature to be correct.
51 +         * Still we will assume the decrypt was ok if we find something that looks
52 +         * like a valid gss_cfx_wrap_token header
53 +         * It is 16 bytes long
54 +         * and starts with 0x05 0x04 and sits at the end of the
55 +         * encrypted data.
56 +         */
57 +        if (ret == KRB5KRB_AP_ERR_BAD_INTEGRITY && len > 16) {
58 +            char *dec_hdr = output->data + (len - 16);
59 +            char GSS_CFX_TOKEN_MAGIC[2] = { 0x05, 0x04 };
60 +            if (memcmp(GSS_CFX_TOKEN_MAGIC, dec_hdr, 2) != 0) {
61 +                zap(output->data, plain_len);
62 +            } else {
63 +                output->length = plain_len;
64 +                ret = 0;
65 +            }
66 +        } else {
67 +           zap(output->data, plain_len);
68 +        }
69 +    }
70 +    else {
71          output->length = plain_len;
72 +    }
73      zapfree(scratch, header_len + trailer_len);
74      return ret;
75  }
76 -- 
77 1.9.1
78