Coverage Report

Created: 2025-08-03 06:32

/src/ndpi/src/lib/protocols/ultrasurf.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * ultrasurf.c
3
 *
4
 * Copyright (C) 2022-23 - ntop.org
5
 *
6
 * nDPI is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * nDPI is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with nDPI.  If not, see <http://www.gnu.org/licenses/>.
18
 *
19
 */
20
21
22
#include "ndpi_protocol_ids.h"
23
24
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_ULTRASURF
25
26
#include "ndpi_api.h"
27
#include "ndpi_private.h"
28
29
static void ndpi_int_ultrasurf_add_connection(struct ndpi_detection_module_struct * const ndpi_struct,
30
                                              struct ndpi_flow_struct * const flow)
31
0
{
32
0
  NDPI_LOG_INFO(ndpi_struct, "found UltraSurf\n");
33
0
  ndpi_set_detected_protocol(ndpi_struct, flow,
34
0
                             NDPI_PROTOCOL_ULTRASURF,
35
0
                             NDPI_PROTOCOL_UNKNOWN,
36
0
                             NDPI_CONFIDENCE_DPI);
37
0
}
38
39
static void ndpi_search_ultrasurf(struct ndpi_detection_module_struct *ndpi_struct,
40
                                  struct ndpi_flow_struct *flow)
41
2.00k
{
42
2.00k
  struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
43
44
2.00k
  NDPI_LOG_DBG(ndpi_struct, "search UltraSurf\n");
45
46
2.00k
  if (packet->payload_packet_len < 8)
47
111
  {
48
111
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
49
111
    return;
50
111
  }
51
52
1.89k
  if (htonl(get_u_int32_t(packet->payload, 0)) == 0xcc1c3041 &&
53
1.89k
      htonl(get_u_int32_t(packet->payload, 4)) == 0x5ba43866)
54
0
  {
55
0
    ndpi_int_ultrasurf_add_connection(ndpi_struct, flow);
56
0
  }
57
58
1.89k
  NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
59
1.89k
}
60
61
void init_ultrasurf_dissector(struct ndpi_detection_module_struct *ndpi_struct)
62
8.01k
{
63
8.01k
  register_dissector("UltraSurf", ndpi_struct,
64
8.01k
                     ndpi_search_ultrasurf,
65
8.01k
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
66
8.01k
                     1, NDPI_PROTOCOL_ULTRASURF);
67
8.01k
}