2 * Routines for dissection of Group Policy : Encrypted File System Extension
3 * Described in Microsoft document MS-GPEF.pdf
4 * Copyright 2008, Ronnie Sahlberg
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include "packet-windows-common.h"
17 #include <epan/asn1.h>
18 #include "packet-x509af.h"
20 void proto_register_gpef(void);
22 static int proto_gpef
;
23 static int hf_gpef_keycount
;
24 static int hf_gpef_efskey
;
25 static int hf_gpef_efskey_length1
;
26 static int hf_gpef_efskey_length2
;
27 static int hf_gpef_efskey_sid_offset
;
28 static int hf_gpef_efskey_cert_offset
;
29 static int hf_gpef_efskey_cert_length
;
30 static int hf_gpef_efskey_certificate
;
33 static int ett_gpef_efskey
;
36 /* MS-GPEF section 2.2.1.2.2 EfsKey*/
38 dissect_gpef_efskey(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
, proto_tree
*parent_tree
)
40 proto_item
*item
= NULL
;
41 proto_tree
*tree
= NULL
;
42 int old_offset
= offset
;
43 uint32_t length1
, sid_offset
;
44 uint32_t cert_length
, cert_offset
;
47 asn1_ctx_init(&asn1_ctx
, ASN1_ENC_BER
, true, pinfo
);
50 item
= proto_tree_add_item(parent_tree
, hf_gpef_efskey
, tvb
, -1, -1, ENC_NA
);
51 tree
= proto_item_add_subtree(item
, ett_gpef_efskey
);
55 length1
= tvb_get_letohl(tvb
, offset
);
56 proto_tree_add_item(tree
, hf_gpef_efskey_length1
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
60 proto_tree_add_item(tree
, hf_gpef_efskey_length2
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
64 sid_offset
= tvb_get_letohl(tvb
, offset
);
65 proto_tree_add_item(tree
, hf_gpef_efskey_sid_offset
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
72 cert_length
= tvb_get_letohl(tvb
, offset
);
73 proto_tree_add_item(tree
, hf_gpef_efskey_cert_length
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
77 cert_offset
= tvb_get_letohl(tvb
, offset
);
78 proto_tree_add_item(tree
, hf_gpef_efskey_cert_offset
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
81 /* reserved, must be 0x20 0x00 0x00 0x00 */
85 dissect_nt_sid(tvb
, old_offset
+4+sid_offset
, tree
, "sid", NULL
, -1);
88 next_tvb
= tvb_new_subset_length(tvb
, old_offset
+4+cert_offset
, cert_length
);
89 (void)dissect_x509af_Certificate(false, next_tvb
, 0, &asn1_ctx
, tree
, hf_gpef_efskey_certificate
);
92 offset
= old_offset
+ length1
;
93 proto_item_set_len(item
, offset
-old_offset
);
97 /* MS-GPEF section 2.2.1.2.1 */
99 dissect_gpef_efsblob(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void *data _U_
)
106 item
= proto_tree_add_item(parent_tree
, proto_gpef
, tvb
, 0, -1, ENC_NA
);
107 tree
= proto_item_add_subtree(item
, ett_gpef
);
109 /* reserved, must be 0x01 0x00 0x01 0x00 */
113 count
= tvb_get_letohl(tvb
, offset
);
114 proto_tree_add_item(tree
, hf_gpef_keycount
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
118 offset
= dissect_gpef_efskey(tvb
, offset
, pinfo
, tree
);
125 proto_register_gpef(void)
127 static hf_register_info hf
[] = {
129 { "Key Count", "gpef.key_count", FT_UINT32
, BASE_DEC
, NULL
,
132 { &hf_gpef_efskey_length1
,
133 { "Length1", "gpef.efskey.length1", FT_UINT32
, BASE_DEC
, NULL
,
136 { &hf_gpef_efskey_length2
,
137 { "Length2", "gpef.efskey.length2", FT_UINT32
, BASE_DEC
, NULL
,
140 { &hf_gpef_efskey_sid_offset
,
141 { "SID Offset", "gpef.efskey.sid_offset", FT_UINT32
, BASE_DEC
, NULL
,
144 { &hf_gpef_efskey_cert_offset
,
145 { "Cert Offset", "gpef.efskey.cert_offset", FT_UINT32
, BASE_DEC
, NULL
,
148 { &hf_gpef_efskey_cert_length
,
149 { "Cert Length", "gpef.efskey.cert_length", FT_UINT32
, BASE_DEC
, NULL
,
153 { "EfsKey", "gpef.efskey", FT_NONE
, BASE_NONE
, NULL
,
156 { &hf_gpef_efskey_certificate
,
157 { "Certificate", "gpef.efskey.certificate", FT_NONE
, BASE_NONE
, NULL
,
162 static int *ett
[] = {
167 proto_gpef
= proto_register_protocol("GPEF", "GPEF", "gpef");
168 proto_register_field_array(proto_gpef
, hf
, array_length(hf
));
169 proto_register_subtree_array(ett
, array_length(ett
));
171 register_dissector("efsblob", dissect_gpef_efsblob
, proto_gpef
);
175 * Editor modelines - https://www.wireshark.org/tools/modelines.html
180 * indent-tabs-mode: t
183 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
184 * :indentSize=8:tabSize=8:noTabs=false: