1

由于 windows 不为单个文件夹提供密码保护,因此有许多第三方软件,如“文件夹锁定”,可以完成这项工作。我想知道这类应用程序背后的逻辑,并找到了一个类似这样的代码:'lock-a-folder'。这是我不熟悉的 AutoIt 脚本。但是,我只想知道这里使用的逻辑。

这些是我感兴趣的脚本的主要功能:

Func Lock($slected)
  Local $Temp,$TempFile
  If @error or $slected = "" Then Return("Empty selection/Cancel Pressed")
  If Not FileExists($slected) Then
    MsgBox(0, $AppName, $slected & " " & Lang('doesntexist'), 0, $WIN1)
    Return('doesntexist')
  EndIf
  Local $l0ckd = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders")
  _DebugOut('RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders") = ' & $l0ckd)

  If Not StringInStr($l0ckd, $slected & ".{90F8C996-7C70-4331-9D70-FB357D559FD5}|") = 0 Then
    MsgBox(0, $AppName, $slected & " " & Lang('alreadyinlist'), 0, $WIN1)
    Return('alreadyinlist')
  EndIf
  If $CmdLine[0] = 0 Then
    GUICtrlSetData($List1, "")
    GUICtrlSetData($List1, Lang('plzwait') & "....")
    GUISetState(@SW_DISABLE)
  EndIf
  _DebugOut($slected)
  If $CmdLine[0] = 0 Then GUISetState(@SW_ENABLE)
  If DirMove($slected, $slected & ".{90F8C996-7C70-4331-9D70-FB357D559FD5}") = 0 Then
  FileSetAttrib($slected, "-RSH")
  MsgBox(0, $AppName, $slected & " " & Lang('unable2lock'), 0, $WIN1)
  If $CmdLine[0] = 0 Then Readfolders()
    Return('unable2lock')
  EndIf
  $slected = $slected & ".{90F8C996-7C70-4331-9D70-FB357D559FD5}"
  FileSetAttrib($slected, "+RSH")
  $l0ckd &= $slected & "|"
  _DebugOut("$l0ckd &= $slected| = " & $l0ckd)
  $debug = RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders", "REG_SZ", $l0ckd)
  _DebugOut('RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders", "REG_SZ", $l0ckd) = ' & $debug)
  If $CmdLine[0] = 0 Then Readfolders()
  Return("Done")
EndFunc ;==>Lock


Func UnLock($slected)
  _DebugOut($slected)
  If $slected = "" Or @error Then
    MsgBox(0, $AppName, Lang('selectfirst'), 0, $WIN1)
    Return("Empty selection/Cancel Pressed")
  EndIf
  If $CmdLine[0] = 0 Then
    GUICtrlSetData($List1, "")
    GUICtrlSetData($List1, Lang('plzwait') & "....")
    GUISetState(@SW_DISABLE)
  EndIf
  Local $Temp = StringReplace($slected, ".{90F8C996-7C70-4331-9D70-FB357D559FD5}", "", 0, 2)
  _DebugOut("$Temp = " & $Temp)
  FileSetAttrib($slected, "-RSH")
  Local $Temp1
  $Temp1 = DirMove($slected, $Temp)
  If $CmdLine[0] = 0 Then GUISetState(@SW_ENABLE)
  If $Temp1 = 0 Then
    $Temp1 = DirMove($slected, $Temp & ".recovered")
  EndIf
  If $Temp1 = 0 Then

  MsgBox(0, $AppName, $slected & " " & Lang('unable2unlock'), 0, $WIN1)
  If $CmdLine[0] = 0 Then Readfolders()
    Return('unable2unlock')
  EndIf
  Local $l0ckd = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders")
  _DebugOut('RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders") = ' & $l0ckd)
  $Temp = StringReplace($l0ckd, $slected & "|", "")
  _DebugOut('StringReplace($l0ckd, $slected & "|", "")' & " = " & $Temp)
  $debug = RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders", "REG_SZ", $Temp)
  _DebugOut('RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $AppName, "lockedfolders", "REG_SZ", $l0ckd) = ' & $debug)
  If $CmdLine[0] = 0 Then Readfolders()
  Return("Done")
EndFunc ;==>UnLock

谁能告诉我逻辑?

4

2 回答 2

2

该脚本创建注册表项,如:

HKCR\CLSID\{90F8C996-7C70-4331-9D70-FB357D559FD5}
HKCR\CLSID\{90F8C996-7C70-4331-9D70-FB357D559FD5}\shell\open
HKCR\CLSID\{90F8C996-7C70-4331-9D70-FB357D559FD5}\shell\explore
HKCR\CLSID\{90F8C996-7C70-4331-9D70-FB357D559FD5}\shell\opennewwindow
HKCR\CLSID\{90F8C996-7C70-4331-9D70-FB357D559FD5}\shell\opennewprocess

HKCU\SOFTWARE\$AppName\lockedfolders

锁定文件夹时,它会被重命名,FolderName.{90F8C996-7C70-4331-9D70-FB357D559FD5}并且此名称会附加到 的值以HKCU\SOFTWARE\$AppName\lockedfolders供将来参考。

解锁时只需将文件夹更改回其原始名称,从注册表值中删除该条目。

所以它似乎根本不安全。

于 2013-01-31T09:19:32.377 回答
0

在命令行中尝试这样的事情:

C:> attrib +a +H +S folder_name 

删除属性替换+-

于 2015-06-30T19:00:08.503 回答