Skip to content

Commit 1445d7f

Browse files
authored
Merge pull request #152 from CESNET/ovpn_enhacment
Better detection of OVPN protocol
2 parents 7ac3641 + 2fbff88 commit 1445d7f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

process/ovpn.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ void OVPNPlugin::update_record(RecordExtOVPN* vpn_data, const Packet &pkt)
151151
vpn_data->status = status_data;
152152
vpn_data->invalid_pkt_cnt = -1;
153153
}
154-
vpn_data->data_pkt_cnt++;
154+
if (pkt.payload_len_wire > c_min_data_packet_size) {
155+
vpn_data->data_pkt_cnt++;
156+
}
155157
break;
156158

157159
//no opcode
@@ -189,6 +191,14 @@ int OVPNPlugin::pre_update(Flow &rec, Packet &pkt)
189191
void OVPNPlugin::pre_export(Flow &rec)
190192
{
191193
RecordExtOVPN *vpn_data = (RecordExtOVPN *) rec.get_extension(RecordExtOVPN::REGISTERED_ID);
194+
195+
//do not export ovpn for short flows, usually port scans
196+
uint32_t packets = rec.src_packets + rec.dst_packets;
197+
if (packets <= min_pckt_export_treshold) {
198+
rec.remove_extension(RecordExtOVPN::REGISTERED_ID);
199+
return;
200+
}
201+
192202
if (vpn_data->pkt_cnt > min_pckt_treshold && vpn_data->status == status_data) {
193203
vpn_data->possible_vpn = 100;
194204
} else if (vpn_data->pkt_cnt > min_pckt_treshold && ((double) vpn_data->data_pkt_cnt / (double) vpn_data->pkt_cnt) >= data_pckt_treshold) {

process/ovpn.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ class OVPNPlugin : public ProcessPlugin
137137
udp = 17
138138
} e_ip_proto_nbr;
139139

140+
static const uint32_t c_min_data_packet_size = 500;
140141
static const uint32_t c_udp_opcode_index = 0;
141142
static const uint32_t c_tcp_opcode_index = 2;
142143
static const uint32_t min_pckt_treshold = 20;
144+
static const uint32_t min_pckt_export_treshold = 5;
143145
static constexpr float data_pckt_treshold = 0.6f;
144146
static const int32_t invalid_pckt_treshold = 4;
145147
static const uint32_t min_opcode = 1;

tests/functional/reference/ovpn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
192.168.43.91,90.178.247.107,1380,0,0,2019-10-05T15:25:12.103104,2019-10-05T15:25:54.374882,3c:6a:a7:fc:00:67,20:39:56:43:58:45,6,0,60753,10102,0,0,17,0,0
2-
192.168.43.91,90.178.247.107,204,0,0,2019-10-05T15:25:20.027044,2019-10-05T15:25:40.347067,3c:6a:a7:fc:00:67,20:39:56:43:58:45,3,0,62158,10100,0,0,17,0,0
32
90.178.247.107,192.168.43.91,49004,64203,0,2019-10-05T15:25:16.735147,2019-10-05T15:25:54.118079,20:39:56:43:58:45,3c:6a:a7:fc:00:67,164,166,10103,54113,0,100,6,30,26
43
ipaddr DST_IP,ipaddr SRC_IP,uint64 BYTES,uint64 BYTES_REV,uint64 LINK_BIT_FIELD,time TIME_FIRST,time TIME_LAST,macaddr DST_MAC,macaddr SRC_MAC,uint32 PACKETS,uint32 PACKETS_REV,uint16 DST_PORT,uint16 SRC_PORT,uint8 DIR_BIT_FIELD,uint8 OVPN_CONF_LEVEL,uint8 PROTOCOL,uint8 TCP_FLAGS,uint8 TCP_FLAGS_REV

0 commit comments

Comments
 (0)