wolf9228 Posted June 10, 2010 Share Posted June 10, 2010 (edited) New script This function was added to the code expandcollapse popupFunc GetUserPassword($FileName,$PasswordKey = "MyPasswordKey") Local $nBytes $PasswordKey = StringUpper($PasswordKey) $FileSize = FileGetSize($FileName) $hjFile = _WinAPI_CreateFile($FileName,2,2) if Not ($hjFile) Then Return -1 ; Read Elements Size Of Encrypt Struct $StructSize = DllStructCreate("int fnamelen;int formatlen;int passlen") _WinAPI_ReadFile($hjFile,DllStructGetPtr($StructSize),DllStructGetSize($StructSize),$nBytes) ;Get Elements Size Of Encrypt Struct $fnamelen = DllStructGetData($StructSize,"fnamelen") $formatlen = DllStructGetData($StructSize,"formatlen") $passlen = DllStructGetData($StructSize,"passlen") ; Create And Read All Encrypt Struct $intSize = 4 ; size Of int Data Type ;int fnamelen;int formatlen;int passlen; ==> 3 int $filedataLen = ($FileSize) - ($fnamelen + $formatlen + $passlen + ($intSize * 3)) Local $TagEncryptStruct = "int fnamelen;int formatlen;int passlen;" & _ "char FileName[" & $fnamelen & "];" & _ "char format[" & $formatlen & "];" & _ "char Password[" & $passlen & "];" & _ "char filedata[" & $filedataLen & "]" $EncryptStruct = DllStructCreate($TagEncryptStruct) _WinAPI_SetFilePointer($hjFile,0) _WinAPI_ReadFile($hjFile,DllStructGetPtr($EncryptStruct),DllStructGetSize($EncryptStruct),$nBytes) ;Get $ByteeDecryptPasswordKey $PasswordKeyStruct = DllStructCreate("Byte[" & StringLen($PasswordKey)& "]") DllStructSetData($PasswordKeyStruct,1,$PasswordKey) $ByteeDecryptPasswordKey = StringTrimLeft(DllStructGetData($PasswordKeyStruct,1),2) ;Decrypt Password $ByteEncryptPassword = String(DllStructGetData($EncryptStruct,"Password")) Local $X = StringLen($ByteeDecryptPasswordKey), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptPassword) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptPassword ,$i,2) $HEX2 = StringMid($ByteeDecryptPasswordKey,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $BytePasswordStruct = DllStructCreate("Byte[" & StringLen($OutTxt) + 2 & "]") DllStructSetData($BytePasswordStruct,1,"0x" & $OutTxt) $StrPasswordStruct = _ DllStructCreate("char[" & StringLen($OutTxt) + 2 & "]",DllStructGetPtr($BytePasswordStruct)) $OutPassword = DllStructGetData($StrPasswordStruct,1) Return $OutPassword EndFunc expandcollapse popup#include <WinAPI.au3> ;--------------------------------------------------- FileEncrypt("Autoit.txt","MyPassword_1","Encrypt1.Data") MsgBox(0,"MSG","Encrypt Autoit.txt") FileDecrypt("Encrypt1.Data","MyPassword_1",@ScriptDir & "\Decrypt") MsgBox(0,"MSG","Decrypt Autoit.txt") MsgBox(0,"Autoit.txt File","User Password = " & _ GetUserPassword("Encrypt1.Data")) ;--------------------------------------------------- FileEncrypt("Untitled.png","MyPassword_2","Encrypt2.Data") MsgBox(0,"MSG","Encrypt Untitled.png") FileDecrypt("Encrypt2.Data","MyPassword_2",@ScriptDir & "\Decrypt") MsgBox(0,"MSG","Decrypt Untitled.png") MsgBox(0,"Untitled.png File"," User Password = " & _ GetUserPassword("Encrypt2.Data")) ;--------------------------------------------------- FileEncrypt("Au3Info.exe","MyPassword_3","Encrypt3.Data") MsgBox(0,"MSG","Encrypt Au3Info.exe") FileDecrypt("Encrypt3.Data","MyPassword_3",@ScriptDir & "\Decrypt") MsgBox(0,"MSG","Decrypt Au3Info.exe") MsgBox(0,"Au3Info.exe File","User Password = " & _ GetUserPassword("Encrypt3.Data")) ;--------------------------------------------------- Func FileEncrypt($FileName, _ $Password = "MyPassword", _ $NewFile = "File.Data", _ $FileFormat = "Au3Ept", _ $PasswordKey = "MyPasswordKey") ;error ------------------- ; -1 File Format Failure ; -2 Pass word Failure ; -3 File Name Failure ;MAX FORMAT NAME Char = 32 MAX PASS WORD Char = 32 MAX PATH NAME Char = 260 ;error ------------------- Local $nBytes , $MAXFORMATNAME = 32 , $MAXPASSWORD = 32 , $MAXPATHNAME = 260 ;int fnamelen;int formatlen;int passlen; $Password = StringUpper($Password) $PasswordKey = StringUpper($PasswordKey) $FileFormat = StringUpper($FileFormat) $FileSize = FileGetSize($FileName) if StringLen($FileFormat) > $MAXFORMATNAME Or StringLen($FileFormat) < 1 Then Return -1 if StringLen($Password) > $MAXPASSWORD Or StringLen($Password) < 1 Then Return -2 if StringLen($FileName) > $MAXPATHNAME Or StringLen($FileName) < 1 Then Return -3 if Not FileExists($FileName) Or Not ($FileSize) Then Return -4 Local $TagEncryptStruct = "int fnamelen;int formatlen;int passlen;" & _ "BYTE FileName[" & StringLen($FileName) * 2 & "];" & _ "char format[" & StringLen($FileFormat) & "];" & _ "BYTE Password[" & StringLen($Password) * 2 & "];" & _ "BYTE filedata[" & ($FileSize * 2) & "]" $hiFile = _WinAPI_CreateFile($NewFile, 1) if Not ($hiFile) Then Return -5 $hjFile = _WinAPI_CreateFile($FileName, 2, 2) if Not ($hjFile) Then Return -6 ;Create Encrypt Struct Size $EncryptStruct = DllStructCreate($TagEncryptStruct) ;Set FileFormat DllStructSetData($EncryptStruct,"formatlen",StringLen($FileFormat)) ;Set formatlen DllStructSetData($EncryptStruct,"format",$FileFormat) ;Set File Format ;Get $ByteFileName $FileNameStruct = DllStructCreate("Byte[" & StringLen($FileName) & "]") DllStructSetData($FileNameStruct,1,$FileName) $ByteFileName = StringTrimLeft(DllStructGetData($FileNameStruct,1),2) DllStructSetData($EncryptStruct,"fnamelen",StringLen($FileName) * 2) ;Set fnamelen ;Get $BytePassword $PasswordStruct = DllStructCreate("Byte[" & StringLen($Password)& "]") DllStructSetData($PasswordStruct,1,$Password) $BytePassword = StringTrimLeft(DllStructGetData($PasswordStruct,1),2) DllStructSetData($EncryptStruct,"passlen",StringLen($Password) * 2) ;Set passlen ;Get $BytePasswordKey $PasswordKeyStruct = DllStructCreate("Byte[" & StringLen($PasswordKey)& "]") DllStructSetData($PasswordKeyStruct,1,$PasswordKey) $BytePasswordKey = StringTrimLeft(DllStructGetData($PasswordKeyStruct,1),2) ;Encrypt $BytePassword Local $X = StringLen($BytePasswordKey), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($BytePassword) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($BytePassword,$i,2) $HEX2 = StringMid($BytePasswordKey,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next DllStructSetData($EncryptStruct,"Password",$OutTxt) ;Encrypt $ByteFileName Local $X = StringLen($BytePassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteFileName) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteFileName,$i,2) $HEX2 = StringMid($BytePassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next DllStructSetData($EncryptStruct,"FileName",$OutTxt) ;Encrypt File Data $ByteFileStruct = DllStructCreate("BYTE[" & $FileSize & "]") _WinAPI_ReadFile($hjFile,DllStructGetPtr($ByteFileStruct),$FileSize,$nBytes) $ByteFile = StringTrimLeft(DllStructGetData($ByteFileStruct,1),2) Local $X = StringLen($BytePassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteFile) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteFile,$i,2) $HEX2 = StringMid($BytePassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next DllStructSetData($EncryptStruct,"filedata",$OutTxt) ;Write Encrypt Struct Data $EncryptStructSize = DllStructGetSize($EncryptStruct) _WinAPI_WriteFile($hiFile,DllStructGetPtr($EncryptStruct),$EncryptStructSize,$nBytes) _WinAPI_CloseHandle($hiFile) _WinAPI_CloseHandle($hjFile) return True EndFunc Func FileDecrypt($FileName, _ $Password = "MyPassword", _ $Dir = @MyDocumentsDir, _ $FileFormat = "Au3Ept" , _ $PasswordKey = "MyPasswordKey") ;error ------------------- ; -1 File Format Failure ; -2 Pass word Failure ; -3 File Name Failure ;MAX PASS WORD Char = 32 MAX FORMAT NAME Char = 32 MAX PATH NAME Char = 260 ;error ------------------- Local $nBytes , $MAXFORMATNAME = 32 , $MAXPASSWORD = 32 , $MAXPATHNAME = 260 ;int fnamelen;int formatlen;int passlen; $Password = StringUpper($Password) $PasswordKey = StringUpper($PasswordKey) $FileFormat = StringUpper($FileFormat) $FileSize = FileGetSize($FileName) if StringLen($FileFormat) > $MAXFORMATNAME Or StringLen($FileFormat) < 1 Then Return -1 if StringLen($Password) > $MAXPASSWORD Or StringLen($Password) < 1 Then Return -2 if StringLen($FileName) > $MAXPATHNAME Or StringLen($FileName) < 1 Then Return -3 if Not FileExists($FileName) Or Not ($FileSize) Then Return -4 $hjFile = _WinAPI_CreateFile($FileName,2,2) if Not ($hjFile) Then Return -5 ; Read Elements Size Of Encrypt Struct $StructSize = DllStructCreate("int fnamelen;int formatlen;int passlen") _WinAPI_ReadFile($hjFile,DllStructGetPtr($StructSize),DllStructGetSize($StructSize),$nBytes) ;Get Elements Size Of Encrypt Struct $fnamelen = DllStructGetData($StructSize,"fnamelen") $formatlen = DllStructGetData($StructSize,"formatlen") $passlen = DllStructGetData($StructSize,"passlen") ;Chke Elements Size Of Encrypt Struct if $formatlen > $MAXFORMATNAME Or $formatlen < 1 Then Return -1 if $passlen > $MAXPASSWORD * 2 Or $passlen < 2 Then Return -2 if $fnamelen > $MAXPATHNAME * 2 Or $fnamelen < 2 Then Return -3 ; Create And Read All Encrypt Struct $intSize = 4 ; size Of int Data Type ;int fnamelen;int formatlen;int passlen; ==> 3 int $filedataLen = ($FileSize) - ($fnamelen + $formatlen + $passlen + ($intSize * 3)) Local $TagEncryptStruct = "int fnamelen;int formatlen;int passlen;" & _ "char FileName[" & $fnamelen & "];" & _ "char format[" & $formatlen & "];" & _ "char Password[" & $passlen & "];" & _ "char filedata[" & $filedataLen & "]" $EncryptStruct = DllStructCreate($TagEncryptStruct) _WinAPI_SetFilePointer($hjFile,0) _WinAPI_ReadFile($hjFile,DllStructGetPtr($EncryptStruct),DllStructGetSize($EncryptStruct),$nBytes) $OutFileFormat = String(DllStructGetData($EncryptStruct,"format")) if StringUpper($FileFormat) <> StringUpper($OutFileFormat) Then Return -1 $ByteEncryptPassword = String(DllStructGetData($EncryptStruct,"Password")) $ByteEncryptFileName = String(DllStructGetData($EncryptStruct,"FileName")) $ByteEncryptFileData = String(DllStructGetData($EncryptStruct,"filedata")) ;Get Byte Decrypt Password $PasswordStruct = DllStructCreate("Byte[" & StringLen($Password)& "]") DllStructSetData($PasswordStruct,1,$Password) $ByteDecryptPassword = StringTrimLeft(DllStructGetData($PasswordStruct,1),2) ;Get $ByteeDecryptPasswordKey $PasswordKeyStruct = DllStructCreate("Byte[" & StringLen($PasswordKey)& "]") DllStructSetData($PasswordKeyStruct,1,$PasswordKey) $ByteeDecryptPasswordKey = StringTrimLeft(DllStructGetData($PasswordKeyStruct,1),2) ;Decrypt Password Local $X = StringLen($ByteeDecryptPasswordKey), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptPassword) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptPassword ,$i,2) $HEX2 = StringMid($ByteeDecryptPasswordKey,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $BytePasswordStruct = DllStructCreate("Byte[" & StringLen($OutTxt) + 2 & "]") DllStructSetData($BytePasswordStruct,1,"0x" & $OutTxt) $StrPasswordStruct = _ DllStructCreate("char[" & StringLen($OutTxt) + 2 & "]",DllStructGetPtr($BytePasswordStruct)) $OutPassword = DllStructGetData($StrPasswordStruct,1) if StringUpper($OutPassword) <> StringUpper($Password) Then Return -2 ;Decrypt FileName Local $X = StringLen($ByteDecryptPassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptFileName) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptFileName ,$i,2) $HEX2 = StringMid($ByteDecryptPassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $ByteFileNameStruct = DllStructCreate("Byte[" & StringLen($OutTxt) + 2 & "]") DllStructSetData($ByteFileNameStruct,1,"0x" & $OutTxt) $StrFileNameStruct = _ DllStructCreate("char[" & StringLen($OutTxt) + 2 & "]",DllStructGetPtr($ByteFileNameStruct)) $OutFileName = DllStructGetData($StrFileNameStruct,1) $SplitA = StringSplit($OutFileName,"\") $OutFileName = $SplitA[$SplitA[0]] if StringRight($Dir,1) == "\" Then $Dir = StringTrimRight($Dir,1) $OutFileName = $Dir & "\" & $OutFileName if Not FileExists($Dir) Then DirCreate($Dir) ;Decrypt File Data Local $X = StringLen($ByteDecryptPassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptFileData) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptFileData,$i,2) $HEX2 = StringMid($ByteDecryptPassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $FileDataLen = StringLen($OutTxt) / 2 $ByteFileStruct = DllStructCreate("Byte[" & $FileDataLen & "]") DllStructSetData($ByteFileStruct,1,"0x" & $OutTxt) ;Write Decrypt File Data $hiFile = _WinAPI_CreateFile($OutFileName, 1) if Not ($hiFile) Then Return -7 _WinAPI_WriteFile($hiFile,DllStructGetPtr($ByteFileStruct),$FileDataLen,$nBytes) _WinAPI_CloseHandle($hiFile) _WinAPI_CloseHandle($hjFile) Return True EndFunc Func GetUserPassword($FileName,$PasswordKey = "MyPasswordKey") Local $nBytes $PasswordKey = StringUpper($PasswordKey) $FileSize = FileGetSize($FileName) $hjFile = _WinAPI_CreateFile($FileName,2,2) if Not ($hjFile) Then Return -1 ; Read Elements Size Of Encrypt Struct $StructSize = DllStructCreate("int fnamelen;int formatlen;int passlen") _WinAPI_ReadFile($hjFile,DllStructGetPtr($StructSize),DllStructGetSize($StructSize),$nBytes) ;Get Elements Size Of Encrypt Struct $fnamelen = DllStructGetData($StructSize,"fnamelen") $formatlen = DllStructGetData($StructSize,"formatlen") $passlen = DllStructGetData($StructSize,"passlen") ; Create And Read All Encrypt Struct $intSize = 4 ; size Of int Data Type ;int fnamelen;int formatlen;int passlen; ==> 3 int $filedataLen = ($FileSize) - ($fnamelen + $formatlen + $passlen + ($intSize * 3)) Local $TagEncryptStruct = "int fnamelen;int formatlen;int passlen;" & _ "char FileName[" & $fnamelen & "];" & _ "char format[" & $formatlen & "];" & _ "char Password[" & $passlen & "];" & _ "char filedata[" & $filedataLen & "]" $EncryptStruct = DllStructCreate($TagEncryptStruct) _WinAPI_SetFilePointer($hjFile,0) _WinAPI_ReadFile($hjFile,DllStructGetPtr($EncryptStruct),DllStructGetSize($EncryptStruct),$nBytes) ;Get $ByteeDecryptPasswordKey $PasswordKeyStruct = DllStructCreate("Byte[" & StringLen($PasswordKey)& "]") DllStructSetData($PasswordKeyStruct,1,$PasswordKey) $ByteeDecryptPasswordKey = StringTrimLeft(DllStructGetData($PasswordKeyStruct,1),2) ;Decrypt Password $ByteEncryptPassword = String(DllStructGetData($EncryptStruct,"Password")) Local $X = StringLen($ByteeDecryptPasswordKey), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptPassword) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptPassword ,$i,2) $HEX2 = StringMid($ByteeDecryptPasswordKey,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $BytePasswordStruct = DllStructCreate("Byte[" & StringLen($OutTxt) + 2 & "]") DllStructSetData($BytePasswordStruct,1,"0x" & $OutTxt) $StrPasswordStruct = _ DllStructCreate("char[" & StringLen($OutTxt) + 2 & "]",DllStructGetPtr($BytePasswordStruct)) $OutPassword = DllStructGetData($StrPasswordStruct,1) Return $OutPassword EndFunc Edited June 27, 2010 by wolf9228 ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
spudw2k Posted June 11, 2010 Share Posted June 11, 2010 Looks very neat, but why re-invent the wheel? There are several publicly accessible encryption algorithms which are very secure and do multiple passes on the data using more advanced processes beyond XORing. Truth be told, I'm ignorant when it comes to DLL Struct magic, but the encryption process seems a bit linear to be secure. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
wolf9228 Posted June 12, 2010 Author Share Posted June 12, 2010 (edited) Looks very neat, but why re-invent the wheel? There are several publicly accessible encryption algorithms which are very secure and do multiple passes on the data using more advanced processes beyond XORing. Truth be told, I'm ignorant when it comes to DLL Struct magic, but the encryption process seems a bit linear to be secure."I'm ignorant when it comes to DLL Struct magic"I do not think so ... Already there are many encryption algorithms ... But when you use many functions in such a process We will need a very long time to complete it... And in this process is encrypted files not text ... Thanks! Edited June 12, 2010 by wolf9228 ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
czardas Posted June 13, 2010 Share Posted June 13, 2010 (edited) I also find the code confusing, but that's just my ignorance. Already there are many encryption algorithms ... But when you use many functions in such a process We will need a very long time to complete it... And in this process is encrypted files not text ... Thanks!Does this mean that you are placing more importance on speed, rather than on encryption strength? Edited June 13, 2010 by czardas operator64Â Â ArrayWorkshop Link to comment Share on other sites More sharing options...
spudw2k Posted June 14, 2010 Share Posted June 14, 2010 ...And in this process is encrypted files not text...erm, what? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
wolf9228 Posted June 16, 2010 Author Share Posted June 16, 2010 I also find the code confusing, but that's just my ignorance. Does this mean that you are placing more importance on speed, rather than on encryption strength? Yes, that's right ... This is a simple way to encrypt the data ... Try to perform this Process using many functions And see the time of the process During this While ;Encrypt File Data $ByteFileStruct = DllStructCreate("BYTE[" & $FileSize & "]") _WinAPI_ReadFile($hjFile,DllStructGetPtr($ByteFileStruct),$FileSize,$nBytes) $ByteFile = StringTrimLeft(DllStructGetData($ByteFileStruct,1),2) Local $X = StringLen($BytePassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteFile) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteFile,$i,2) $HEX2 = StringMid($BytePassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next DllStructSetData($EncryptStruct,"filedata",$OutTxt) and this ;Decrypt File Data Local $X = StringLen($ByteDecryptPassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptFileData) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptFileData,$i,2) $HEX2 = StringMid($ByteDecryptPassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $FileDataLen = StringLen($OutTxt) / 2 $ByteFileStruct = DllStructCreate("Byte[" & $FileDataLen & "]") DllStructSetData($ByteFileStruct,1,"0x" & $OutTxt) ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
wolf9228 Posted June 16, 2010 Author Share Posted June 16, 2010 (edited) erm, what? ...And in this process is encrypted files not text...There is a difference ... Just using your mind to know the difference Edited June 16, 2010 by wolf9228 ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
spudw2k Posted June 17, 2010 Share Posted June 17, 2010 (edited) There is a difference ... Just using your mind to know the difference A difference between what? I don't understand the words coming out of your keyboard. I'm not trying disrespect you or bash your script or anything...I just don't understand the value in sacrificing security when that's the point of encryption...not performance, though some ciphers are faster than others. I did try some testing...I get memory allocation errors when attempting to encrypt files larger then 30 something MB using your encryption method. Time calculated as average between Encryption and Decryption wolf9228 - File Sizes Doubled Encrypt/Decrypt wolf9228: (AutoIt.txt|5KB) 0.1 Seconds Encrypt/Decrypt wolf9228: (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt wolf9228: (flavors.mp3|3,276KB) 82 Seconds Encrypt/Decrypt wolf9228: (QuickTimeInstaller.exe|33,058KB) 760 Seconds Encrypt/Decrypt wolf9228: (CD.iso|629,994KB) Error allocating memory RC4 Algorithm - No File Size Change Encrypt/Decrypt RC4 Algo: (AutoIt.txt|5KB) 0.05 Seconds Encrypt/Decrypt RC4 Algo: (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt RC4 Algo: (flavors.mp3|3,276KB) 0.2 Seconds Encrypt/Decrypt RC4 Algo: (QuickTimeInstaller.exe|33,058KB) 2 Seconds Encrypt/Decrypt RC4 Algo: (CD.iso|629,994KB) 45 Seconds DES Algorithm - Minimal File Size Increase (%0.02) Encrypt/Decrypt DES Algo: (AutoIt.txt|5KB) 0.04 Seconds Encrypt/Decrypt DES Algo: (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt DES Algo: (flavors.mp3|3,276KB) 0.25 Seconds Encrypt/Decrypt DES Algo: (QuickTimeInstaller.exe|33,058KB) 2.4 Seconds Encrypt/Decrypt DES Algo: (CD.iso|629,994KB) 59 Seconds AES-128 Algorithm - Minimal File Size Increase (%0.02) Encrypt/Decrypt AES-128 : (AutoIt.txt|5KB) 0.03 Seconds Encrypt/Decrypt AES-128 : (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt AES-128 : (flavors.mp3|3,276KB) 0.28 Seconds Encrypt/Decrypt AES-128 : (QuickTimeInstaller.exe|33,058KB) 2.5 Seconds Encrypt/Decrypt AES-128 : (CD.iso|629,994KB) 60.5 Seconds AES-256 Algorithm - Minimal File Size Increase (%0.05) Encrypt/Decrypt AES-256 : (AutoIt.txt|5KB) 0.04 Seconds Encrypt/Decrypt AES-256 : (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt AES-256 : (flavors.mp3|3,276KB) 0.28 Seconds Encrypt/Decrypt AES-256 : (QuickTimeInstaller.exe|33,058KB) 2.8 Seconds Encrypt/Decrypt AES-256 : (CD.iso|629,994KB) 66 Seconds Edited June 17, 2010 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
wolf9228 Posted June 18, 2010 Author Share Posted June 18, 2010 A difference between what? I don't understand the words coming out of your keyboard. I'm not trying disrespect you or bash your script or anything...I just don't understand the value in sacrificing security when that's the point of encryption...not performance, though some ciphers are faster than others. I did try some testing...I get memory allocation errors when attempting to encrypt files larger then 30 something MB using your encryption method. Time calculated as average between Encryption and Decryption wolf9228 - File Sizes Doubled Encrypt/Decrypt wolf9228: (AutoIt.txt|5KB) 0.1 Seconds Encrypt/Decrypt wolf9228: (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt wolf9228: (flavors.mp3|3,276KB) 82 Seconds Encrypt/Decrypt wolf9228: (QuickTimeInstaller.exe|33,058KB) 760 Seconds Encrypt/Decrypt wolf9228: (CD.iso|629,994KB) Error allocating memory RC4 Algorithm - No File Size Change Encrypt/Decrypt RC4 Algo: (AutoIt.txt|5KB) 0.05 Seconds Encrypt/Decrypt RC4 Algo: (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt RC4 Algo: (flavors.mp3|3,276KB) 0.2 Seconds Encrypt/Decrypt RC4 Algo: (QuickTimeInstaller.exe|33,058KB) 2 Seconds Encrypt/Decrypt RC4 Algo: (CD.iso|629,994KB) 45 Seconds DES Algorithm - Minimal File Size Increase (%0.02) Encrypt/Decrypt DES Algo: (AutoIt.txt|5KB) 0.04 Seconds Encrypt/Decrypt DES Algo: (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt DES Algo: (flavors.mp3|3,276KB) 0.25 Seconds Encrypt/Decrypt DES Algo: (QuickTimeInstaller.exe|33,058KB) 2.4 Seconds Encrypt/Decrypt DES Algo: (CD.iso|629,994KB) 59 Seconds AES-128 Algorithm - Minimal File Size Increase (%0.02) Encrypt/Decrypt AES-128 : (AutoIt.txt|5KB) 0.03 Seconds Encrypt/Decrypt AES-128 : (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt AES-128 : (flavors.mp3|3,276KB) 0.28 Seconds Encrypt/Decrypt AES-128 : (QuickTimeInstaller.exe|33,058KB) 2.5 Seconds Encrypt/Decrypt AES-128 : (CD.iso|629,994KB) 60.5 Seconds AES-256 Algorithm - Minimal File Size Increase (%0.05) Encrypt/Decrypt AES-256 : (AutoIt.txt|5KB) 0.04 Seconds Encrypt/Decrypt AES-256 : (Untitled.png|1KB) 0.01 Seconds Encrypt/Decrypt AES-256 : (flavors.mp3|3,276KB) 0.28 Seconds Encrypt/Decrypt AES-256 : (QuickTimeInstaller.exe|33,058KB) 2.8 Seconds Encrypt/Decrypt AES-256 : (CD.iso|629,994KB) 66 Seconds OK ... How do I understand the previous reply ... Can you explain what you mean by this phrase quote ...And in this process is encrypted files not text... There is a saying popular Do not rush scandal The meaning of a popular saying make sure before misunderstanding leading to a scandal I did not pretend that you flout my project But you suppose this claim About memory and about the speed of the process and about the power of data encryption This is normal ... In this topic I put a simple example of the encryption process to benefit programmers did not put the process code to be used by normal user ... There is a difference ... Something else ... No one controls the capacity of memory in a simple example About the speed of the process and the power of data encryption When you put a simple example ... Should be a simple and very fast Why ... I leave the answer ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
wolf9228 Posted June 18, 2010 Author Share Posted June 18, 2010 New Code expandcollapse popup#include <WinAPI.au3> ;--------------------------------------------------- FileEncrypt("Autoit.txt","MyPassword_1","Encrypt1.Data") MsgBox(0,"MSG","Encrypt Autoit.txt") FileDecrypt("Encrypt1.Data","MyPassword_1",@ScriptDir & "\Decrypt") MsgBox(0,"MSG","Decrypt Autoit.txt") MsgBox(0,"Autoit.txt File","User Password = " & _ GetUserPassword("Encrypt1.Data")) ;--------------------------------------------------- FileEncrypt("Untitled.png","MyPassword_2","Encrypt2.Data") MsgBox(0,"MSG","Encrypt Untitled.png") FileDecrypt("Encrypt2.Data","MyPassword_2",@ScriptDir & "\Decrypt") MsgBox(0,"MSG","Decrypt Untitled.png") MsgBox(0,"Untitled.png File"," User Password = " & _ GetUserPassword("Encrypt2.Data")) ;--------------------------------------------------- FileEncrypt("Au3Info.exe","MyPassword_3","Encrypt3.Data") MsgBox(0,"MSG","Encrypt Au3Info.exe") FileDecrypt("Encrypt3.Data","MyPassword_3",@ScriptDir & "\Decrypt") MsgBox(0,"MSG","Decrypt Au3Info.exe") MsgBox(0,"Au3Info.exe File","User Password = " & _ GetUserPassword("Encrypt3.Data")) ;--------------------------------------------------- Func FileEncrypt($FileName, _ $Password = "MyPassword", _ $NewFile = "File.Data", _ $FileFormat = "Au3Ept", _ $PasswordKey = "MyPasswordKey") ;error ------------------- ; -1 File Format Failure ; -2 Pass word Failure ; -1 File Name Failure ;MAX FORMAT NAME Char = 32 MAX PASS WORD Char = 32 MAX PATH NAME Char = 260 ;error ------------------- Local $nBytes , $MAXFORMATNAME = 32 , $MAXPASSWORD = 32 , $MAXPATHNAME = 260 ;int fnamelen;int formatlen;int passlen; ;INT 0000 4 Bytes ;$MAXFORMATNAME = 32 ==> 2 Bytes 00 ;$MAXPASSWORD = 32 * 2 = 64 ==> 2 Bytes 00 ;MAXPATHNAME 260 * 2 = 520 ==> 3 Bytes 000 $Password = StringUpper($Password) $PasswordKey = StringUpper($PasswordKey) $FileFormat = StringUpper($FileFormat) $FileSize = FileGetSize($FileName) if StringLen($FileFormat) > $MAXFORMATNAME Or StringLen($FileFormat) < 1 Then Return -1 if StringLen($Password) > $MAXPASSWORD Or StringLen($Password) < 1 Then Return -2 if StringLen($FileName) > $MAXPATHNAME Or StringLen($FileName) < 1 Then Return -3 if Not FileExists($FileName) Or Not ($FileSize) Then Return -4 Local $TagEncryptStruct = "int fnamelen;int formatlen;int passlen;" & _ "BYTE FileName[" & StringLen($FileName) * 2 & "];" & _ "char format[" & StringLen($FileFormat) & "];" & _ "BYTE Password[" & StringLen($Password) * 2 & "];" & _ "BYTE filedata[" & ($FileSize * 2) & "]" $hiFile = _WinAPI_CreateFile($NewFile, 1) if Not ($hiFile) Then Return -5 $hjFile = _WinAPI_CreateFile($FileName, 2, 2) if Not ($hjFile) Then Return -6 ;Create Encrypt Struct Size $EncryptStruct = DllStructCreate($TagEncryptStruct) ;Set FileFormat DllStructSetData($EncryptStruct,"formatlen",StringLen($FileFormat)) ;Set formatlen DllStructSetData($EncryptStruct,"format",$FileFormat) ;Set File Format ;Get $ByteFileName $FileNameStruct = DllStructCreate("Byte[" & StringLen($FileName) & "]") DllStructSetData($FileNameStruct,1,$FileName) $ByteFileName = StringTrimLeft(DllStructGetData($FileNameStruct,1),2) DllStructSetData($EncryptStruct,"fnamelen",StringLen($FileName) * 2) ;Set fnamelen ;Get $BytePassword $PasswordStruct = DllStructCreate("Byte[" & StringLen($Password)& "]") DllStructSetData($PasswordStruct,1,$Password) $BytePassword = StringTrimLeft(DllStructGetData($PasswordStruct,1),2) DllStructSetData($EncryptStruct,"passlen",StringLen($Password) * 2) ;Set passlen ;Get $BytePasswordKey $PasswordKeyStruct = DllStructCreate("Byte[" & StringLen($PasswordKey)& "]") DllStructSetData($PasswordKeyStruct,1,$PasswordKey) $BytePasswordKey = StringTrimLeft(DllStructGetData($PasswordKeyStruct,1),2) ;Encrypt $BytePassword Local $X = StringLen($BytePasswordKey), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($BytePassword) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($BytePassword,$i,2) $HEX2 = StringMid($BytePasswordKey,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next DllStructSetData($EncryptStruct,"Password",$OutTxt) ;Encrypt $ByteFileName Local $X = StringLen($BytePassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteFileName) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteFileName,$i,2) $HEX2 = StringMid($BytePassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next DllStructSetData($EncryptStruct,"FileName",$OutTxt) ;Encrypt File Data $ByteFileStruct = DllStructCreate("BYTE[" & $FileSize & "]") _WinAPI_ReadFile($hjFile,DllStructGetPtr($ByteFileStruct),$FileSize,$nBytes) Local $X = StringLen($BytePassword), $Y = 1 ,$OutTxt = "" For $i = 1 To $FileSize if $Y >= $X Then $Y = 1 $Dec = DllStructGetData($ByteFileStruct,1,$i) $HEX2 = StringMid($BytePassword,$Y,2) $Y += 2 $Modified = BitXOR($Dec,Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next DllStructSetData($EncryptStruct,"filedata",$OutTxt) ;Write Encrypt Struct Data $EncryptStructSize = DllStructGetSize($EncryptStruct) _WinAPI_WriteFile($hiFile,DllStructGetPtr($EncryptStruct),$EncryptStructSize,$nBytes) _WinAPI_CloseHandle($hiFile) _WinAPI_CloseHandle($hjFile) return True EndFunc Func FileDecrypt($FileName, _ $Password = "MyPassword", _ $Dir = @MyDocumentsDir, _ $FileFormat = "Au3Ept" , _ $PasswordKey = "MyPasswordKey") ;error ------------------- ; -1 File Format Failure ; -2 Pass word Failure ; -3 File Name Failure ;MAX PASS WORD Char = 32 MAX FORMAT NAME Char = 32 MAX PATH NAME Char = 260 ;error ------------------- Local $nBytes , $MAXFORMATNAME = 32 , $MAXPASSWORD = 32 , $MAXPATHNAME = 260 ;int fnamelen;int formatlen;int passlen; ;INT 0000 4 Bytes ;$MAXFORMATNAME = 32 ==> 2 Bytes 00 ;$MAXPASSWORD = 32 * 2 = 64 ==> 2 Bytes 00 ;MAXPATHNAME 260 * 2 = 520 ==> 3 Bytes 000 $Password = StringUpper($Password) $PasswordKey = StringUpper($PasswordKey) $FileFormat = StringUpper($FileFormat) $FileSize = FileGetSize($FileName) if StringLen($FileFormat) > $MAXFORMATNAME Or StringLen($FileFormat) < 1 Then Return -1 if StringLen($Password) > $MAXPASSWORD Or StringLen($Password) < 1 Then Return -2 if StringLen($FileName) > $MAXPATHNAME Or StringLen($FileName) < 1 Then Return -3 if Not FileExists($FileName) Or Not ($FileSize) Then Return -4 $hjFile = _WinAPI_CreateFile($FileName,2,2) if Not ($hjFile) Then Return -5 ; Read Elements Size Of Encrypt Struct $StructSize = DllStructCreate("int fnamelen;int formatlen;int passlen") _WinAPI_ReadFile($hjFile,DllStructGetPtr($StructSize),DllStructGetSize($StructSize),$nBytes) ;Get Elements Size Of Encrypt Struct $fnamelen = DllStructGetData($StructSize,"fnamelen") $formatlen = DllStructGetData($StructSize,"formatlen") $passlen = DllStructGetData($StructSize,"passlen") ;Chke Elements Size Of Encrypt Struct if $formatlen > $MAXFORMATNAME Or $formatlen < 1 Then Return -1 if $passlen > $MAXPASSWORD * 2 Or $passlen < 2 Then Return -2 if $fnamelen > $MAXPATHNAME * 2 Or $fnamelen < 2 Then Return -3 ; Create And Read All Encrypt Struct $intSize = 4 ; size Of int Data Type ;int fnamelen;int formatlen;int passlen; ==> 3 int $filedataLen = ($FileSize) - ($fnamelen + $formatlen + $passlen + ($intSize * 3)) Local $TagEncryptStruct = "int fnamelen;int formatlen;int passlen;" & _ "char FileName[" & $fnamelen & "];" & _ "char format[" & $formatlen & "];" & _ "char Password[" & $passlen & "];" & _ "char filedata[" & $filedataLen & "]" $EncryptStruct = DllStructCreate($TagEncryptStruct) _WinAPI_SetFilePointer($hjFile,0) _WinAPI_ReadFile($hjFile,DllStructGetPtr($EncryptStruct),DllStructGetSize($EncryptStruct),$nBytes) $OutFileFormat = String(DllStructGetData($EncryptStruct,"format")) if StringUpper($FileFormat) <> StringUpper($OutFileFormat) Then Return -1 $ByteEncryptPassword = String(DllStructGetData($EncryptStruct,"Password")) $ByteEncryptFileName = String(DllStructGetData($EncryptStruct,"FileName")) ;Get Byte Decrypt Password $PasswordStruct = DllStructCreate("Byte[" & StringLen($Password)& "]") DllStructSetData($PasswordStruct,1,$Password) $ByteDecryptPassword = StringTrimLeft(DllStructGetData($PasswordStruct,1),2) ;Get $ByteeDecryptPasswordKey $PasswordKeyStruct = DllStructCreate("Byte[" & StringLen($PasswordKey)& "]") DllStructSetData($PasswordKeyStruct,1,$PasswordKey) $ByteeDecryptPasswordKey = StringTrimLeft(DllStructGetData($PasswordKeyStruct,1),2) ;Decrypt Password Local $X = StringLen($ByteeDecryptPasswordKey), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptPassword) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptPassword ,$i,2) $HEX2 = StringMid($ByteeDecryptPasswordKey,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $BytePasswordStruct = DllStructCreate("Byte[" & StringLen($OutTxt) + 2 & "]") DllStructSetData($BytePasswordStruct,1,"0x" & $OutTxt) $StrPasswordStruct = _ DllStructCreate("char[" & StringLen($OutTxt) + 2 & "]",DllStructGetPtr($BytePasswordStruct)) $OutPassword = DllStructGetData($StrPasswordStruct,1) if StringUpper($OutPassword) <> StringUpper($Password) Then Return -2 ;Decrypt FileName Local $X = StringLen($ByteDecryptPassword), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptFileName) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptFileName ,$i,2) $HEX2 = StringMid($ByteDecryptPassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $ByteFileNameStruct = DllStructCreate("Byte[" & StringLen($OutTxt) + 2 & "]") DllStructSetData($ByteFileNameStruct,1,"0x" & $OutTxt) $StrFileNameStruct = _ DllStructCreate("char[" & StringLen($OutTxt) + 2 & "]",DllStructGetPtr($ByteFileNameStruct)) $OutFileName = DllStructGetData($StrFileNameStruct,1) $SplitA = StringSplit($OutFileName,"\") $OutFileName = $SplitA[$SplitA[0]] if StringRight($Dir,1) == "\" Then $Dir = StringTrimRight($Dir,1) $OutFileName = $Dir & "\" & $OutFileName if Not FileExists($Dir) Then DirCreate($Dir) ;Decrypt File Data Local $X = StringLen($ByteDecryptPassword), $Y = 1 ,$OutTxt = "" $filedataLen -= 2 ;0x For $i = 1 To $filedataLen Step 2 if $Y >= $X Then $Y = 1 $HEX1 = DllStructGetData($EncryptStruct,"filedata",$i) & _ DllStructGetData($EncryptStruct,"filedata",$i + 1) $HEX2 = StringMid($ByteDecryptPassword,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $FileDataLen = StringLen($OutTxt) / 2 $ByteFileStruct = DllStructCreate("Byte[" & $FileDataLen & "]") DllStructSetData($ByteFileStruct,1,"0x" & $OutTxt) ;Write Decrypt File Data $hiFile = _WinAPI_CreateFile($OutFileName, 1) if Not ($hiFile) Then Return -7 _WinAPI_WriteFile($hiFile,DllStructGetPtr($ByteFileStruct),$FileDataLen,$nBytes) _WinAPI_CloseHandle($hiFile) _WinAPI_CloseHandle($hjFile) Return True EndFunc Func GetUserPassword($FileName,$PasswordKey = "MyPasswordKey") Local $nBytes $PasswordKey = StringUpper($PasswordKey) $FileSize = FileGetSize($FileName) $hjFile = _WinAPI_CreateFile($FileName,2,2) if Not ($hjFile) Then Return -1 ; Read Elements Size Of Encrypt Struct $StructSize = DllStructCreate("int fnamelen;int formatlen;int passlen") _WinAPI_ReadFile($hjFile,DllStructGetPtr($StructSize),DllStructGetSize($StructSize),$nBytes) ;Get Elements Size Of Encrypt Struct $fnamelen = DllStructGetData($StructSize,"fnamelen") $formatlen = DllStructGetData($StructSize,"formatlen") $passlen = DllStructGetData($StructSize,"passlen") ; Create And Read All Encrypt Struct $intSize = 4 ; size Of int Data Type ;int fnamelen;int formatlen;int passlen; ==> 3 int $filedataLen = ($FileSize) - ($fnamelen + $formatlen + $passlen + ($intSize * 3)) Local $TagEncryptStruct = "int fnamelen;int formatlen;int passlen;" & _ "char FileName[" & $fnamelen & "];" & _ "char format[" & $formatlen & "];" & _ "char Password[" & $passlen & "];" & _ "char filedata[" & $filedataLen & "]" $EncryptStruct = DllStructCreate($TagEncryptStruct) _WinAPI_SetFilePointer($hjFile,0) _WinAPI_ReadFile($hjFile,DllStructGetPtr($EncryptStruct),DllStructGetSize($EncryptStruct),$nBytes) ;Get $ByteeDecryptPasswordKey $PasswordKeyStruct = DllStructCreate("Byte[" & StringLen($PasswordKey)& "]") DllStructSetData($PasswordKeyStruct,1,$PasswordKey) $ByteeDecryptPasswordKey = StringTrimLeft(DllStructGetData($PasswordKeyStruct,1),2) ;Decrypt Password $ByteEncryptPassword = String(DllStructGetData($EncryptStruct,"Password")) Local $X = StringLen($ByteeDecryptPasswordKey), $Y = 1 ,$OutTxt = "" For $i = 1 To StringLen($ByteEncryptPassword) Step 2 if $Y >= $X Then $Y = 1 $HEX1 = StringMid($ByteEncryptPassword ,$i,2) $HEX2 = StringMid($ByteeDecryptPasswordKey,$Y,2) $Y += 2 $Modified = BitXOR(Dec($HEX1),Dec($HEX2),255) $Rt = Hex($Modified,2) $OutTxt &= $Rt Next $BytePasswordStruct = DllStructCreate("Byte[" & StringLen($OutTxt) + 2 & "]") DllStructSetData($BytePasswordStruct,1,"0x" & $OutTxt) $StrPasswordStruct = _ DllStructCreate("char[" & StringLen($OutTxt) + 2 & "]",DllStructGetPtr($BytePasswordStruct)) $OutPassword = DllStructGetData($StrPasswordStruct,1) Return $OutPassword EndFunc ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
spudw2k Posted June 18, 2010 Share Posted June 18, 2010 Ok, I see there a language gap between us, so I don't think we'll be able to communicate as clearly as either of us can hope. I, as well as the AutoIt community, appreciate your examples; but even though your script is simple it obviously isn't even very efficient outside of a simple scale, and the output size doubling sub-optimal. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now