Sign in to follow this  
Followers 0
unuro

_Crypt_EncryptFile problem

1 post in this topic

hello!

I have a problem with this script, if someone can help me ....

As you can see the script, displaying folders in program files and select one block all executables within it, the problem is that not decrypt properly.

Anyone knows any better alternative?

Problem is:

_Crypt_EncryptFile($path[1]&$path[2]&$path[3]&$path[4],$path[1]&$path[2]&$path[3]&$iii&$path[4],"unuro",$CALG_DES)

and

_Crypt_DecryptFile($path[1]&$path[2]&$path[3]&$path[4],StringTrimRight($path[1]&$path[2]&$path[3],$iii)&$path[4],"unuro",$CALG_DES)

SCRIPT :

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>

$Form1 = GUICreate("Blocker Installed Programs", 569, 600, -1, -1)
$TreeView1 = GUICtrlCreateListView("#|List", 10, 10, 560, 560)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1,500)
$mMen = GUICtrlCreateContextMenu($TreeView1)
$lock_true = GUICtrlCreateMenuItem('Lock Software', $mMen)
$unlock_true = GUICtrlCreateMenuItem('Unlock Software', $mMen)

$_dir2 = _FileListToArray(@ProgramFilesDir, "*", 2)

If IsArray($_dir2) Then
For $n = 1 To $_dir2[0]
$sPath = @ProgramFilesDir & '\' & $_dir2[$n]
If FileExists($sPath) Then
$TreeView1_0 = GUICtrlCreateListViewItem($n& '|' &$_dir2[$n],$TreeView1)
EndIf
Next
EndIf

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $lock_true
$TreeView = GUICtrlRead($TreeView1)
$text = GUICtrlRead($TreeView,1)
$temp = StringSplit($text, "|")
$b1 = _FileListToArrayEx(@ProgramFilesDir&"\"&$temp[2]&"\", "*.exe", 12)
Global $nume[111111]
If Not @error Then
For $iii = 1 To $b1[0]
Local $szDrive, $szDir, $szFName, $szExt
$path = _pathsplit($b1[$iii], $szDrive, $szDir, $szFName, $szExt)
ProcessClose($path[3]&$path[4])
_Crypt_EncryptFile($path[1]&$path[2]&$path[3]&$path[4],$path[1]&$path[2]&$path[3]&$iii&$path[4],"unuro",$CALG_DES)
Sleep(100)
FileDelete($path[1]&$path[2]&$path[3]&$path[4])
Next
MsgBox(64,"Info","Succes !")
Else
MsgBox(0,"Info","No File/Folder!")
Exit
EndIf


Case $unlock_true
$TreeView = GUICtrlRead($TreeView1)
$text = GUICtrlRead($TreeView,1)
$temp = StringSplit($text, "|")
$b1 = _FileListToArrayEx(@ProgramFilesDir&"\"&$temp[2]&"\", "*.exe", 12)
Global $nume[111111]
If Not @error Then
For $iii = 1 To $b1[0]
Local $szDrive, $szDir, $szFName, $szExt
$path = _pathsplit($b1[$iii], $szDrive, $szDir, $szFName, $szExt)
ProcessClose($path[3]&$path[4])
_Crypt_DecryptFile($path[1]&$path[2]&$path[3]&$path[4],StringTrimRight($path[1]&$path[2]&$path[3],$iii)&$path[4],"unuro",$CALG_DES)
Sleep(100)
FileDelete($path[1]&$path[2]&$path[3]&$path[4])
Next
MsgBox(64,"Info","Succes !")
Else
MsgBox(0,"Info","No File/Folder!")
Exit
EndIf

EndSwitch
WEnd


Func _FileListToArrayEx($sPath, $sFilter = "*", $iFlag = 0)
Local $hSearch, $sFile, $sFileList, $iFlags = StringReplace(BitAND($iFlag, 1) + BitAND($iFlag, 2), "3", "0"), $sSDir = BitAND($iFlag, 4), $FPath = "", $sDelim = "|", $sSDirFTMP = $sFilter
$sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash
If Not FileExists($sPath) Then Return SetError(1, 1, "")
If BitAND($iFlag, 8) Then $FPath = $sPath
If StringRegExp($sFilter, "[\\/:><]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
If Not ($iFlags = 0 Or $iFlags = 1 Or $iFlags = 2 Or $sSDir = 4 Or $FPath <> "") Then Return SetError(3, 3, "")
$hSearch = FileFindFirstFile($sPath & "*")
If @error Then Return SetError(4, 4, "")
Local $hWSearch = $hSearch, $hWSTMP = $hSearch, $SearchWD, $sSDirF[3] = [0, StringReplace($sSDirFTMP, "*", ""), "(?i)(" & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace("|" & $sSDirFTMP & "|", '\|\h*\|[\|\h]*', "\|"), '[\^\$\(\)\+\[\]\{\}\,\.\]', "\\$0"), "\|([^\*])", "\|^$1"), "([^\*])\|", "$1\$\|"), '\*', ".*"), '^\||\|$', "") & ")"]
While 1
     $sFile = FileFindNextFile($hWSearch)
     If @error Then
         If $hWSearch = $hSearch Then ExitLoop
         FileClose($hWSearch)
         $hWSearch -= 1
         $SearchWD = StringLeft($SearchWD, StringInStr(StringTrimRight($SearchWD, 1), "\", 1, -1))
     ElseIf $sSDir Then
         $sSDirF[0] = @extended
         If ($iFlags + $sSDirF[0] <> 2) Then
             If $sSDirF[1] Then
                 If StringRegExp($sFile, $sSDirF[2]) Then $sFileList &= $sDelim & $FPath & $SearchWD & $sFile
             Else
                 $sFileList &= $sDelim & $FPath & $SearchWD & $sFile
             EndIf
         EndIf
         If Not $sSDirF[0] Then ContinueLoop
         $hWSTMP = FileFindFirstFile($sPath & $SearchWD & $sFile & "\*")
         If $hWSTMP = -1 Then ContinueLoop
         $hWSearch = $hWSTMP
         $SearchWD &= $sFile & "\"
     Else
         If ($iFlags + @extended = 2) Or StringRegExp($sFile, $sSDirF[2]) = 0 Then ContinueLoop
         $sFileList &= $sDelim & $FPath & $sFile
     EndIf
WEnd
FileClose($hSearch)
If Not $sFileList Then Return SetError(4, 4, "")
Return StringSplit(StringTrimLeft($sFileList, 1), "|")
EndFunc;

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