Jump to content
Jfish

Create Self Extracting Encrypted EXE files

Recommended Posts

Jfish

Hello all.  I was playing around with encrypt.au3 and thought it would be neat to build an executable that could extract and decrypt an encrypted file (sort of like an option in PGP if you have ever used that before).  I had to think on the issue of installing the file in the exe because you can't use variable path names.  The approach I came up with may not be the best - others may have much better ideas - but I thought I would share it nonetheless in case anyone finds it interesting.

;*********************************************
; Example script
; ENCRYPT A FILE INTO A SELF-EXTRACTING EXE
; by: JFish
;
;********************************************

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include <Crypt.au3> ; will be used for the encryption
#include <File.au3> ; will be used to manipulate au3 file before we compile

#Region ### START Koda GUI section ### Form=C:\Users\RC01712\Documents\Scripts\Encrypt Tool\encrypt_GUI.kxf
$Form1 = GUICreate("Form1", 657, 244, 192, 132)
$sourceInput = GUICtrlCreateInput("", 144, 48, 337, 24)
$sourceBtn = GUICtrlCreateButton("Browse", 40, 48, 89, 25)
$encryptBtn = GUICtrlCreateButton("Encrypt", 224, 128, 145, 33)
$passwordInput = GUICtrlCreateInput("", 144, 80, 337, 24)
$Label1 = GUICtrlCreateLabel("Password", 40, 80, 73, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$decryptBtn = GUICtrlCreateButton("Decrypt", 224, 176, 145, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; var declaration for global scope
dim $sourceFile, $password, $filename, $filenameRoot, $fileExtension, $publicEncFileNameFullPath, $publicEncFileName

; select a source file that we want to encrypt
func _selectFile()
    GUICtrlSetData($sourceInput,"")
    $filename=""
    $sourceFile=FileOpenDialog("Please select a file to encrypt",@ScriptDir,"All (*.*)")
    $dirLen=stringlen(@WorkingDir)+1
    ;grab the file name
    $filename=StringTrimLeft($sourceFile,$dirLen)
    local $firstDot=stringinstr($filename,".",0,-1)
    ;grab the file root name without the extension
    $filenameRoot=stringtrimright($filename,stringlen($filename)-$firstDot+1)
    ;grab the file extension
    $fileExtension=stringtrimleft($filename,$firstDot-1)
    ;MsgBox("","",$fileExtension)
    GUICtrlSetData($sourceInput,$sourceFile)
EndFunc

func _encrypt()
$password = GUICtrlRead($passwordInput)
if $password="" then
    MsgBox("","","please enter a password")
EndIf
; encrypt the file NOTE: method in example of AES 256 is hard coded
$result =_Crypt_EncryptFile($sourceFile,@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension,$password,$CALG_AES_256)
; if the encryptions works ...
    if $result=True Then
        ; set the full path name to the file including the new "_enc" showing that it is encrypted
        $publicEncFileNameFullPath=@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension
        ; setr the name of the encrypted file without the path
        $publicEncFileName=$filenameRoot&"_enc"&$fileExtension
        ; call the function to create the exe
        _createEXE($publicEncFileName,$publicEncFileName)
    else
        MsgBox("","","encryption error")
    EndIf
MsgBox("","Encrypt status",$result)
EndFunc


func _createEXE($publicEncFileNameFullPath,$publicEncFileName)

;*****************************************************************
; This functions writes an au3 file that will get compiled and become our
; 'self extracting' encrypted file and program to decrypt
; The biggest issue is embedding the encrypted file with fileinstall
; b/c it does not take variable path names
;******************************************************************

; craete an INI file with the full path name and file name of the encrypted file
IniWrite(@ScriptDir&"\temp.ini","filedata","filename",$publicEncFileName)
IniWrite(@ScriptDir&"\temp.ini","filedata","filepath",@ScriptDir&"\"&$publicEncFileName)

; stuff our au3 script into a variable called "wrapper"
; NOTE: there are two spots called "REPLACEME" and "REPLACEFILENAME" that will get replaced with ini text
$wrapper='#include <Crypt.au3>'&@crlf& _
'local $readFileName="REPLACEFILENAME"'&@crlf& _
'MsgBox("","",$readFileName)'&@crlf& _
'if FileExists(@ScriptDir&"\"&$readFileName) Then'&@crlf& _
'Else'&@crlf& _
'FileInstall("REPLACEME",@ScriptDir&"\"&$readFileName,1)'&@crlf& _
'EndIf'&@crlf& _
'$passkey=InputBox("Please enter the decryption password","PASSWORD","","*",400,150)' &@crlf& _
'local $newfilename=stringreplace($readFileName,"_enc","_dec")'&@crlf& _
'$firstDot=stringinstr($readFileName,".",0,-1)'&@crlf& _
'$fileExtension=stringtrimleft($readFileName,$firstDot-1)'&@crlf& _
'if _Crypt_DecryptFile($readFileName, @ScriptDir&"\"&$newfilename&$fileExtension, $passkey, $CALG_AES_256) Then'&@crlf& _
'Else'&@crlf& _
'   MsgBox("","","invalid password")'&@crlf& _
'   Exit'&@crlf& _
'EndIf'
; open a new file for our "standalone" decryption program
$tempFile=fileopen(@ScriptDir&"\standalone.au3",2)
FileWrite($tempFile,$wrapper)
FileClose($tempFile)
;after the au3 file is created read in the filename of the file to install and replace the text
$readFileName=IniRead(@ScriptDir&"\temp.ini","filedata","filename","decryptedfile.txt")
_ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEFILENAME",$readFileName)
; after the au3 file is created read in the full path of the file to install and replace the text in au3
local $readFilePath=IniRead(@ScriptDir&"\temp.ini","filedata","filepath","default")
_ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEME",$readFilePath)
;compile the au3 file into an executable using the command line
ShellExecuteWait("Aut2exe.exe"," /in standalone.au3 /out "&$filenameRoot&".exe",@ScriptDir)
;delete the temporary au3 file
FileDelete(@ScriptDir&"\standalone.au3")
EndFunc


;*************************************************
; This function will decrypt the file from the UI
; used to create the encrypted file (make sure you
; select the new name with the _enc first
;************************************************
func _decrypt()
$password = GUICtrlRead($passwordInput)
if $password="" then
    MsgBox("","","please enter a password")
EndIf
local $newfilename=stringreplace($filenameRoot,"_enc","_dec")
$result=_Crypt_DecryptFile($sourceFile, @ScriptDir&"\"&$newfilename&$fileExtension, $password, $CALG_AES_256)
MsgBox("","decrypt status",$result)
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        case $sourceBtn
            _selectFile()
        case $encryptBtn
            _encrypt()
        case $decryptBtn
            _decrypt()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

encrypt2exe.au3


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
guinness

Quite a few bugs in that code, first one to stand out is _decrypt() where you check if the password is empty, display a message box and then continue to decrypt. Same for _encrypt(). Also Dim is outdated in AutoIt with Local and Global being used in favour of. Then little language changes such as If $variable = True Then can just be If $variable Then, less typing is what we like!


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Jfish

Here is a revised version incorporating your comments / suggestions:

;*********************************************
; Example script
; ENCRYPT A FILE INTO A SELF-EXTRACTING EXE
; by: JFish
;
;********************************************

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include <Crypt.au3> ; will be used for the encryption
#include <File.au3> ; will be used to manipulate au3 file before we compile

#Region ### START Koda GUI section ### Form=C:\Users\RC01712\Documents\Scripts\Encrypt Tool\encrypt_GUI.kxf
$Form1 = GUICreate("Form1", 657, 244, 192, 132)
$sourceInput = GUICtrlCreateInput("", 144, 48, 337, 24)
$sourceBtn = GUICtrlCreateButton("Browse", 40, 48, 89, 25)
$encryptBtn = GUICtrlCreateButton("Encrypt", 224, 128, 145, 33)
$passwordInput = GUICtrlCreateInput("", 144, 80, 337, 24)
$Label1 = GUICtrlCreateLabel("Password", 40, 80, 73, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$decryptBtn = GUICtrlCreateButton("Decrypt", 224, 176, 145, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; var declaration for global scope
global $sourceFile, $password, $filename, $filenameRoot, $fileExtension, $publicEncFileNameFullPath, $publicEncFileName

; select a source file that we want to encrypt
func _selectFile()
    GUICtrlSetData($sourceInput,"")
    $filename=""
    $sourceFile=FileOpenDialog("Please select a file to encrypt",@ScriptDir,"All (*.*)")
    $dirLen=stringlen(@WorkingDir)+1
    ;grab the file name
    $filename=StringTrimLeft($sourceFile,$dirLen)
    $firstDot=stringinstr($filename,".",0,-1)
    ;grab the file root name without the extension
    $filenameRoot=stringtrimright($filename,stringlen($filename)-$firstDot+1)
    ;grab the file extension
    $fileExtension=stringtrimleft($filename,$firstDot-1)
    ;MsgBox("","",$fileExtension)
    GUICtrlSetData($sourceInput,$sourceFile)
EndFunc

func _encrypt()
$password = GUICtrlRead($passwordInput)
if $password="" then
    MsgBox("","","please enter a password")
Else
    ; encrypt the file NOTE: method in example of AES 256 is hard coded
    $result =_Crypt_EncryptFile($sourceFile,@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension,$password,$CALG_AES_256)
    ; if the encryptions works ...
        if $result Then
            ; set the full path name to the file including the new "_enc" showing that it is encrypted
            $publicEncFileNameFullPath=@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension
            ; setr the name of the encrypted file without the path
            $publicEncFileName=$filenameRoot&"_enc"&$fileExtension
            ; call the function to create the exe
            _createEXE($publicEncFileName,$publicEncFileName)
        else
            MsgBox("","","encryption error")
        EndIf
    MsgBox("","Encrypt status",$result)
EndIf
EndFunc


func _createEXE($publicEncFileNameFullPath,$publicEncFileName)

;*****************************************************************
; This functions writes an au3 file that will get compiled and become our
; 'self extracting' encrypted file and program to decrypt
; The biggest issue is embedding the encrypted file with fileinstall
; b/c it does not take variable path names
;******************************************************************

; craete an INI file with the full path name and file name of the encrypted file
IniWrite(@ScriptDir&"\temp.ini","filedata","filename",$publicEncFileName)
IniWrite(@ScriptDir&"\temp.ini","filedata","filepath",@ScriptDir&"\"&$publicEncFileName)

; stuff our au3 script into a variable called "wrapper"
; NOTE: there are two spots called "REPLACEME" and "REPLACEFILENAME" that will get replaced with ini text
$wrapper='#include <Crypt.au3>'&@crlf& _
'local $readFileName="REPLACEFILENAME"'&@crlf& _
'MsgBox("","",$readFileName)'&@crlf& _
'if FileExists(@ScriptDir&"\"&$readFileName) Then'&@crlf& _
'Else'&@crlf& _
'FileInstall("REPLACEME",@ScriptDir&"\"&$readFileName,1)'&@crlf& _
'EndIf'&@crlf& _
'$passkey=InputBox("Please enter the decryption password","PASSWORD","","*",400,150)' &@crlf& _
'local $newfilename=stringreplace($readFileName,"_enc","_dec")'&@crlf& _
'$firstDot=stringinstr($readFileName,".",0,-1)'&@crlf& _
'$fileExtension=stringtrimleft($readFileName,$firstDot-1)'&@crlf& _
'if _Crypt_DecryptFile($readFileName, @ScriptDir&"\"&$newfilename&$fileExtension, $passkey, $CALG_AES_256) Then'&@crlf& _
'Else'&@crlf& _
'   MsgBox("","","invalid password")'&@crlf& _
'   Exit'&@crlf& _
'EndIf'
; open a new file for our "standalone" decryption program
$tempFile=fileopen(@ScriptDir&"\standalone.au3",2)
FileWrite($tempFile,$wrapper)
FileClose($tempFile)
;after the au3 file is created read in the filename of the file to install and replace the text
$readFileName=IniRead(@ScriptDir&"\temp.ini","filedata","filename","decryptedfile.txt")
_ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEFILENAME",$readFileName)
; after the au3 file is created read in the full path of the file to install and replace the text in au3
local $readFilePath=IniRead(@ScriptDir&"\temp.ini","filedata","filepath","default")
_ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEME",$readFilePath)
;compile the au3 file into an executable using the command line
ShellExecuteWait("Aut2exe.exe"," /in standalone.au3 /out "&$filenameRoot&".exe",@ScriptDir)
;delete the temporary au3 file
FileDelete(@ScriptDir&"\standalone.au3")
EndFunc


;*************************************************
; This function will decrypt the file from the UI
; used to create the encrypted file (make sure you
; select the new name with the _enc first
;************************************************
func _decrypt()
$password = GUICtrlRead($passwordInput)
if $password="" then
    MsgBox("","","please enter a password")
Else
    local $newfilename=stringreplace($filenameRoot,"_enc","_dec")
    $result=_Crypt_DecryptFile($sourceFile, @ScriptDir&"\"&$newfilename&$fileExtension, $password, $CALG_AES_256)
    ;MsgBox("","decrypt status",$result)
EndIf
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        case $sourceBtn
            _selectFile()
        case $encryptBtn
            _encrypt()
        case $decryptBtn
            _decrypt()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

encrypt2exe.au3


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
Jfish

I actually tested this thing ... the EXE needed a lot of work.  Now it will delete an unsuccessful file and delete the encrypted version of the file after it is successful. 

;*********************************************
; Example script
; ENCRYPT A FILE INTO A SELF-EXTRACTING EXE
; by: JFish
;
;********************************************

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include <Crypt.au3> ; will be used for the encryption
#include <File.au3> ; will be used to manipulate au3 file before we compile

#Region ### START Koda GUI section ### Form=C:\Users\RC01712\Documents\Scripts\Encrypt Tool\encrypt_GUI.kxf
$Form1 = GUICreate("Form1", 657, 244, 192, 132)
$sourceInput = GUICtrlCreateInput("", 144, 48, 337, 24)
$sourceBtn = GUICtrlCreateButton("Browse", 40, 48, 89, 25)
$encryptBtn = GUICtrlCreateButton("Encrypt", 224, 128, 145, 33)
$passwordInput = GUICtrlCreateInput("", 144, 80, 337, 24)
$Label1 = GUICtrlCreateLabel("Password", 40, 80, 73, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$decryptBtn = GUICtrlCreateButton("Decrypt", 224, 176, 145, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; var declaration for global scope
global $sourceFile, $password, $filename, $filenameRoot, $fileExtension, $publicEncFileNameFullPath, $publicEncFileName

; select a source file that we want to encrypt
func _selectFile()
    GUICtrlSetData($sourceInput,"")
    $filename=""
    $sourceFile=FileOpenDialog("Please select a file to encrypt",@ScriptDir,"All (*.*)")
    $dirLen=stringlen(@WorkingDir)+1
    ;grab the file name
    $filename=StringTrimLeft($sourceFile,$dirLen)
    $firstDot=stringinstr($filename,".",0,-1)
    ;grab the file root name without the extension
    $filenameRoot=stringtrimright($filename,stringlen($filename)-$firstDot+1)
    ;grab the file extension
    $fileExtension=stringtrimleft($filename,$firstDot-1)
    ;MsgBox("","",$fileExtension)
    GUICtrlSetData($sourceInput,$sourceFile)
EndFunc

func _encrypt()
$password = GUICtrlRead($passwordInput)
if $password="" then
    MsgBox("","","please enter a password")
Else
    ; encrypt the file NOTE: method in example of AES 256 is hard coded
    $result =_Crypt_EncryptFile($sourceFile,@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension,$password,$CALG_AES_256)
    ; if the encryptions works ...
        if $result Then
            ; set the full path name to the file including the new "_enc" showing that it is encrypted
            $publicEncFileNameFullPath=@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension
            ; setr the name of the encrypted file without the path
            $publicEncFileName=$filenameRoot&"_enc"&$fileExtension
            ; call the function to create the exe
            _createEXE($publicEncFileName,$publicEncFileName)
        else
            MsgBox("","","encryption error")
        EndIf
    ;MsgBox("","Encrypt status",$result)
EndIf
EndFunc


func _createEXE($publicEncFileNameFullPath,$publicEncFileName)

;*****************************************************************
; This functions writes an au3 file that will get compiled and become our
; 'self extracting' encrypted file and program to decrypt
; The biggest issue is embedding the encrypted file with fileinstall
; b/c it does not take variable path names
;******************************************************************

; craete an INI file with the full path name and file name of the encrypted file
IniWrite(@ScriptDir&"\temp.ini","filedata","filename",$publicEncFileName)
IniWrite(@ScriptDir&"\temp.ini","filedata","filepath",@ScriptDir&"\"&$publicEncFileName)

; stuff our au3 script into a variable called "wrapper"
; NOTE: there are two spots called "REPLACEME" and "REPLACEFILENAME" that will get replaced with ini text
$wrapper='#include <Crypt.au3>'&@crlf& _
'local $readFileName="REPLACEFILENAME"'&@crlf& _
'if FileExists(@ScriptDir&"\"&$readFileName) Then'&@crlf& _
'Else'&@crlf& _
'FileInstall("REPLACEME",@ScriptDir&"\"&$readFileName,1)'&@crlf& _
'EndIf'&@crlf& _
'local $newfilename=stringreplace($readFileName,"_enc","_dec")'&@crlf& _
'$firstDot=stringinstr($readFileName,".",0,-1)'&@crlf& _
'$fileExtension=stringtrimleft($readFileName,$firstDot-1)'&@crlf& _
'$passkey=InputBox("Please enter the decryption password","PASSWORD","","*",400,150)' &@crlf& _
'if _Crypt_DecryptFile($readFileName, @ScriptDir&"\"&$newfilename, $passkey, $CALG_AES_256) Then'&@crlf& _
'   FileDelete(@ScriptDir&"\"&$readFileName)'&@crlf& _
'Else'&@crlf& _
'   FileDelete(@ScriptDir&"\"&$newfilename)'&@crlf& _
'   MsgBox("","","invalid password")'&@crlf& _
'   Exit'&@crlf& _
'EndIf'

; open a new file for our "standalone" decryption program
$tempFile=fileopen(@ScriptDir&"\standalone.au3",2)
FileWrite($tempFile,$wrapper)
FileClose($tempFile)
;after the au3 file is created read in the filename of the file to install and replace the text
$readFileName=IniRead(@ScriptDir&"\temp.ini","filedata","filename","decryptedfile.txt")
_ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEFILENAME",$readFileName)
; after the au3 file is created read in the full path of the file to install and replace the text in au3
local $readFilePath=IniRead(@ScriptDir&"\temp.ini","filedata","filepath","default")
_ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEME",$readFilePath)
;compile the au3 file into an executable using the command line
ShellExecuteWait("Aut2exe.exe"," /in standalone.au3 /out "&$filenameRoot&".exe",@ScriptDir)
;delete the temporary au3 file
FileDelete(@ScriptDir&"\standalone.au3")
EndFunc


;*************************************************
; This function will decrypt the file from the UI
; used to create the encrypted file (make sure you
; select the new name with the _enc first
;************************************************
func _decrypt()
$password = GUICtrlRead($passwordInput)
if $password="" then
    MsgBox("","","please enter a password")
Else
    local $newfilename=stringreplace($filenameRoot,"_enc","_dec")
    $result=_Crypt_DecryptFile($sourceFile, @ScriptDir&"\"&$newfilename&$fileExtension, $password, $CALG_AES_256)
    ;MsgBox("","decrypt status",$result)
EndIf
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        case $sourceBtn
            _selectFile()
        case $encryptBtn
            _encrypt()
        case $decryptBtn
            _decrypt()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

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

  • Similar Content

    • colombeen
      By colombeen
      Hi everyone, I created a function to gather bitlocker information. It can tell you whether or not a drive is protected, which encryption method is being used, ...
      I tried to cover all the details in the function description
       
      The function (and 3 "internal" functions) :
      ; #FUNCTION# ==================================================================================================================== ; Name...........: _BitlockerDriveInfo ; Description ...: Get Bitlocker information for one or multiple drives ; Syntax.........: _BitlockerDriveInfo([$sDrive[, $sComputer = @ComputerName[, $bDebug = False]]]) ; Parameters ....: $sDrive - Optional: The drive. Allowed values are: ; |"" - Get the info for all available drives ; |Letter: - Get the info for the specific drive ; $sComputer - Optional: The computer from which the info should be requested ; $bDebug - Optional: Shows the hex ReturnValue from the WMI methods if set to True ; Return values .: Success - Returns a 2D array with the following information ; |[string] Drive Letter ; |[string] Drive Label ; |[string] Volume Type ; |[bool] Initialized For Protection ; |[string] Protection Status ; |[string] Lock Status ; |[bool] Auto Unlock Enabled ; |[bool] Auto Unlock Key Stored ; |[string] Conversion Status ; |[string] Encryption Method ; |[int] Encryption Percentage ; |[string] Wiping Status ; |[int] Wiping Percentage ; |[array] Key Protectors (Or [string] "None" if the drive isn't protected) ; Failure - 0, sets @error to: ; |1 - There was an issue retrieving the COM object. @extended returns error code from ObjGet ; |2 - The specified drive in $Drive doesn't exist ; |3 - There was an issue running the WMI query ; Author ........: colombeen ; Modified.......: ; Remarks .......: Requires to be run with admin elevation. Windows Vista or newer! ; A BIG THANKS to everyone from the community who contributed! ; Related .......: ; Link ..........: ; Example .......: #include <Array.au3> ; $Header = "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|" & _ ; "Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption " & _ ; "Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors" ; _ArrayDisplay(_BitlockerDriveInfo(), "Bitlocker Drive Info", "", 64, Default, $Header) ; =============================================================================================================================== Func _BitlockerDriveInfo($sDrive = "", $sComputer = @ComputerName, $bDebug = False) Local $aConversionStatusMsg[7] = ["Unknown", "Fully Decrypted", "Fully Encrypted", "Encryption In Progress", "Decryption In Progress", "Encryption Paused", "Decryption Paused"] Local $aEncryptionMethodMsg[9] = ["Unknown", "None", "AES_128_WITH_DIFFUSER", "AES_256_WITH_DIFFUSER", "AES_128", "AES_256", "HARDWARE_ENCRYPTION", "XTS_AES_128", "XTS_AES_256"] Local $aKeyProtectorTypeMsg[11] = ["Unknown or other protector type", "Trusted Platform Module (TPM)", "External key", "Numerical password", "TPM And PIN", "TPM And Startup Key", "TPM And PIN And Startup Key", "Public Key", "Passphrase", "TPM Certificate", "CryptoAPI Next Generation (CNG) Protector"] Local $aLockStatusMsg[3] = ["Unknown", "Unlocked", "Locked"] Local $aProtectionStatusMsg[3] = ["Unprotected", "Protected", "Unknown"] Local $aVolumeTypeMsg[3] = ["Operating System Volume", "Fixed Data Volume", "Portable Data Volume"] Local $aWipingStatusMsg[5] = ["Unknown", "Free Space Not Wiped", "Free Space Wiped", "Free Space Wiping In Progress", "Free Space Wiping Paused"] Local $iRow = 0 Local $sRunMethod, $objWMIService, $objWMIQuery, $sDriveFilter, $iProtectionStatus, $iLockStatus, $bIsAutoUnlockEnabled, $bIsAutoUnlockKeyStored, $iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage, $iEncryptionMethod, $aVolumeKeyProtectorID, $aVolumeKeyProtectors, $iKeyProtectorType $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") If @error Then Return SetError(1, @error, 0) If $sDrive <> "" Then Local $iDriveType = _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $sDrive & "'", Default, $sComputer) If @error Or ($iDriveType <> 2 And $iDriveType <> 3) Then Return SetError(2, 0, 0) $sDriveFilter = " WHERE DriveLetter='" & $sDrive & "'" EndIf $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume" & $sDriveFilter, "WQL", 0) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) Local $aResult[$objWMIQuery.count][14] For $objDrive In $objWMIQuery If $bDebug Then ConsoleWrite(@CRLF & "+> " & $objDrive.DriveLetter & @CRLF) If _WMIMethodExists($objDrive, "GetConversionStatus") Then $sRunMethod = $objDrive.GetConversionStatus($iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage) If $bDebug Then ConsoleWrite("!> GetConversionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iConversionStatus = -1 $iWipingStatus = -1 $iEncryptionPercentage = 0 $iWipingPercentage = 0 EndIf If _WMIMethodExists($objDrive, "GetEncryptionMethod") Then $sRunMethod = $objDrive.GetEncryptionMethod($iEncryptionMethod) If $bDebug Then ConsoleWrite("!> GetEncryptionMethod 0x" & Hex($sRunMethod) & @CRLF) Else $iEncryptionMethod = 0 EndIf If _WMIMethodExists($objDrive, "GetKeyProtectors") Then $sRunMethod = $objDrive.GetKeyProtectors("0", $aVolumeKeyProtectorID) If $bDebug Then ConsoleWrite("!> GetKeyProtectors 0x" & Hex($sRunMethod) & @CRLF) Else $aVolumeKeyProtectorID = 0 EndIf If _WMIMethodExists($objDrive, "GetLockStatus") Then $sRunMethod = $objDrive.GetLockStatus($iLockStatus) If $bDebug Then ConsoleWrite("!> GetLockStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iLockStatus = -1 EndIf If _WMIMethodExists($objDrive, "GetProtectionStatus") Then $sRunMethod = $objDrive.GetProtectionStatus($iProtectionStatus) If $bDebug Then ConsoleWrite("!> GetProtectionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iProtectionStatus = 2 EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockEnabled") Then $sRunMethod = $objDrive.IsAutoUnlockEnabled($bIsAutoUnlockEnabled) If $bDebug Then ConsoleWrite("!> IsAutoUnlockEnabled 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockEnabled = "Unknown" EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockKeyStored") Then $sRunMethod = $objDrive.IsAutoUnlockKeyStored($bIsAutoUnlockKeyStored) If $bDebug Then ConsoleWrite("!> IsAutoUnlockKeyStored 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockKeyStored = "Unknown" EndIf If IsArray($aVolumeKeyProtectorID) And UBound($aVolumeKeyProtectorID) > 0 Then Dim $aVolumeKeyProtectors[UBound($aVolumeKeyProtectorID)][2] For $i = 0 To UBound($aVolumeKeyProtectorID) - 1 $aVolumeKeyProtectors[$i][0] = $aVolumeKeyProtectorID[$i] If _WMIMethodExists($objDrive, "GetKeyProtectorType") Then If $objDrive.GetKeyProtectorType($aVolumeKeyProtectorID[$i], $iKeyProtectorType) = 0 Then $aVolumeKeyProtectors[$i][1]= $aKeyProtectorTypeMsg[$iKeyProtectorType] Else $aVolumeKeyProtectors[$i][1]= "Unknown" EndIf Else $aVolumeKeyProtectors[$i][1] = "Unknown" EndIf Next Else $aVolumeKeyProtectors = "None" EndIf ; DriveLetter $aResult[$iRow][0] = $objDrive.DriveLetter ; DriveLabel $aResult[$iRow][1] = _WMIPropertyValue("VolumeName", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) ; VolumeType If _WMIPropertyExists($objDrive, "VolumeType") Then $aResult[$iRow][2] = $aVolumeTypeMsg[$objDrive.VolumeType] Else If $objDrive.DriveLetter = _WMIPropertyValue("SystemDrive", "Win32_OperatingSystem", "", Default, $sComputer) Then $aResult[$iRow][2]= $aVolumeTypeMsg[0] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 3 Then $aResult[$iRow][2]= $aVolumeTypeMsg[1] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 2 Then $aResult[$iRow][2]= $aVolumeTypeMsg[2] Else $aResult[$iRow][2]= "Unknown" EndIf EndIf ; IsVolumeInitializedForProtection If _WMIPropertyExists($objDrive, "IsVolumeInitializedForProtection") Then $aResult[$iRow][3] = $objDrive.IsVolumeInitializedForProtection Else $aResult[$iRow][3] = "Unkown" EndIf ; ProtectionStatus $aResult[$iRow][4] = $aProtectionStatusMsg[$iProtectionStatus] ; LockStatus $aResult[$iRow][5] = $aLockStatusMsg[$iLockStatus + 1] ; IsAutoUnlockEnabled $aResult[$iRow][6] = $bIsAutoUnlockEnabled ; IsAutoUnlockEnabled $aResult[$iRow][7] = $bIsAutoUnlockKeyStored ; ConversionStatus $aResult[$iRow][8] = $aConversionStatusMsg[$iConversionStatus + 1] ; EncryptionMethod $aResult[$iRow][9] = $aEncryptionMethodMsg[$iEncryptionMethod + 1] ; EncryptionPercentage $aResult[$iRow][10] = $iEncryptionPercentage ; WipingStatus $aResult[$iRow][11] = $aWipingStatusMsg[$iWipingStatus + 1] ; WipingPercentage $aResult[$iRow][12] = $iWipingPercentage ; KeyProtectors $aResult[$iRow][13] = $aVolumeKeyProtectors $iRow += 1 Next _ArraySort($aResult) Return $aResult EndFunc ;==>_BitlockerDriveInfo Func _WMIPropertyExists($Object, $Property) If Not IsObj($Object) Then Return False For $sProperty In $Object.Properties_ If $sProperty.Name = $Property Then Return True Next Return False EndFunc ;==>_WMIPropertyExists Func _WMIMethodExists($Object, $Method) If Not IsObj($Object) Then Return False For $sMethod In $Object.Methods_ If $sMethod.Name = $Method Then Return True Next Return False EndFunc ;==>_WMIMethodExists Func _WMIPropertyValue($sProperty = "", $sClass = "", $sFilter = "", $sNamespace = Default, $sComputer = @ComputerName) Local $objWMIService, $objWMIQuery If $sClass = "" Or $sProperty = "" Then Return SetError(1, 0, 0) If $sFilter <> "" Then $sFilter = " " & $sFilter If $sNamespace = Default Then $sNamespace = "\root\CIMV2" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & $sNamespace) If @error Then Return SetError(2, @error, 0) $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM " & $sClass & $sFilter, "WQL", 0x30) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) For $objItem In $objWMIQuery For $Property In $objItem.Properties_ If $Property.Name = $sProperty Then Return $Property.Value EndIf Next Next Return SetError(4, 0, 0) EndFunc ;==>_WMIPropertyValue  
      Example 1:
      #RequireAdmin #include <array.au3> ; Get information on all available drives Global $test = _BitlockerDriveInfo() If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then _ArrayDisplay($test, "Bitlocker Drive Info", "", 64, Default, "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors") ; Display the Key Protectors for the first record If IsArray($test[0][13]) Then _ArrayDisplay($test[0][13]) EndIf Example 2:
      #RequireAdmin #include <array.au3> ; Get information on the C-drive of the current computer + show extra information in the console Global $test = _BitlockerDriveInfo("C:", @ComputerName, True) If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then ConsoleWrite("Bitlocker information on the " & $test[0][0] & " drive" & @CRLF) ConsoleWrite("Protection Status: " & $test[0][4] & @CRLF) EndIf  
      Screenshot for the first example:

       
      Suggestions? Bugs?
      Just let me know
       
      TODO:
      ???  
      Version 1.0:
      Initial release Version 1.1:
      Fixed: Drive Label will not work when you request the information from a remote system (currently using DriveGetLabel) Fixed: The current fix for the missing VolumeType property in some Windows versions will only work locally Added: New internal function (_WMIPropertyValue()) Version 1.2:
      Fixed: The drive exists & drive type check only worked locally when a drive was specified in $sDrive
    • colombeen
      By colombeen
      Hi guys,
      I'm trying to get some information using WMI, from the Win32_EncryptableVolume class.
      I exec my query, filter out the C-drive, but when I need more info using the objects methods, I only get 1 value back and I can't seem to retrieve the other out params that should be there.
      A very minimal version of what I'm trying to do (no error checking etc, very basic). You need to start SciTE as admin or you won't see any results in the console!
      #RequireAdmin $strComputer = @ComputerName $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume WHERE DriveLetter='C:'", "WQL", 0) For $objDrive In $objWMIQuery ConsoleWrite("> " & $objDrive.GetConversionStatus() & @CRLF) ConsoleWrite("> " & $objDrive.GetConversionStatus().ConversionStatus & @CRLF) ConsoleWrite("> " & $objDrive.GetConversionStatus().EncryptionPercentage & @CRLF) Next The result from the console is : 
      > 0 > > What I'm expecting to get back is : 
      > 0 > 0 > 0 When using powershell I get this (run as admin is required!!!) : 
      PS C:\WINDOWS\system32> (Get-WmiObject -namespace "Root\cimv2\security\MicrosoftVolumeEncryption" -ClassName "Win32_Encryptablevolume" -Filter "DriveLetter='C:'").GetConversionStatus() ... ConversionStatus : 0 EncryptionFlags : 0 EncryptionPercentage : 0 ReturnValue : 0 ... All I seem to be getting is the ReturnValue when I use the method.
      I've tried this on multiple methods, always ending up with the same result
      Anyone here who has experience with this type of thing?
       
      Greetz
      colombeen
    • careca
      By careca
      Let's say you have some files you dont want anyone to know what they are,
      and you dont want anyone to be able to open them, you could encrypt them,
      but if the files are big it'll take a long time to do the operations for you to be able to open those files.
      I made this to make this process faster, and still not easy for someone to open the files, or even know what type they are.
      What it does is change the filename to a random number with 8 digits and .inc extension.
      The original filename is encrypted in the file itself, with a PIN provided by the user up to 4 digits, this PIN is also a number that's going to be used to split the file and change it internally, so the end result is a file with a header that's got the original filename encrypted, and the rest of the file scrambled a bit.
      The way it works is simple, place the application in a folder where you want to hide the files, it will ask for a pin, after you press ok, the application asks :
      Encrypt or decrypt?
      If encrypt, the files will become the 8 digit .inc files.
      The originals will stay, the user can delete the originals or do whatever.
      Then to open the files back, same process, but this time choose decrypt, and a listview will show the random filenames and the corresponding decrypted/original filenames and extension, uppon double click they open with whatever application is the default for them. There's a search feature, and an "extract all" button, to get all files back to original/unencrypted versions.
      Feedback is wellcome.
    • Barrtrek
      By Barrtrek
      I get the "Unable to add resources" error related to AppData\Local\AutoIt v3\Aut2Exe when compiling with a large FileInstall of a 1.5GB file.  Is there a size limit I need to be aware of?  I've also disabled or removed Trend from three different machines and had the same results.  I've had issues like this in the past but have compiled after the Aut2Exe folder was excluded in AV.  That doesn't seem to be the problem this time around.  If I comment out the FileInstall the script compiles successfully.
    • Overkill
      By Overkill
      Hi all,
      I am working on a GUI program to update Google's Dynamic DNS (API at https://support.google.com/domains/answer/6147083?authuser=1&hl=en if you scroll to bottom). I am not a programmer by any means - just a sysadmin who has picked up on some things along the way. I am sure that there's better ways to do a lot of things in this script; I'm just going with what I know.
      My challenge right now is that I'd like a better way to store the credentials both in memory as well as in system registry or INI file (not sure which way I want to go for local storage). How should I convert the passwords to a secure string in a manner that can't be easily reversed, yet is still accessible to the script? Is that even an option in AutoIt?
      Can anybody provide me with links to good reference posts, or coding suggestions for how best to achieve this in the script below? I am using the WinHTTP UDF (https://github.com/dragana-r/autoit-winhttp/releases) to make my API calls.
      #include<WinHTTP.au3> #include<GUIConstantsEx.au3> #include<EditConstants.au3> #include<iNet.au3> #include<Array.au3> DIM $aDomainList[1][4] $aDomainList[0][0] = 0 $gMainGUI = GUICreate("Overkill's Google DNS Updater",800,800) $gDomainLabel = GUICtrlCreateLabel("FQDN",21,8) $gDomainInput = GUICtrlCreateInput("",60,5,300) $gUserLabel = GUICtrlCreateLabel("Username",5,36) $gUserInput = GUICtrlCreateInput("",60,32,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gPasswordLabel = GUICtrlCreateLabel("Password",6,64) $gPassInput = GUICtrlCreateInput("",60,60,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gAddButton = GUICtrlCreateButton("ADD DOMAIN",200,31,160,52) $gCurrentIP = GUICtrlCreateLabel("Current IP: " & _CheckIP(),5,780) $gDomainList = GUICtrlCreateListView("Domain | Resolved IP | Update Status",5,120,600,600) GUISetState(@SW_SHOW,$gMainGUI) while 1 $m = GUIGetMsg() IF $M = $GUI_EVENT_CLOSE then Exit IF $M = $gAddButton Then $sAddDomain = GUICtrlRead($gDomainInput) $sAddUser = GUICtrlRead($gUserInput) $sAddPass = GUICtrlRead($gPassInput) $sResolveIP = _DNSCheck($sAddDomain) ;Google wants you to avoid sending updates when there are no changes If StringCompare($sResolveIP,_CheckIP()) = 0 Then $sStatus = "No change, not sending update" Else $sStatus = _DNSUpdate($sAddDomain,$sAddUser,$sAddPass) EndIf ;Check to make sure all fields are completed before continuing IF StringLen($sAddDomain) = 0 OR StringLen($sAddUser) = 0 OR StringLen($sAddPass) = 0 Then MsgBox(0,"","Please complete all fields") Else ; If the fields all have data, then continue ;Check to see if the entry exists in the array already $iSanity = _ArraySearch($aDomainList,$sAddDomain) IF $iSanity = 0 Then _ArrayAdd($aDomainList,$sAddDomain & "|" & $sAddUser & "|" & $sAddPass ) If @error = 0 Then $aDomainList[0][0] += 1 $aDomainList[$aDomainList[0][0]][3] = GUICtrlCreateListViewItem($sAddDomain & "|" & $sResolveIP & "|" & $sStatus,$gDomainList) Else MsgBox(0,"","Error adding input to list") EndIf Else ; If $iSanity <> 0 ; Update existing info in array and listviewitem $aDomainList[$iSanity][0] = $sAddDomain $aDomainList[$iSanity][1] = $sAddUser $aDomainList[$iSanity][2] = $sAddPass GUICtrlSetData($aDomainList[$iSanity][3],$sAddDomain & "|" & $sResolveIP & "|" & $sStatus) EndIf ; If $iSanity = 0 EndIf ; If StringLen... EndIf ; If $m = $gaddbutton WEnd ;---------------------------------------------------------------------------------------- Func _DNSCheck($sFQDN) $sJSON = _INetGetSource("https://dns.google.com/resolve?name=" & $sFQDN & "&cd=1") ConsoleWrite($sJSON & @CRLF) $sIPAddress = StringRegExpReplace($sJSON,'^.*data": "(.*?)".*?$',"\1") Return $sIPAddress EndFunc ;---------------------------------------------------------------------------------------- Func _DNSUpdate($sFQDN,$sUser,$sPass) Local $sGoogleAPIURI = "https://domains.google.com" Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, $sGoogleAPIURI) Local $sHeader = _ 'Authorization: Basic ' & _Base64Encode($sUser & ":" & $sPass) & @CRLF & _ 'Accept: */*' & @CRLF & _ 'User-Agent: AutoITScript/' & @AutoItVersion & @CRLF & _ 'Content-Type: application/x-www-form-urlencoded' Local $aHTTPResponse = _WinHttpSimpleSSLRequest($hConnect, "POST", "/nic/update", Default, "hostname=" & $sFQDN, $sHeader, True, Default, Default, Default, True) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If IsArray($aHTTPResponse) Then $sHTTPResponse = "Header:" & @CRLF & $aHTTPResponse[0] & @CRLF & "Data:" & @CRLF & $aHTTPResponse[1] & @CRLF & @CRLF & @CRLF Return $aHTTPResponse[1] Else $sHTTPResponse = "NO REPLY" Return "No reply from " & $sGoogleAPIURI EndIf EndFunc ;---------------------------------------------------------------------------------------- Func _Base64Encode($sData) Local $oXml = ObjCreate("Msxml2.DOMDocument") If Not IsObj($oXml) Then SetError(1, 1, 0) EndIf Local $oElement = $oXml.createElement("b64") If Not IsObj($oElement) Then SetError(2, 2, 0) EndIf $oElement.dataType = "bin.base64" $oElement.nodeTypedValue = Binary($sData) Local $sReturn = $oElement.Text If StringLen($sReturn) = 0 Then SetError(3, 3, 0) EndIf Return $sReturn EndFunc ;---------------------------------------------------------------------------------------- Func _CheckIP() Return _INetGetSource("https://domains.google.com/checkip") EndFunc ;----------------------------------------------------------------------------------------  
×