dt667 has asked for the wisdom of the Perl Monks concerning the following question:
And the script that works outside of the main project:sub getEffectiveRights { my $object = $_[1]; my $objectType = $_[2]; my $binarySid = $_[3]; my $error = undef; my $result = undef; # Establish variables. my $psidOwner; my $psidGroup; my $pDacl; my $pSacl; my $pSecurityDescriptor; try { $logger->debug("Object: $object"); # Call GetNamedSecurityInfo. This is to get the DACL. ($psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescriptor) + = Win32::Security::Raw::GetNamedSecurityInfo( $object, $objectType, 'DACL_SECURITY_INFORMATION'); print "returned from Win32::Security::Raw::GetNamedSecurityInf +o\n"; unless (defined($pDacl)) { throw Error::Simple("An error occurred trying to access th +e discretionary access control entries for security object '" . $obje +ct . "'."); } # Build the trustee structure. my $trustee = System_Functions->buildTrusteeWithSid($binarySid +); # Get the access mask. $result = System_Functions->getEffectiveRightsFromAcl($pDacl, +$trustee); } catch Error::Simple with { $error = shift; print "error = $error\n"; } finally { # Clear memory. if (defined($pSecurityDescriptor)) { Win32::Security::Raw::LocalFree($pSecurityDescriptor); } }; if (defined($error)) { throw Error::Simple("Could not access '$object'. Verify that i +t exists and that you have permission to access it. $error"); } return $result; }
I noticed that Win32::API, which is called by Win32::Security::Raw, changed significantly since Perl 5.12 and now has buffer overflow protection built-in but I'm unsure why it would be complaining about "parameter 1". Any help would be greatly appreciative as this is preventing us from upgrading to Perl 5.20.use warnings; use strict; use Win32::Security::Raw; #my $object = "MACHINE\\SYSTEM\\CurrentControlSet\\Services"; my @objects = ("MACHINE\\SYSTEM\\CurrentControlSet\\services","MACHINE +\\SYSTEM\\CurrentControlSet\\Services","MACHINE\\SYSTEM\\CurrentContr +olSet\\services\\.NET CLR Data", "MACHINE\\SYSTEM\\CurrentControlSet\ +\services\\Lsa\\Performance"); my $ObjectType = 'SE_REGISTRY_KEY'; my $SecurityInfo = 'DACL_SECURITY_INFORMATION'; # Establish variables. my $psidOwner; my $psidGroup; my $pDacl; my $pSacl; my $pSecurityDescriptor; foreach my $object (@objects) { print "object = $object\n"; # Call GetNamedSecurityInfo. This is to get the DACL. ($psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescriptor) = W +in32::Security::Raw::GetNamedSecurityInfo($object, $ObjectType, 'DACL +_SECURITY_INFORMATION'); print "$psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescripto +r.\n"; if (defined($pSecurityDescriptor)) { Win32::Security::Raw::LocalFree($pSecurityDescriptor); } print "\n\n"; }
|
|---|