2 * Routines for ssh packet dissection
4 * Huagang XIE <huagang@intruvert.com>
6 * $Id: packet-ssh.c,v 1.7 2003/04/17 07:39:18 guy Exp $
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * Copied from packet-mysql.c
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 * Note: support SSH v1 and v2 now.
38 #include <epan/packet.h>
39 #include <epan/conversation.h>
41 #include "packet-smb-common.h"
42 #include "packet-tcp.h"
43 #include "reassemble.h"
46 /* get from openssh ssh2.h */
47 #define SSH2_MSG_DISCONNECT 1
48 #define SSH2_MSG_IGNORE 2
49 #define SSH2_MSG_UNIMPLEMENTED 3
50 #define SSH2_MSG_DEBUG 4
51 #define SSH2_MSG_SERVICE_REQUEST 5
52 #define SSH2_MSG_SERVICE_ACCEPT 6
54 /* transport layer: alg negotiation */
56 #define SSH2_MSG_KEXINIT 20
57 #define SSH2_MSG_NEWKEYS 21
59 /* transport layer: kex specific messages, can be reused */
61 #define SSH2_MSG_KEXDH_INIT 30
62 #define SSH2_MSG_KEXDH_REPLY 31
65 #define SSH2_MSG_KEX_DH_GEX_REQUEST_OLD 30
66 #define SSH2_MSG_KEX_DH_GEX_GROUP 31
68 #define SSH2_MSG_KEX_DH_GEX_INIT 32
69 #define SSH2_MSG_KEX_DH_GEX_REPLY 33
70 #define SSH2_MSG_KEX_DH_GEX_REQUEST 34
72 /* SSH Version 1 definition , from openssh ssh1.h */
74 #define SSH_MSG_NONE 0 /* no message */
75 #define SSH_MSG_DISCONNECT 1 /* cause (string) */
76 #define SSH_SMSG_PUBLIC_KEY 2 /* ck,msk,srvk,hostk */
77 #define SSH_CMSG_SESSION_KEY 3 /* key (BIGNUM) */
78 #define SSH_CMSG_USER 4 /* user (string) */
81 #define SSH_VERSION_UNKNOWN 0
82 #define SSH_VERSION_1 1
83 #define SSH_VERSION_2 2
92 struct ssh_flow_data {
97 static GMemChunk *ssh_this_data=NULL;
98 static GMemChunk *ssh_global_data = NULL;
100 static int proto_ssh = -1;
101 static int hf_ssh_packet_length= -1;
102 static int hf_ssh_padding_length= -1;
103 static int hf_ssh_payload= -1;
104 static int hf_ssh_protocol= -1;
105 static int hf_ssh_encrypted_packet= -1;
106 static int hf_ssh_padding_string= -1;
107 static int hf_ssh_mac_string= -1;
108 static int hf_ssh_msg_code = -1;
109 static int hf_ssh_cookie = -1;
110 static int hf_ssh_kex_algorithms = -1;
111 static int hf_ssh_server_host_key_algorithms = -1;
112 static int hf_ssh_encryption_algorithms_client_to_server = -1;
113 static int hf_ssh_encryption_algorithms_server_to_client = -1;
114 static int hf_ssh_mac_algorithms_client_to_server=-1;
115 static int hf_ssh_mac_algorithms_server_to_client=-1;
116 static int hf_ssh_compression_algorithms_client_to_server=-1;
117 static int hf_ssh_compression_algorithms_server_to_client=-1;
118 static int hf_ssh_languages_client_to_server=-1;
119 static int hf_ssh_languages_server_to_client=-1;
120 static int hf_ssh_kex_algorithms_length= -1;
121 static int hf_ssh_server_host_key_algorithms_length= -1;
122 static int hf_ssh_encryption_algorithms_client_to_server_length= -1;
123 static int hf_ssh_encryption_algorithms_server_to_client_length= -1;
124 static int hf_ssh_mac_algorithms_client_to_server_length= -1;
125 static int hf_ssh_mac_algorithms_server_to_client_length= -1;
126 static int hf_ssh_compression_algorithms_client_to_server_length= -1;
127 static int hf_ssh_compression_algorithms_server_to_client_length= -1;
128 static int hf_ssh_languages_client_to_server_length= -1;
129 static int hf_ssh_languages_server_to_client_length= -1;
131 static gint ett_ssh = -1;
132 static gint ett_key_exchange= -1;
133 static gint ett_key_init= -1;
134 static gint ett_ssh1= -1;
135 static gint ett_ssh2= -1;
137 static gboolean ssh_desegment = TRUE;
139 #define TCP_PORT_SSH 22
141 static const value_string ssh2_msg_vals[] = {
142 {SSH2_MSG_DISCONNECT, "Disconnect"},
143 {SSH2_MSG_IGNORE, "Ignore"},
144 {SSH2_MSG_UNIMPLEMENTED, "Unimplemented"},
145 {SSH2_MSG_DEBUG, "Debug"},
146 {SSH2_MSG_SERVICE_REQUEST, "Service Request"},
147 {SSH2_MSG_SERVICE_ACCEPT, "Service Accept"},
148 {SSH2_MSG_KEXINIT, "Key Exchange Init"},
149 {SSH2_MSG_NEWKEYS, "New Keys"},
150 {SSH2_MSG_KEXDH_INIT, "Diffie-Hellman Key Exchange Init"},
151 {SSH2_MSG_KEXDH_REPLY, "Diffie-Hellman Key Exchange Reply"},
152 {SSH2_MSG_KEX_DH_GEX_INIT, "Diffie-Hellman GEX Init"},
153 {SSH2_MSG_KEX_DH_GEX_REPLY, "Diffie-Hellman GEX Reply"},
154 {SSH2_MSG_KEX_DH_GEX_REQUEST, "Diffie-Hellman GEX Request"},
158 static const value_string ssh1_msg_vals[] = {
159 {SSH_MSG_NONE,"No Message"},
160 {SSH_MSG_DISCONNECT, "Disconnect"},
161 {SSH_SMSG_PUBLIC_KEY,"Public Key"},
162 {SSH_CMSG_SESSION_KEY,"Session Key"},
163 {SSH_CMSG_USER,"User"},
167 static const value_string ssh_opcode_vals[] = {
171 static int ssh_dissect_key_init(tvbuff_t *tvb, int offset, proto_tree *tree);
173 static int ssh_dissect_ssh1(tvbuff_t *tvb, packet_info *pinfo,
174 int offset, proto_tree *tree,int is_response,
175 int number, gboolean *need_desegmentation);
176 static int ssh_dissect_ssh2(tvbuff_t *tvb, packet_info *pinfo,
177 int offset, proto_tree *tree,int is_response,
178 int number, gboolean *need_desegmentation );
179 static int ssh_dissect_key_exchange(tvbuff_t *tvb, packet_info *pinfo,
180 int offset, proto_tree *tree,int is_response,
181 int number, gboolean *need_desegmentation );
182 static int ssh_dissect_protocol(tvbuff_t *tvb, packet_info *pinfo,
183 int offset, proto_tree *tree,int is_response,int *version,
184 gboolean *need_desegmentation);
185 static int ssh_dissect_encrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
186 int offset, proto_tree *tree,int is_response);
187 proto_item * ssh_proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
188 gint start, gint length, gboolean little_endian);
191 ssh_init_protocol(void)
194 g_mem_chunk_destroy(ssh_global_data);
196 g_mem_chunk_destroy(ssh_this_data);
198 ssh_global_data = g_mem_chunk_new("ssh_global_datas",
199 sizeof(struct ssh_flow_data),
200 100* sizeof(struct ssh_flow_data), G_ALLOC_AND_FREE);
201 ssh_this_data = g_mem_chunk_new("ssh_pku_data",
202 sizeof(struct ssh_pdu_data),
203 100* sizeof(struct ssh_pdu_data), G_ALLOC_AND_FREE);
208 dissect_ssh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
211 proto_tree *ssh_tree = NULL;
213 conversation_t *conversation=NULL;
216 guint this_number,number;
220 gboolean is_response;
222 gboolean need_desegmentation;
225 struct ssh_pdu_data *this_data=NULL;
226 struct ssh_flow_data *global_data=NULL;
229 this_data = p_get_proto_data(pinfo->fd, proto_ssh);
231 conversation = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype,
232 pinfo->srcport, pinfo->destport, 0);
235 /* create a new conversation */
236 conversation = conversation_new(&pinfo->src, &pinfo->dst, pinfo->ptype,
237 pinfo->srcport, pinfo->destport, 0);
240 global_data = conversation_get_proto_data(conversation,proto_ssh);
242 global_data = g_mem_chunk_alloc(ssh_global_data);
243 global_data->req_counter=0;
244 global_data->rsp_counter=0;
245 global_data->version=SSH_VERSION_UNKNOWN;
246 conversation_add_proto_data(conversation,proto_ssh,global_data);
250 * end of attaching data
252 if (pinfo->destport == pinfo->match_port) {
255 this_data = g_mem_chunk_alloc(ssh_this_data);
256 this_data->counter = global_data->req_counter++;
257 p_add_proto_data(pinfo->fd, proto_ssh, this_data);
263 this_data = g_mem_chunk_alloc(ssh_global_data);
264 this_data->counter = global_data->rsp_counter++;
265 p_add_proto_data(pinfo->fd, proto_ssh, this_data);
270 ti = proto_tree_add_item(tree, proto_ssh, tvb, offset, -1, FALSE);
271 ssh_tree = proto_item_add_subtree(ti, ett_ssh);
275 version = global_data->version;
277 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
279 case SSH_VERSION_UNKNOWN:
280 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSH");
283 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSHv1");
286 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSHv2");
292 if(this_data->counter != 0 && version == SSH_VERSION_UNKNOWN) {
293 offset = ssh_dissect_encrypted_packet(tvb, pinfo,
294 offset,ssh_tree,is_response);
298 while((remain_length = tvb_reported_length_remaining(tvb,offset))> 0 ) {
299 need_desegmentation = FALSE;
300 last_offset = offset;
301 this_number = this_data->counter+number;
303 if(number > 1 && is_newdata) {
304 /* update the this_data and flow_data */
306 global_data->rsp_counter++;
308 global_data->req_counter++;
313 if(this_number == 0) {
314 offset = ssh_dissect_protocol(tvb, pinfo,
315 offset,ssh_tree, is_response,
316 &version, &need_desegmentation);
318 global_data->version= version;
321 if(version == SSH_VERSION_1) {
322 offset = ssh_dissect_ssh1(tvb, pinfo,
323 offset,ssh_tree,is_response,this_number,
324 &need_desegmentation);
325 } else if(version == SSH_VERSION_2) {
326 offset = ssh_dissect_ssh2(tvb, pinfo,
327 offset,ssh_tree,is_response,this_number,
328 &need_desegmentation);
332 if(need_desegmentation) return;
337 ssh_dissect_ssh2(tvbuff_t *tvb, packet_info *pinfo,
338 int offset, proto_tree *tree,int is_response, int this_number,
339 gboolean *need_desegmentation)
342 proto_item *ssh2_tree=NULL;
345 ti=proto_tree_add_text(tree,tvb,offset,-1,"SSH Version 2");
346 ssh2_tree = proto_item_add_subtree(ti ,ett_ssh2);
349 if((is_response && this_number > 3) || (!is_response && this_number>4)) {
350 offset = ssh_dissect_encrypted_packet(tvb, pinfo,
351 offset,ssh2_tree,is_response);
353 offset = ssh_dissect_key_exchange(tvb,pinfo,
354 offset,ssh2_tree,is_response,this_number,
355 need_desegmentation);
361 ssh_dissect_ssh1(tvbuff_t *tvb, packet_info *pinfo,
362 int offset, proto_tree *tree,int is_response,
363 int number, gboolean *need_desegmentation)
365 guint plen, padding_length,len;
370 proto_item *ssh1_tree =NULL;
373 ti=proto_tree_add_text(tree,tvb,offset,-1,"SSH Version 1");
374 ssh1_tree = proto_item_add_subtree(ti ,ett_ssh1);
378 * We use "tvb_ensure_length_remaining()" to make sure there
379 * actually *is* data remaining.
381 * This means we're guaranteed that "remain_length" is positive.
383 remain_length = tvb_ensure_length_remaining(tvb,offset);
384 if (ssh_desegment && pinfo->can_desegment) {
385 if(remain_length < 4) {
386 pinfo->desegment_offset = offset;
387 pinfo->desegment_len = 4-remain_length;
388 *need_desegmentation = TRUE;
392 plen = tvb_get_ntohl(tvb, offset) ;
393 padding_length = 8 - plen%8;
396 if (ssh_desegment && pinfo->can_desegment) {
397 if(plen+4+padding_length > remain_length ) {
398 pinfo->desegment_offset = offset;
399 pinfo->desegment_len = plen+padding_length - remain_length;
400 *need_desegmentation = TRUE;
405 if (check_col(pinfo->cinfo, COL_INFO)) {
406 col_add_fstr(pinfo->cinfo, COL_INFO, "%s: ",
407 is_response?"Server":"Client");
411 if (ssh1_tree && plen > 0) {
412 proto_tree_add_uint_format(ssh1_tree, hf_ssh_packet_length, tvb,
413 offset, 4, plen,"Overly large length %x",plen);
415 plen = remain_length-4-padding_length;
417 if (ssh1_tree && plen > 0) {
418 proto_tree_add_uint(ssh1_tree, hf_ssh_packet_length, tvb,
426 proto_tree_add_uint(ssh1_tree, hf_ssh_padding_length, tvb,
427 offset, padding_length, padding_length);
429 offset += padding_length;
432 tf=proto_tree_add_text(tree,tvb,offset,-1,"SSH Version 1");
433 ssh1_tree = proto_item_add_subtree(tf ,ett_ssh1);
438 msg_code = tvb_get_guint8(tvb, offset);
440 proto_tree_add_uint_format(ssh1_tree, hf_ssh_msg_code, tvb,
441 offset, 1, msg_code,"Msg code: %s (%u)",
442 val_to_str(msg_code, ssh1_msg_vals, "Unknown (%u)"),
445 if (check_col(pinfo->cinfo, COL_INFO)) {
446 col_append_fstr(pinfo->cinfo, COL_INFO, "%s",
447 val_to_str(msg_code, ssh1_msg_vals, "Unknown (%u)"));
453 if (check_col(pinfo->cinfo, COL_INFO)) {
454 col_append_fstr(pinfo->cinfo, COL_INFO, "Encrypted packet len=%d", len);
459 ssh_proto_tree_add_item(ssh1_tree, hf_ssh_payload,
460 tvb, offset, len, FALSE);
468 ssh_dissect_key_exchange(tvbuff_t *tvb, packet_info *pinfo,
469 int offset, proto_tree *tree,int is_response,int number,
470 gboolean *need_desegmentation)
473 guint8 padding_length;
475 int last_offset=offset;
479 proto_item *key_ex_tree =NULL;
482 * We use "tvb_ensure_length_remaining()" to make sure there
483 * actually *is* data remaining.
485 * This means we're guaranteed that "remain_length" is positive.
487 remain_length = tvb_ensure_length_remaining(tvb,offset);
488 if (ssh_desegment && pinfo->can_desegment) {
489 if(remain_length < 4) {
490 pinfo->desegment_offset = offset;
491 pinfo->desegment_len = 4-remain_length;
492 *need_desegmentation = TRUE;
496 plen = tvb_get_ntohl(tvb, offset) ;
498 if (ssh_desegment && pinfo->can_desegment) {
499 if(plen +4 > remain_length ) {
500 pinfo->desegment_offset = offset;
501 pinfo->desegment_len = plen+4 - remain_length;
502 *need_desegmentation = TRUE;
507 * Need to check plen > 0x80000000 here
510 if (check_col(pinfo->cinfo, COL_INFO)) {
511 col_add_fstr(pinfo->cinfo, COL_INFO, "%s: ",
512 is_response?"Server":"Client");
517 proto_tree_add_uint_format(tree, hf_ssh_packet_length, tvb,
518 offset, 4, plen,"Overly large number 0x%x",plen);
520 plen = remain_length-4;
523 proto_tree_add_uint(tree, hf_ssh_packet_length, tvb,
529 padding_length = tvb_get_guint8(tvb, offset);
531 proto_tree_add_uint(tree, hf_ssh_padding_length, tvb,
532 offset, 1, padding_length);
537 tf=proto_tree_add_text(tree,tvb,offset,-1,"Key Exchange");
538 key_ex_tree = proto_item_add_subtree(tf ,ett_key_exchange);
541 msg_code = tvb_get_guint8(tvb, offset);
543 proto_tree_add_uint_format(key_ex_tree, hf_ssh_msg_code, tvb,
544 offset, 1, msg_code,"Msg code: %s (%u)",
545 val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"),
549 if (check_col(pinfo->cinfo, COL_INFO)) {
550 col_append_fstr(pinfo->cinfo, COL_INFO, "%s",
551 val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
555 /* 16 bytes cookie */
557 offset = ssh_dissect_key_init(tvb, offset,key_ex_tree);
560 len = plen+4-padding_length-(offset-last_offset);
562 ssh_proto_tree_add_item(key_ex_tree, hf_ssh_payload,
563 tvb, offset, len, FALSE);
569 ssh_proto_tree_add_item(key_ex_tree, hf_ssh_padding_string,
570 tvb, offset, padding_length, FALSE);
572 offset+= padding_length;
574 /* MAC , if there is still bytes, treat it as 16bytes MAC*/
575 if(msg_code == SSH2_MSG_KEX_DH_GEX_REPLY) {
576 len = tvb_reported_length_remaining(tvb,offset);
579 proto_tree_add_item(key_ex_tree, hf_ssh_mac_string,
580 tvb, offset, len , FALSE);
589 ssh_dissect_encrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
590 int offset, proto_tree *tree,int is_response)
594 len = tvb_reported_length_remaining(tvb,offset);
595 if (check_col(pinfo->cinfo, COL_INFO)) {
596 col_add_fstr(pinfo->cinfo, COL_INFO, "Encrypted %s packet len=%d",
597 is_response?"response":"request",len);
600 ssh_proto_tree_add_item(tree, hf_ssh_encrypted_packet,
601 tvb, offset, len, FALSE);
608 ssh_dissect_protocol(tvbuff_t *tvb, packet_info *pinfo,
609 int offset, proto_tree *tree, int is_response, int * version,
610 gboolean *need_desegmentation)
613 gint linelen, protolen;
616 * If the first packet do not contain the banner,
617 * it is dump in the middle of a flow or not a ssh at all
619 if(tvb_strncaseeql(tvb,offset,"SSH-",4) != 0 ) {
620 offset = ssh_dissect_encrypted_packet(tvb, pinfo,
621 offset,tree,is_response);
626 if(tvb_strncaseeql(tvb,offset,"SSH-2.",6) == 0 ) {
627 *(version) = SSH_VERSION_2;
628 }else if(tvb_strncaseeql(tvb,offset,"SSH-1.99-",9) == 0 ) {
629 *(version) = SSH_VERSION_2;
630 }else if(tvb_strncaseeql(tvb,offset,"SSH-1.",6) == 0 ) {
631 *(version) = SSH_VERSION_1;
636 * We use "tvb_ensure_length_remaining()" to make sure there
637 * actually *is* data remaining.
639 * This means we're guaranteed that "remain_length" is positive.
641 remain_length = tvb_ensure_length_remaining(tvb,offset);
642 /*linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
644 linelen = tvb_find_guint8(tvb, offset, -1, '\n');
646 if (ssh_desegment && pinfo->can_desegment) {
647 if(linelen == -1 || remain_length < (guint)linelen-offset ) {
648 pinfo->desegment_offset = offset;
649 pinfo->desegment_len = linelen-remain_length;
650 *need_desegmentation = TRUE;
655 /* XXX - reassemble across segment boundaries? */
656 linelen = remain_length;
659 linelen = linelen - offset + 1;
660 protolen = linelen - 1;
663 if (check_col(pinfo->cinfo, COL_INFO)) {
664 col_add_fstr(pinfo->cinfo, COL_INFO, "%s Protocol: %s",
665 is_response?"Server":"Client",
666 tvb_format_text(tvb,offset,protolen));
669 ssh_proto_tree_add_item(tree, hf_ssh_protocol,
670 tvb, offset, linelen, FALSE);
676 #define SSH_PROPOSAL(item)\
677 { &hf_ssh_ ## item, &hf_ssh_ ## item ## _length }
681 } ssh_proposals[] = {
682 SSH_PROPOSAL(kex_algorithms),
683 SSH_PROPOSAL(server_host_key_algorithms),
684 SSH_PROPOSAL(encryption_algorithms_client_to_server),
685 SSH_PROPOSAL(encryption_algorithms_server_to_client),
686 SSH_PROPOSAL(mac_algorithms_client_to_server),
687 SSH_PROPOSAL(mac_algorithms_server_to_client),
688 SSH_PROPOSAL(compression_algorithms_client_to_server),
689 SSH_PROPOSAL(compression_algorithms_server_to_client),
690 SSH_PROPOSAL(languages_client_to_server),
691 SSH_PROPOSAL(languages_server_to_client),
696 ssh_dissect_key_init(tvbuff_t *tvb, int offset, proto_tree *tree )
702 proto_item *key_init_tree=NULL;
705 tf=proto_tree_add_text(tree,tvb,offset,-1,"Algorithms");
706 key_init_tree = proto_item_add_subtree(tf, ett_key_init);
707 proto_tree_add_item(key_init_tree, hf_ssh_cookie,
708 tvb, offset, 16, FALSE);
712 for (i = 0; ssh_proposals[i].value; i++) {
713 len = tvb_get_ntohl(tvb, offset);
715 proto_tree_add_uint(key_init_tree,
716 *ssh_proposals[i].length, tvb, offset, 4, len);
720 ssh_proto_tree_add_item(key_init_tree,
721 *ssh_proposals[i].value, tvb, offset, len, FALSE);
728 ssh_proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
729 gint start, gint length, gboolean little_endian)
731 if (tree && length <0xffff && length > 0) {
732 return proto_tree_add_item(tree, hfindex, tvb, start, length,little_endian);
738 proto_register_ssh(void)
740 static hf_register_info hf[] = {
741 { &hf_ssh_packet_length,
742 { "Packet Length", "ssh.packet_length",
743 FT_UINT32, BASE_DEC, NULL, 0x0,
744 "SSH packet length", HFILL }},
746 { &hf_ssh_padding_length,
747 { "Padding Length", "ssh.padding_length",
748 FT_UINT8, BASE_DEC, NULL, 0x0,
749 "SSH Packet Number", HFILL }},
752 { "Message Code", "ssh.message_code",
753 FT_UINT8, BASE_DEC, NULL, 0x0,
754 "SSH Message Code", HFILL }},
757 { "Cookie", "ssh.cookie",
758 FT_BYTES, BASE_NONE, NULL, 0x0,
759 "SSH Cookie", HFILL }},
761 { &hf_ssh_encrypted_packet,
762 { "Encrypted Packet", "ssh.encrypted_packet",
763 FT_BYTES, BASE_NONE, NULL, 0x0,
764 "SSH Protocol Packet", HFILL }},
767 { "Protocol", "ssh.protocol",
768 FT_STRING, BASE_NONE, NULL, 0x0,
769 "SSH Protocol", HFILL }},
772 { "Payload", "ssh.payload",
773 FT_BYTES, BASE_NONE, NULL, 0x0,
774 "SSH Payload", HFILL }},
776 { &hf_ssh_padding_string,
777 { "Padding String", "ssh.padding_string",
778 FT_STRING, BASE_NONE, NULL, 0x0,
779 "SSH Padding String", HFILL }},
781 { &hf_ssh_mac_string,
782 { "MAC String", "ssh.mac_string",
783 FT_STRING, BASE_NONE, NULL, 0x0,
784 "SSH MAC String", HFILL }},
786 { &hf_ssh_kex_algorithms,
787 { "kex_algorithms string", "ssh.kex_algorithms",
788 FT_STRINGZ, BASE_NONE, NULL, 0x0,
789 "SSH kex_algorithms string", HFILL }},
791 { &hf_ssh_server_host_key_algorithms,
792 { "server_host_key_algorithms string", "ssh.server_host_key_algorithms",
793 FT_STRINGZ, BASE_NONE, NULL, 0x0,
794 "SSH server_host_key_algorithms string", HFILL }},
796 { &hf_ssh_encryption_algorithms_client_to_server,
797 { "encryption_algorithms_client_to_server string", "ssh.encryption_algorithms_client_to_server",
798 FT_STRINGZ, BASE_NONE, NULL, 0x0,
799 "SSH encryption_algorithms_client_to_server string", HFILL }},
801 { &hf_ssh_encryption_algorithms_server_to_client,
802 { "encryption_algorithms_server_to_client string", "ssh.encryption_algorithms_server_to_client",
803 FT_STRINGZ, BASE_NONE, NULL, 0x0,
804 "SSH encryption_algorithms_server_to_client string", HFILL }},
806 { &hf_ssh_mac_algorithms_client_to_server,
807 { "mac_algorithms_client_to_server string", "ssh.mac_algorithms_client_to_server",
808 FT_STRINGZ, BASE_NONE, NULL, 0x0,
809 "SSH mac_algorithms_client_to_server string", HFILL }},
811 { &hf_ssh_mac_algorithms_server_to_client,
812 { "mac_algorithms_server_to_client string", "ssh.mac_algorithms_server_to_client",
813 FT_STRINGZ, BASE_NONE, NULL, 0x0,
814 "SSH mac_algorithms_server_to_client string", HFILL }},
816 { &hf_ssh_compression_algorithms_client_to_server,
817 { "compression_algorithms_client_to_server string", "ssh.compression_algorithms_client_to_server",
818 FT_STRINGZ, BASE_NONE, NULL, 0x0,
819 "SSH compression_algorithms_client_to_server string", HFILL }},
821 { &hf_ssh_compression_algorithms_server_to_client,
822 { "compression_algorithms_server_to_client string", "ssh.compression_algorithms_server_to_client",
823 FT_STRINGZ, BASE_NONE, NULL, 0x0,
824 "SSH compression_algorithms_server_to_client string", HFILL }},
826 { &hf_ssh_languages_client_to_server,
827 { "languages_client_to_server string", "ssh.languages_client_to_server",
828 FT_STRINGZ, BASE_NONE, NULL, 0x0,
829 "SSH languages_client_to_server string", HFILL }},
831 { &hf_ssh_languages_server_to_client,
832 { "languages_server_to_client string", "ssh.languages_server_to_client",
833 FT_STRINGZ, BASE_NONE, NULL, 0x0,
834 "SSH languages_server_to_client string", HFILL }},
836 { &hf_ssh_kex_algorithms_length,
837 { "kex_algorithms length", "ssh.kex_algorithms_length",
838 FT_UINT32, BASE_DEC, NULL, 0x0,
839 "SSH kex_algorithms length", HFILL }},
841 { &hf_ssh_server_host_key_algorithms_length,
842 { "server_host_key_algorithms length", "ssh.server_host_key_algorithms_length",
843 FT_UINT32, BASE_DEC, NULL, 0x0,
844 "SSH server_host_key_algorithms length", HFILL }},
846 { &hf_ssh_encryption_algorithms_client_to_server_length,
847 { "encryption_algorithms_client_to_server length", "ssh.encryption_algorithms_client_to_server_length",
848 FT_UINT32, BASE_DEC, NULL, 0x0,
849 "SSH encryption_algorithms_client_to_server length", HFILL }},
851 { &hf_ssh_encryption_algorithms_server_to_client_length,
852 { "encryption_algorithms_server_to_client length", "ssh.encryption_algorithms_server_to_client_length",
853 FT_UINT32, BASE_DEC, NULL, 0x0,
854 "SSH encryption_algorithms_server_to_client length", HFILL }},
856 { &hf_ssh_mac_algorithms_client_to_server_length,
857 { "mac_algorithms_client_to_server length", "ssh.mac_algorithms_client_to_server_length",
858 FT_UINT32, BASE_DEC, NULL, 0x0,
859 "SSH mac_algorithms_client_to_server length", HFILL }},
861 { &hf_ssh_mac_algorithms_server_to_client_length,
862 { "mac_algorithms_server_to_client length", "ssh.mac_algorithms_server_to_client_length",
863 FT_UINT32, BASE_DEC, NULL, 0x0,
864 "SSH mac_algorithms_server_to_client length", HFILL }},
866 { &hf_ssh_compression_algorithms_client_to_server_length,
867 { "compression_algorithms_client_to_server length", "ssh.compression_algorithms_client_to_server_length",
868 FT_UINT32, BASE_DEC, NULL, 0x0,
869 "SSH compression_algorithms_client_to_server length", HFILL }},
871 { &hf_ssh_compression_algorithms_server_to_client_length,
872 { "compression_algorithms_server_to_client length", "ssh.compression_algorithms_server_to_client_length",
873 FT_UINT32, BASE_DEC, NULL, 0x0,
874 "SSH compression_algorithms_server_to_client length", HFILL }},
876 { &hf_ssh_languages_client_to_server_length,
877 { "languages_client_to_server length", "ssh.languages_client_to_server_length",
878 FT_UINT32, BASE_DEC, NULL, 0x0,
879 "SSH languages_client_to_server length", HFILL }},
881 { &hf_ssh_languages_server_to_client_length,
882 { "languages_server_to_client length", "ssh.languages_server_to_client_length",
883 FT_UINT32, BASE_DEC, NULL, 0x0,
884 "SSH languages_server_to_client length", HFILL }},
888 static gint *ett[] = {
895 module_t *ssh_module;
897 proto_ssh = proto_register_protocol("SSH Protocol",
899 proto_register_field_array(proto_ssh, hf, array_length(hf));
900 proto_register_subtree_array(ett, array_length(ett));
901 register_init_routine(&ssh_init_protocol);
903 ssh_module = prefs_register_protocol(proto_ssh, NULL);
904 prefs_register_bool_preference(ssh_module, "desegment_buffers",
905 "Desegment all SSH buffers spanning multiple TCP segments",
906 "Whether the SSH dissector should desegment all SSH buffers spanning multiple TCP segments",
911 proto_reg_handoff_ssh(void)
913 dissector_handle_t ssh_handle;
915 ssh_handle = create_dissector_handle(dissect_ssh, proto_ssh);
917 dissector_add("tcp.port", TCP_PORT_SSH, ssh_handle);