script/regml.pl untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 58 CC 4 SCAR 23.0
CC
4
Cov
0%
traverse
20.0
usage
2.0
BEGIN
2.0
CRAP 10.0
1 #!/usr/local/bin/perl
2 use strict;
3 use warnings;
4  
5 use File::Basename;
6 use Parse::Win32Registry 0.60;
7  
8 binmode(STDOUT, ':utf8');
9  
10 my $filename = shift or die usage();
11  
12 my $registry = Parse::Win32Registry->new($filename)
13 or die "'$filename' is not a registry file\n";
14 my $root_key = $registry->get_root_key
15 or die "Could not get root key of '$filename'\n";
16  
17 my $security = $root_key->get_security
18 or die "Root key of '$filename' does not have any security information\n";
19  
20 traverse($root_key);
21  
22 sub traverse {
23 my $key = shift;
24  
25 my $security = $key->get_security;
26 if (defined $security) {
27 my $sd = $security->get_security_descriptor;
28 my $sacl = $sd->get_sacl;
29 if (defined $sacl) {
30 foreach my $ace ($sacl->get_list_of_aces) {
31 if ($ace->get_type == 0x11) {
32 print $key->as_string, "\n";
33 print "ACE: ", $ace->as_string, "\n\n";
34 }
35 }
36 }
37 }
38  
39 foreach my $subkey ($key->get_list_of_subkeys) {
40 traverse($subkey);
41 }
42 }
43  
44 sub usage {
45 my $script_name = basename $0;
46 return <<USAGE;
47 $script_name for Parse::Win32Registry $Parse::Win32Registry::VERSION
48  
49 Displays those keys in a registry file that have a System ACL
50 that includes a System Mandatory Label ACE.
51 Only Windows NT registry files contain security information.
52  
53 $script_name <filename>
54 USAGE
55 }