Sign in to follow this  
Followers 0
ioliver

_displaycacls

1 post in this topic

#1 ·  Posted (edited)

$folder = "C:\Windows\System32"
$intfolder = StringLen($folder)
$intfolder1 = $intfolder + 1
$caclsresult = "Key:" & @CR & "(CI) - Container Inherit" & @CR & "(OI) - Object Inherit" &_
@CR & "(IO) - Inherit Only" & @CR & "----------" & @CR & ""
RunWait(@comspec & ' /c ' & 'cacls ' & '"' & $folder & '"' & ' > c:\cacls.txt', '', @SW_HIDE)

$caclstxt = FileOpen("c:\cacls.txt", 0)

While 1
    $line2notexist = "False"
    $line = FileReadLine($caclstxt)
    If @error = -1 Then ExitLoop
    $line = StringTrimLeft($line, $intfolder1)
    $line = StringStripWS($line, 1); 1 = Strip Leading Whitespace   
    $line = StringSplit($line, ":")
    If @error = 1 Then $line2notexist = "True"
;MsgBox(0, "Line[1] read:", $line[1])
    If $line2notexist = "False" Then
       ;MsgBox(0, "Line[2] read:", $line[2])
      If StringInStr($line[2], "special access") Then
        $line[2] = $line[2] & ":)"
      Else
        $line[2] = StringStripWS($line[2], 2); 2 = Strip Trailing Whitespace
        Select
            Case StringRight($line[2], 1) = "N"
                $line[2] = "None"
                
            Case StringRight($line[2], 1) = "R"
                $line[2] = "Read"

            Case StringRight($line[2], 1) = "W"
                $line[2] = "Write"
                
            Case StringRight($line[2], 1) = "C"
                $line[2] = "Change"
                
            Case StringRight($line[2], 1) = "F"
                $line[2] = "Full Control"

        EndSelect
      EndIf 
     ;MsgBox(0, "Line[2] read:", $line[2])
    EndIf
    
    If $line2notexist = "False" Then
        If StringLen($line[1]) < 15 Then
            $caclsresult = $caclsresult & $line[1] & @TAB & @TAB & $line[2] & @CR
        Else
            $caclsresult = $caclsresult & $line[1] & @TAB & $line[2] & @CR
        EndIf   
    Else
        $caclsresult = $caclsresult & $line[1] & @CR
    EndIf
Wend

FileClose($caclstxt)
MsgBox(0, "CACLS Results for " & $folder, $caclsresult)

Just replace the $folder variable with whatever folder you want. Please try it out and let me know what you think.

-> Thanks to Lary...

Thanks for reading my post,

Ian

EDIT: I added a Key to the script. Ln. 4.

EDIT: Updated Code...

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0