aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--etc/profile-m-z/mov-cli.profile2
-rw-r--r--src/fnettrace/Makefile7
-rw-r--r--src/fnettrace/main.c34
-rw-r--r--src/fnettrace/radix.c93
-rw-r--r--src/fnettrace/radix.h2
-rw-r--r--src/fnettrace/static-ip-map.txt (renamed from src/fnettrace/static-ip-map)137
7 files changed, 269 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 1d1d81566..35bd9dc44 100644
--- a/Makefile
+++ b/Makefile
@@ -160,6 +160,7 @@ clean:
160 rm -f $(SECCOMP_FILTERS) 160 rm -f $(SECCOMP_FILTERS)
161 rm -f $(MANPAGES) $(MANPAGES:%=%.gz) firejail*.rpm 161 rm -f $(MANPAGES) $(MANPAGES:%=%.gz) firejail*.rpm
162 rm -f $(SYNTAX_FILES) 162 rm -f $(SYNTAX_FILES)
163 rm -f src/fnettrace/static-ip-map
163 rm -f test/utils/index.html* 164 rm -f test/utils/index.html*
164 rm -f test/utils/wget-log 165 rm -f test/utils/wget-log
165 rm -f test/utils/firejail-test-file* 166 rm -f test/utils/firejail-test-file*
diff --git a/etc/profile-m-z/mov-cli.profile b/etc/profile-m-z/mov-cli.profile
index 74d630e24..c5f764912 100644
--- a/etc/profile-m-z/mov-cli.profile
+++ b/etc/profile-m-z/mov-cli.profile
@@ -22,7 +22,7 @@ notv
22disable-mnt 22disable-mnt
23private-bin ffmpeg,fzf,mov-cli 23private-bin ffmpeg,fzf,mov-cli
24#private-cache 24#private-cache
25private-etc alsa,alternatives,asound.conf,ca-certificates,crypto-policies,fonts,host.conf,hostname,hosts,ld.so.cache,ld.so.conf,ld.so.conf.d,ld.so.preload,locale,locale.alias,locale.conf,localtime,machine-id,mime.types,nsswitch.conf,pango,pki,protocols,pulse,resolv.conf,rpc,services,ssl,X11,xdg 25private-etc alsa,alternatives,asound.conf,ca-certificates,crypto-policies,fonts,group,host.conf,hostname,hosts,ld.so.cache,ld.so.conf,ld.so.conf.d,ld.so.preload,locale,locale.alias,locale.conf,localtime,machine-id,magic,magic.mgc,mime.types,nsswitch.conf,pango,passwd,pki,protocols,pulse,resolv.conf,rpc,services,ssl,X11,xdg
26private-tmp 26private-tmp
27 27
28# Redirect 28# Redirect
diff --git a/src/fnettrace/Makefile b/src/fnettrace/Makefile
index fe74afda2..9748a3b47 100644
--- a/src/fnettrace/Makefile
+++ b/src/fnettrace/Makefile
@@ -7,3 +7,10 @@ PROG = fnettrace
7TARGET = $(PROG) 7TARGET = $(PROG)
8 8
9include $(ROOT)/src/prog.mk 9include $(ROOT)/src/prog.mk
10
11all: $(TARGET) static-ip-map
12static-ip-map: static-ip-map.txt fnettrace
13 ./fnettrace --squash-map=static-ip-map.txt > static-ip-map
14
15
16
diff --git a/src/fnettrace/main.c b/src/fnettrace/main.c
index 3eb7a13f5..2d5072379 100644
--- a/src/fnettrace/main.c
+++ b/src/fnettrace/main.c
@@ -677,7 +677,9 @@ static const char *const usage_str =
677 "Options:\n" 677 "Options:\n"
678 " --help, -? - this help screen\n" 678 " --help, -? - this help screen\n"
679 " --log=filename - netlocker logfile\n" 679 " --log=filename - netlocker logfile\n"
680 " --netfilter - build the firewall rules and commit them.\n" 680 " --netfilter - build the firewall rules and commit them\n"
681 " --print-map - print IP map\n"
682 " --squash-map - compress IP map\n"
681 " --tail - \"tail -f\" functionality\n" 683 " --tail - \"tail -f\" functionality\n"
682 "Examples:\n" 684 "Examples:\n"
683 " # fnettrace - traffic trace\n" 685 " # fnettrace - traffic trace\n"
@@ -710,6 +712,36 @@ int main(int argc, char **argv) {
710 usage(); 712 usage();
711 return 0; 713 return 0;
712 } 714 }
715 else if (strcmp(argv[i], "--print-map") == 0) {
716 char *fname = "static-ip-map.txt";
717 load_hostnames(fname);
718 radix_print();
719 return 0;
720 }
721 else if (strncmp(argv[i], "--squash-map=", 13) == 0) {
722 if (i !=(argc - 1)) {
723 fprintf(stderr, "Error: please provide a map file\n");
724 return 1;
725 }
726 load_hostnames(argv[i] + 13);
727 int in = radix_nodes;
728 radix_squash();
729 radix_squash();
730 radix_squash();
731 radix_squash();
732 radix_squash();
733
734 printf("#\n");
735 printf("# This file is part of firejail project\n");
736 printf("# The following list of addresses was compiled from various public sources.\n");
737 printf("# License GPLv2\n");
738 printf("#\n");
739
740 radix_print();
741 printf("\n#\n#\n# input %d, output %d\n#\n#\n", in, radix_nodes);
742 fprintf(stderr, "static ip map: input %d, output %d\n", in, radix_nodes);
743 return 0;
744 }
713 else if (strcmp(argv[i], "--netfilter") == 0) 745 else if (strcmp(argv[i], "--netfilter") == 0)
714 arg_netfilter = 1; 746 arg_netfilter = 1;
715 else if (strcmp(argv[i], "--tail") == 0) 747 else if (strcmp(argv[i], "--tail") == 0)
diff --git a/src/fnettrace/radix.c b/src/fnettrace/radix.c
index a1d510a61..f0a22da74 100644
--- a/src/fnettrace/radix.c
+++ b/src/fnettrace/radix.c
@@ -55,10 +55,14 @@ static RNode *rmalloc(void) {
55static inline char *duplicate_name(const char *name) { 55static inline char *duplicate_name(const char *name) {
56 assert(name); 56 assert(name);
57 57
58 if (strcmp(name, "United States") == 0) 58 if (strcmp(name, "Amazon") == 0)
59 return "United States";
60 else if (strcmp(name, "Amazon") == 0)
61 return "Amazon"; 59 return "Amazon";
60 else if (strcmp(name, "Digital Ocean") == 0)
61 return "Digital Ocean";
62 else if (strcmp(name, "Linode") == 0)
63 return "Linode";
64 else if (strcmp(name, "Google") == 0)
65 return "Google";
62 return strdup(name); 66 return strdup(name);
63} 67}
64 68
@@ -152,3 +156,86 @@ char *radix_longest_prefix_match(uint32_t ip) {
152 156
153 return (rv)? rv->name: NULL; 157 return (rv)? rv->name: NULL;
154} 158}
159
160static uint32_t sum;
161static void print(RNode *ptr, int level) {
162 if (!ptr)
163 return;
164 if (ptr->name) {
165 printf("%d.%d.%d.%d/%d ", PRINT_IP(sum << (32 - level)), level);
166 printf("%s\n", ptr->name);
167 }
168
169 if (ptr->zero == NULL && ptr->one == NULL)
170 return;
171
172 level++;
173 sum <<= 1;
174 print(ptr->zero, level);
175 sum++;
176 print(ptr->one, level);
177 sum--;
178 sum >>= 1;
179}
180
181void radix_print(void) {
182 if (!head)
183 return;
184 printf("\n");
185 sum = 0;
186 print(head->zero, 1);
187 assert(sum == 0);
188 sum = 1;
189 print(head->one, 1);
190 assert(sum == 1);
191}
192
193static inline int strnullcmp(const char *a, const char *b) {
194 if (!a || !b)
195 return -1;
196 return strcmp(a, b);
197}
198
199void squash(RNode *ptr, int level) {
200 if (!ptr)
201 return;
202
203 if (ptr->name == NULL &&
204 ptr->zero && ptr->one &&
205 strnullcmp(ptr->zero->name, ptr->one->name) == 0 &&
206 !ptr->zero->zero && !ptr->zero->one &&
207 !ptr->one->zero && !ptr->one->one) {
208 ptr->name = ptr->one->name;
209// fprintf(stderr, "squashing %d.%d.%d.%d/%d ", PRINT_IP(sum << (32 - level)), level);
210// fprintf(stderr, "%s\n", ptr->name);
211 ptr->zero = NULL;
212 ptr->one = NULL;
213 radix_nodes--;
214 return;
215 }
216
217 if (ptr->zero == NULL && ptr->one == NULL)
218 return;
219
220 level++;
221 sum <<= 1;
222 squash(ptr->zero, level);
223 sum++;
224 squash(ptr->one, level);
225 sum--;
226 sum >>= 1;
227}
228
229// using stderr for printing
230void radix_squash(void) {
231 if (!head)
232 return;
233
234 sum = 0;
235 squash(head->zero, 1);
236 assert(sum == 0);
237 sum = 1;
238 squash(head->one, 1);
239 assert(sum == 1);
240
241}
diff --git a/src/fnettrace/radix.h b/src/fnettrace/radix.h
index d75fe3999..349d0e4b8 100644
--- a/src/fnettrace/radix.h
+++ b/src/fnettrace/radix.h
@@ -23,5 +23,7 @@
23extern int radix_nodes; 23extern int radix_nodes;
24char *radix_longest_prefix_match(uint32_t ip); 24char *radix_longest_prefix_match(uint32_t ip);
25char *radix_add(uint32_t ip, uint32_t mask, char *name); 25char *radix_add(uint32_t ip, uint32_t mask, char *name);
26void radix_print(void);
27void radix_squash(void);
26 28
27#endif 29#endif
diff --git a/src/fnettrace/static-ip-map b/src/fnettrace/static-ip-map.txt
index f7758896e..92c55d148 100644
--- a/src/fnettrace/static-ip-map
+++ b/src/fnettrace/static-ip-map.txt
@@ -44,6 +44,13 @@
44172.16.0.0/16 local network 44172.16.0.0/16 local network
45169.254.0.0/16 local link 45169.254.0.0/16 local link
46 46
47# multicast
48224.0.0.0/4 multicast
49224.0.0.9/32 RIPv2
50224.0.0.5/32 OSPF
51224.0.0.6/32 OSPF
52224.0.0.251/32 Multicast DNS
53
47# huge address ranges 54# huge address ranges
484.0.0.0/9 Level 3 554.0.0.0/9 Level 3
494.128.0.0/9 Microsoft 564.128.0.0/9 Microsoft
@@ -67,8 +74,7 @@
6755.0.0.0/8 US Army 7455.0.0.0/8 US Army
6856.0.0.0/8 US Postal Service 7556.0.0.0/8 US Postal Service
6973.0.0.0/8 Comcast 7673.0.0.0/8 Comcast
70205.0.0.0/8 US Army 77214.0.0.0/8 US Army
71214.0.0.0/8 US Army
72215.0.0.0/8 US Army 78215.0.0.0/8 US Army
73 79
74# DNS 80# DNS
@@ -107,6 +113,7 @@
10737.77.184.0/21 Netflix 11337.77.184.0/21 Netflix
10845.57.0.0/17 Netflix 11445.57.0.0/17 Netflix
10945.58.64.0/20 Dropbox 11545.58.64.0/20 Dropbox
11645.88.203.0/24 Gab
11045.113.128.0/22 Twitch 11745.113.128.0/22 Twitch
11147.88.0.0/14 Alibaba 11847.88.0.0/14 Alibaba
11252.223.192.0/18 Twitch 11952.223.192.0/18 Twitch
@@ -166,6 +173,7 @@
166185.125.188.0/22 Ubuntu One 173185.125.188.0/22 Ubuntu One
167185.199.108.0/22 GitHub 174185.199.108.0/22 GitHub
168185.205.69.0/24 Tutanota 175185.205.69.0/24 Tutanota
176185.238.113.0/24 Bitchute
169188.64.224.0/21 Twitter 177188.64.224.0/21 Twitter
170190.217.33.0/24 Steam 178190.217.33.0/24 Steam
171192.0.64.0/18 Wordpress 179192.0.64.0/18 Wordpress
@@ -188,6 +196,30 @@
188208.75.76.0/22 Netflix 196208.75.76.0/22 Netflix
189208.78.164.0/22 Steam 197208.78.164.0/22 Steam
190208.80.152.0/22 Wikipedia 198208.80.152.0/22 Wikipedia
199
200# Level 3
201205.128.0.0/14 Level 3
202205.180.0.0/14 Level 3
203205.184.0.0/19 Level 3
204205.184.32.0/20 Level 3
205205.184.96.0/19 Level 3
206205.184.128.0/18 Level 3
207205.184.192.0/20 Level 3
208205.184.240.0/20 Level 3
209205.128.0.0/14 Level 3
210205.180.0.0/14 Level 3
211205.184.0.0/19 Level 3
212205.184.32.0/20 Level 3
213205.184.96.0/19 Level 3
214205.184.128.0/18 Level 3
215205.184.192.0/20 Level 3
216205.184.240.0/20 Level 3
217205.187.32.0/20 Level 3
218205.187.80.0/20 Level 3
219205.187.128.0/19 Level 3
220205.187.176.0/20 Level 3
221205.187.192.0/18 Level 3
222205.224.0.0/14 Level 3
191209.244.0.0/14 Level 3 223209.244.0.0/14 Level 3
192 224
193# WholeSale Internet 225# WholeSale Internet
@@ -204,6 +236,28 @@
20469.16.174.0/23 StackPath 23669.16.174.0/23 StackPath
20569.16.176.0/20 StackPath 23769.16.176.0/20 StackPath
206151.139.0.0/16 StackPath 238151.139.0.0/16 StackPath
239205.185.194.0/23 StackPath
240205.185.196.0/23 StackPath
241205.185.198.0/24 StackPath
242205.185.200.0/21 StackPath
243205.185.212.0/23 StackPath
244205.185.215.0/24 StackPath
245205.185.216.0/23 StackPath
246205.185.219.0/24 StackPath
247205.185.220.0/24 StackPath
248205.185.215.0/24 StackPath
249205.185.216.0/23 StackPath
250205.185.219.0/24 StackPath
251205.185.220.0/24 StackPath
252205.185.194.0/23 StackPath
253205.185.196.0/23 StackPath
254205.185.198.0/24 StackPath
255205.185.200.0/21 StackPath
256205.185.212.0/23 StackPath
257205.185.215.0/24 StackPath
258205.185.216.0/23 StackPath
259205.185.219.0/24 StackPath
260205.185.220.0/24 StackPath
207 261
208# Linode 262# Linode
209103.29.68.0/22 Linode 263103.29.68.0/22 Linode
@@ -314,6 +368,7 @@
31496.6.0.0/15 Akamai 36896.6.0.0/15 Akamai
31596.16.0.0/15 Akamai 36996.16.0.0/15 Akamai
316104.64.0.0/10 Akamai 370104.64.0.0/10 Akamai
371173.222.0.0/15 Akamai
317184.24.0.0/13 Akamai 372184.24.0.0/13 Akamai
318184.50.0.0/15 Akamai 373184.50.0.0/15 Akamai
319184.84.0.0/14 Akamai 374184.84.0.0/14 Akamai
@@ -371,6 +426,13 @@
371192.229.128.0/17 MCI 426192.229.128.0/17 MCI
372 427
373# Microsoft 428# Microsoft
42920.40.0.0/13 Microsoft
43020.64.0.0/10 Microsoft
43120.48.0.0/12 Microsoft
43220.128.0.0/16 Microsoft
43320.33.0.0/16 Microsoft
43420.36.0.0/14 Microsoft
43520.34.0.0/15 Microsoft
37440.76.0.0/14 Microsoft 43640.76.0.0/14 Microsoft
37540.96.0.0/12 Microsoft 43740.96.0.0/12 Microsoft
37640.112.0.0/13 Microsoft 43840.112.0.0/13 Microsoft
@@ -5407,3 +5469,74 @@
5407209.97.144.0/20 Digital Ocean 5469209.97.144.0/20 Digital Ocean
5408209.97.160.0/20 Digital Ocean 5470209.97.160.0/20 Digital Ocean
5409209.97.176.0/20 Digital Ocean 5471209.97.176.0/20 Digital Ocean
5472
5473# Leaseweb
5474185.28.70.0/24 Leaseweb
5475108.177.128.0/22 Leaseweb
5476108.177.216.0/22 Leaseweb
5477108.177.244.0/22 Leaseweb
5478108.62.152.0/21 Leaseweb
5479108.62.192.0/22 Leaseweb
5480108.62.197.0/24 Leaseweb
5481108.62.199.0/24 Leaseweb
5482108.62.220.0/22 Leaseweb
5483108.62.5.0/24 Leaseweb
5484108.62.56.0/21 Leaseweb
5485142.234.104.0/21 Leaseweb
5486142.234.168.0/21 Leaseweb
5487142.234.180.0/22 Leaseweb
5488142.234.188.0/22 Leaseweb
5489142.234.232.0/21 Leaseweb
5490142.234.248.0/22 Leaseweb
5491142.91.116.0/22 Leaseweb
5492142.91.208.0/22 Leaseweb
5493142.91.88.0/21 Leaseweb
5494147.255.224.0/21 Leaseweb
5495172.241.120.0/22 Leaseweb
5496172.241.136.0/22 Leaseweb
5497172.241.156.0/22 Leaseweb
5498172.241.200.0/22 Leaseweb
5499173.208.118.0/24 Leaseweb
5500173.208.32.0/21 Leaseweb
5501173.234.180.0/22 Leaseweb
5502173.234.80.0/22 Leaseweb
5503173.234.88.0/23 Leaseweb
5504174.34.144.0/24 Leaseweb
5505174.34.145.0/24 Leaseweb
5506216.6.228.0/24 Leaseweb
5507216.6.236.0/24 Leaseweb
550823.105.64.0/19 Leaseweb
550923.106.0.0/19 Leaseweb
551023.106.192.0/19 Leaseweb
551123.108.128.0/19 Leaseweb
551223.108.224.0/19 Leaseweb
551323.19.104.0/22 Leaseweb
551423.19.124.0/22 Leaseweb
551523.19.128.0/22 Leaseweb
551623.19.168.0/22 Leaseweb
551723.19.216.0/22 Leaseweb
551823.19.248.0/22 Leaseweb
551923.19.32.0/21 Leaseweb
552023.19.80.0/21 Leaseweb
552123.81.0.0/21 Leaseweb
552223.81.136.0/21 Leaseweb
552323.81.208.0/21 Leaseweb
552423.82.144.0/21 Leaseweb
552523.82.192.0/20 Leaseweb
552623.82.208.0/21 Leaseweb
552723.82.216.0/21 Leaseweb
552823.82.224.0/21 Leaseweb
552923.82.240.0/21 Leaseweb
553023.82.32.0/21 Leaseweb
553123.82.72.0/21 Leaseweb
553264.120.106.0/24 Leaseweb
553364.120.123.0/24 Leaseweb
553464.120.16.0/22 Leaseweb
553564.120.2.0/24 Leaseweb
553664.120.4.0/22 Leaseweb
553764.120.48.0/22 Leaseweb
553864.120.65.0/24 Leaseweb
553964.120.68.0/24 Leaseweb
554064.120.69.0/24 Leaseweb
554169.147.236.0/24 Leaseweb
554270.32.34.0/24 Leaseweb