2013-03-01 02:07:58 +00:00
|
|
|
/* packet-hpfeeds.c
|
|
|
|
* Routines for Honeypot Protocol Feeds packet disassembly
|
|
|
|
* Copyright 2013, Sebastiano DI PAOLA - <sebastiano.dipaola@gmail.com>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2013-03-01 02:07:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Additional information regarding hpfeeds protocol can be found here
|
|
|
|
* https://redmine.honeynet.org/projects/hpfeeds/wiki
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/prefs.h>
|
|
|
|
#include <epan/expert.h>
|
2015-01-13 14:13:27 +00:00
|
|
|
#include <epan/tap.h>
|
|
|
|
#include <epan/stats_tree.h>
|
|
|
|
#include <epan/wmem/wmem_list.h>
|
2013-03-01 02:07:58 +00:00
|
|
|
|
|
|
|
#include "packet-tcp.h"
|
|
|
|
|
2015-01-13 14:13:27 +00:00
|
|
|
struct HpfeedsTap {
|
|
|
|
guint payload_size;
|
|
|
|
guint8* channel;
|
|
|
|
guint8 opcode;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int hpfeeds_tap = -1;
|
|
|
|
|
|
|
|
static const guint8* st_str_channels_payload = "Payload size per channel";
|
|
|
|
static const guint8* st_str_opcodes = "Opcodes";
|
|
|
|
|
|
|
|
static int st_node_channels_payload = -1;
|
|
|
|
static int st_node_opcodes = -1;
|
|
|
|
|
|
|
|
static wmem_list_t* channels_list;
|
|
|
|
|
|
|
|
struct channel_node {
|
|
|
|
guint8* channel;
|
|
|
|
guint st_node_channel_payload;
|
|
|
|
};
|
|
|
|
|
2013-12-15 23:44:12 +00:00
|
|
|
void proto_register_hpfeeds(void);
|
|
|
|
void proto_reg_handoff_hpfeeds(void);
|
|
|
|
|
2015-01-02 20:33:49 +00:00
|
|
|
static heur_dissector_list_t heur_subdissector_list;
|
|
|
|
|
2013-04-02 15:55:35 +00:00
|
|
|
/* Preferences */
|
2013-03-01 02:07:58 +00:00
|
|
|
static gboolean hpfeeds_desegment = TRUE;
|
2015-01-02 20:33:49 +00:00
|
|
|
static gboolean try_heuristic = TRUE;
|
2013-03-01 02:07:58 +00:00
|
|
|
|
|
|
|
static int proto_hpfeeds = -1;
|
|
|
|
|
|
|
|
static int hf_hpfeeds_opcode = -1;
|
|
|
|
static int hf_hpfeeds_msg_length = -1;
|
|
|
|
static int hf_hpfeeds_nonce = -1;
|
|
|
|
static int hf_hpfeeds_secret = -1;
|
2013-10-13 19:56:52 +00:00
|
|
|
static int hf_hpfeeds_payload = -1;
|
|
|
|
static int hf_hpfeeds_server_len = -1;
|
|
|
|
static int hf_hpfeeds_server = -1;
|
2013-03-01 02:07:58 +00:00
|
|
|
static int hf_hpfeeds_ident_len = -1;
|
|
|
|
static int hf_hpfeeds_ident = -1;
|
|
|
|
static int hf_hpfeeds_channel = -1;
|
|
|
|
static int hf_hpfeeds_chan_len = -1;
|
|
|
|
static int hf_hpfeeds_errmsg = -1;
|
|
|
|
|
|
|
|
static gint ett_hpfeeds = -1;
|
|
|
|
|
2013-05-26 03:29:07 +00:00
|
|
|
static expert_field ei_hpfeeds_opcode_unknown = EI_INIT;
|
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
/* OPCODE */
|
|
|
|
#define OP_ERROR 0 /* error message*/
|
|
|
|
#define OP_INFO 1 /* server name, nonce */
|
|
|
|
#define OP_AUTH 2 /* client id, sha1(nonce+authkey) */
|
|
|
|
#define OP_PUBLISH 3 /* client id, channelname, payload */
|
|
|
|
#define OP_SUBSCRIBE 4 /* client id, channelname*/
|
|
|
|
|
|
|
|
/* OFFSET FOR HEADER */
|
|
|
|
#define HPFEEDS_HDR_LEN 5
|
|
|
|
|
|
|
|
static const value_string opcode_vals[] = {
|
2013-04-02 15:55:35 +00:00
|
|
|
{ OP_ERROR, "Error" },
|
|
|
|
{ OP_INFO, "Info" },
|
|
|
|
{ OP_AUTH, "Auth" },
|
|
|
|
{ OP_PUBLISH, "Publish" },
|
|
|
|
{ OP_SUBSCRIBE, "Subscribe" },
|
|
|
|
{ 0, NULL },
|
2013-03-01 02:07:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_hpfeeds_error_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
|
|
|
|
{
|
2014-04-06 14:57:33 +00:00
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_errmsg, tvb, offset, -1, ENC_ASCII|ENC_NA);
|
2013-10-13 19:56:52 +00:00
|
|
|
}
|
2013-03-01 02:07:58 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_hpfeeds_info_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
|
|
|
|
{
|
|
|
|
guint8 len = 0;
|
2014-08-09 17:43:44 +00:00
|
|
|
proto_tree *data_subtree;
|
2013-03-01 02:07:58 +00:00
|
|
|
guint8 *strptr = NULL;
|
|
|
|
|
|
|
|
len = tvb_get_guint8(tvb, offset);
|
|
|
|
/* don't move the offset yet as we need to get data after this operation */
|
2014-06-17 15:30:58 +00:00
|
|
|
strptr = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, len, ENC_ASCII);
|
2014-08-09 17:43:44 +00:00
|
|
|
data_subtree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_hpfeeds, NULL, "Broker: %s", strptr);
|
2013-03-01 02:07:58 +00:00
|
|
|
|
|
|
|
proto_tree_add_item(data_subtree, hf_hpfeeds_server_len, tvb, offset, 1,
|
|
|
|
ENC_BIG_ENDIAN);
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
proto_tree_add_item(data_subtree, hf_hpfeeds_server, tvb, offset, len,
|
2014-04-06 14:57:33 +00:00
|
|
|
ENC_ASCII|ENC_NA);
|
2013-10-13 19:56:52 +00:00
|
|
|
offset += len;
|
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
proto_tree_add_item(data_subtree, hf_hpfeeds_nonce, tvb, offset, -1,
|
2014-04-06 14:57:33 +00:00
|
|
|
ENC_NA);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_hpfeeds_auth_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
|
|
|
|
{
|
|
|
|
guint8 len = 0;
|
2013-10-13 19:56:52 +00:00
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
len = tvb_get_guint8(tvb, offset);
|
2013-10-13 19:56:52 +00:00
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_ident_len, tvb,
|
2013-03-01 02:07:58 +00:00
|
|
|
offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
offset += 1;
|
2013-10-13 19:56:52 +00:00
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_ident, tvb,
|
2014-04-06 14:57:33 +00:00
|
|
|
offset, len, ENC_ASCII|ENC_NA);
|
2013-10-13 19:56:52 +00:00
|
|
|
offset += len;
|
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_secret, tvb,
|
2014-04-06 14:57:33 +00:00
|
|
|
offset, -1, ENC_NA);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
2015-01-13 14:13:27 +00:00
|
|
|
static guint8*
|
|
|
|
hpfeeds_get_channel_name(tvbuff_t* tvb, guint offset)
|
|
|
|
{
|
|
|
|
guint8 len = tvb_get_guint8(tvb, offset);
|
|
|
|
offset += len + 1;
|
|
|
|
len = tvb_get_guint8(tvb, offset);
|
|
|
|
offset += 1;
|
|
|
|
return tvb_get_string_enc(wmem_file_scope(), tvb, offset, len, ENC_ASCII);
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
hpfeeds_get_payload_size(tvbuff_t* tvb, guint offset)
|
|
|
|
{
|
|
|
|
guint message_len = tvb_get_ntohl(tvb, offset);
|
|
|
|
guint ident_len = tvb_get_guint8(tvb, offset + 5);
|
|
|
|
guint channel_len = tvb_get_guint8(tvb, offset + 6 + ident_len);
|
|
|
|
return (message_len - 2 - ident_len - 1 - channel_len);
|
|
|
|
}
|
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
static void
|
2013-04-02 15:55:35 +00:00
|
|
|
dissect_hpfeeds_publish_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|
|
|
guint offset)
|
2013-03-01 02:07:58 +00:00
|
|
|
{
|
|
|
|
guint8 len = 0;
|
2015-01-02 20:33:49 +00:00
|
|
|
heur_dtbl_entry_t *hdtbl_entry;
|
|
|
|
tvbuff_t *next_tvb;
|
2016-10-28 21:00:24 +00:00
|
|
|
const guint8 *channelname = NULL;
|
|
|
|
const char* save_match_string = NULL;
|
2013-03-01 02:07:58 +00:00
|
|
|
|
|
|
|
len = tvb_get_guint8(tvb, offset);
|
2015-01-02 20:33:49 +00:00
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_ident_len, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2013-03-01 02:07:58 +00:00
|
|
|
offset += 1;
|
2015-01-02 20:33:49 +00:00
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_ident, tvb, offset, len, ENC_ASCII|ENC_NA);
|
2013-10-13 19:56:52 +00:00
|
|
|
offset += len;
|
2013-03-01 02:07:58 +00:00
|
|
|
len = tvb_get_guint8(tvb, offset);
|
2015-01-02 20:33:49 +00:00
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_chan_len, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2016-10-28 21:00:24 +00:00
|
|
|
offset += 1;
|
2013-10-13 19:56:52 +00:00
|
|
|
|
2016-10-28 21:00:24 +00:00
|
|
|
/* get the channel name as ephemeral string to pass it to the heuristic decoders */
|
|
|
|
proto_tree_add_item_ret_string(tree, hf_hpfeeds_channel, tvb, offset, len, ENC_ASCII|ENC_NA,
|
|
|
|
wmem_packet_scope(), &channelname);
|
|
|
|
offset += len;
|
2015-01-02 20:33:49 +00:00
|
|
|
|
|
|
|
/* try the heuristic dissectors */
|
|
|
|
if (try_heuristic) {
|
2016-10-28 21:00:24 +00:00
|
|
|
/* save the current match_string before calling the subdissectors */
|
|
|
|
if (pinfo->match_string)
|
|
|
|
save_match_string = pinfo->match_string;
|
|
|
|
pinfo->match_string = channelname;
|
|
|
|
|
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
|
|
|
|
2016-10-28 15:10:02 +00:00
|
|
|
if (dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
|
2015-01-02 20:33:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-10-28 21:00:24 +00:00
|
|
|
|
|
|
|
pinfo->match_string = save_match_string;
|
2015-01-02 20:33:49 +00:00
|
|
|
}
|
2013-03-01 02:07:58 +00:00
|
|
|
|
2015-01-02 20:33:49 +00:00
|
|
|
/* heuristic failed. Print remaining bytes as flat payload */
|
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_payload, tvb, offset, -1, ENC_NA);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
2015-01-13 14:13:27 +00:00
|
|
|
static void hpfeeds_stats_tree_init(stats_tree* st)
|
|
|
|
{
|
2018-12-27 19:47:02 +00:00
|
|
|
st_node_channels_payload = stats_tree_create_node(st, st_str_channels_payload, 0, STAT_DT_INT, TRUE);
|
2015-01-13 14:13:27 +00:00
|
|
|
st_node_opcodes = stats_tree_create_pivot(st, st_str_opcodes, 0);
|
|
|
|
|
|
|
|
channels_list = wmem_list_new(wmem_epan_scope());
|
|
|
|
}
|
|
|
|
|
2019-01-01 03:36:12 +00:00
|
|
|
static tap_packet_status hpfeeds_stats_tree_packet(stats_tree* st _U_, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* p)
|
2015-01-13 14:13:27 +00:00
|
|
|
{
|
2015-12-28 20:43:46 +00:00
|
|
|
const struct HpfeedsTap *pi = (const struct HpfeedsTap *)p;
|
2015-01-13 14:13:27 +00:00
|
|
|
wmem_list_frame_t* head = wmem_list_head(channels_list);
|
|
|
|
wmem_list_frame_t* cur = head;
|
|
|
|
struct channel_node* ch_node;
|
|
|
|
|
|
|
|
if (pi->opcode == OP_PUBLISH) {
|
|
|
|
/* search an existing channel node and create it if it does not */
|
|
|
|
while(cur != NULL) {
|
|
|
|
ch_node = (struct channel_node*)wmem_list_frame_data(cur);
|
|
|
|
if (strncmp(ch_node->channel, pi->channel, strlen(pi->channel)) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cur = wmem_list_frame_next(cur);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur == NULL) {
|
|
|
|
ch_node = (struct channel_node*)wmem_alloc0(wmem_file_scope(), sizeof(struct channel_node));
|
|
|
|
ch_node->channel = wmem_strdup(wmem_file_scope(), pi->channel);
|
|
|
|
ch_node->st_node_channel_payload = stats_tree_create_node(st, ch_node->channel,
|
2018-12-27 19:47:02 +00:00
|
|
|
st_node_channels_payload, STAT_DT_INT, FALSE);
|
2015-01-13 14:13:27 +00:00
|
|
|
wmem_list_append(channels_list, ch_node);
|
|
|
|
}
|
|
|
|
|
2018-12-27 19:47:02 +00:00
|
|
|
avg_stat_node_add_value_int(st, st_str_channels_payload, 0, FALSE, pi->payload_size);
|
|
|
|
avg_stat_node_add_value_int(st, ch_node->channel, 0, FALSE, pi->payload_size);
|
2015-01-13 14:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stats_tree_tick_pivot(st, st_node_opcodes,
|
|
|
|
val_to_str(pi->opcode, opcode_vals, "Unknown opcode (%d)"));
|
2019-01-01 03:36:12 +00:00
|
|
|
return TAP_PACKET_REDRAW;
|
2015-01-13 14:13:27 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
static void
|
|
|
|
dissect_hpfeeds_subscribe_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
|
|
|
|
{
|
|
|
|
guint8 len = 0;
|
2013-10-13 19:56:52 +00:00
|
|
|
/* get length of ident field */
|
2013-03-01 02:07:58 +00:00
|
|
|
len = tvb_get_guint8(tvb, offset);
|
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_ident_len, tvb, offset, 1,
|
|
|
|
ENC_BIG_ENDIAN);
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_ident, tvb, offset, len,
|
2014-04-06 14:57:33 +00:00
|
|
|
ENC_ASCII|ENC_NA);
|
2013-03-01 02:07:58 +00:00
|
|
|
/* move forward inside data */
|
|
|
|
offset += len;
|
|
|
|
proto_tree_add_item(tree, hf_hpfeeds_channel, tvb, offset, -1,
|
2014-04-06 14:57:33 +00:00
|
|
|
ENC_ASCII|ENC_NA);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the length of the HPFEED message, including header
|
|
|
|
* This is a trivial function, but it's mandatory as it is used as a callback
|
|
|
|
* by the routine to re-assemble the protocol spread on multiple TCP packets
|
|
|
|
*/
|
|
|
|
static guint
|
2015-01-25 19:30:13 +00:00
|
|
|
get_hpfeeds_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
|
2013-03-01 02:07:58 +00:00
|
|
|
{
|
2013-04-02 15:55:35 +00:00
|
|
|
return tvb_get_ntohl(tvb, offset + 0);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
2013-11-09 17:46:28 +00:00
|
|
|
static int
|
|
|
|
dissect_hpfeeds_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2013-03-01 02:07:58 +00:00
|
|
|
{
|
2015-01-13 14:13:27 +00:00
|
|
|
struct HpfeedsTap *hpfeeds_stats;
|
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
/* We have already parsed msg length we need to skip to opcode offset */
|
2013-11-11 04:01:50 +00:00
|
|
|
guint offset = 0;
|
2013-03-01 02:07:58 +00:00
|
|
|
|
|
|
|
guint8 opcode;
|
|
|
|
proto_item *ti;
|
2013-11-11 04:01:50 +00:00
|
|
|
proto_tree *hpfeeds_tree, *data_subtree;
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "HPFEEDS");
|
|
|
|
|
|
|
|
ti = proto_tree_add_item(tree, proto_hpfeeds, tvb, 0, -1, ENC_NA);
|
|
|
|
hpfeeds_tree = proto_item_add_subtree(ti, ett_hpfeeds);
|
|
|
|
proto_tree_add_item(hpfeeds_tree, hf_hpfeeds_msg_length, tvb, offset,
|
|
|
|
4, ENC_BIG_ENDIAN);
|
|
|
|
offset += 4;
|
2013-10-13 19:56:52 +00:00
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
/* Get opcode and write it */
|
|
|
|
opcode = tvb_get_guint8(tvb, offset);
|
|
|
|
|
|
|
|
/* Clear out stuff in the info column */
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Type %s",
|
|
|
|
val_to_str(opcode, opcode_vals, "Unknown (0x%02x)"));
|
|
|
|
|
2013-11-11 04:01:50 +00:00
|
|
|
ti = proto_tree_add_item(hpfeeds_tree, hf_hpfeeds_opcode, tvb, offset,
|
2013-03-01 02:07:58 +00:00
|
|
|
1, ENC_BIG_ENDIAN);
|
|
|
|
data_subtree = proto_item_add_subtree(ti, ett_hpfeeds);
|
|
|
|
offset += 1;
|
|
|
|
|
2013-04-02 15:55:35 +00:00
|
|
|
if (opcode >= array_length(opcode_vals) - 1) {
|
2013-09-09 00:44:09 +00:00
|
|
|
expert_add_info_format(pinfo, ti, &ei_hpfeeds_opcode_unknown,
|
2013-03-01 02:07:58 +00:00
|
|
|
"Unknown value %02x for opcode field", opcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) { /* we are being asked for details */
|
|
|
|
switch (opcode) {
|
|
|
|
case OP_ERROR:
|
|
|
|
dissect_hpfeeds_error_pdu(tvb, data_subtree, offset);
|
|
|
|
break;
|
|
|
|
case OP_INFO:
|
|
|
|
dissect_hpfeeds_info_pdu(tvb, data_subtree, offset);
|
|
|
|
break;
|
|
|
|
case OP_AUTH:
|
|
|
|
dissect_hpfeeds_auth_pdu(tvb, data_subtree, offset);
|
|
|
|
break;
|
|
|
|
case OP_PUBLISH:
|
2013-04-02 15:55:35 +00:00
|
|
|
dissect_hpfeeds_publish_pdu(tvb, pinfo, data_subtree, offset);
|
2013-03-01 02:07:58 +00:00
|
|
|
break;
|
|
|
|
case OP_SUBSCRIBE:
|
|
|
|
dissect_hpfeeds_subscribe_pdu(tvb, data_subtree, offset);
|
|
|
|
break;
|
|
|
|
/* No need for a default, we check that outside the if(tree)
|
|
|
|
* block earlier */
|
|
|
|
}
|
|
|
|
}
|
2013-11-09 17:46:28 +00:00
|
|
|
|
2015-01-13 14:13:27 +00:00
|
|
|
/* In publish, generate stats every packet, even not in tree */
|
|
|
|
hpfeeds_stats = wmem_new0(wmem_file_scope(), struct HpfeedsTap);
|
|
|
|
if (opcode == OP_PUBLISH) {
|
|
|
|
hpfeeds_stats->channel = hpfeeds_get_channel_name(tvb, offset);
|
|
|
|
hpfeeds_stats->payload_size = hpfeeds_get_payload_size(tvb, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
hpfeeds_stats->opcode = opcode;
|
|
|
|
tap_queue_packet(hpfeeds_tap, pinfo, hpfeeds_stats);
|
2015-01-02 20:33:49 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
2013-11-09 17:46:28 +00:00
|
|
|
static int
|
|
|
|
dissect_hpfeeds(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
2013-03-01 02:07:58 +00:00
|
|
|
{
|
2013-11-11 04:01:50 +00:00
|
|
|
tcp_dissect_pdus(tvb, pinfo, tree, hpfeeds_desegment, HPFEEDS_HDR_LEN,
|
|
|
|
get_hpfeeds_pdu_len, dissect_hpfeeds_pdu, data);
|
2015-01-02 20:33:49 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_hpfeeds(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
2013-10-13 19:56:52 +00:00
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
{ &hf_hpfeeds_opcode,
|
|
|
|
{ "Opcode", "hpfeeds.opcode",
|
|
|
|
FT_UINT8, BASE_DEC_HEX,
|
|
|
|
VALS(opcode_vals), 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_msg_length,
|
|
|
|
{ "Message Length", "hpfeeds.msglen",
|
|
|
|
FT_UINT32, BASE_DEC_HEX,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_nonce,
|
|
|
|
{ "Nonce", "hpfeeds.nonce",
|
|
|
|
FT_BYTES, BASE_NONE,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_secret,
|
|
|
|
{ "Secret", "hpfeeds.secret",
|
|
|
|
FT_BYTES, BASE_NONE,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_payload,
|
|
|
|
{ "Payload", "hpfeeds.payload",
|
|
|
|
FT_BYTES, BASE_NONE,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_server,
|
|
|
|
{ "Server", "hpfeeds.server",
|
|
|
|
FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_ident,
|
|
|
|
{ "Ident", "hpfeeds.ident",
|
|
|
|
FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_channel,
|
|
|
|
{ "Channel", "hpfeeds.channel",
|
|
|
|
FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_chan_len,
|
|
|
|
{ "Channel length", "hpfeeds.channel_len",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_ident_len,
|
|
|
|
{ "Ident length", "hpfeeds.ident_len",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_errmsg,
|
|
|
|
{ "Error message", "hpfeeds.errmsg",
|
|
|
|
FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_hpfeeds_server_len,
|
|
|
|
{ "Server length", "hpfeeds.server_len",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_hpfeeds
|
|
|
|
};
|
|
|
|
|
2013-05-26 03:29:07 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_hpfeeds_opcode_unknown, { "hpfeeds.opcode.unknown", PI_PROTOCOL, PI_WARN, "Unknown value for opcode field", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
module_t *hpfeeds_module;
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_module_t* expert_hpfeeds;
|
2013-03-01 02:07:58 +00:00
|
|
|
|
|
|
|
proto_hpfeeds = proto_register_protocol (
|
|
|
|
"HPFEEDS HoneyPot Feeds Protocol", /* name */
|
|
|
|
"HPFEEDS", /* short name */
|
|
|
|
"hpfeeds" /* abbrev */
|
|
|
|
);
|
|
|
|
|
2016-03-13 11:51:45 +00:00
|
|
|
heur_subdissector_list = register_heur_dissector_list("hpfeeds", proto_hpfeeds);
|
2015-01-02 20:33:49 +00:00
|
|
|
|
2013-03-01 02:07:58 +00:00
|
|
|
proto_register_field_array(proto_hpfeeds, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_hpfeeds = expert_register_protocol(proto_hpfeeds);
|
|
|
|
expert_register_field_array(expert_hpfeeds, ei, array_length(ei));
|
2013-03-01 02:07:58 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
hpfeeds_module = prefs_register_protocol(proto_hpfeeds, NULL);
|
2013-03-01 02:07:58 +00:00
|
|
|
prefs_register_bool_preference(hpfeeds_module, "desegment_hpfeeds_messages",
|
|
|
|
"Reassemble HPFEEDS messages spanning multiple TCP segments",
|
2013-04-02 15:55:35 +00:00
|
|
|
"Whether the HPFEEDS dissector should reassemble messages spanning "
|
|
|
|
"multiple TCP segments. "
|
|
|
|
"To use this option, you must also enable \"Allow subdissectors to "
|
|
|
|
"reassemble TCP streams\" in the TCP protocol settings.",
|
2013-03-01 02:07:58 +00:00
|
|
|
&hpfeeds_desegment);
|
2013-10-13 19:56:52 +00:00
|
|
|
|
2015-01-02 20:33:49 +00:00
|
|
|
prefs_register_bool_preference(hpfeeds_module, "try_heuristic",
|
|
|
|
"Try heuristic sub-dissectors",
|
|
|
|
"Try to decode the payload using an heuristic sub-dissector",
|
|
|
|
&try_heuristic);
|
2015-01-13 14:13:27 +00:00
|
|
|
|
|
|
|
hpfeeds_tap = register_tap("hpfeeds");
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_hpfeeds(void)
|
|
|
|
{
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_handle_t hpfeeds_handle;
|
2013-04-02 15:55:35 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
hpfeeds_handle = create_dissector_handle(dissect_hpfeeds, proto_hpfeeds);
|
|
|
|
stats_tree_register("hpfeeds", "hpfeeds", "HPFEEDS", 0, hpfeeds_stats_tree_packet, hpfeeds_stats_tree_init, NULL);
|
2013-03-01 02:07:58 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_add_for_decode_as_with_preference("tcp.port", hpfeeds_handle);
|
2013-03-01 02:07:58 +00:00
|
|
|
}
|
2013-04-02 15:55:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|