Skip to content

Commit 966c33e

Browse files
andrewchiGitHub Enterprise
authored andcommitted
Merge branch 'dev' into new-cbor-fps
2 parents df34f7c + e5148c1 commit 966c33e

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

src/cbor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int main(int argc, char *argv[]) {
8787
}
8888
}
8989
if (decode_fdc) {
90-
static const size_t MAX_FP_STR_LEN = 4096;
90+
static const size_t MAX_FP_STR_LEN = 8192;
9191
char fp_str[MAX_FP_STR_LEN];
9292
char dst_ip_str[MAX_ADDR_STR_LEN];
9393
char sn_str[MAX_SNI_LEN];

src/libmerc/analysis.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ class classifier {
474474
return fingerprint_type_quic;
475475
} else if (s == "tofsee") {
476476
return fingerprint_type_tofsee;
477+
} else if (s == "ssh") {
478+
return fingerprint_type_ssh;
477479
}
478480
return fingerprint_type_unknown;
479481
}
@@ -530,6 +532,8 @@ class classifier {
530532
type = fingerprint_type_quic;
531533
} else if (s.compare(0, idx, "tofsee") == 0) {
532534
type = fingerprint_type_tofsee;
535+
} else if (s.compare(0, idx, "ssh") == 0) {
536+
type = fingerprint_type_ssh;
533537
}
534538
std::string version_and_tail{s.substr(idx+1)};
535539

src/libmerc/fdc.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ class fdc {
785785

786786
// decode the data in the buffer to decoded_fdc
787787
//
788-
static const size_t MAX_FP_STR_LEN = 4096;
788+
static const size_t MAX_FP_STR_LEN = 8192;
789789
char fp_str[MAX_FP_STR_LEN];
790790
char dst_ip_str[MAX_ADDR_STR_LEN];
791791
char sn_str[MAX_SNI_LEN];
@@ -840,7 +840,7 @@ class fdc {
840840

841841
[[maybe_unused]] static std::string get_json_decoded_fdc(const char *fdc_blob, ssize_t blob_len) {
842842
datum fdc_data = datum{(uint8_t*)fdc_blob,(uint8_t*)(fdc_blob+blob_len)};
843-
static const size_t MAX_FP_STR_LEN = 4096;
843+
static const size_t MAX_FP_STR_LEN = 8192;
844844
char fp_str[MAX_FP_STR_LEN];
845845
char dst_ip_str[MAX_ADDR_STR_LEN];
846846
char sn_str[MAX_SNI_LEN];

src/libmerc/fingerprint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class fingerprint {
1414
enum fingerprint_type type;
15-
static const size_t MAX_FP_STR_LEN = 4096;
15+
static const size_t MAX_FP_STR_LEN = 8192;
1616
char fp_str[MAX_FP_STR_LEN];
1717
struct buffer_stream fp_buf;
1818

src/libmerc/pkt_proc.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ struct do_observation {
247247
analysis_.reset_user_agent();
248248
}
249249

250+
void operator()(ssh_init_packet &m) {
251+
// create event and send it to the data/stats aggregator
252+
event_string ev_str{k_, analysis_, m};
253+
mq_->push(ev_str.construct_event_string());
254+
analysis_.reset_user_agent();
255+
}
256+
250257
template <typename T>
251258
void operator()(T &) { }
252259

src/libmerc/ssh.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,11 @@ struct ssh_init_packet : public base_protocol {
328328
struct datum comment_string;
329329
ssh_binary_packet binary_pkt;
330330
ssh_kex_init kex_pkt;
331+
data_buffer<MAX_USER_AGENT_LEN> user_agent;
331332

332333
static constexpr size_t max_data_size = 8192;
333334

334-
ssh_init_packet(datum &p) : protocol_string{NULL, NULL}, comment_string{NULL, NULL}, binary_pkt{}, kex_pkt{} {
335+
ssh_init_packet(datum &p) : protocol_string{NULL, NULL}, comment_string{NULL, NULL}, binary_pkt{}, kex_pkt{}, user_agent{} {
335336
parse(p);
336337
}
337338

@@ -462,6 +463,24 @@ struct ssh_init_packet : public base_protocol {
462463
{ 'S', 'S', 'H', '-', 0x00, 0x00, 0x00, 0x00}
463464
};
464465

466+
bool do_analysis(const struct key &k_, struct analysis_context &analysis_, classifier *c_) {
467+
if (!kex_pkt.is_not_empty()) {
468+
return false;
469+
}
470+
471+
// concatenate protocol and comment strings for analysis
472+
datum tmp_protocol_str = protocol_string;
473+
datum tmp_comment_str = comment_string;
474+
user_agent.parse(tmp_protocol_str);
475+
user_agent.parse(tmp_comment_str);
476+
477+
analysis_.destination.init({nullptr, nullptr}, user_agent.contents(), {nullptr, nullptr}, k_);
478+
if (c_ == nullptr) {
479+
return false;
480+
}
481+
return c_->analyze_fingerprint_and_destination_context(analysis_.fp, analysis_.destination, analysis_.result);
482+
}
483+
465484
};
466485

467486
[[maybe_unused]] inline int ssh_init_packet_fuzz_test(const uint8_t *data, size_t size) {

0 commit comments

Comments
 (0)