Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/13/2011 in all areas

  1. I would like to see the white space before and after sections be reduced by another 40%. You are changing font size and color at each of the boudaries and I don't believe so much white space is required to deliniate the sections. Dale
    2 points
  2. FredAI

    Set Acl permissions UDF

    Hi. I've been working on this for a while. I think now it's good enough to post it here. Functions to do most everything with the DACL and ownership on all types of objects: Files or folders, Registry keys, services, Kernel and WMI objects, etc. Here's a good example to test: #include 'Permissions.au3' _InitiatePermissionResources() FileWrite(@ScriptDir&'test.txt','Test') Local $TI = TimerInit() Local $ret = _DenyAllAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@UserName) Local $TD = TimerDiff($TI) MsgBox(0,'','Deny all access to test.txt and take ownership:'&@CRLF&@CRLF& _ '_DenyAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantReadAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,'Administrators') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone read access, all access to admins and system, and set the owner: Admins group'&@CRLF&@CRLF& _ '_GrantReadAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantAllAccess(@ScriptDir&'test.txt') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone access'&@CRLF&@CRLF& _ '_GrantAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _CopyFullDacl(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@ScriptDir) $TD = TimerDiff($TI) MsgBox(0,'','Restore all inherited permissions'&@CRLF&@CRLF& _ '_CopyFullDacl return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $aPerm[2][3] = [['Restricted',1,$GENERIC_ALL],['Users',1,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Add two granted access aces: Restricted and Users'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',1,$GENERIC_READ],['Users',1,$GENERIC_READ]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Give only read access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',0,$GENERIC_ALL],['Users',0,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Deny access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $Hndl = _Permissions_OpenProcess(@AutoItPID) Local $SDBefore = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) Local $CODRet = _ClearObjectDacl($Hndl,$SE_KERNEL_OBJECT) Local $DARet = _DenyAllAccess($Hndl,$SE_KERNEL_OBJECT) Local $SDAfter = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) $TD = Round(TimerDiff($TI),2) MsgBox(0,'', 'Deny everyone access to the current process:'&@CRLF&@CRLF& _ '@AutoItPID original security descriptor: '&@CRLF&$SDBefore&@CRLF&@CRLF& _ '_ClearObjectDacl return value: '&$CODRet&@CRLF&@CRLF& _ '_DenyAllAccess_ return value: '&$DARet&@CRLF&@CRLF& _ 'New @AutoItPID security descriptor: '&@CRLF& _ $SDAfter&@CRLF&@CRLF& 'Time taken: '&$TD&' miliseconds.') _Permissions_CloseHandle($Hndl) FileDelete(@ScriptDir&'test.txt') _ClosePermissionResources()I'm planning to add functions to deal with the Sacl in the future, even though I don't think it's very important. Edit: Let me know if you need an example for the registry. Updated: Fixed a bug in the _ClearObjectDacl function. I thought that adding a null DACL would work fine, but it causes problems later when adding a new DACL. Those who have downloaded, please update. Shoot! Now it wasn't clearing the DACL at all. Updated again. I think it's fixed now. Updated 9/11/2011 - Added the security descriptor functions and removed unnecessary constants. Updated 10/11/2011 - There were some functions missing in the index, and some parameters in the comments. Also removed the "MustDeclareVars" option. (About 50 total downloads before) Update 12/12/2011 - Added more functions: New Update 12/12/2011 - Missing declaration keywords in 3 constants. Sorry Update 16/12/2011 - Added support for all object types, including window and process handles. Added more functions, modified most of them, and removed one. Here's the new function list: Updated 22/2/2012.. This time I'm including SecurityConstants.au3 and FileConstants.au3 to prevent constants conflicts. Added a few more functions and fixed a few bugs. Also added the ability to include the inherited aces in the _EditObjectPermissions function. Now the permissions array can have four elements (optional). It will still work with three elements arrays though. The fourth element is intended to have the inheritance flag for the corresponding ace. Here's the new list of functions: 400 previous downloads Permissions.au3
    1 point
  3. eltorro

    _PathSplitByRegExp()

    Try this Func _PathSplitByRegExp($sPath) If $sPath = "" Or (StringInStr($sPath, "\") And StringInStr($sPath, "/")) Then Return SetError(1, 0, -1) Local $RetArray[8], $pDelim = "" If StringRegExp($sPath, '^(?i)([A-Z]:|\\)(\\[^\\]+)+$') Then $pDelim = "\" If StringRegExp($sPath, '(?i)(^.*:/)(/[^/]+)+$') Then $pDelim = "//" If $pDelim = "" Then $pDelim = "/" If Not StringInStr($sPath, $pDelim) Then Return $sPath If $pDelim = "\" Then $pDelim &= "\" $RetArray[0] = $sPath $RetArray[1] = StringReplace($sPath,StringRegExpReplace($sPath, '(?i)([A-Z]:' & $pDelim & '|\\\\\w*|\\w*\\)', ''),"") $RetArray[2] = StringRegExpReplace($sPath, $pDelim & '[^' & $pDelim & ']*$', '') $RetArray[3] = StringRegExpReplace($sPath, '\.[^.]*$', '') $RetArray[4] = StringRegExpReplace($sPath, '(?i)([A-Z]:' & $pDelim & '|\\\\\w*\\|\\w*\\)', '') $RetArray[5] = StringRegExpReplace($sPath, '^.*' & $pDelim, '') $RetArray[6] = StringRegExpReplace($RetArray[5], '\.[^.]*$', '') $RetArray[7] = StringRegExpReplace($sPath, '^.*\.', '') Return $RetArray EndFunc Results: C:/my test/path/file.zip [0] =C:/my test/path/file.zip [1] =C:/ [2] =C:/my test/path [3] =C:/my test/path/file [4] =my test/path/file.zip [5] =file.zip [6] =file [7] =zip \\nas\public\videos\Hackers.avi [0] =\\nas\public\videos\Hackers.avi [1] =\\nas [2] =\\nas\public\videos [3] =\\nas\public\videos\Hackers [4] =public\videos\Hackers.avi [5] =Hackers.avi [6] =Hackers [7] =avi C:\my test\path\file.zip [0] =C:\my test\path\file.zip [1] =C:\ [2] =C:\my test\path [3] =C:\my test\path\file [4] =my test\path\file.zip [5] =file.zip [6] =file [7] =zip Regards
    1 point
×
×
  • Create New...