How folder locking works

As windows doesn't provide password protection for individual folder, there are many third party software like 'Folder Lock' that does the job. I wanted to know the logic behind these kind of applications and found one code like this: 'lock-a-folder'. This is an AutoIt script which I am not familiar with. However, I just want to know the logic used here.

These are the main functions of the script I am interested in:

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

Can anybody please tell me the logic?

Answers


Ok, I got this.

The script create some registry entry like this

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

and

HKCU\SOFTWARE\$AppName\lockedfolders

Now when locking a folder, it is renaming the folder as FolderName.{90F8C996-7C70-4331-9D70-FB357D559FD5} and appending this name to the value of HKCU\SOFTWARE\$AppName\lockedfolders for future reference.

When unlocking, it is just renaming the folder back to its original name and removing the entry from the registry value.

So it seems, it is not so much secure at all, however.


Try something like this in command line:

C:> attrib +a +H +S folder_name 

to remove attributes replace + with -


Need Your Help

Generate Semantic HTML forms

forms zend-framework2

I want to use zend framework forms generation and validation techniques, but I don't want the generated html script to be generated as HTML Table script .

my code doesn't work with two setintervals

jquery setinterval

I want my code to grab a certain time using moment.js, correlate that to a "frame" number and then use that to populate a url to get a specified image in a sequence. That url will then iterate thro...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.