Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/10/2014 in all areas

  1. Melba23

    New MVPs

    In case you had not noticed we have a new MVP, czardas. I am sure you will all join me in congratulating him on his new status. M23
    2 points
  2. Don't forget to use FileClose() once you have finished with the file handle. As for why it didn't work I don't know, as it worked for me. As BrewManNH said, use the proper location in Windows for storing config/temp files.
    2 points
  3. czardas

    ORfuscator

    ORfuscate your script. I'm not sure if this exists, but it is intended as a pre-obfuscation tool. It might be a new invention! While it does not guarantee any protection by itself, ORfuscation does offer some benefit in certain situations. It's more useful in cases where knowing the original numbers is essential to fully understand a script. In other cases it's just adds a slight inconvenience to the reverse engineer due to superflous internal routines. You may wish to convert globals to magic numbers before ORfuscation. I believe PreExpand by guinness will do this. Additional features such as creating fake constants may be included in a future release. Please do not post ORfuscated scripts on the forum. You may post them in this thread if it is relevant to the topic or provides an interesting example. Please double check to make sure that your scripts are still functional after ORfuscation. The example at the end of the script (lines 236 onwards) should be removed before testing with your own script. ; ; #FUNCTION# ==================================================================================================================== ; Name...........: ORfuscate ; Description ...: Refactorization of magic numbers, 32-bit integers and hard coded BitOR() arguments. ; Syntax.........: ORfuscate($sScript) ; Parameters ....: $sScript - String input of an AutoIt script. ; Return values .: Success - Returns the orfuscated script. ; Failure - Returns the original script and sets @error to the following values: ; |@error = 1 : Script contains no data. ; |@error = 2 : No suitable separators found (this should not happen). ; Author ........: czardas ; Modified.......: ; Remarks .......: This is an experimental project with very little testing - so use at your own risk. ; Link ..........: ; Example .......: ; =============================================================================================================================== Func ORfuscate($sScript) If $sScript = "" Then Return SetError(1, 0, "") ; Get suitable padding to separate strings, comments and directives from the AutoIt. Local $iCount = 63743 ; BMP Private Range Upper Limit $sScript &= @LF Local $sIgnoreOn = " " & __GetSubstitute($sScript, $iCount) & " " ; Spaces are used for extra padding. If @error Then Return SetError(2, 0, $sScript) Local $sIgnoreOff = " " & __GetSubstitute($sScript, $iCount) & " " If @error Then Return SetError(2, 0, $sScript) Local $bIsAutoIt = True, _ ; The current position is outside strings, comments and directives. $sNotAutoIt = "", _ ; Strings, comments or directives to avoid. $sExpected = "", _ ; Regexp pattern to match the termination of a string, comment or directive. $sNextChar, $sNewAutoIt = "" ; Identify strings, comments and directives. For $i = 1 To StringLen($sScript) $sNextChar = StringMid($sScript, $i, 1) If $bIsAutoIt Then If StringRegExp($sNextChar, '[#''";]') Then $sNewAutoIt &= $sIgnoreOn & $sNextChar $bIsAutoIt = False Switch $sNextChar Case "#" $sExpected = StringRegExp(StringMid($sScript, $i, 4), "(?:)(#cs\b)") ? "(?:)([\r\n]\h*#ce\b.*\v)" : "\v" Case "'" $sExpected = "'" Case """" $sExpected = """" Case ";" $sExpected = "\v" EndSwitch Else $sNewAutoIt &= $sNextChar EndIf Else $sNotAutoIt &= $sNextChar If StringRegExp($sNotAutoIt, $sExpected) Then $sNewAutoIt &= $sNotAutoIt & $sIgnoreOff $bIsAutoIt = True $sExpected = "" $sNotAutoIt = "" EndIf EndIf Next ; Split the script to reveal 32-bit integers, Bitwise-OR'ed integers and also capture the rest of the code. Local $aAutoIt = StringRegExp($sNewAutoIt, "(?i)(?s)(?U)(" & $sIgnoreOn & ".+" & $sIgnoreOff & ")|\b\d*\.\d+\b|\b\d*\.?\d+e[\+\-]?\d+\b|(?<=[\s=,/\Q[(+-*^?:\E])(\d+|0x[A-F0-9]+|BitOR\h*\([x\h0-9,A-F]+\))(?=[\s=,/\Q)]+-*^?:\E])|\$*\b\w+\b|.", 3) ; Search for integers Local $iBound = UBound($aAutoIt), $iInt32, $sIdx = "" For $i = 0 To $iBound -1 $iInt32 = "" If StringIsInt($aAutoIt[$i]) Or StringRegExp($aAutoIt[$i], "(?i)(\A0x[A-F\d]{1,8}\z)") Or StringRegExp($aAutoIt[$i], "(?i)(BitOR\h*\([x\h\d,A-F]+\))") Then $iInt32 = Execute($aAutoIt[$i]) If VarGetType ($iInt32) <> "Int32" Then ContinueLoop $aAutoIt[$i] = $iInt32 $sIdx &= $i & "," Next If Not $sIdx Then Return SetExtended(1, $sScript) ; No changes can be made Local $aIdx = StringSplit(StringTrimRight($sIdx, 1), ",", 2) Local $iBoundIdx = Ubound($aIdx) Local $aSplit, $aMagic[$iBoundIdx][2][3] For $i = 0 to $iBoundIdx -1 $aSplit = MagicSplit($aAutoIt[$aIdx[$i]]) $aMagic[$i][0][0] = $aSplit[0] ; 1st int $aMagic[$i][1][0] = $aSplit[1] ; 2nd int $aSplit = MagicSplit($aMagic[$i][0][0]) $aMagic[$i][0][1] = $aSplit[0] ; 1st int - 1st element $aMagic[$i][0][2] = $aSplit[1] ; 1st int - 2nd element $aSplit = MagicSplit($aMagic[$i][1][0]) $aMagic[$i][1][1] = $aSplit[0] ; 2nd int - 1st element $aMagic[$i][1][2] = $aSplit[1] ; 2nd int - 2nd element Next ;_WalkThrough3D($aMagic, "zx") Local $sCheckDupes For $i = 0 to $iBoundIdx -1 If $aMagic[$i][0][0] = 0 Then If $aMagic[$i][1][1] = 0 Or $aMagic[$i][1][2] = 0 Then $aAutoIt[$aIdx[$i]] = MagicFormat($aAutoIt[$aIdx[$i]]) Else $aAutoIt[$aIdx[$i]] = "BitOR(" & MagicFormat($aMagic[$i][1][1]) & ", " & MagicFormat($aMagic[$i][1][2]) & ")" EndIf ElseIf $aMagic[$i][1][0] = 0 Then If $aMagic[$i][0][1] = 0 Or $aMagic[$i][0][2] = 0 Then $aAutoIt[$aIdx[$i]] = MagicFormat($aAutoIt[$aIdx[$i]]) Else $aAutoIt[$aIdx[$i]] = "BitOR(" & MagicFormat($aMagic[$i][0][1]) & ", " & MagicFormat($aMagic[$i][0][2]) & ")" EndIf ElseIf Random(0, 1, 1) Then $aAutoIt[$aIdx[$i]] = "BitOR(" $sCheckDupes = "|" For $j = 0 To 1 For $k = 1 To 2 If $aMagic[$i][$j][$k] <> 0 And Not StringInStr($sCheckDupes, "|" & $aMagic[$i][$j][$k] & "|") Then $aAutoIt[$aIdx[$i]] &= MagicFormat($aMagic[$i][$j][$k]) & ", " $sCheckDupes &= $aMagic[$i][$j][$k] & "|" EndIf Next Next $aAutoIt[$aIdx[$i]] = StringTrimRight($aAutoIt[$aIdx[$i]], 2) & ")" ElseIf $aMagic[$i][0][0] <> $aMagic[$i][1][0] Then $aAutoIt[$aIdx[$i]] = "BitOR(" & MagicFormat($aMagic[$i][0][0]) & ", " & MagicFormat($aMagic[$i][1][0]) & ")" Else $aAutoIt[$aIdx[$i]] = MagicFormat($aAutoIt[$aIdx[$i]]) EndIf Next $sScript = "" For $i = 0 To $iBound -1 $sScript &= $aAutoIt[$i] Next $sScript = StringReplace($sScript, $sIgnoreOn, "") $sScript = StringReplace($sScript, $sIgnoreOff, "") $sScript = StringTrimRight($sScript, 1) ; Remove LF added at the start Return $sScript EndFunc Func XORSplit($i32Bit) ; Splits an integer into two randomly selected bitwise exclusive integers. If Not IsInt($i32Bit) Or $i32Bit >= 2^32 Or $i32Bit < 0x80000000 Then Return SetError(1, 0, 0) Local $aXOR[2] $aXOR[0] = 0 ; Randomly select which bits to reproduce in the first return value. => $aXOR[0] Local $iBitPos For $i = 0 To 31 $iBitPos = 2^$i If BitAND($i32Bit, $iBitPos) = $iBitPos And Random(0, 1, 1) Then $aXOR[0] = BitOR($aXOR[0], $iBitPos) Next ; Check the sign bit. If BitAND($i32Bit, 0x80000000) = 0x80000000 And Random(0, 1, 1) Then $aXOR[0] = BitOR($aXOR[0], 0x80000000) ; Exclude the bits set to one (in the first return value) from the original input. $aXOR[1] = BitXOR($i32Bit, $aXOR[0]) Return $aXOR ; Array values can be Bitwise-OR'ed together to reproduce the original input. EndFunc ;==> XORSplit Func ORSplit($i32Bit) ; Splits an integer into two randomly selected bitwise non-exclusive integers. If Not IsInt($i32Bit) Or $i32Bit >= 2^32 Or $i32Bit < 0x80000000 Then Return SetError(1, 0, 0) Local $aOR[2] $aOR[0] = 0 $aOR[1] = 0 ; Randomly select which bits to reproduce in either one or both return values. Local $iBitPos, $iSwitch = Random(1,3,1) For $i = 0 To 31 $iBitPos = 2^$i If BitAND($i32Bit, $iBitPos) = $iBitPos Then For $n = 1 To 2 If BitAND($iSwitch, $n) = $n Then $aOR[$n -1] = BitOR($aOR[$n -1], $iBitPos) Next $iSwitch = Random(1,3,1) ; Set the switch for the next run. EndIf Next ; Check the sign bit. If BitAND($i32Bit, 0x80000000) = 0x80000000 Then For $n = 1 To 2 If BitAND($iSwitch, $n) = $n Then $aOR[$n -1] = BitOR($aOR[$n -1], 0x80000000) Next EndIf Return $aOR ; Array values can be Bitwise-OR'ed together to reproduce the original input. EndFunc ;==> ORSplit Func MagicFormat($iInt) Return '0x' & StringRegExpReplace(Hex($iInt), '\A0{0,'& 2*Random(2,3,1) &'}', '') EndFunc Func MagicSplit($iInt) Local $aSplit = ORSplit($iInt) If $aSplit[0] = $iInt Or $aSplit[1] = $iInt Or $aSplit[0] = 1 Or $aSplit[1] = 1 Then $aSplit = XORSplit($iInt) Return $aSplit EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __GetSubstitute ; Description ...: Searches for a character to be used for substitution, ie one not contained within the input string ; Syntax.........: __GetSubstitute($string, ByRef $iCountdown) ; Parameters ....: $string - The string of characters to avoid ; $iCountdown - The first code point to begin checking ; Return values .: Success - Returns a suitable substitution character not found within the first parameter ; Failure - Sets @error to 1 => No substitution character available ; Author ........: czardas ; Comments ......; This function is connected to the function _CSVSplit and was not intended for general use ; $iCountdown is returned ByRef to avoid selecting the same character on subsequent calls to this function ; Initially $iCountown should be passed with a value = 63743 ; =============================================================================================================================== Func __GetSubstitute($string, ByRef $iCountdown) If $iCountdown < 57344 Then Return SetError(1, 0, "") ; Out of options Local $sTestChar For $i = $iCountdown To 57344 Step -1 $sTestChar = ChrW($i) $iCountdown -= 1 If Not StringInStr($string, $sTestChar) Then Return $sTestChar EndIf Next Return SetError(1, 0, "") ; Out of options EndFunc ;==> __GetSubstitute ; ==> Example - ORfuscate this script. ; See what it does to an array of numbers: Local $aArrayOfNumbers[8] = [387, 0xFFFFFFFF, BitOR(1,2,4,8,16,32,64,128), 0.178, 13/167, 0.1e-78, -876, 20] Global $hFile = FileOpen(@ScriptFullPath) Global $sScript = FileRead($hFile) FileClose($hFile) ConsoleWrite(ORfuscate($sScript) & @CRLF) #cs Ignores multiline comments 100, 0xFFFFFFFF, BitOR(23, 57) #ce ; Have fun!
    1 point
  4. VBScript translates pretty easily, something like this: Const $CSIDL_COMMON_PROGRAMS = "&H17" Const $CSIDL_PROGRAMS = "&H2" Const $CSIDL_STARTMENU = "&HB" $oShell = ObjCreate("Shell.Application") $oFSO = ObjCreate("Scripting.FileSystemObject") $oCurrentUserStartFolder = $oShell.NameSpace($CSIDL_STARTMENU) $sCurrentUserStartFolderPath = $oCurrentUserStartFolder.Self.Path $oAllUsersProgramsFolder = $oShell.NameSpace($CSIDL_COMMON_PROGRAMS) $sAllUsersProgramsPath = $oAllUsersProgramsFolder.Self.Path If $oFSO.FileExists($sCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then $oFolder = $oShell.Namespace($sCurrentUserStartFolderPath & "\Programs\Accessories") $oFolderItem = $oFolder.ParseName("Windows Explorer.lnk") $aVerbs = $oFolderItem.Verbs For $verb in $aVerbs $sVerb = StringReplace($verb.name, "&", "") If $sVerb = "Unpin from Taskbar" Then $verb.DoIt Next EndIf But is there a reason why you want to just unpin it instead of deleting it? #include <Array.au3> #include <File.au3> $Folder = @AppDataDir & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar" Local $aArray = _FileListToArray($Folder, "*.lnk", Default, True) For $sFile In $aArray If StringInStr($sFile, "Windows Explorer") Then FileDelete($sFile) EndIf Next
    1 point
  5. Check if the fifth letter is an s. Is this a real question.
    1 point
  6. Sure. First you need to get a reference to the frame containing the desired elements using either _IEFrameGetCollection or _IEFrameGetObjByName. Then use this frame reference in place of your standard $oIE reference in your call to _IEGetObjById. For example: #include <IE.au3> Local $oIE = _IEAttach("Service") Local $oFrame = _IEFrameGetObjByName($oIE, "iFrame2") ; retrieve frame named "iFrame2" Local $oElement = _IEGetObjById($oFrame, "X314")
    1 point
  7. Maybe using _IEFormGetObjByName() _IEAction() ; param 'click' to click on specific element.
    1 point
  8. AutoIt is basically superior than batch scripting tenfold. Okay you have to invest a little bit of time learning, but when you do you'll appreciate just how quick it is to bang out a script than do it manually yourself.
    1 point
  9. [NEW VERSION] - 9 Oct 14 Added: mjolnirmarkiv has been most helpful in pointing out small improvements that could be made - so as a payback I have added something that he requested. The UDF now reads the current delimiter/separator character and uses that in place of using a default "|". If you do not change the default character then you need do nothing - but if you do change the character then you must do so using Opt("GUIDataSeparatorChar", ) before you include the UDF file so that it is correctly set. New UDF in the first post. M23
    1 point
  10. ramoyous, There are several issues with what you are trying to do: The fields in the code that you posted are not populated. If your server requires authentication, the function that you are using will not work. You do not have an error routine to catch COM errors. What did you intend to do with this statement? "$s_Password = """ I understand that you are a new user. I will be glad to show you how to do this if you tell us exactly what you want to do and provide an example of the input file. kylomas
    1 point
  11. Sounds like a great idea. I'll try that. I'll let you know. Thank you very much
    1 point
  12. Melba23

    _ArrayAdd problem

    RTFC, As Basil Fawlty once remarked: "A satisfied customer. We should have him stuffed". Glad you like the final result. M23
    1 point
×
×
  • Create New...