File Server,Access Path,Current Permissions,Logon Name,Inherited From Folders,Flags,User/Group,Classification Results,Classification Results by Category (Including Nested),Total Hit Count 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,@FOO NOW Onsite Support,\Common,This folder only,Pathway12.My.Corp.com\@FOO NOW Onsite Support,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,Administrators,\Common,This folder only,10.15.106.71\Administrators,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,Creator Owner,\Common,This folder only,Abstract\Creator Owner,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,FP NOW BMG FSE NTFS Admins,\Common,This folder only,Pathway12.My.Corp.com\FP NOW BMG FSE NTFS Admins,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,ClusterSvcDIR,\Common,This folder only,Pathway12.My.Corp.com\ClusterSvcDIR,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,SYSTEM,\Common,This folder only,Abstract\SYSTEM,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,MiJim,,This folder only,"Pathway12.My.Corp.com\Michaels, Jim@My",IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,MRWX,@FP DIR BMG,\Common,This folder only,Pathway12.My.Corp.com\@FP DIR BMG,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,RX,&CDAdmin,\Common,This folder only,Pathway12.My.Corp.com\&CDAdmin,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,RX,@FOO DSMS Admins,\Common,This folder only,Pathway12.My.Corp.com\@FOO DSMS Admins,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,RX,FOO BMG FS Support,\Common,This folder only,Pathway12.My.Corp.com\FOO BMG FS Support,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,RX,DPeterso,\Common,This folder only,"Pathway12.My.Corp.com\Peterson, Dan@My",IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,RX,FP BMG IMG Read Access,\Common,This folder only,Pathway12.My.Corp.com\FP BMG IMG Read Access,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/My-B8245.pdf,FMRWX,@FOO NOW Onsite Support,\Common,This folder only,Pathway12.My.Corp.com\@FOO NOW Onsite Support,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/My-B8245.pdf,FMRWX,Administrators,\Common,This folder only,10.15.106.71\Administrators,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/My-B8245.pdf,FMRWX,Creator Owner,\Common,This folder only,Abstract\Creator Owner,IRS Data (1/1),PII (1),1

#### File Server,Access Path,Current Permissions,Logon Name,Inherited From Folders,Flags,User/Group,Classification Results,Classification Results by Category (Including Nested),Total Hit Count 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,FMRWX,"@FOO NOW Onsite Support,Administrators,Creator Owner,FP NOW BMG FSE NTFS Admins,ClusterSvcDIR,SYSTEM,MiJim(*)",\Common,This folder only,Pathway12.My.Corp.com\@FOO NOW Onsite Support,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,MRWX,@FP DIR BMG,\Common,This folder only,Pathway12.My.Corp.com\@FP DIR BMG,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/Axidome Quote My Corp 2020211 KnowBe4 2-yr Renewal FINAL.pdf,RX,"&CDAdmin,@FOO DSMS Admins,FOO BMG FS Support,DPeterso,FP BMG IMG Read Access",\Common,This folder only,Pathway12.My.Corp.com\&CDAdmin,IRS Data (1/1),PII (1),1 10.15.106.71,/Common/Awareness and Training/KnowBe4/2020- KnowBe4 Subscription Renewal Docs/My-B8245.pdf,FMRWX,"@FOO NOW Onsite Support,Administrators,Creator Owner",\Common,This folder only,Pathway12.My.Corp.com\@FOO NOW Onsite Support,IRS Data (1/1),PII (1),1 #### #!/usr/bin/perl use NetAddr::IP; #used for CIDR use Getopt::Long; # handle command line arguments/flags use File::Basename; # use strict; # Okay, I'm gonna take some heat for this. # use warnings 'all'; # Yeah, this too. use Text::CSV qw( csv ); # see https://metacpan.org/pod/Text::sort { $a <=> $b } keys %hash;CSV for info use open ":std", ":encoding(UTF-8)"; use Data::Dumper; # use print Dumper($scalar_var); to see data structures or objects $command = basename($0); sub help { print "\n"; print "perl $command -r report# report_name Use perl $command -l to list supported report formats\n\n"; print "example: perl $command -r 4b May24.csv\n\n"; print "\nUSAGE:\n"; print " -h -H or -help Display this help\n"; print " -r report# Required argument - report number\n"; print " -l -L or -list List supported report numbers\n"; print " report Report name to process (csv format)\n"; exit; } # sub help sub list { print "Supported report formats: ". join(" ",@supported_reports) . " \n"; print " 4b - User or Group Permissions for Directory - (compress report based on folders and permissions)\n\n"; print "\n"; help; exit; } # sub list # Default values for options # $list = ""; # $help = ""; # GetOptions complains if you use upper AND lower case options below. It converts args into lowercase. GetOptions ( 'list|l' => sub { list }, 'report|r=s' => \$report, 'help|h' => sub { help } ); # Put supported report formats here - note the format! # @supported_reports = qw( 4b 5c 6d); # multiple report formats can be listed like this - need subroutines for each @supported_reports = qw( 4b ); # list if $list; help if ($#ARGV >= 1); #needs minimum -r filename as arguments - should be nothing but a filename now # assign filename ($filename) = @ARGV; # (should only have one argument) # see if report is supported - %reports is a hash array unless ( grep {$_ eq $report } @supported_reports ) { print "Report format $report is NOT supported\n"; list(); exit(1); } # can't get map to work except with @ARGV - don't know why - keeping for later analysis #my %reports = map { $_ => 1 } @supported_reports; #if (exists($reports{$report})) { ... } # I started to work with manually parsing them but ran into embbeded commas in fields, and found Text::CSV. It slurps in everything, but pulls it into a hash of hashes (never worked with that before, but thought I'd try to slog through it as a learning exercise. # Open file, if it exists open(my $fh , '<', $filename) or die "Unable to open file, $filename"; # old method slurping in lines manually # Grab 1st line headers $first_line = <$fh>; $first_line =~ s/\x{FEFF}//; # strip out leading UTF8 Byte Order Marker (BOM) chomp $first_line; # strip off trailing carriage return @headers = split(",",$first_line); # Grab headers into array, split on commas $num_headers = scalar @headers; # get number of headers. # Here's the newer stuff # $aoa and $aoh are hash refs (in a scalar) - need to figure out how to parse/manipulate them. And build new ones $aoa = csv (in => $filename , encoding => "UTF-8"); # this slurps a file into an array of arrays (need to find a way to sort this and also remove all the UTF-8 encodings on each line.) $aoh = csv (in => $filename , headers => "auto", encoding => "UTF-8"); # this slurps a file into an array of hashes (need to find a way to sort this and also remove all the UTF-8 encodings on each line.) # pre-process keys to remove unicode embedded in key names - Found in first few characters of 1st line, but was embedded in all the arrays. (this fixed it!) for $key ( keys @{$aoh} ) { $data = $aoh->[$key]; for $temp_key (keys %$data) { if ($temp_key =~ /\x{FEFF}/) { $new_key = $temp_key; $new_key =~ s/\x{FEFF}//; $data->{$new_key} = delete $data->{$temp_key}; $temp_key = $new_key; print "------> Data key $data->{$temp_key} \n"; #print statements to look at data } print "Temp key $temp_key \n"; #print statements to look at data print "Data key $data->{$temp_key} \n"; #print statements to look at data } } # These were earlier attempts to understand the data structure - I can delete this for $key ( keys @{$aoh} ) { $data = $aoh->[$key]; print "key: $key, data $data \n"; print "key: $key, values:\n"; for $field ( keys %$data ) { $temp_field = $field; # $field =~ s/\x{FEFF}//; # (error in read only field) print " temp_field = $temp_field field = $field \n"; printf " %-18s => %s\n", $field, $data->{$field}; } } # for $key ( keys @{$aoh} ) { # $data = $aoh->[$key]; # print "key: $key, values:\n"; # for $field ( "Logon Name", "Current Permissions" ) { # printf " %-18s => %s\n", $field, $data->{$field}; # } # } # Generated # key: 0, values: # Logon Name => @FOO NOW Onsite Support # Current Permissions => FMRWX # key: 1, values: # Logon Name => Administrators # Current Permissions => FMRWX # key: 2, values: # Logon Name => Creator Owner # Current Permissions => FMRWX # route errors to the bit bucket (disappears) open STDERR, '>/dev/null'; # For each server and Access Path (file) basis, Collect the Current Permissions, and concatenate all the logon names with that same permission. Note when it's not inherited "" in the Inherited From Folders field. # # {File Server}{Access Path}{Current Permissions}{Logon Name}{Inherited From Folders}{Flags}{User/Group}{Classification Results}..... # # 4b headers # 0 'File Server' # 1 'Access Path' # 2 'Current Permissions' # 3 'Logon Name' # 4 'Inherited From Folders' # 5 'Flags' # 6 'User/Group' # 7 'Classification Results' # 8 'Classification Results by Category (Including Nested)' # 9 'Total Hit Count' # Process 4b report # Need code about dynamic arrays here. # Early code to manually loop through the file, but found embedded commas in various fields, throwing the count of fields relative to the headers. Gave it up after finding TEXT::CSV # Loop through file $line_count = 0; while (<$fh>) { $line_count++; chomp; # remove CR/LF @curr_line = split(",",$_); print "Line $line_count Field count != header count - Could be extra commas embedded\n $_ \n\n" if ((scalar @curr_line) != (scalar @headers)); exit if ($line_count == 10); } # (<$fh>)