3 # find-zlib - scan for zlib tables in compiled code
4 # Copyright (C) 2002 RUS-CERT, University of Stuttgart.
5 # Written by Florian Weimer <Weimer@CERT.Uni-Stuttgart.DE>.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
13 print "usage: find-zlib filename...\n";
21 my @inflate_table = (3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
22 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227,
33 return (quotemeta($be), quotemeta($le));
36 sub table_to_re_config (@) {
44 return (quotemeta($be), quotemeta($le));
47 my ($inflate_table_be, $inflate_table_le) = table_to_re (@inflate_table);
50 my (@config_table_le, @config_table_be) = ();
51 foreach $line ([8, 32, 128, 256],
53 [32, 258, 258, 4096]) {
54 my ($be, $le) = table_to_re_config(@$line);
55 push @config_table_be, $be;
56 push @config_table_le, $le;
58 my ($config_table_be_32,
62 = (join("....", @config_table_be),
63 join("........", @config_table_be),
64 join("....", @config_table_le),
65 join("........", @config_table_le));
70 open (FILE, "<$file");
74 if ($data =~ /$config_table_le_32/o) {
75 print "$file: zlib configuration table, little endian, 32 bit\n";
79 if ($data =~ /$config_table_be_32/o) {
80 print "$file: zlib configuration table, big endian, 32 bit\n";
83 if ($data =~ /$config_table_le_64/o) {
84 print "$file: zlib configuration table, little endian, 64 bit\n";
88 if ($data =~ /$config_table_be_64/o) {
89 print "$file: zlib configuration table, big endian, 64bit\n";
91 if ($data =~ /$inflate_table_le/o) {
92 print "$file: zlib inflate table, little endian\n";
95 if ($data =~ /$inflate_table_be/o) {
96 print "$file: zlib inflate table, big endian\n";