2 * Routines for Microsoft Proxy packet dissection
3 * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * This was derived from the dante socks implementation source code.
26 * Most of the information came from common.h and msproxy_clientprotocol.c
28 * See http://www.inet.no/dante for more information
31 /************************************************************************
33 * Notes: These are possible command values. User input is welcome *
35 * Command = 0x040a - Remote host closed connection (maybe ?? ) *
36 * Command = 0x0411 - Remote host closed connection *
37 * Command = 0x0413 - Local host closed connection or SYN worked *
39 ************************************************************************/
51 #include <epan/packet.h>
52 #include <epan/addr_resolv.h>
53 #include <epan/conversation.h>
54 #include <epan/emem.h>
56 #include "packet-tcp.h"
57 #include "packet-udp.h"
59 extern void udp_hash_add(guint16 proto,
60 void (*dissect)(const guchar *, int, frame_data *, proto_tree *));
63 static int proto_msproxy = -1;
65 static int ett_msproxy = -1;
66 static int ett_msproxy_name = -1;
68 static int hf_msproxy_cmd = -1;
69 static int hf_msproxy_clntport = -1;
71 static int hf_msproxy_dstaddr = -1;
73 static int hf_msproxy_srcport = -1;
74 static int hf_msproxy_dstport = -1;
75 static int hf_msproxy_serverport = -1;
76 static int hf_msproxy_serveraddr = -1;
77 static int hf_msproxy_bindport = -1;
78 static int hf_msproxy_bindaddr = -1;
79 static int hf_msproxy_boundport = -1;
80 static int hf_msproxy_bind_id = -1;
81 static int hf_msproxy_resolvaddr = -1;
83 static int hf_msproxy_server_int_addr = -1;
84 static int hf_msproxy_server_int_port = -1;
85 static int hf_msproxy_server_ext_addr = -1;
86 static int hf_msproxy_server_ext_port = -1;
88 static dissector_handle_t msproxy_sub_handle;
91 #define UDP_PORT_MSPROXY 1745
93 #define N_MSPROXY_HELLO 0x05 /* packet 1 from client */
94 #define N_MSPROXY_ACK 0x10 /* packet 1 from server */
95 #define N_MSPROXY_USERINFO_ACK 0x04 /* packet 2 from server */
96 #define N_MSPROXY_AUTH 0x47 /* packet 3 from client */
97 #define N_MSPROXY_RESOLVE 0x07 /* Resolve request */
100 /*$$$ 0x0500 was dante value, I see 0x05ff and 0x0500 */
102 #define MSPROXY_HELLO 0x0500
103 #define MSPROXY_HELLO_2 0x05ff
105 #define MSPROXY_HELLO_ACK 0x1000
107 #define MSPROXY_USERINFO 0x1000
108 #define MSPROXY_USERINFO_ACK 0x0400
110 #define MSPROXY_AUTH 0x4700
111 #define MSPROXY_AUTH_1_ACK 0x4714
112 #define MSPROXY_AUTH_2 0x4701
113 #define MSPROXY_AUTH_2_ACK 0x4715
114 #define MSPROXY_AUTH_2_ACK2 0x4716
116 #define MSPROXY_RESOLVE 0x070d
117 #define MSPROXY_RESOLVE_ACK 0x070f
119 #define MSPROXY_BIND 0x0704
120 #define MSPROXY_BIND_ACK 0x0706
122 #define MSPROXY_TCP_BIND 0x0707
123 #define MSPROXY_TCP_BIND_ACK 0x0708
125 #define MSPROXY_LISTEN 0x0406
127 #define MSPROXY_BINDINFO 0x0709
129 #define MSPROXY_BINDINFO_ACK 0x070a
131 #define MSPROXY_CONNECT 0x071e
132 #define MSPROXY_CONNECT_ACK 0x0703
134 #define MSPROXY_UDPASSOCIATE 0x0705
135 #define MSPROXY_UDPASSOCIATE_ACK 0x0706
137 #define MSPROXY_UDP_BIND_REQ 0x070b
139 #define MSPROXY_CONNECTED 0x042c
140 #define MSPROXY_SESSIONEND 0x251e
142 #define MSPROXY_BIND_AUTHFAILED 0x0804
143 #define MSPROXY_CONNECT_AUTHFAILED 0x081e
144 #define MSPROXY_CONNREFUSED 0x4 /* low 12 bits seem to vary. */
146 #define FROM_SERVER 1 /* direction of packet data for get_msproxy_cmd_name */
147 #define FROM_CLIENT 0
152 /*$$$ should this be the same as redirect_entry_t ?? */
153 /* then the add_conversation could just copy the structure */
154 /* using the same allocation (instance for you object guys) */
155 /* wouldn't work because there may be multiple child conversations */
156 /* from the same MSProxy conversation */
162 guint32 server_int_port;
167 /************** conversation hash stuff ***************/
172 guint32 server_int_port;
178 /************** negotiated conversation hash stuff ***************/
181 static guint32 last_row= 0; /* used to see if packet is new */
183 static void msproxy_sub_dissector( tvbuff_t *tvb, packet_info *pinfo,
186 /* Conversation dissector called from TCP or UDP dissector. Decode and */
187 /* display the msproxy header, the pass the rest of the data to the tcp */
188 /* or udp port decode routine to handle the payload. */
191 redirect_entry_t *redirect_info;
192 conversation_t *conversation;
193 proto_tree *msp_tree;
196 conversation = find_conversation( pinfo->fd->num, &pinfo->src, &pinfo->dst,
197 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
199 DISSECTOR_ASSERT( conversation); /* should always find a conversation */
201 redirect_info = conversation_get_proto_data(conversation,
204 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MS Proxy");
206 if (check_col(pinfo->cinfo, COL_INFO))
207 col_set_str(pinfo->cinfo, COL_INFO,
208 (( redirect_info->proto == PT_TCP) ? "TCP stream" :
212 ti = proto_tree_add_item( tree, proto_msproxy, tvb, 0, 0,
215 msp_tree = proto_item_add_subtree(ti, ett_msproxy);
217 proto_tree_add_uint( msp_tree, hf_msproxy_dstport, tvb, 0, 0,
218 redirect_info->remote_port);
220 proto_tree_add_ipv4( msp_tree, hf_msproxy_dstaddr, tvb, 0, 0,
221 redirect_info->remote_addr);
225 /* set pinfo->{src/dst port} and call the UDP sub-dissector lookup */
227 if ( pinfo->srcport == redirect_info->clnt_port)
228 ptr = &pinfo->destport;
230 ptr = &pinfo->srcport;
232 *ptr = redirect_info->remote_port;
234 if ( redirect_info->proto == PT_TCP)
235 decode_tcp_ports( tvb, 0, pinfo, tree, pinfo->srcport,
236 pinfo->destport, NULL);
238 decode_udp_ports( tvb, 0, pinfo, tree, pinfo->srcport,
239 pinfo->destport, -1);
241 *ptr = redirect_info->server_int_port;
246 static void add_msproxy_conversation( packet_info *pinfo,
247 hash_entry_t *hash_info){
249 /* check to see if a conversation already exists, if it does assume */
250 /* it's our conversation and quit. Otherwise create a new conversation. */
251 /* Load the conversation dissector to our dissector and load the */
252 /* conversation data structure with the info needed to call the TCP or */
253 /* UDP port decoder. */
255 /* NOTE: Currently this assume that the conversation will be created */
256 /* during a packet from the server. If that changes, pinfo->src */
257 /* and pinfo->dst will not be correct and this routine will have */
260 conversation_t *conversation;
261 redirect_entry_t *new_conv_info;
263 if (pinfo->fd->flags.visited) {
265 * We've already processed this frame once, so we
266 * should already have done this.
271 conversation = find_conversation( pinfo->fd->num, &pinfo->src,
272 &pinfo->dst, hash_info->proto, hash_info->server_int_port,
273 hash_info->clnt_port, 0);
275 if ( !conversation) {
276 conversation = conversation_new( pinfo->fd->num, &pinfo->src, &pinfo->dst,
277 hash_info->proto, hash_info->server_int_port,
278 hash_info->clnt_port, 0);
280 conversation_set_dissector(conversation, msproxy_sub_handle);
282 new_conv_info = se_alloc(sizeof(redirect_entry_t));
284 new_conv_info->remote_addr = hash_info->dst_addr;
285 new_conv_info->clnt_port = hash_info->clnt_port;
286 new_conv_info->remote_port = hash_info->dst_port;
287 new_conv_info->server_int_port = hash_info->server_int_port;
288 new_conv_info->proto = hash_info->proto;
290 conversation_add_proto_data(conversation, proto_msproxy,
296 static int display_application_name(tvbuff_t *tvb, int offset,
299 /* display the application name in the proto tree. */
301 /* NOTE: this routine assumes that the tree pointer is valid (not NULL) */
305 length = tvb_strnlen( tvb, offset, 255);
306 proto_tree_add_text( tree, tvb, offset, length, "Application: %.*s",
307 length, tvb_get_ephemeral_string( tvb, offset, length));
313 static const char *get_msproxy_cmd_name( int cmd, int direction) {
315 /* return the command name string for cmd */
318 case MSPROXY_HELLO_2:
319 case MSPROXY_HELLO: return "Hello";
321 /* MSPROXY_HELLO_ACK & MSPROXY_USERINFO have the same value (0x1000). */
322 /* So use the direction flag to determine which to use. */
324 case MSPROXY_USERINFO:
325 if ( direction == FROM_SERVER)
326 return "Hello Acknowledge";
329 case MSPROXY_USERINFO_ACK: return "User Info Acknowledge";
330 case MSPROXY_AUTH: return "Authentication";
331 case MSPROXY_AUTH_1_ACK: return "Authentication Acknowledge";
332 case MSPROXY_AUTH_2: return "Authentication 2";
333 case MSPROXY_AUTH_2_ACK: return "Authentication 2 Acknowledge";
334 case MSPROXY_RESOLVE: return "Resolve";
335 case MSPROXY_RESOLVE_ACK: return "Resolve Acknowledge";
336 case MSPROXY_BIND: return "Bind";
337 case MSPROXY_TCP_BIND: return "TCP Bind";
338 case MSPROXY_TCP_BIND_ACK: return "TCP Bind Acknowledge";
339 case MSPROXY_LISTEN: return "Listen";
340 case MSPROXY_BINDINFO: return "Bind Info";
341 case MSPROXY_BINDINFO_ACK: return "Bind Info Acknowledge";
342 case MSPROXY_CONNECT: return "Connect";
343 case MSPROXY_CONNECT_ACK: return "Connect Acknowledge";
344 case MSPROXY_UDPASSOCIATE: return "UDP Associate";
345 case MSPROXY_UDP_BIND_REQ: return "UDP Bind";
346 case MSPROXY_UDPASSOCIATE_ACK: return "Bind or Associate Acknowledge";
347 case MSPROXY_CONNECTED: return "Connected";
348 case MSPROXY_SESSIONEND: return "Session End";
350 default: return "Unknown";
356 static void dissect_user_info_2(tvbuff_t *tvb, int offset,
359 /* decode the user, application, computer name */
365 length = tvb_strnlen( tvb, offset, 255);
368 proto_tree_add_text( tree, tvb, offset, length + 1,
369 "User name: %.*s", length,
370 tvb_get_ephemeral_string( tvb, offset, length));
371 offset += length + 2;
373 length = tvb_strnlen( tvb, offset, 255);
376 proto_tree_add_text( tree, tvb, offset, length + 1,
377 "Application name: %.*s", length,
378 tvb_get_ephemeral_string( tvb, offset, length));
379 offset += length + 1;
381 length = tvb_strnlen( tvb, offset, 255);
384 proto_tree_add_text( tree, tvb, offset, length + 1,
385 "Client computer name: %.*s", length,
386 tvb_get_ephemeral_string( tvb, offset, length));
392 static void dissect_msproxy_request_1(tvbuff_t *tvb, int offset,
395 /* decode the request _1 structure */
400 dissect_user_info_2( tvb, offset, tree);
406 static void dissect_bind(tvbuff_t *tvb, int offset,
407 proto_tree *tree, hash_entry_t *conv_info) {
409 /* decode the bind request */
414 proto_tree_add_item( tree, hf_msproxy_bindaddr, tvb, offset, 4,
419 proto_tree_add_item( tree, hf_msproxy_bindport, tvb, offset, 2,
424 proto_tree_add_item( tree, hf_msproxy_clntport, tvb, offset, 2,
428 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
432 proto_tree_add_item( tree, hf_msproxy_boundport, tvb, offset, 2,
436 display_application_name( tvb, offset, tree);
442 static void dissect_auth(tvbuff_t *tvb, int offset,
445 /* decode the authorization request */
450 proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
451 tvb_get_ephemeral_string( tvb, offset, 7));
458 static void dissect_tcp_bind(tvbuff_t *tvb, int offset,
459 proto_tree *tree, hash_entry_t *conv_info) {
461 /* decode the bind packet. Set the protocol type in the conversation */
462 /* information so the bind_info can use it to create the payload */
466 conv_info->proto = PT_TCP;
471 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
475 proto_tree_add_item( tree, hf_msproxy_boundport, tvb, offset, 2,
479 display_application_name( tvb, offset, tree);
484 static void dissect_request_connect(tvbuff_t *tvb, int offset,
485 proto_tree *tree, hash_entry_t *conv_info) {
487 /* decode the connect request, display */
489 conv_info->proto = PT_TCP;
494 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
497 conv_info->dst_port = tvb_get_ntohs( tvb, offset);
501 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
504 conv_info->dst_addr = tvb_get_ipv4( tvb, offset);
508 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
511 proto_tree_add_uint( tree, hf_msproxy_clntport, tvb, offset, 2,
512 conv_info->clnt_port);
516 display_application_name( tvb, offset, tree);
521 static void dissect_bind_info_ack(tvbuff_t *tvb, int offset, proto_tree *tree) {
523 /* decode the client bind info ack */
529 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
533 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
537 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
541 proto_tree_add_item( tree, hf_msproxy_server_int_port, tvb,
542 offset, 2, ENC_BIG_ENDIAN);
545 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
546 offset, 2, ENC_BIG_ENDIAN);
549 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
550 offset, 4, ENC_BIG_ENDIAN);
553 display_application_name( tvb, offset, tree);
558 static void dissect_request_resolve(tvbuff_t *tvb, int offset,
561 /* dissect the request resolve structure */
562 /* display a string with a length, characters encoding */
563 /* they are displayed under a tree with the name in Label variable */
564 /* return the length of the string and the length byte */
566 proto_tree *name_tree;
569 int length = tvb_get_guint8( tvb, offset);
572 ti = proto_tree_add_text(tree, tvb, offset, length + 1,
573 "Host Name: %.*s", length,
574 tvb_get_ephemeral_string( tvb, offset + 18, length));
576 name_tree = proto_item_add_subtree(ti, ett_msproxy_name);
578 proto_tree_add_text( name_tree, tvb, offset, 1, "Length: %d",
584 proto_tree_add_text( name_tree, tvb, offset, length, "String: %s",
585 tvb_get_ephemeral_string( tvb, offset, length));
591 static void dissect_udp_bind(tvbuff_t *tvb, int offset,
592 proto_tree *tree, hash_entry_t *conv_info) {
594 /* Dissect the udp bind request. Load the protocol id (PT_UDP) and the */
595 /* remote address so bind_info can use it to create conversation */
598 conv_info->proto = PT_UDP;
604 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
610 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
615 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
621 display_application_name( tvb, offset, tree);
625 static void dissect_udp_assoc(tvbuff_t *tvb, int offset,
626 proto_tree *tree, hash_entry_t *conv_info) {
628 /* dissect the udp associate request. And load client port into */
629 /* conversation data structure for later. */
635 proto_tree_add_item( tree, hf_msproxy_clntport, tvb, offset, 2,
638 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
643 display_application_name( tvb, offset, tree);
647 static void dissect_msproxy_request(tvbuff_t *tvb,
648 proto_tree *tree, hash_entry_t *conv_info) {
654 proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
655 tvb_get_letohl( tvb, offset));
658 proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
659 tvb_get_letohl( tvb, offset));
662 proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%0x",
663 tvb_get_letohl( tvb, offset));
666 proto_tree_add_text( tree, tvb, offset, 1, "Server ack: %u",
667 tvb_get_guint8( tvb, offset));
670 proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: %u",
671 tvb_get_guint8( tvb, offset));
674 proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
675 tvb_get_ephemeral_string( tvb, offset, 4));
681 cmd = tvb_get_ntohs( tvb, offset);
684 proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
685 cmd, "Command: 0x%02x (%s)", cmd,
686 get_msproxy_cmd_name( cmd, FROM_CLIENT));
692 dissect_auth( tvb, offset, tree);
696 dissect_bind( tvb, offset, tree, conv_info);
699 case MSPROXY_UDP_BIND_REQ:
700 dissect_udp_bind( tvb, offset, tree, conv_info);
703 case MSPROXY_AUTH_2: /*$$ this is probably wrong place for this */
704 case MSPROXY_TCP_BIND:
705 dissect_tcp_bind( tvb, offset, tree, conv_info);
708 case MSPROXY_RESOLVE:
709 dissect_request_resolve( tvb, offset, tree);
712 case MSPROXY_CONNECT:
714 dissect_request_connect( tvb, offset, tree,
718 case MSPROXY_BINDINFO_ACK:
719 dissect_bind_info_ack( tvb, offset, tree);
723 case MSPROXY_HELLO_2:
724 dissect_msproxy_request_1( tvb, offset, tree);
727 case MSPROXY_UDPASSOCIATE:
728 dissect_udp_assoc( tvb, offset, tree, conv_info);
732 proto_tree_add_text( tree, tvb, offset, 0,
733 "Unhandled request command (report this, please)");
739 static void dissect_hello_ack(tvbuff_t *tvb, int offset, proto_tree *tree) {
741 /* decode the hello acknowledge packet */
746 proto_tree_add_item( tree, hf_msproxy_serverport, tvb, offset, 2,
750 proto_tree_add_item( tree, hf_msproxy_serveraddr, tvb, offset, 4,
758 /* XXX - implement me */
759 static void dissect_user_info_ack(tvbuff_t *tvb _U_, int offset,
760 proto_tree *tree _U_) {
762 /* decode the response _2 structure */
772 static void dissect_udpassociate_ack(tvbuff_t *tvb, int offset,
778 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
782 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
783 offset, 2, ENC_BIG_ENDIAN);
786 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
787 offset, 4, ENC_BIG_ENDIAN);
790 display_application_name( tvb, offset, tree);
796 static void dissect_auth_1_ack(tvbuff_t *tvb, int offset,
801 proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
802 tvb_get_ephemeral_string( tvb, offset, 7));
805 /* XXX - always 255? */
806 proto_tree_add_text( tree, tvb, offset, 255, "NT domain: %.255s",
807 tvb_get_ephemeral_string( tvb, offset, 255));
813 /* XXX - implement me */
814 static void dissect_msproxy_response_4( tvbuff_t *tvb _U_, int offset,
815 proto_tree *tree _U_) {
817 /* decode the response _4 structure */
824 static void dissect_connect_ack( tvbuff_t *tvb, int offset, packet_info *pinfo,
825 proto_tree *tree, hash_entry_t *conv_info) {
827 /* decode the connect ack packet */
831 proto_tree_add_item( tree, hf_msproxy_server_int_port, tvb,
832 offset, 2, ENC_BIG_ENDIAN);
835 conv_info->proto = PT_TCP;
836 conv_info->server_int_port = tvb_get_ntohs( tvb, offset);
840 proto_tree_add_item( tree, hf_msproxy_server_int_addr, tvb,
841 offset, 4, ENC_BIG_ENDIAN);
844 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
845 offset, 2, ENC_BIG_ENDIAN);
848 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
849 offset, 4, ENC_BIG_ENDIAN);
852 display_application_name( tvb, offset, tree);
855 add_msproxy_conversation( pinfo, conv_info);
860 static void dissect_tcp_bind_ack( tvbuff_t *tvb, int offset, proto_tree *tree) {
862 /* decode the tcp bind */
867 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
871 proto_tree_add_uint( tree, hf_msproxy_server_int_port, tvb,
875 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
876 offset, 2, ENC_BIG_ENDIAN);
879 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
880 offset, 4, ENC_BIG_ENDIAN);
884 display_application_name( tvb, offset, tree);
890 static void dissect_bind_info( tvbuff_t *tvb, int offset, packet_info *pinfo,
891 proto_tree *tree, hash_entry_t *conv_info) {
893 /* decode the Bind info response from server */
898 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
903 conv_info->dst_port = tvb_get_ntohs( tvb, offset);
905 proto_tree_add_uint( tree, hf_msproxy_dstport, tvb, offset, 2,
906 conv_info->dst_port);
909 conv_info->dst_addr = tvb_get_ipv4( tvb, offset);
911 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
915 conv_info->server_int_port = tvb_get_ntohs( tvb, offset);
917 proto_tree_add_uint( tree, hf_msproxy_server_int_port, tvb,
918 offset, 2, conv_info->server_int_port);
922 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
923 offset, 2, ENC_BIG_ENDIAN);
926 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
927 offset, 4, ENC_BIG_ENDIAN);
930 display_application_name( tvb, offset, tree);
934 add_msproxy_conversation( pinfo, conv_info);
939 static void dissect_resolve(tvbuff_t *tvb, int offset, proto_tree *tree) {
941 /* dissect the response resolve structure */
942 /* display a string with a length, characters encoding */
943 /* they are displayed under a tree with the name in Label variable */
944 /* return the length of the string and the length byte */
949 addr_offset = tvb_get_guint8( tvb, offset);
951 proto_tree_add_text( tree, tvb, offset, 1, "Address offset: %d",
958 offset += addr_offset;
960 proto_tree_add_item( tree, hf_msproxy_resolvaddr, tvb, offset, 4,
967 static void dissect_msproxy_response(tvbuff_t *tvb, packet_info *pinfo,
968 proto_tree *tree, hash_entry_t *conv_info) {
974 proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
975 tvb_get_letohl( tvb, offset));
978 proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
979 tvb_get_letohl( tvb, offset));
982 proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%04x",
983 tvb_get_letohl( tvb, offset));
986 proto_tree_add_text( tree, tvb, offset, 1, "Client ack: 0x%02x",
987 tvb_get_guint8( tvb, offset));
990 proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: 0x%02x",
991 tvb_get_guint8( tvb, offset));
995 proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
996 tvb_get_ephemeral_string( tvb, offset, 4));
1003 cmd = tvb_get_ntohs( tvb, offset);
1006 proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
1007 cmd, "Command: 0x%02x (%s)", cmd,
1008 get_msproxy_cmd_name( cmd, FROM_SERVER));
1012 case MSPROXY_HELLO_ACK:
1013 dissect_hello_ack( tvb, offset, tree);
1016 case MSPROXY_USERINFO_ACK:
1017 dissect_user_info_ack( tvb, offset, tree);
1020 case MSPROXY_AUTH_1_ACK:
1021 dissect_auth_1_ack( tvb, offset, tree);
1024 /* this also handle the MSPROXY_BIND_ACK ??? check this */
1026 case MSPROXY_UDPASSOCIATE_ACK:
1027 dissect_udpassociate_ack( tvb, offset, tree);
1030 case MSPROXY_AUTH_2_ACK:
1031 case MSPROXY_AUTH_2_ACK2:
1032 dissect_msproxy_response_4( tvb, offset, tree);
1035 case MSPROXY_TCP_BIND_ACK:
1036 dissect_tcp_bind_ack( tvb, offset, tree);
1039 case MSPROXY_CONNECT_ACK:
1040 dissect_connect_ack( tvb, offset, pinfo, tree,
1044 case MSPROXY_BINDINFO:
1045 dissect_bind_info( tvb, offset, pinfo, tree, conv_info);
1048 case MSPROXY_RESOLVE_ACK:
1049 dissect_resolve( tvb, offset, tree);
1052 case MSPROXY_CONNECT_AUTHFAILED:
1053 case MSPROXY_BIND_AUTHFAILED:
1054 proto_tree_add_text( tree, tvb, offset, 0, "No know information (help wanted)");
1060 (((cmd >> 8) == MSPROXY_CONNREFUSED) ||
1061 ((cmd >> 12) == MSPROXY_CONNREFUSED)))
1062 proto_tree_add_text( tree, tvb, offset, 0,
1063 "No know information (help wanted)");
1066 proto_tree_add_text( tree, tvb, offset, 0,
1067 "Unhandled response command (report this, please)");
1075 static void dissect_msproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1078 proto_tree *msproxy_tree = NULL;
1083 hash_entry_t *hash_info;
1084 conversation_t *conversation;
1086 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSproxy");
1087 col_clear(pinfo->cinfo, COL_INFO);
1089 conversation = find_or_create_conversation(pinfo);
1091 hash_info = conversation_get_proto_data(conversation, proto_msproxy);
1093 hash_info = se_alloc(sizeof(hash_entry_t));
1094 conversation_add_proto_data(conversation, proto_msproxy,
1098 if (check_col(pinfo->cinfo, COL_INFO)){
1100 cmd = tvb_get_ntohs( tvb, 36);
1102 if ( pinfo->srcport == UDP_PORT_MSPROXY)
1103 col_add_fstr( pinfo->cinfo, COL_INFO, "Server message: %s",
1104 get_msproxy_cmd_name( cmd, FROM_SERVER));
1106 col_add_fstr(pinfo->cinfo, COL_INFO, "Client message: %s",
1107 get_msproxy_cmd_name( cmd, FROM_CLIENT));
1111 if (tree) { /* if proto tree, decode data */
1112 ti = proto_tree_add_item( tree, proto_msproxy, tvb, 0, -1,
1115 msproxy_tree = proto_item_add_subtree(ti, ett_msproxy);
1118 if ( pinfo->srcport == UDP_PORT_MSPROXY)
1119 dissect_msproxy_response( tvb, pinfo, msproxy_tree, hash_info);
1121 dissect_msproxy_request( tvb, msproxy_tree, hash_info);
1126 static void msproxy_reinit( void){
1128 /* Do the cleanup work when a new pass through the packet list is */
1129 /* performed. Reset the highest row seen counter */
1137 proto_register_msproxy( void){
1139 /* Prep the msproxy protocol, for now, just register it */
1141 static gint *ett[] = {
1145 static hf_register_info hf[] = {
1148 { "Command", "msproxy.command", FT_UINT16, BASE_DEC,
1149 NULL, 0x0, NULL, HFILL
1153 { &hf_msproxy_dstaddr,
1154 { "Destination Address", "msproxy.dstaddr", FT_IPv4, BASE_NONE, NULL,
1159 { &hf_msproxy_srcport,
1160 { "Source Port", "msproxy.srcport", FT_UINT16,
1161 BASE_DEC, NULL, 0x0, NULL, HFILL
1164 { &hf_msproxy_dstport,
1165 { "Destination Port", "msproxy.dstport", FT_UINT16,
1166 BASE_DEC, NULL, 0x0, NULL, HFILL
1169 { &hf_msproxy_clntport,
1170 { "Client Port", "msproxy.clntport", FT_UINT16,
1171 BASE_DEC, NULL, 0x0, NULL, HFILL
1174 { &hf_msproxy_server_ext_addr,
1175 { "Server External Address", "msproxy.server_ext_addr", FT_IPv4, BASE_NONE, NULL,
1180 { &hf_msproxy_server_ext_port,
1181 { "Server External Port", "msproxy.server_ext_port", FT_UINT16,
1182 BASE_DEC, NULL, 0x0, NULL, HFILL
1186 { &hf_msproxy_server_int_addr,
1187 { "Server Internal Address", "msproxy.server_int_addr", FT_IPv4, BASE_NONE, NULL,
1192 { &hf_msproxy_server_int_port,
1193 { "Server Internal Port", "msproxy.server_int_port", FT_UINT16,
1194 BASE_DEC, NULL, 0x0, NULL, HFILL
1197 { &hf_msproxy_serverport,
1198 { "Server Port", "msproxy.serverport", FT_UINT16,
1199 BASE_DEC, NULL, 0x0, NULL, HFILL
1202 { &hf_msproxy_bindport,
1203 { "Bind Port", "msproxy.bindport", FT_UINT16,
1204 BASE_DEC, NULL, 0x0, NULL, HFILL
1207 { &hf_msproxy_boundport,
1208 { "Bound Port", "msproxy.boundport", FT_UINT16,
1209 BASE_DEC, NULL, 0x0, NULL, HFILL
1212 { &hf_msproxy_serveraddr,
1213 { "Server Address", "msproxy.serveraddr", FT_IPv4, BASE_NONE, NULL,
1217 { &hf_msproxy_bindaddr,
1218 { "Destination", "msproxy.bindaddr", FT_IPv4, BASE_NONE, NULL,
1222 { &hf_msproxy_bind_id,
1223 { "Bound Port Id", "msproxy.bindid", FT_UINT32,
1224 BASE_HEX, NULL, 0x0, NULL, HFILL
1227 { &hf_msproxy_resolvaddr,
1228 { "Address", "msproxy.resolvaddr", FT_IPv4, BASE_NONE, NULL,
1235 proto_msproxy = proto_register_protocol( "MS Proxy Protocol",
1236 "MS Proxy", "msproxy");
1238 proto_register_field_array(proto_msproxy, hf, array_length(hf));
1239 proto_register_subtree_array(ett, array_length(ett));
1241 register_init_routine( &msproxy_reinit); /* register re-init routine */
1243 msproxy_sub_handle = create_dissector_handle(msproxy_sub_dissector,
1249 proto_reg_handoff_msproxy(void) {
1251 /* dissector install routine */
1253 dissector_handle_t msproxy_handle;
1255 msproxy_handle = create_dissector_handle(dissect_msproxy,
1257 dissector_add_uint("udp.port", UDP_PORT_MSPROXY, msproxy_handle);