summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorzhuzhenjun <[email protected]>2023-10-23 09:52:21 +0800
committerzhuzhenjun <[email protected]>2023-10-23 09:52:21 +0800
commit77a47deb92e53cb54bc33f20717ddf6342adada0 (patch)
tree459470d3d8a0bec6cf40f41867e73fa66b05414a /example
parent1de666a56e3d275de0525b77eb97d30e7719430b (diff)
example: print fingerprints
Diffstat (limited to 'example')
-rw-r--r--example/osfp_example.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/example/osfp_example.c b/example/osfp_example.c
index 2a53ac6..a9b3017 100644
--- a/example/osfp_example.c
+++ b/example/osfp_example.c
@@ -431,7 +431,7 @@ const char *PrintInet(int af, const void *src, char *dst, socklen_t size)
void example_detect(struct osfp_db *osfp_db, Packet *p)
{
int ret;
- char str_buf[1024];
+ char str_buf[1024] = "";
//unsigned char *iph = (unsigned char *)(p->iph != NULL ? (void *)p->iph : (void *)p->ip6h);
struct iphdr *iph;
struct ip6_hdr *ip6h;
@@ -448,11 +448,15 @@ void example_detect(struct osfp_db *osfp_db, Packet *p)
osfp_profile_cycle(c2);
+ struct osfp_fingerprint fp = {0};
+
osfp_profile_get_cycle(c1);
if (iph) {
result = osfp_ipv4_identify(osfp_db, iph, tcph, tcph_len);
+ osfp_fingerprinting(iph, tcph, tcph_len, &fp, 4);
} else if (ip6h) {
result = osfp_ipv6_identify(osfp_db, ip6h, tcph, tcph_len);
+ osfp_fingerprinting(iph, tcph, tcph_len, &fp, 6);
} else {
goto exit;
}
@@ -471,6 +475,9 @@ void example_detect(struct osfp_db *osfp_db, Packet *p)
char *json = osfp_result_score_detail_export(result);
+ osfp_fingerprint_to_json_buf(&fp, str_buf, 2048, 0);
+ printf("%s\n", str_buf);
+
if (1) {
printf("Example ipv4 header detect: --------------------------\n");
printf("Connection info: %s:%d -> %s:%d\n", p->srcip, p->sp, p->dstip, p->dp);