2006-01-03 23:59:13 +00:00
|
|
|
/* packet-oicq.c
|
|
|
|
* Routines for OICQ - IM software,popular in China - packet dissection
|
2007-04-27 18:16:05 +00:00
|
|
|
* (c) Copyright Secfire <secfire@gmail.com>
|
2006-01-03 23:59:13 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* OICQ is an IM software,which is popular in China. And,
|
|
|
|
* OICQ has more than 10 millions users at present.
|
2011-10-21 02:10:19 +00:00
|
|
|
* The Protocol showed in this file, is found by investigating OICQ's
|
2006-01-03 23:59:13 +00:00
|
|
|
* Packets as a black box.
|
|
|
|
*
|
2011-10-21 02:10:19 +00:00
|
|
|
* The OICQ client software is always changing,and the protocol of
|
2006-01-03 23:59:13 +00:00
|
|
|
* communication is also.
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-01-03 23:59:13 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
Protocol Flag: 8bit unsigned
|
|
|
|
Sender Flag: 16bit unsigned
|
|
|
|
Command Number: 16bit unsigned
|
2006-07-10 05:05:01 +00:00
|
|
|
Sequence Number: 16bit unsigned
|
|
|
|
OICQ Number: 32bit unsigned
|
2006-01-03 23:59:13 +00:00
|
|
|
Data: Variable Length data
|
2011-10-21 02:10:19 +00:00
|
|
|
|
2006-01-03 23:59:13 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* By default, but can be completely different */
|
|
|
|
#define UDP_PORT_OICQ 8000
|
|
|
|
|
|
|
|
static int proto_oicq = -1;
|
|
|
|
|
|
|
|
static int hf_oicq_flag = -1;
|
2006-07-10 05:05:01 +00:00
|
|
|
static int hf_oicq_version = -1;
|
2006-01-03 23:59:13 +00:00
|
|
|
static int hf_oicq_command = -1;
|
2006-07-10 05:05:01 +00:00
|
|
|
static int hf_oicq_seq = -1;
|
|
|
|
static int hf_oicq_qqid = -1;
|
2006-01-03 23:59:13 +00:00
|
|
|
static int hf_oicq_data = -1;
|
|
|
|
|
|
|
|
|
|
|
|
static gint ett_oicq = -1;
|
|
|
|
|
|
|
|
static const value_string oicq_flag_vals[] = {
|
|
|
|
{ 0x02, "Oicq packet" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
2006-07-10 05:05:01 +00:00
|
|
|
|
2006-01-03 23:59:13 +00:00
|
|
|
static const value_string oicq_command_vals[] = {
|
|
|
|
{ 0x0001, "Log out" },
|
|
|
|
{ 0x0002, "Heart Message" },
|
|
|
|
{ 0x0004, "Update User information" },
|
|
|
|
{ 0x0005, "Search user" },
|
|
|
|
{ 0x0006, "Get User informationBroadcast" },
|
|
|
|
{ 0x0009, "Add friend no auth" },
|
|
|
|
{ 0x000a, "Delete user" },
|
|
|
|
{ 0x000b, "Add friend by auth" },
|
|
|
|
{ 0x000d, "Set status" },
|
|
|
|
{ 0x0012, "Confirmation of receiving message from server" },
|
|
|
|
{ 0x0016, "Send message" },
|
|
|
|
{ 0x0017, "Receive message" },
|
2006-07-10 05:05:01 +00:00
|
|
|
{ 0x0018, "Retrieve information" },
|
2006-01-03 23:59:13 +00:00
|
|
|
{ 0x001a, "Reserved " },
|
2006-07-10 05:05:01 +00:00
|
|
|
{ 0x001c, "Delete Me" },
|
|
|
|
{ 0x001d, "Request KEY" },
|
|
|
|
{ 0x0021, "Cell Phone" },
|
2006-01-03 23:59:13 +00:00
|
|
|
{ 0x0022, "Log in" },
|
|
|
|
{ 0x0026, "Get friend list" },
|
|
|
|
{ 0x0027, "Get friend online" },
|
2006-07-10 05:05:01 +00:00
|
|
|
{ 0x0029, "Cell PHONE" },
|
2006-01-03 23:59:13 +00:00
|
|
|
{ 0x0030, "Operation on group" },
|
2006-07-10 05:05:01 +00:00
|
|
|
{ 0x0031, "Log in test" },
|
|
|
|
{ 0x003c, "Group name operation" },
|
|
|
|
{ 0x003d, "Upload group friend" },
|
|
|
|
{ 0x003e, "MEMO Operation" },
|
|
|
|
{ 0x0058, "Download group friend" },
|
|
|
|
{ 0x005c, "Get level" },
|
|
|
|
{ 0x0062, "Request login" },
|
|
|
|
{ 0x0065, "Request extra information" },
|
|
|
|
{ 0x0067, "Signature operation" },
|
|
|
|
{ 0x0080, "Receive system message" },
|
2008-12-20 00:09:02 +00:00
|
|
|
{ 0x0081, "Get status of friend" },
|
|
|
|
{ 0x00b5, "Get friend's status of group" },
|
2006-01-03 23:59:13 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
2006-07-10 05:05:01 +00:00
|
|
|
|
2006-01-03 23:59:13 +00:00
|
|
|
/* dissect_oicq - dissects oicq packet data
|
|
|
|
* tvb - tvbuff for packet data (IN)
|
|
|
|
* pinfo - packet info
|
|
|
|
* proto_tree - resolved protocol tree
|
|
|
|
*/
|
2008-05-17 23:40:07 +00:00
|
|
|
static int
|
2006-01-03 23:59:13 +00:00
|
|
|
dissect_oicq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree *oicq_tree;
|
|
|
|
proto_item *ti;
|
|
|
|
int offset = 0;
|
2008-05-17 23:40:07 +00:00
|
|
|
|
2009-03-06 00:24:06 +00:00
|
|
|
/* Make sure this packet is for us. */
|
|
|
|
/* heuristic: OICQ iff (([0] == STX) && ([3/4] == <valid_command>) ) */
|
|
|
|
/* (Supposedly each OICQ message ends with an ETX so a test for */
|
|
|
|
/* same could also be part of the heuristic). */
|
|
|
|
if ( (match_strval(tvb_get_guint8(tvb, 0), oicq_flag_vals) == NULL) ||
|
|
|
|
(match_strval(tvb_get_ntohs(tvb, 3), oicq_command_vals) == NULL) )
|
2008-05-17 23:40:07 +00:00
|
|
|
return 0;
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "OICQ");
|
2006-01-03 23:59:13 +00:00
|
|
|
|
2009-09-24 19:50:43 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "OICQ Protocol ");
|
2006-01-03 23:59:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (tree) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_oicq, tvb, 0, -1, ENC_NA);
|
2006-01-03 23:59:13 +00:00
|
|
|
oicq_tree = proto_item_add_subtree(ti, ett_oicq);
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(oicq_tree, hf_oicq_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2006-01-03 23:59:13 +00:00
|
|
|
offset += 1;
|
2011-10-21 02:10:19 +00:00
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(oicq_tree, hf_oicq_version, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2006-01-03 23:59:13 +00:00
|
|
|
offset += 2;
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(oicq_tree, hf_oicq_command, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2006-01-03 23:59:13 +00:00
|
|
|
offset += 2;
|
|
|
|
|
2006-07-10 05:05:01 +00:00
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(oicq_tree, hf_oicq_seq, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2006-07-10 05:05:01 +00:00
|
|
|
offset += 2;
|
|
|
|
|
2011-10-16 23:38:49 +00:00
|
|
|
proto_tree_add_item(oicq_tree, hf_oicq_qqid, tvb, offset, 4, ENC_BIG_ENDIAN);
|
2006-07-10 05:05:01 +00:00
|
|
|
offset += 4;
|
2011-10-21 02:10:19 +00:00
|
|
|
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item(oicq_tree, hf_oicq_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
|
2011-10-21 02:10:19 +00:00
|
|
|
|
|
|
|
|
2006-01-03 23:59:13 +00:00
|
|
|
}
|
2011-10-21 02:10:19 +00:00
|
|
|
|
2008-05-17 23:40:07 +00:00
|
|
|
return tvb_length(tvb);
|
2006-01-03 23:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_oicq(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_oicq_flag, {
|
|
|
|
"Flag", "oicq.flag", FT_UINT8, BASE_HEX,
|
|
|
|
VALS(oicq_flag_vals), 0, "Protocol Flag", HFILL }},
|
2006-07-10 05:05:01 +00:00
|
|
|
{ &hf_oicq_version, {
|
|
|
|
"Version", "oicq.version", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0, "Version-zz", HFILL }},
|
2006-01-03 23:59:13 +00:00
|
|
|
{ &hf_oicq_command, {
|
|
|
|
"Command", "oicq.command", FT_UINT16, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
VALS(oicq_command_vals), 0, NULL, HFILL }},
|
2006-07-10 05:05:01 +00:00
|
|
|
{ &hf_oicq_seq, {
|
|
|
|
"Sequence", "oicq.seq", FT_UINT16, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0, NULL, HFILL }},
|
2006-07-10 05:05:01 +00:00
|
|
|
{ &hf_oicq_qqid, {
|
|
|
|
"Data(OICQ Number,if sender is client)", "oicq.qqid", FT_UINT32, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0, NULL, HFILL }},
|
2006-01-03 23:59:13 +00:00
|
|
|
{ &hf_oicq_data, {
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
"Data", "oicq.data", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0, NULL, HFILL }},
|
2006-01-03 23:59:13 +00:00
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_oicq,
|
|
|
|
};
|
|
|
|
|
2006-07-10 05:05:01 +00:00
|
|
|
proto_oicq = proto_register_protocol("OICQ - IM software, popular in China", "OICQ",
|
2006-01-03 23:59:13 +00:00
|
|
|
"oicq");
|
|
|
|
proto_register_field_array(proto_oicq, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_oicq(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t oicq_handle;
|
|
|
|
|
2008-05-17 23:40:07 +00:00
|
|
|
oicq_handle = new_create_dissector_handle(dissect_oicq, proto_oicq);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("udp.port", UDP_PORT_OICQ, oicq_handle);
|
2006-01-03 23:59:13 +00:00
|
|
|
}
|
|
|
|
|