aboutsummaryrefslogtreecommitdiffstats
path: root/src/fnettrace-sni
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2023-08-08 16:27:18 -0400
committerLibravatar netblue30 <netblue30@protonmail.com>2023-08-08 16:27:18 -0400
commitc4962789fc88e349a0c6a6c51af4a7cfc09fcc99 (patch)
tree83e69a67a17f9962846175e3f5cd0856d5e50de0 /src/fnettrace-sni
parentMerge branch 'master' of ssh://github.com/netblue30/firejail (diff)
downloadfirejail-c4962789fc88e349a0c6a6c51af4a7cfc09fcc99.tar.gz
firejail-c4962789fc88e349a0c6a6c51af4a7cfc09fcc99.tar.zst
firejail-c4962789fc88e349a0c6a6c51af4a7cfc09fcc99.zip
nettrace stats
Diffstat (limited to 'src/fnettrace-sni')
-rw-r--r--src/fnettrace-sni/main.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/fnettrace-sni/main.c b/src/fnettrace-sni/main.c
index d4fbf703a..d0a4f115a 100644
--- a/src/fnettrace-sni/main.c
+++ b/src/fnettrace-sni/main.c
@@ -32,16 +32,15 @@ static char last[512] = {'\0'};
32static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) { 32static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) {
33 assert(pkt); 33 assert(pkt);
34 34
35 // expecting a handshake packet and client hello
36 if (pkt[0] != 0x16 || pkt[5] != 0x01)
37 return;
38
35 char ip[30]; 39 char ip[30];
36 sprintf(ip, "%d.%d.%d.%d", PRINT_IP(ip_dest)); 40 sprintf(ip, "%d.%d.%d.%d", PRINT_IP(ip_dest));
37 time_t seconds = time(NULL); 41 time_t seconds = time(NULL);
38 struct tm *t = localtime(&seconds); 42 struct tm *t = localtime(&seconds);
39 43
40 // expecting a handshake packet and client hello
41 if (pkt[0] != 0x16 || pkt[5] != 0x01)
42 goto errout;
43
44
45 // look for server name indication 44 // look for server name indication
46 unsigned char *ptr = pkt; 45 unsigned char *ptr = pkt;
47 unsigned int i = 0; 46 unsigned int i = 0;
@@ -74,7 +73,7 @@ static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) {
74 if (name) { 73 if (name) {
75 // filter output 74 // filter output
76 char tmp[sizeof(last)]; 75 char tmp[sizeof(last)];
77 snprintf(tmp, sizeof(last), "%02d:%02d:%02d %-15s %s", t->tm_hour, t->tm_min, t->tm_sec, ip, name); 76 snprintf(tmp, sizeof(last), "%02d:%02d:%02d %-15s SNI %s", t->tm_hour, t->tm_min, t->tm_sec, ip, name);
78 if (strcmp(tmp, last)) { 77 if (strcmp(tmp, last)) {
79 printf("%s\n", tmp); 78 printf("%s\n", tmp);
80 fflush(0); 79 fflush(0);
@@ -85,11 +84,6 @@ static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) {
85 goto nosni; 84 goto nosni;
86 return; 85 return;
87 86
88errout:
89 printf("%02d:%02d:%02d %-15s Error: invalid TLS packet\n", t->tm_hour, t->tm_min, t->tm_sec, ip);
90 fflush(0);
91 return;
92
93nosni: 87nosni:
94 printf("%02d:%02d:%02d %-15s no SNI\n", t->tm_hour, t->tm_min, t->tm_sec, ip); 88 printf("%02d:%02d:%02d %-15s no SNI\n", t->tm_hour, t->tm_min, t->tm_sec, ip);
95 return; 89 return;