Skip to content

Commit 6d9ab05

Browse files
authored
Merge pull request #72 from CESNET/hoststats-dns-amp-threshold
hoststats - changed condition for detection of dns amplif. attack
2 parents 9eaaf20 + 1a89b6d commit 6d9ab05

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

hoststatsnemea/src/subprofiles.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ bool DNSSubprofile::update_src_ip(hosts_record_t& main_record, const void* data,
345345

346346
/* Update items */
347347
dns_data_t &src_host_rec = *main_record.dns_data;
348-
if (dir_flags & DIR_FLAG_RSP && ur_get(tmplt, data, F_BYTES) >=
348+
size_t packets_in_flow = ur_get(tmplt, data, F_PACKETS);
349+
if (!packets_in_flow) {
350+
packets_in_flow = 1;
351+
}
352+
if (dir_flags & DIR_FLAG_RSP && (ur_get(tmplt, data, F_BYTES) / packets_in_flow) >=
349353
DNS_BYTES_OVERLIMIT) {
350354
INC(src_host_rec.out_rsp_overlimit_cnt);
351355
}
@@ -366,7 +370,11 @@ bool DNSSubprofile::update_dst_ip(hosts_record_t& main_record, const void* data,
366370

367371
/* Update items */
368372
dns_data_t &dst_host_rec = *main_record.dns_data;
369-
if (dir_flags & DIR_FLAG_RSP && ur_get(tmplt, data, F_BYTES) >=
373+
size_t packets_in_flow = ur_get(tmplt, data, F_PACKETS);
374+
if (!packets_in_flow) {
375+
packets_in_flow = 1;
376+
}
377+
if (dir_flags & DIR_FLAG_RSP && (ur_get(tmplt, data, F_BYTES) / packets_in_flow) >=
370378
DNS_BYTES_OVERLIMIT) {
371379
INC(dst_host_rec.in_rsp_overlimit_cnt);
372380
}

hoststatsnemea/src/subprofiles.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct dns_data_t {
206206
// DNS subprofile
207207
class DNSSubprofile : public SubprofileBase {
208208
private:
209-
// A threshold for excessive flows
209+
// A threshold for excessive average packet size in flows
210210
static const unsigned DNS_BYTES_OVERLIMIT = 1000;
211211

212212
// A filter for incomming flows

0 commit comments

Comments
 (0)