Leaderboard
Popular Content
Showing content with the highest reputation on 03/05/2022 in all areas
-
AutoIt v3.3.15.5 Beta
HurleyShanabarger and 5 others reacted to Jon for a topic
Release candidate 1 Installer: https://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.16.0-setup-rc1.exe Zip: https://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.16.0-rc1.zip Edit: I've noticed over the last few years, and at work, it's almost impossible in modern browsers to download .exe files. So I think I'm going to wrap the installer in a .zip as well. I'll probably have two installer versions up though so it doesn't break any updater type scripts.6 points -
AutoIt v3.3.15.5 Beta
Musashi and 2 others reacted to AspirinJunkie for a topic
The bug itself has been fixed. To illustrate the impact it had: My JSON UDF previously took ~7 minutes to parse a 2MB JSON file into nested AutoIt types. Now it takes 3s... Whether generally speaking StringRegEx has not received any new bugs is difficult to say. I don't have a comprehensive test case collection for this. So I just tried StringRegExp with all possible options and parameters and everything worked as expected. In short: it looks good - let's give the fix a chance.3 points -
Release Candidate 2 Reverted a reg exp fix that was causing issues. AutoIt v3.3.15.5 Beta issue with _pathsplit - AutoIt General Help and Support - AutoIt Forums (autoitscript.com) Installer: https://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.16.0-setup-rc2.exe Zip: https://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.16.0-rc2.zip2 points
-
Valik was such a character. When I initially read this, I thought that you were stating that Valik was a garbage collector. 😆2 points
-
Can you check that I've not broken RegExp with this fix? https://www.autoitscript.com/autoit3/files/beta/autoit/AutoIt3-RegExTest.zip2 points
-
AutoIt v3.3.15.5 Beta View File 3.3.15.5 (27th February, 2022) (Beta) AutoIt: - Added #3826: GUI "On event" While loop precision. - Added: Doc Symbolic constants for MouseGetCursor(), GUISetCursor() $MCID_*. - Added #3849: @OSVersion for Windows 11 and Server 2022. - Fixed #3836: FileExits trailing quotation mark. - Fixed #3844: Right bracket does not register as a hotkey. - Fixed #3830: GUICtrlSetResizing $GUI_DOCKBOTTOM fullscreen. - Fixed #3831: GUICtrlSetPos $GUI_DOCKHCENTER. - Fixed #2696: StringRegExp non-participating groups. - Fixed #2866: Regread x64 remote from x86. - Fixed #3667: empty continuation line. - Fixed #3760: oversized Number conversion. - Fixed #3215: GUICtrlCreateUpdown Show-Hide. UDFs: - Added: $ARRAYDISPLAY_NUMERICSORT for selected column for _ArrayDisplay() and _DebugArrayDisplay(). - Added: _GUICtrlEdit_SetPadding(). - Added: _WinAPI_ShellExecuteEx() Doc example. - Fixed #3828: SetError(), SetExtended() broken doc links. - Fixed #3827: _GUICtrlListView_ClickItem() outside listview area. - Fixed #3835: Magic numbers in GDIPlus doc. - Fixed #3833: _WinAPI_RegisterRawInputDevices() $iCount. - Fixed #3842: -StringToArray() default parameter doc precision. - Fixed #3846: missing $LVKF_* constants definition. - Fixed #3847: _GUICtrlEdit_ShowBalloonTip() crash in _WinAPI_MultiByteToWideChar(). - Fixed #3848: _GUICtrlListView_GetItemTextArray() no error detection in multicolumn. - Fixed #3850: _WinAPI_GetDriveNumber() does return - 1 as partition number. - Fixed #3852: _ArrayToString() speed optimization. - Fixed: Constants for _WinAPI_GetCursorInfo(). - Fixed: Debug.au3 when stripping. - Fixed #3861: RunAs() doc remark. Submitter Jon Submitted 02/27/2022 Category Beta1 point
-
Or something like: #include <Array.au3> Global $sText = '"text": "Some Youtube comment as example", "timestamp":346230, "text": "SomeSDGs example", "timestamp": 15833460, "text": "Some YoutFGNSFGJnt as example", "timestamp": 45634572800, "' Global $aText = StringRegExp($sText, '(?<=\"text\": \").*?(?=\", \"timestamp\")', 3) _ArrayDisplay($aText)1 point
-
I don't know how to use RegEx but you can use _StringBetween(): #include <String.au3> Local $InputData = '"text": "Some Youtube comment as example", "timestamp":346230, "text": "SomeSDGs example", "timestamp": 15833460, "text": "Some YoutFGNSFGJnt as example", "timestamp": 45634572800, "' $InputData = StringReplace($InputData, ', "', ',"') $InputData = StringReplace($InputData, '": ', '":') Local $textArray = _StringBetween($InputData, '"text":', ',"') If IsArray($textArray) Then For $i = 0 To UBound($textArray) - 1 ConsoleWrite($textArray[$i] & @CRLF) Next EndIf Local $timestampArray = _StringBetween($InputData, '"timestamp":', ',"') If IsArray($timestampArray) Then For $i = 0 To UBound($timestampArray) - 1 ConsoleWrite($timestampArray[$i] & @CRLF) Next EndIf1 point
-
See, this is why I'm not blindly adding the alpha patches. It's really easy to mess up some of this codebase.1 point
-
AutoIt v3.3.15.5 Beta
Danp2 reacted to pixelsearch for a topic
I didn't laugh like that for days, ty DanP21 point -
Please no, I've tried a couple of times to use the full scite and i dont like it, i always go back to Lite, I simply cant get used to all the garble in the console that the full scite provides, Lite is fine for me Though i'm ofcourse one the ones that rarely produces any exe files, i mostly just run my scripts from scite (lite)1 point
-
I like keeping it simple. I currently use If @OSBuild >= 22000 to detect Windows 11.1 point
-
I'm leaving it in the release but still with the experimental tag. I struggle to remember the nature of the bug with them...1 point
-
Wrong RunAs Parameters #include <ScaleSetup.au3> #include <AutoItConstants.au3> ScaleInstall() Func ScaleInstall() ; Change the username and password to the appropriate values for your system. Local $sUserName = "administrator" Local $sPassword = "mypassword" Local $ComputerName = @ComputerName Local $FilePath = "d:\install\Weight\Megalen_scale.exe" ; Install Shekel OPOS with the window maximized. Program will run under the user previously specified. Local $iPID = RunAs($sUserName, $ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, $FilePath, "", @SW_SHOWMAXIMIZED) ConsoleWrite("+ PID: " & $iPID & ' - Error:'& @error & @CRLF) ; Wait for 4 seconds. Sleep(4000) ; Close the setup process using the PID returned by RunAs. ProcessClose($iPID) EndFunc ;==>ScaleInstall or #RequireAdmin Local $FilePath = "d:\install\Weight\Megalen_scale.exe" Local $iPID = Run( $FilePath, "", @SW_SHOWMAXIMIZED) ConsoleWrite("+ PID: " & $iPID & ' - Error:'& @error & @CRLF)1 point
-
I strongly believe Map datatype is mature enough to enter AutoIt release thru the main door!1 point
-
@Jos Nine has posted the script i just wanted to post too. His script crashes in the new autoit version. The error message is "D:\System\Programme\Portable\AutoIt\Current\Include\File.au3" (1012) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $sFileName = $aArray[$PATH_FILENAME] $sFileName = ^ ERROR1 point
-
So I wanted a free obfuscator that was coded in AutoIt3 and was actually decent. So I spliced together several different ones found across the web and spent about two weeks programming this one. It is capable of: Encrypting ALL strings (len > 1) Renaming vars Renaming functions The string encryption is really the most innovative part of my obfuscator and also was the biggest pain in the ass. If you need or want to use a seperate string encryption method just make sure its a stream algorithm similar to the way XOR functions (one mode) Anyways here's the script. ENJOY!!!! ; Title: CryptoDragon AutoIt Obfuscator ; Version: v1.4.0.1 ; Requirements: AutoIt Version 3.1.1.0 (Beta is NOT required) ; Date: November 6th, 2018 ; Authors: Freak, taurus905 ; Purpose: This script obfuscates an AutoIt script by identifying, counting and replacing all ; variables and functions within that script, as well as encrypting strings. according to the following notes. ; Notes: Variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE, will not be obfuscated. ; All strings with single and double quotes are to be encrypted with a multikey XOR algo. (in order) ; Add arguments in the "Functions_NOT_to_obfuscate_section:" to bypass these functions. ; Uncomment: (in the script) ; Global $Show_Messages = "Yes" ; to show Message Boxes and Array Displays during execution. ; Input: An AutoIt Script --> OriginalScriptName.au3 ; Output: Variables to be Obfuscated --> OriginalScriptName - Vars to Obfuscate.txt ; Functions to be Obfuscated --> OriginalScriptName - Funcs to Obfuscate.txt ; Random Names --> OriginalScriptName - Random Names.txt ; CryptoDragon Obfuscated Script --> OriginalScriptName - CryptoDragon Obfuscated.au3 ; Modified by Freak to encrypt all strings in target program with multichar XOR, also added bug fixes. ; :::ChAnGeLoG:::: ; v1.2 - Original "Simple Obfuscator" by taurus905 ; v1.3 - Freak creates CryptoDragon project based off taurus905's "Simple Obfuscator" ; v1.3.4 - Added improved speed ; v1.3.5.1 - Improved functionality ; v1.3.6 - Added string length to _CryptoDragon_Crypt function for improved stability handling funny strings in version ; v1.4 - Improved security on encryption algorythm. Also obfuscator automatically writes encryption function to top of file automatically. ; v1.4.0.1 - Fixed encrypt function writing process. ; =================================================================================================== #include <GUIConstants.au3> #include <Array.au3> Func _CryptoDragon_Crypt($s_String, $s_Key, $iLen, $xorK2 = 0x12, $s_Level = 1.337) Local $s_Encrypted = "", $fin_Encrypted = "", $s_kc = 1 If StringLen($s_Key) = 0 Or $s_Level < 1 Then Return 0 $s_Key = StringSplit($s_Key, '') $s_String = StringSplit($s_String, '') For $x = 1 To $s_String[0] If $s_kc > $s_Key[0] Then $s_kc = 1 $s_Encrypted = $s_Key[$s_kc] $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted = BitNOT($s_Encrypted); $s_Encrypted = BitXOR($s_Encrypted, Floor(Asc($s_Key[$s_kc]) * $s_Level)); $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted -= Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted = BitXOR($s_Encrypted, Floor(Asc($s_Key[$s_kc]) * $s_Level)); $s_Encrypted = $s_Encrypted - 1; $s_Encrypted = BitXOR($s_Encrypted, Floor(Asc($s_Key[$s_kc]) * $s_Level)); $s_Encrypted = $s_Encrypted + 1; $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted = BitXOR($s_Encrypted, $xorK2); $s_Encrypted = BitNOT($s_Encrypted); $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $fin_Encrypted &= Chr(BitXOR(Asc($s_String[$x]), Floor(Asc($s_Key[$s_kc]) * $s_Level))) $s_kc += 1 Next Return StringLeft($fin_Encrypted, $iLen) EndFunc ;==>_CryptoDragon_Crypt Global $Show_Messages = "No" ; Uncomment the following line to see progress messages and arrays during execution. ;Global $Show_Messages = "Yes" ; =================================================================================================== Global $file_Script_to_Obfuscate _Choose_Script_to_Obfuscate() ; Choose Script to Obfuscate ; =================================================================================================== ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines Global $Num_of_Lines _Count_Lines() ; Count Lines of Script to Obfuscate If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Lines", $Num_of_Lines) Global $Array_of_Lines[$Num_of_Lines + 1] _Read_Lines_to_Array() ; Read Lines to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Lines, "$Array_of_Lines") ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines ; =================================================================================================== ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars Global $Num_of_Vars _Count_Vars() ; Count Variables in Script to Obfuscate If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Vars", $Num_of_Vars) Global $Array_of_Vars[$Num_of_Vars + 1] _Read_Vars_to_Array() ; Read Variables to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Vars, "$Array_of_Vars") _Sort_Array_of_Vars() ; Sort Array of Variables If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Vars, "$Array_of_Vars") Global $Num_of_Unique_Vars _Count_Unique_Vars() ; Count Unique Variables If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Unique_Vars", $Num_of_Unique_Vars) Global $Array_of_Unique_Vars[$Num_of_Unique_Vars + 1] _Read_Unique_Vars_to_Array() ; Read Unique Variables to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Unique_Vars, "$Array_of_Unique_Vars") _Write_Unique_Vars_to_File() ; Write Unique Variables to File ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars ; =================================================================================================== ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs Global $Num_of_Funcs _Count_Funcs() ; Count Functions in Script to Obfuscate If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Funcs", $Num_of_Funcs) Global $Array_of_Funcs[$Num_of_Funcs + 1] _Read_Funcs_to_Array() ; Read Functions to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Funcs, "$Array_of_Funcs") _Sort_Array_of_Funcs() ; Sort Array of Functions If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Funcs, "$Array_of_Funcs") ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs ; =================================================================================================== ; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random Global $Num_of_Random_Names _Find_Random_Name_Count() ; Find Random Name Count Global $Random_Name[$Num_of_Random_Names + 1] _Read_Random_Names_to_Array() ; Read Random Names to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Random_Name, "$Random_Name") _Write_Random_Names_to_File() ; Write Random Names to File ; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random ; =================================================================================================== ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace Global $New_Array_of_Lines[$Num_of_Lines + 1] _Remove_Comments() ; Remove Comments _ArraySortDblDel($Array_of_Unique_Vars) _ArraySortDblDel($Array_of_Funcs) $vars_finished = False $func_finished = False $Script_Data = _ArrayToString($Array_of_Lines, @CRLF) For $iii = 0 To $Num_of_Lines For $jjj = UBound($Array_of_Unique_Vars) - 1 To 1 Step -1 If $vars_finished Then ExitLoop If $Array_of_Unique_Vars[$jjj] <> $Array_of_Unique_Vars[1] Then If $Array_of_Unique_Vars[$jjj] <> "_" And $Array_of_Unique_Vars[$jjj] <> "$'" And StringLower($Array_of_Unique_Vars[$jjj]) <> "$cmdline" Then If StringInStr($Array_of_Unique_Vars[$jjj], ".") Then $temp = StringSplit($Array_of_Unique_Vars[$jjj], ".") $Array_of_Unique_Vars[$jjj] = $temp[1] EndIf If StringRight($Array_of_Unique_Vars[$jjj], 1) = "&" Then $Array_of_Unique_Vars[$jjj] = StringTrimRight($Array_of_Unique_Vars[$jjj], 1) EndIf $Script_Data = StringReplace($Script_Data, $Array_of_Unique_Vars[$jjj], "$" & $Random_Name[$jjj]) ConsoleWrite($Array_of_Unique_Vars[$jjj] & ":$" & $Random_Name[$jjj] & @CRLF) EndIf Else If $Array_of_Unique_Vars[$jjj] <> "_" And $Array_of_Unique_Vars[$jjj] <> "$'" Then If StringInStr($Array_of_Unique_Vars[$jjj], ".") Then $temp = StringSplit($Array_of_Unique_Vars[$jjj], ".") $Array_of_Unique_Vars[$jjj] = $temp[1] EndIf If StringRight($Array_of_Unique_Vars[$jjj], 1) = "&" Then $Array_of_Unique_Vars[$jjj] = StringTrimRight($Array_of_Unique_Vars[$jjj], 1) EndIf $Script_Data = StringReplace($Script_Data, $Array_of_Unique_Vars[$jjj], "$" & $Random_Name[$jjj]) ConsoleWrite($Array_of_Unique_Vars[$jjj] & ":$" & $Random_Name[$jjj] & @CRLF) EndIf $vars_finished = True EndIf Next Next For $iii = 0 To $Num_of_Lines For $jjj = UBound($Array_of_Funcs) - 1 To 1 Step -1 ; If StringLeft($Array_of_Funcs[$jjj], 1) = "_" Then ContinueLoop If $func_finished Then ExitLoop If $Array_of_Funcs[$jjj] <> $Array_of_Funcs[1] Then If StringInStr($Array_of_Funcs[$jjj], "=") Then ContinueLoop ; Au3wrapper, not a function. $Script_Data = StringReplace($Script_Data, $Array_of_Funcs[$jjj], $Random_Name[$jjj]) ConsoleWrite($Array_of_Funcs[$jjj] & ":" & $Random_Name[$jjj] & @CRLF) Else If StringInStr($Array_of_Funcs[$jjj], "=") Then $func_finished = True ContinueLoop ; Au3wrapper, not a function. EndIf $Script_Data = StringReplace($Script_Data, $Array_of_Funcs[$jjj], $Random_Name[$jjj]) ConsoleWrite($Array_of_Funcs[$jjj] & ":" & $Random_Name[$jjj] & @CRLF) $func_finished = True EndIf Next Next If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Lines, "$New_Array_of_Lines") ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace ; =================================================================================================== _Write_CryptoDragon_Obfuscated_File($Script_Data) ; Write CryptoDragon Obfuscated Script Exit Func _ArraySortDblDel(ByRef $ARRAY, $CASESENS=0, $iDESCENDING=0, $iDIM=0, $iSORT=0) Local $arTmp1D[1], $arTmp2D[1][2], $dbl = 0 $arTmp1D[0] = "" $arTmp2D[0][0] = "" If $iDIM = 0 Then $iDIM = 1 _ArraySort($ARRAY,$iDESCENDING,0,0,$iDIM,$iSORT) Switch $iDIM Case 1 ; 1D For $i = 0 To UBound($ARRAY)-1 $dbl = 0 For $k = 0 To UBound($arTmp1D)-1 Switch $CASESENS Case 0 If $arTmp1D[$k] = $ARRAY[$i] Then $dbl = 1 Case 1 If $arTmp1D[$k] == $ARRAY[$i] Then $dbl = 1 EndSwitch Next If $dbl = 0 Then If $arTmp1D[0] = "" Then $arTmp1D[0] = $ARRAY[$i] Else _ArrayAdd($arTmp1D, $ARRAY[$i]) EndIf Else $dbl = 0 EndIf Next $ARRAY = $arTmp1D Case 2 ; 2D For $i = 0 To UBound($ARRAY)-1 $dbl = 0 For $k = 0 To UBound($arTmp2D)-1 Switch $CASESENS Case 0 If ( $arTmp2D[$k][0] = $ARRAY[$i][0] ) And _ ( $arTmp2D[$k][1] = $ARRAY[$i][1] ) Then $dbl = 1 Case 1 If ( $arTmp2D[$k][0] == $ARRAY[$i][0] ) And _ ( $arTmp2D[$k][1] == $ARRAY[$i][1] ) Then $dbl = 1 EndSwitch Next If $dbl = 0 Then If $arTmp2D[0][0] = "" Then $arTmp2D[0][0] = $ARRAY[$i][0] $arTmp2D[0][1] = $ARRAY[$i][1] Else ReDim $arTmp2D[UBound($arTmp2D)+1][2] $arTmp2D[UBound($arTmp2D)-1][0] = $ARRAY[$i][0] $arTmp2D[UBound($arTmp2D)-1][1] = $ARRAY[$i][1] EndIf Else $dbl = 0 EndIf Next $ARRAY = $arTmp2D EndSwitch EndFunc ; ==>_ArraySortDblDel ; ################################################################################################### ; =================================================================================================== Func _Choose_Script_to_Obfuscate() ; Choose Script to Obfuscate $file_Script_to_Obfuscate = FileOpenDialog("Choose an AutoIt Script to Obfuscate:", @ScriptDir, "Scripts (*.au3)", 1 + 2) If @error Then Exit EndFunc ; ==> _Choose_Script_to_Obfuscate ; =================================================================================================== ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines Func _Count_Lines() ; Count Lines of Script to Obfuscate FileOpen($file_Script_to_Obfuscate, 0) ; Open File to Obfuscate $Num_of_Lines = 0 While 1 $Num_of_Lines = $Num_of_Lines + 1 FileReadLine($file_Script_to_Obfuscate, $Num_of_Lines) ; Read All Lines for Count If @error = -1 Then ExitLoop WEnd EndFunc ; ==> _Count_Lines ; =================================================================================================== Func _Read_Lines_to_Array() ; Read Lines to Array For $iii = 1 To $Num_of_Lines $Array_of_Lines[$iii] = FileReadLine($file_Script_to_Obfuscate, $iii) ; Read All Lines Next FileClose($file_Script_to_Obfuscate) ; Close File to Obfuscate EndFunc ; ==> _Read_Lines_to_Array ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines ; =================================================================================================== ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars Func _Count_Vars() ; Count Variables in Script to Obfuscate $Num_of_Vars = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $char = "$" And $quote_on = "No" Then $Num_of_Vars = $Num_of_Vars + 1 $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Count_Vars ; =================================================================================================== Func _Read_Vars_to_Array() ; Read Variables to Array Local $var_ct = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $char = "$" And $quote_on = "No" Then ; Read One Variable $var_ct = $var_ct + 1 $Array_of_Vars[$var_ct] = "" For $kkk = 1 To 256 $char = StringLeft($Array_of_Lines[0], 1) If $char = " " Or _ $char = " " Or _ $char = "=" Or _ $char = "[" Or _ $char = "]" Or _ $char = "," Or _ $char = ")" Or _ $char = ";" Or _ $char = "+" Or _ $char = "-" Or _ $char = "*" Or _ $char = "/" Or _ $char = Chr(34) Then ExitLoop $Array_of_Vars[$var_ct] = $Array_of_Vars[$var_ct] & $char $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next EndIf $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Read_Vars_to_Array ; =================================================================================================== Func _Sort_Array_of_Vars() ; Sort Array of Variables _ArraySortDblDel($Array_of_Vars) EndFunc ; ==> _Sort_Array_of_Vars ; =================================================================================================== Func _Count_Unique_Vars() ; Count Unique Variables $Num_of_Unique_Vars = 0 For $iii = 1 To UBound($Array_of_Vars) - 1 If $Array_of_Vars[$iii] <> $Array_of_Vars[$iii - 1] Then If StringIsUpper(StringTrimLeft(StringReplace($Array_of_Vars[$iii], "_", ""), 1)) Then ContinueLoop ; Don't write any system variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE $Num_of_Unique_Vars = $Num_of_Unique_Vars + 1 EndIf Next EndFunc ; ==> _Count_Unique_Vars ; =================================================================================================== Func _Read_Unique_Vars_to_Array() ; Read Unique Variables to Array Local $var_unique_ct = 0 For $iii = 1 To UBound($Array_of_Vars) - 1 If $Array_of_Vars[$iii] <> $Array_of_Vars[$iii - 1] Then If StringIsUpper(StringTrimLeft(StringReplace($Array_of_Vars[$iii], "_", ""), 1)) Then ContinueLoop ; Don't read any System Variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE $var_unique_ct = $var_unique_ct + 1 $Array_of_Unique_Vars[$var_unique_ct] = $Array_of_Vars[$iii] EndIf Next EndFunc ; ==> _Read_Unique_Vars_to_Array ; =================================================================================================== Func _Write_Unique_Vars_to_File() ; Write Unique Variables to File Local $file_Unique_Vars = StringTrimRight($file_Script_to_Obfuscate, 4) & " - Vars to Obfuscate.txt" ; Create Unique Variables Filename FileOpen($file_Unique_Vars, 2) ; Open File to Write Unique Variables For $iii = 1 To $Num_of_Unique_Vars FileWrite($file_Unique_Vars, $Array_of_Unique_Vars[$iii] & @CRLF) Next FileClose($file_Unique_Vars) ; Close Unique Variables File EndFunc ; ==> _Write_Unique_Vars_to_File ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars ; =================================================================================================== ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs Func _Count_Funcs() ; Count Functions in Script to Obfuscate $Num_of_Funcs = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" Local $var_on = "No" Local $func_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = "(" Or $char = " " Then $func_on = "No" If $char = "$" And $quote_on = "No" Then $var_on = "Yes" If $char = "@" And $quote_on = "No" Then $var_on = "Yes" If $char = "<" And $quote_on = "No" Then $var_on = "Yes" If $char = " " And $quote_on = "No" Then $var_on = "No" If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $quote_on = "No" And $func_on = "No" And $var_on = "No" Then $func_on = "Yes" $Num_of_Funcs = $Num_of_Funcs + 1 EndIf $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Count_Funcs ; =================================================================================================== Func _Read_Funcs_to_Array() ; Read Functions to Array Local $func_ct = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" Local $var_on = "No" Local $func_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = "(" Or $char = " " Then $func_on = "No" If $char = "$" And $quote_on = "No" Then $var_on = "Yes" If $char = "@" And $quote_on = "No" Then $var_on = "Yes" If $char = "<" And $quote_on = "No" Then $var_on = "Yes" If $char = " " And $quote_on = "No" Then $var_on = "No" If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $char = "_" And $quote_on = "No" And $func_on = "No" And $var_on = "No" Then ; Read One Function $func_ct = $func_ct + 1 $Array_of_Funcs[$func_ct] = "" For $kkk = 1 To 256 $char = StringLeft($Array_of_Lines[0], 1) If $char = " " Or $char = "(" Then ExitLoop $Array_of_Funcs[$func_ct] = $Array_of_Funcs[$func_ct] & $char $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next ; Functions_NOT_to_obfuscate_section: ; Add functions to the following lines that start with an underscore "_" that you ; do NOT want to be obfuscated. Example: ; If $Array_of_Funcs[$func_ct] = "_ArraySortDblDel" Or _ If $Array_of_Funcs[$func_ct] = "_ArraySortDblDel" Or _ $Array_of_Funcs[$func_ct] = "_ArrayDisplay" Or _ $Array_of_Funcs[$func_ct] = "_ChooseColor" Or _ $Array_of_Funcs[$func_ct] = "_ChooseFont" Or _ $Array_of_Funcs[$func_ct] = "_ImageGetSize" Or _ $Array_of_Funcs[$func_ct] = "_IsPressed" Or _ $Array_of_Funcs[$func_ct] = "_StringEncrypt" Or _ $Array_of_Funcs[$func_ct] = "_" Then ; Do NOT Count Built-In Functions $func_ct = $func_ct - 1 EndIf EndIf $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Read_Funcs_to_Array ; =================================================================================================== Func _Sort_Array_of_Funcs() ; Sort Array of Functions _ArraySortDblDel($Array_of_Funcs) EndFunc ; ==> _Sort_Array_of_Funcs ; =================================================================================================== ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs ; =================================================================================================== Func _Find_Random_Name_Count() ; Find Random Name Count If $Num_of_Unique_Vars > $Num_of_Funcs Then $Num_of_Random_Names = $Num_of_Vars Else $Num_of_Random_Names = $Num_of_Funcs EndIf EndFunc ; ==> _Find_Random_Name_Count ; =================================================================================================== Func _Read_Random_Names_to_Array() ; Read Random Names to Array Local $random[16] For $iii = 1 To $Num_of_Random_Names $Random_Name[$iii] = "" For $jjj = 1 To Random(4, 15, 1) ; The number of random characters to use in each random name $random[$jjj] = Random(48, 122, 1) If $random[$jjj] > 64 And $random[$jjj] < 91 Or $random[$jjj] > 96 And $random[$jjj] < 123 Then $Random_Name[$iii] = $Random_Name[$iii] & Chr($random[$jjj]) Else $jjj = $jjj - 1 ContinueLoop EndIf Next Next Return $Random_Name EndFunc ; ==> _Read_Random_Names_to_Array ; =================================================================================================== Func _Write_Random_Names_to_File() ; Write Random Names to File Local $file_Random_Names = StringTrimRight($file_Script_to_Obfuscate, 4) & " - Random Names.txt" ; Create Random Names Filename FileOpen($file_Random_Names, 2) ; Open File to Write Random Names For $iii = 1 To $Num_of_Random_Names FileWrite($file_Random_Names, $Random_Name[$iii] & @CRLF) Next FileClose($file_Random_Names) ; Close Random Names File Return $Random_Name EndFunc ; ==> _Write_Random_Names_to_File ; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random ; =================================================================================================== ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace ; =================================================================================================== Func _Remove_Comments() ; Remove Comments For $iii = 1 To $Num_of_Lines Local $quote_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) $New_Array_of_Lines[$iii] = "" For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop $New_Array_of_Lines[$iii] = $New_Array_of_Lines[$iii] & $char $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next Return $New_Array_of_Lines EndFunc ; ==> _Remove_Comments ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace ; =================================================================================================== Func _StringBetween($S_STRING, $S_START, $S_END, $V_CASE = -1) Local $S_CASE = "" If $V_CASE = Default Or $V_CASE = -1 Then $S_CASE = "(?i)" Local $S_PATTERN_ESCAPE = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)" $S_START = StringRegExpReplace($S_START, $S_PATTERN_ESCAPE, "\\$1") $S_END = StringRegExpReplace($S_END, $S_PATTERN_ESCAPE, "\\$1") If $S_START = "" Then $S_START = "\A" If $S_END = "" Then $S_END = "\z" Local $A_RET = StringRegExp($S_STRING, "(?s)" & $S_CASE & $S_START & "(.*?)" & $S_END, 3) If @error Then Return SetError(1, 0, 0) Return $A_RET EndFunc ;==>_STRINGBETWEEN Func _Add_Strings($aList, $AU3, $splitChar) Global $sPass = "" Dim $sRndChr[3] Local $Digits = Random(4, 15, 1) For $i = 1 To $Digits $sRndChr[0] = Chr(Random(65, 90, 1)) $sRndChr[1] = Chr(Random(97, 122, 1)) $sRndChr[2] = Chr(Random(48, 57, 1)) $sPass &= $sRndChr[Random(0, 2, 1)] Next Local $doneEncryption = False Local $newAU3 = $AU3 _ArraySortDblDel($aList) For $A = 0 To UBound($aList) - 1 If StringInStr($aList[$A], @CRLF) Then ContinueLoop ElseIf $aList[$A] <> "" And StringInStr($aList[$A], "_CryptoDragon_Crypt") = False And StringLeft($aList[$A], 1) <> "'" And StringRight($aList[$A], 1) <> "'" And StringLeft($aList[$A], 1) <> '"' And StringRight($aList[$A], 1) <> '"' And StringLen($aList[$A]) > 1 Then If StringInStr($aList[$A], "&") Then If StringRight($aList[$A], 1) = "&" Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimRight($aList[$A], 1) & $splitChar, " & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 1), $sPass, StringLen(StringTrimRight($aList[$A], 1)))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")&") ConsoleWrite($splitChar & StringTrimRight($aList[$A], 1) & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 1), $sPass, StringLen(StringTrimRight($aList[$A], 1)))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")&" & @CRLF) ElseIf StringRight($aList[$A], 2) = "& " Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimRight($aList[$A], 2) & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ") & ") ConsoleWrite($splitChar & StringTrimRight($aList[$A], 2) & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ") &" & @CRLF) ElseIf StringLeft($aList[$A], 1) = "&" Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimLeft($aList[$A], 1) & $splitChar, "&_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 1))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")") ConsoleWrite($splitChar & StringTrimLeft($aList[$A], 1) & $splitChar & ":&_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 1), $sPass, StringLen(String($aList[$A]) - 1))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")" & @CRLF) ElseIf StringLeft($aList[$A], 2) = " &" Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimLeft($aList[$A], 2) & $splitChar, " & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'))") ConsoleWrite($splitChar & StringTrimLeft($aList[$A], 2) & $splitChar & ": & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ")" & @CRLF) Else $newAU3 = StringReplace($newAU3, $splitChar & $aList[$A] & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ")") ConsoleWrite($splitChar & $aList[$A] & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ")" & @CRLF) EndIf Else $newAU3 = StringReplace($newAU3, $splitChar & $aList[$A] & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & StringLen($aList[$A]) & ")") ConsoleWrite($splitChar & $aList[$A] & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ")" & @CRLF) EndIf EndIf Next Return $newAU3 EndFunc ;==>_ADD_STRINGS Func base64($vCode, $bEncode = True, $bUrl = False) Local $oDM = ObjCreate("Microsoft.XMLDOM") If Not IsObj($oDM) Then Return SetError(1, 0, 1) Local $oEL = $oDM.createElement("Tmp") $oEL.DataType = "bin.base64" If $bEncode then $oEL.NodeTypedValue = Binary($vCode) If Not $bUrl Then Return $oEL.Text Return StringReplace(StringReplace(StringReplace($oEL.Text, "+", "-"),"/", "_"), @LF, "") Else If $bUrl Then $vCode = StringReplace(StringReplace($vCode, "-", "+"), "_", "/") $oEL.Text = $vCode Return BinaryToString($oEL.NodeTypedValue, 4) EndIf EndFunc ;==>base64 Func _Encrypt_Strings($AU3, $file_Simple_Obfuscated) Local $sSTRINGS = _StringBetween($AU3, "'", "'") Local $newAU3 = _Add_Strings($sSTRINGS, $AU3, "'") Local $dSTRINGS = _StringBetween($newAU3, '"', '"') Local $epicAU3 = _Add_Strings($dSTRINGS, $newAU3, '"') Local $fileHandle = FileOpen($file_Simple_Obfuscated, 18) FileWrite($fileHandle, base64("RnVuYyBfQ3J5cHRvRHJhZ29uX0NyeXB0KCRzX1N0cmluZywgJHNfS2V5LCAkaUxlbiwgJHhvcksyID0gMHgxMiwgJHNfTGV2ZWwgPSAxLjMzNykKCUxvY2FsICRzX0VuY3J5cHRlZCA9ICIiLCAkZmluX0VuY3J5cHRlZCA9ICIiLCAkc19rYyA9IDEKCUlmIFN0cmluZ0xlbigkc19LZXkpID0gMCBPciAkc19MZXZlbCA8IDEgVGhlbiBSZXR1cm4gMAoJJHNfS2V5ID0gU3RyaW5nU3BsaXQoJHNfS2V5LCAnJykKCSRzX1N0cmluZyA9IFN0cmluZ1NwbGl0KCRzX1N0cmluZywgJycpCglGb3IgJHggPSAxIFRvICRzX1N0cmluZ1swXQoJCUlmICRzX2tjID4gJHNfS2V5WzBdIFRoZW4gJHNfa2MgPSAxCgkJJHNfRW5jcnlwdGVkID0gJHNfS2V5WyRzX2tjXQoJCSRzX0VuY3J5cHRlZCArPSBGbG9vcihBc2MoJHNfS2V5WyRzX2tjXSkgKiAkc19MZXZlbCk7CgkJJHNfRW5jcnlwdGVkID0gQml0Tk9UKCRzX0VuY3J5cHRlZCk7CgkJJHNfRW5jcnlwdGVkID0gQml0WE9SKCRzX0VuY3J5cHRlZCwgRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpKTsKCQkkc19FbmNyeXB0ZWQgKz0gRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpOwoJCSRzX0VuY3J5cHRlZCAtPSBGbG9vcihBc2MoJHNfS2V5WyRzX2tjXSkgKiAkc19MZXZlbCk7CgkJJHNfRW5jcnlwdGVkID0gQml0WE9SKCRzX0VuY3J5cHRlZCwgRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpKTsKCQkkc19FbmNyeXB0ZWQgPSAkc19FbmNyeXB0ZWQgLSAxOwoJCSRzX0VuY3J5cHRlZCA9IEJpdFhPUigkc19FbmNyeXB0ZWQsIEZsb29yKEFzYygkc19LZXlbJHNfa2NdKSAqICRzX0xldmVsKSk7CgkJJHNfRW5jcnlwdGVkID0gJHNfRW5jcnlwdGVkICsgMTsKCQkkc19FbmNyeXB0ZWQgKz0gRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpOwoJCSRzX0VuY3J5cHRlZCA9IEJpdFhPUigkc19FbmNyeXB0ZWQsICR4b3JLMik7CgkJJHNfRW5jcnlwdGVkID0gQml0Tk9UKCRzX0VuY3J5cHRlZCk7CgkJJHNfRW5jcnlwdGVkICs9IEZsb29yKEFzYygkc19LZXlbJHNfa2NdKSAqICRzX0xldmVsKTsKCQkkZmluX0VuY3J5cHRlZCAmPSBDaHIoQml0WE9SKEFzYygkc19TdHJpbmdbJHhdKSwgRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpKSkKCQkkc19rYyArPSAxCglOZXh0CglSZXR1cm4gU3RyaW5nTGVmdCgkZmluX0VuY3J5cHRlZCwgJGlMZW4pCkVuZEZ1bmMgICA7PT0+X0NyeXB0b0RyYWdvbl9DcnlwdA==", False)) FileWrite($fileHandle, $epicAU3) FileClose($fileHandle) EndFunc ;==>_ENCRYPT_STRINGS Func _Write_CryptoDragon_Obfuscated_File($AU3) ; Write CryptoDragon Obfuscated File Local $file_Simple_Obfuscated = StringTrimRight($file_Script_to_Obfuscate, 4) & " - CryptoDragon Obfuscated.au3" ; Create CryptoDragon Obfuscated Filename _Encrypt_Strings($AU3, $file_Simple_Obfuscated) EndFunc ; ==> _Write_CryptoDragon_Obfuscated_File ; ===================================================================================================1 point
-
...I do not know, however you could use a running powershell instance started with redirected I/O streams and use it to execute multiple commands without having to rerun it with each new command. Since it is necessary to be able to identify the beginning and the end of the output stream of the various commands, I thought of "injecting" two "flags", one for the beginning and one for the end, for each command executed, so as to be able to extract only the body of the output of the different commands. This little script perhaps clarifies it better than many words. I hope it will be useful to you #include <constants.au3> #include <string.au3> #RequireAdmin ; Use RunAs if you want use a fixed username/password within the script: ; Global $hPowerShellPID = RunAs("UserName", "Domain", "Password", "", "powershell.exe", '', @SW_HIDE, BitOR($STDIN_CHILD, $STDERR_MERGED)) ; or use #RequireAdmin and a simple Run Statement to enter Admin credentials (if needed) at runtime ; Here we start a "permanent" powershell prompt with redirected streams Global $hPowerShellPID = Run("powershell.exe", '', @SW_HIDE, BitOR($STDIN_CHILD, $STDERR_MERGED)) ; this little loop is to wait for the "welcome" message from powershell ; just a way to be sure that the powershell is running and "streaming" Do StdoutRead($hPowerShellPID) Until @extended ; out stream started ; example: ; Here we "execute a command via the Powershell that is running in background... ; ...and we get back to resulting output Local $Out = _Run_Cmdlet("Get-ItemPropertyValue 'Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'EnableLUA'", $hPowerShellPID) ConsoleWrite($Out) ; here another command ConsoleWrite(_Run_Cmdlet("dir c:\", $hPowerShellPID)) ; .... and so on ... ; this function execute the passed powershell command and returns the resulting output Func _Run_Cmdlet($sCmd, ByRef $hPS) Local $sStdOut = '' ; we insert a start and an end message in order to identify the "body" of the result of the command executed $sCmd = 'write-host "->StartOfStream<-"; ' & $sCmd & '; write-host "->EndOfStream<-"' & @CRLF StdinWrite($hPS, $sCmd) Do Sleep(250) $sStdOut &= StdoutRead($hPS) ; the presence of the known end message signals the end of the execution Until StringInStr($sStdOut, "->EndOfStream<-" & @LF) ; return only the body of the outpu of the passed command Return _StringBetween($sStdOut, "->StartOfStream<-" & @LF, "->EndOfStream<-" & @LF)[0] EndFunc ;==>_Run_Cmdlet1 point
-
Sometimes I see posts where people are complaining about the 32kb limit on IniReadSetion. I never did understand why you would have a section that was 32kb's... One of my string parsing functions reads and writes to an ini, well for the first time ever, the section was 34.x kbs and I couldn't understand for the longest time (about 10 trials of re-writing different things) why I wasn't getting all the values... Just bits and pieces it seemed. I never check for anything other than if IniReadSection is an array... But then I thought to look at the size... and their lay the problem. I wrote a really slow IniReadSection for someone else 2 or so months ago that had this problem, and to be honest, it was 2000 times slower than the current released one that Valik wrote... This didn't suite my needs either, as every second counts ... So I wrote another one, This one isn't near as fast as Valiks for obvious reasons, but it did the trick 20x's faster than the last one I wrote. Hope it helps someone... Update: - 2011/05/18 - SmOke_N Changed: _IniReadSectionEx() - Changed all existing functions; hopefully more proficient; thanks llewxam Old Code: ; New code with changes, be sure to test if you have doubts. I only moderately tested. ; The IniRead* functions now accept a passed string ( like from a FileRead() or ClipPut() etc... ) ; change added - SmOke_N - 2011/05/18 Func _IniDeleteEx($s_file, $s_section, $s_key = "") If Not FileExists($s_file) Then Return SetError(-1, 0, 0) Local $i_size = FileGetSize($s_file) Local $i_delete = 0 If $i_size < 31 Then $i_delete = IniDelete($s_file, $s_section, $s_key) Return SetError(@error, 0, $i_delete) EndIf ; is file read only If StringInStr(FileGetAttrib($s_file), "R") Then Return SetError(-2, 0, 0) EndIf Local $s_fread = FileRead($s_file) ; find out if section exist, if so get data Local $s_secpatt = "(?si)(?:^|\v)(\h*\[\h*\Q" $s_secpatt &= $s_section $s_secpatt &= "\E\h*\].*?)(?:\z|\v\v?\[)" Local $a_data = StringRegExp($s_fread, $s_secpatt, 1) Local $f_dataexists = Not @error If Not $f_dataexists Then Return 1 Local $h_open, $i_write = 0 If $s_key = "" Then If $s_fread = $a_data[0] Then $h_open = FileOpen($s_file, 2) If $h_open = -1 Then Return SetError(-3, 0, 0) FileClose($h_open) Return 1 EndIf $s_fread = StringReplace($s_fread, $a_data[0], "", 1, 1) $h_open = FileOpen($s_file, 2) If $h_open = -1 Then Return SetError(-3, 0, 0) $i_write = FileWrite($h_open, $s_fread) FileClose($h_open) If Not $i_write Then Return SetError(-4, 0, 0) Return 1 EndIf ; since we stop at cr/lf then lets just split Local $a_lines If StringInStr($a_data[0], @CRLF, 1, 1) Then $a_lines = StringSplit(StringStripCR($a_data[0]), @LF) ElseIf StringInStr($a_data[0], @LF, 1, 1) Then $a_lines = StringSplit($a_data[0], @LF) Else $a_lines = StringSplit($a_data[0], @CR) EndIf Local $a_key, $f_found = False, $s_write Local $s_keypatt = "\h*(?!;|#)(.*?)\h*=" For $iline = 1 To $a_lines[0] If $a_lines[$iline] = "" Then ContinueLoop $a_key = StringRegExp($a_lines[$iline], $s_keypatt, 1) If @error Or $s_key <> $a_key[0] Then $s_write &= $a_lines[$iline] & @CRLF ContinueLoop EndIf $f_found = True Next If Not $f_found Then Return 1 $s_fread = StringReplace($s_fread, $a_data[0], $s_write) Local $h_open = FileOpen($s_file, 2) $i_write = FileWrite($h_open, $s_fread) FileClose($h_open) Return $i_write EndFunc ; change added - SmOke_N - 2011/05/18 Func _IniWriteEx($s_file, $s_section, $s_key, $s_value) If Not $s_file Then Return SetError(-1, 0, 0) Local $f_exists = FileExists($s_file) If Not $f_exists Then FileClose(FileOpen($s_file, 2)) EndIf Local $i_write = 0 Local $i_size = FileGetSize($s_file) / 1024 ; if the file is smaller than 32kb, no need for regex If $i_size <= 31 Then $i_write = IniWrite($s_file, $s_section, $s_key, $s_value) Return SetError(@error, 0, $i_write) EndIf ; is file read only If $f_exists Then If StringInStr(FileGetAttrib($s_file), "R") Then Return SetError(-2, 0, 0) EndIf EndIf Local $s_fread = FileRead($s_file) Local $s_write = "" ; find out if section exist, if so get data Local $s_secpatt = "(?si)(?:^|\v)(\h*\[\h*\Q" $s_secpatt &= $s_section $s_secpatt &= "\E\h*\].*?)(?:\z|\v\v?\[)" Local $a_data = StringRegExp($s_fread, $s_secpatt, 1) Local $f_dataexists = Not @error Local $s_write = "" ; if section doesn't exist; append If Not $f_dataexists Then If $s_fread Then If StringRight($s_fread, 2) <> @CRLF Then $s_write &= @CRLF EndIf EndIf $s_write &= "[" & $s_section & "]" & @CRLF $s_write &= $s_key & "=" & $s_value & @CRLF Return FileWrite($s_file, $s_write) EndIf ; since we stop at cr/lf then lets just split Local $a_lines If StringInStr($a_data[0], @CRLF, 1, 1) Then $a_lines = StringSplit(StringStripCR($a_data[0]), @LF) ElseIf StringInStr($a_data[0], @LF, 1, 1) Then $a_lines = StringSplit($a_data[0], @LF) Else $a_lines = StringSplit($a_data[0], @CR) EndIf Local $a_key, $f_changed = False Local $s_keypatt = "\h*(?!;|#)(.*?)\h*=" For $iline = 1 To $a_lines[0] If $a_lines[$iline] = "" Then ContinueLoop $a_key = StringRegExp($a_lines[$iline], $s_keypatt, 1) If @error Or $s_key <> $a_key[0] Then $s_write &= $a_lines[$iline] & @CRLF ContinueLoop EndIf $f_changed = True $s_write &= $s_key & "=" & $s_value & @CRLF Next If Not $f_changed Then If StringRight($s_fread, 2) <> @CRLF Then $s_write &= @CRLF EndIf $s_write &= $s_key & "=" & $s_value & @CRLF EndIf $s_fread = StringReplace($s_fread, $a_data[0], $s_write) Local $h_open = FileOpen($s_file, 2) $i_write = FileWrite($h_open, $s_fread) FileClose($h_open) Return $i_write EndFunc ; change added - SmOke_N - 2011/05/18 Func _IniReadSectionNamesEx($v_file) If Not $v_file Then Return SetError(-1, 0, 0) Local $f_exists = FileExists($v_file) Local $i_size, $a_secs If $f_exists Then $i_size = FileGetSize($v_file) / 1024 ; if the file is smaller than 32kb, no need for regex If $i_size <= 31 Then $a_secs = IniReadSectionNames($v_file) If @error Then Return SetError(@error, 0, 0) If Not IsArray($a_secs) Then Return SetError(-2, 0, 0) Return $a_secs EndIf EndIf Local $s_fread If Not $f_exists Then ; string of data was passed $s_fread = $v_file Else $s_fread = FileRead($v_file) EndIf Local $s_secpatt = "(?m)(?:^|\v)\h*\[\h*(.*?)\h*\]" Local $a_secsre = StringRegExp($s_fread, $s_secpatt, 3) If @error Then Return SetError(-3, 0, 0) Local $i_ub = UBound($a_secsre) Local $a_secret[$i_ub + 1] = [$i_ub] For $isec = 0 To $i_ub - 1 $a_secret[$isec + 1] = $a_secsre[$isec] Next Return $a_secret EndFunc ; change added - SmOke_N - 2011/05/17 Func _IniReadSectionEx($v_file, $s_section) If Not $v_file Then Return SetError(-1, 0, 0) Local $f_exists = FileExists($v_file) Local $i_size, $a_secread If $f_exists Then $i_size = FileGetSize($v_file) / 1024 ; if the file is smaller than 32kb, no need for regex If $i_size <= 31 Then $a_secread = IniReadSection($v_file, $s_section) If @error Then Return SetError(@error, 0, 0) If Not IsArray($a_secread) Then Return SetError(-2, 0, 0) Return $a_secread EndIf EndIf Local $s_fread If Not $f_exists Then ; string of data was passed $s_fread = $v_file Else $s_fread = FileRead($v_file) EndIf ; data between sections or till end of file Local $s_datapatt = "(?is)(?:^|\v)(?!;|#)\h*\[\h*\Q" $s_datapatt &= $s_section $s_datapatt &= "\E\h*\]\h*\v+(.*?)(?:\z|\v\h*\[)" Local $a_data = StringRegExp($s_fread, $s_datapatt, 1) If @error Then Return SetError(-3, 0, 0) ; sanity check for inf people If Not StringInStr($a_data[0], "=", 1, 1) Then Return SetError(-4, 0, 0) EndIf ; since we stop at cr/lf then lets just split Local $a_lines If StringInStr($a_data[0], @CRLF, 1, 1) Then $a_lines = StringSplit(StringStripCR($a_data[0]), @LF) ElseIf StringInStr($a_data[0], @LF, 1, 1) Then $a_lines = StringSplit($a_data[0], @LF) Else $a_lines = StringSplit($a_data[0], @CR) EndIf ; prevent capturing commented keys Local $a_key, $a_value Local $s_keypatt = "\h*(?!;|#)(.*?)\h*=" Local $s_valpatt = "\h*=\h*(.*)" Local $a_secs[$a_lines[0] + 1][2], $i_add = 0 For $iline = 1 To $a_lines[0] $a_key = StringRegExp($a_lines[$iline], $s_keypatt, 1) If @error Then ContinueLoop $s_valpatt = "\h*=\h*(.*)" $a_value = StringRegExp($a_lines[$iline], $s_valpatt, 1) If @error Then ContinueLoop If StringLeft($a_key[0], 1) = '"' And StringRight($a_key[0], 1) = '"' Then $a_key[0] = StringTrimLeft(StringTrimRight($a_key[0], 1), 1) EndIf If StringLeft($a_value[0], 1) = '"' And StringRight($a_value[0], 1) = '"' Then $a_value[0] = StringTrimLeft(StringTrimRight($a_value[0], 1), 1) EndIf $i_add += 1 $a_secs[$i_add][0] = $a_key[0] $a_secs[$i_add][1] = $a_value[0] Next If Not $i_add Then Return SetError(-5, 0, 0) ; cleanup return array ReDim $a_secs[$i_add + 1][2] $a_secs[0][0] = $i_add Return $a_secs EndFunc ; change added - SmOke_N - 2011/05/18 Func _IniReadEx($v_file, $s_section, $s_key, $v_default = -1) If Not $v_file Then Return SetError(-1, 0, 0) If $v_default = -1 Or $v_default = Default Then $v_default = "" EndIf Local $f_exists = FileExists($v_file) Local $i_size, $s_read If $f_exists Then $i_size = FileGetSize($v_file) / 1024 ; if the file is smaller than 32kb, no need for regex If $i_size <= 31 Then $s_read = IniRead($v_file, $s_section, $s_key, $v_default) Return $s_read EndIf EndIf Local $s_fread If Not $f_exists Then ; string of data was passed $s_fread = $v_file Else $s_fread = FileRead($v_file) EndIf ; data between sections or till end of file Local $s_datapatt = "(?is)(?:^|\v)(?!;|#)\h*\[\h*\Q" $s_datapatt &= $s_section $s_datapatt &= "\E\h*\]\h*\v+(.*?)(?:\z|\v\h*\[)" Local $a_data = StringRegExp($s_fread, $s_datapatt, 1) If @error Then Return SetError(-2, 0, 0) ; sanity check for inf people If Not StringInStr($a_data[0], "=", 1, 1) Then Return SetError(-3, 0, 0) EndIf ; since we stop at cr/lf then lets just split Local $a_lines If StringInStr($a_data[0], @CRLF, 1, 1) Then $a_lines = StringSplit(StringStripCR($a_data[0]), @LF) ElseIf StringInStr($a_data[0], @LF, 1, 1) Then $a_lines = StringSplit($a_data[0], @LF) Else $a_lines = StringSplit($a_data[0], @CR) EndIf ; prevent capturing commented keys Local $a_key, $a_value, $s_ret Local $s_keypatt = "\h*(?!;|#)(.*?)\h*=" Local $s_valpatt = "\h*=\h*(.*)" For $iline = 1 To $a_lines[0] $a_key = StringRegExp($a_lines[$iline], $s_keypatt, 1) If @error Then ContinueLoop If StringLeft($a_key[0], 1) = '"' And StringRight($a_key[0], 1) = '"' Then $a_key[0] = StringTrimLeft(StringTrimRight($a_key[0], 1), 1) EndIf If $a_key[0] <> $s_key Then ContinueLoop $s_valpatt = "\h*=\h*(.*)" $a_value = StringRegExp($a_lines[$iline], $s_valpatt, 1) If @error Then ContinueLoop If StringLeft($a_value[0], 1) = '"' And StringRight($a_value[0], 1) = '"' Then $a_value[0] = StringTrimLeft(StringTrimRight($a_value[0], 1), 1) EndIf $s_ret = $a_value[0] ExitLoop Next If Not $s_ret Then Return $v_default Return $s_ret EndFuncIf you're interested in Ini encryption, you might take a look at this thread: I might integrate these with the IniCrypt.au3 at some future time if I don't get bug feedback from the above.1 point
-
Sort of not. AutoIt does not have a garbage collector. When an object is goes out of scope it's destroyed, full stop. There is no delayed/deferred/scheduled cleanup. A variable goes out of scope, it's gone. Return values are a special case, obviously. monoceres said it best. You don't need to worry about memory so stop worrying about it. I find it a little insulting that you think there is even potential we'd overlook such a glaring logic hole there.1 point