Jump to content

A3X Script Extract - detect + extract A3x embedded resource


Recommended Posts

A3X Script Extract


With newer versions of AutoIT (v3.3.10.0+), the compiled script is no longer appended to files as an overlay, and instead is embedded as a binary resource.  This leads my previous AutoIt-script detection UDF lacking.  However, since that UDF (>PE File Overlay Extraction) was targeted towards overlays in general, its still a worthwhile tool to have.

This UDF on the other hand is pretty specific - it lets you detect and optionally extract A3X scripts from a compiled executable.  The method is rather straightforward - it looks for a resource type of RT_RCDATA with a resource name of "SCRIPT", and then extracts the binary, testing for the A3X signature along the way.

The main UDF has two functions:

  • _FileContainsScriptResource()
  • _FileContainsA3XScript()

The first of these functions is there only for checking if a resource with "SCRIPT" exists.  Its main purpose is to report on possible embedded scripts.  I made this a separate function primarily because of issues with compressed executables.  Tools like UPX and MPRESS can compress the resources as well as the rest of the executable, so any detection of the A3X signature will fail in those circumstances.  (Note that UPX and MPRESS don't compress overlay data, which is why the older Overlay-Extraction A3X-detection worked regardless)

The second function will both check for and optionally return the A3X script resource as binary.  It also does a signature check for verification.

Anyway, here's an example of its usage.  The main UDF is attached below.

#include <_FileContainsA3XScript.au3>
; ========================================================================================================
; <A3XScriptExtract.au3>
;
; Example of detecting AutoIt Scripts embedded as binary resources (in AutoIt v3.3.10.0+ exe's), and
; extracting them to .A3X files.
;
; This script can be invoked in interactive or command-line mode.
; Passing an executable as a parameter will extract an A3X resource, writing it out to
; an A3X file with the same base name as the executable.
;
; Uses <_FileContainsA3XScript.au3> functions
;
; Author: Ascend4nt
; ========================================================================================================


; ---------------------- MAIN CODE -------------------------------

Local $sFile, $sLastDir, $sLastFile, $binA3X, $iErr, $nA3XSize

; Command-line parameter received? Simply do a direct A3X extraction
If $CmdLine[0] Then
    $sFile = $CmdLine[1]
    If Not FileExists($sFile) Then Exit 1
    $binA3X = _FileContainsA3XScript($sFile, True)
    If @error Then Exit @error
    $nA3XSize = @extended

    Local $nExt = StringInStr($sFile, '.', 0, -1)
    If $nExt Then
        $sFile = StringLeft($sFile, $nExt - 1)
    EndIf
    $sFile &= '.a3x'
    Exit Not FileWrite($sFile, $binA3X)
EndIf

; No command-line parameters, query the user in interactive mode
$sLastDir = @ScriptDir
While 1
    $sFile=FileOpenDialog("Select PE File To Look for Embedded A3X scripts In",$sLastDir,"PE Files (*.exe;*.dll;*.scr)|All Files (*.*)",3,$sLastFile)
    If @error Or $sFile="" Then Exit
    $sLastFile = StringMid($sFile, StringInStr($sFile, '\', 1, -1) + 1)
    $sLastDir = StringLeft($sFile, StringInStr($sFile, '\', 1, -1) - 1)

; Resource 'Script' check
    $bScriptResourceFound = _FileContainsScriptResource($sFile)
    ConsoleWrite("_FileContainsScriptResource() return: " & $bScriptResourceFound & ", @error = " & @error & ", @extended = " & @extended & @CRLF)

; Actual A3X script resource check. True to return the A3X script as binary
    $binA3X = _FileContainsA3XScript($sFile, True)
    $iErr = @error
    $nA3XSize = @extended

    ; No A3X script found?
    If $iErr Or $nA3XSize = 0 Then
        ConsoleWrite("Failed Return from _FileContainsA3XScript(), @error = " & $iErr & ", @extended = " & $nA3XSize & @CRLF)
        MsgBox(64, "No AutoIt A3X script resource Found", "AutoIt A3X script resource not Found!" & @CRLF & _
            ($bScriptResourceFound ? "However, *A* script resource was found" : "No 'Script' resource found either") & @CRLF & _
            "for '" & $sLastFile & "'")
        ContinueLoop
    EndIf

    ConsoleWrite("_FileContainsA3XScript() return type: " & VarGetType($binA3X) & ", value = " & (IsBinary($binA3X) ? "[A3X_Binary]" : $binA3X) & @CRLF)
    ConsoleWrite(@TAB & "@error = " & $iErr & ", @extended = " & $nA3XSize & @CRLF)


    Local $hFileOut = -1, $sOutFile, $iMsgBox, $bSuccess = 0
    $iMsgBox = MsgBox(35, "A3X script resource found in " & $sLastFile, "A3X script resource found. File size: " & FileGetSize($sLastFile) & _
        ", A3X script size: " & $nA3XSize & @CRLF & @CRLF & _
        "Would you like to Extract and save A3X file?")

    If $iMsgBox = 6 Then
;~         If $nA3XSize > 134217728 Then
;~             MsgBox(48, "A3X script is too huge", "A3X script size is > 128MB, skipping..")
;~             ContinueLoop
;~         EndIf
        $sOutFile = FileSaveDialog("A3X script - SAVE: Choose a file to write A3X script data to (from " & $sLastFile&")", _
            $sLastDir, "AutoIt Compiled Sript (*.a3x)|All (*.*)", 2 + 16)
        If @error Then ContinueLoop

        ; Simple check for extension - if none, add .a3x
        If StringInStr($sOutFile, '.') = 0 Then $sOutFile &= ".a3x"

        ; Else
        $hFileOut = FileOpen($sOutFile, 16 + 2)
        If $hFileOut <> - 1 Then
            $bSuccess = FileWrite($hFileOut, $binA3X)
            FileClose($hFileOut)
        EndIf
    Else
        ContinueLoop
    EndIf

    If $bSuccess Then
        ShellExecute(StringLeft($sOutFile,StringInStr($sOutFile,'\',1,-1)-1))
    Else
        MsgBox(64, "Error Opening or writing to file", "Error opening, reading, or saving A3X file")
    EndIf
WEnd
Exit

_FileContainsA3XScript.au3

*edit: Modified example: Now alternatively accepts a command-line parameter for automated script extraction

Edited by Ascend4nt
Link to post
Share on other sites
  • Moderators

aminfear,

Welcome to the AutoIt forum. :)

No problem being new (we all were at one point) but if you have to ask then you do not need to use it - so your question is entirely moot. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Moderators

aminfear,

I am not the Admin - he is far too busy. :)

And the "rules of here" have nothing to do with this - although you might like to read the Forum rules (there is also a link at bottom right of each page) if you have not already done so. The point is that the purpose and use of this UDF is so evident to anyone who understands AutoIt (and very clearly explained in the first post) that having to ask the question means that you probably would not understand any further answers that were given. ;)

As a complete beginner to AutoIt (which we all were at some point, so no problem there) might I suggest reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) as this will help you enormously. You should also look at this excellent tutorial - you will find other tutorials in the Wiki (the link is at the top of the page). Once you understand how AutoIt works and is compiled, you will see the utility and purpose of this UDF. :)

And now back to our normal programming... :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Nice. It moves on from my _GetSavedSource() function I created. Is there a reason you went for DllCalls and not the relevant functions in WinAPI?

One suggestion, just change A3X to a3x, is just looks better.

Edited by guinness

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

Link to post
Share on other sites

..

The point is that the purpose and use of this UDF is so evident to anyone who understands AutoIt (and very clearly explained in the first post) that having to ask the question means that you probably would not understand any further answers that were given.

Actually, and not to knock you Melba, but I believe the A3X compiled format isn't documented in enough places, which can cause some to totally not understand it.  Thats probably not exactly what aminfear meant, but I remember not knowing at first that A3X is both an option to use as a compile-to target and also the embedded resource type (or overlay, in previous versions) in an AutoIt executable.

Link to post
Share on other sites

Nice. It moves on from my _GetSavedSource() function I created. Is there a reason you went for DllCalls and not the relevant functions in WinAPI?

One suggestion, just change A3X to a3x, is just looks better.

The resource code was pretty much copied from an earlier UDF I wrote to read the Manifest (_FileReadManifest).. but I see now that the API functions are now part of the standard AutoIt UDF's.  Ah well, I could write a _WinAPI_... version but at least I know this UDF will work on older versions of AutoIt.   By the way, isnt _GetSaveSource() only for an embedded text file?

I did go ahead and make the appended extension part of the example a lowercase 'a3x'. Thanks

Link to post
Share on other sites

You know I hold the help file close to my heart, a3x is documented in certain parts of the help file. Whether needs to be revised remains to be seen, as Melba23 did add additional information about including a .a3x as though it was a standard .au3 file.

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

Link to post
Share on other sites

By the way, isnt _GetSaveSource() only for an embedded text file?

Yes, so it's slightly different in that I required a user to have previously used the AutoIt3Wrapper directive. We both "mess around" with the resources of the executable, which is where the similarity ends.

I did go ahead and make the appended extension part of the example a lowercase 'a3x'.

Thanks

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

Link to post
Share on other sites
  • Moderators

Ascend4nt,

 

I believe the A3X compiled format isn't documented in enough places

[...]

that A3X is both an option to use as a compile-to target and also the embedded resource type (or overlay, in previous versions) in an AutoIt executable

I will take a look tomorow and see what we can do to make it clearer. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

What purpose does extracting the A3X serve since:

* Decompilation is no longer supported.

* The A3X is written as a standalone application which is no good for inclusion in its raw form in another script. (3.3.10.0+)

Vlad

Edited by Mobius

wtfpl-badge-1.png

Link to post
Share on other sites

Ascend4nt,

 

I will take a look tomorow and see what we can do to make it clearer. :)

M23

Melba, here's one place the documentation could be modified:

Macro Reference

- @Compiled returns 1 for A3X scripts also, not just executables

- @AutoItExe will return the path to the AutoIt executable for A3X-compiled scripts

- @ScriptName will return the executable name for scripts compiled to executable. Otherwise it will return the AU3 or A3X name

Along the same notes:

Running another script or compiled executable using /AutoIt3ExecuteScript will cause @AutoItExe to take on the executable name of the program invoking the given script, and otherwise will behave like an A3X-compiled script.

If /AutoIt3ExecuteScript is used on another executable, the script will not have access to resources embedded in the executable without treating it as an external module.

Link to post
Share on other sites

What purpose does extracting the A3X serve since:

* Decompilation is no longer supported.

* The A3X is written as a standalone application which is no good for inclusion in its raw form in another script. (3.3.10.0+)

Vlad

Mobius,

The A3X file can be used for whatever purpose the person using the script wants it for (including running it standalone or #include'ing it).  It's not my place to say what it should or should not be used for.  The reasoning behind me writing the script is moreso a matter of me asking 'can I?', rather than having some grander plan on what to do with extracted A3X scripts.

While people could potentially use the script for malicious intent, that's not my concern, nor is it my responsibility.  There are plenty of scripts on the forums that can be used for malicious intent (embedding and hiding executables and resources, manipulating Windows' behavior, etc).  This script on its own amounts to little more than a simplified version of resource extraction.  And that in itself is nothing new - anyone can grab a Resourcce Hacker tool to pull out or edit resources.  I just perhaps made it a little more accessible for people.

This whole A3X-detect project grew out of a need to prevent a certain program - namely 'FileOptimizer' - from stripping the A3X overlays from executables (they've since addressed that issue).  That project became >PE File Overlay Extraction, which itself turned out to be a very nice tool for things other than A3X script detection.  For example, if I am suspcious of a certain executable, I can now extract and examine just the overlay to see if there's anything suspicious in it (perhaps identifying it with TrID).

Since I'm a completionist, I decided that the previous project was not fully done, so I wrote more code to detect newer compiled scripts.  And of course I thought it'd be neat to add the option to extract that file in addition to detecting it.  And wa-la, A3X Script Extract.

Anyway, long story short, I wrote this script just because 'it can be done'. I provide it free, and people can make their own decisions on what to do with it.

Oh, and about your points:

- Decompilation: I'm sure someone out there is probably working on updating '3rd party' decompilers for the latest version. Truthfully, it's always bothered me a little that only the developers can decompile our scripts.  Wouldn't it seem more fair that we should be able to encode our scripts so that only we the programmers could extract them?  That's why in general I really don't care about decompilers.

- A3X being #include'd in another script: This can actually be done with many scripts.  You can just put the #include after some code that precedes it.  Not that there's many good reasons to do so.  Its just more interesting that you can detach the A3x script from an EXE and run it on its own, really.

Link to post
Share on other sites

- A3X being #include'd in another script: This can actually be done with many scripts.  You can just put the #include after some code that precedes it.

See I like this, because I can now publish a "closed source" UDF and just have to worry about the documentation.

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

Link to post
Share on other sites
  • Moderators

Ascend4nt,

 

While people could potentially use the script for malicious intent, that's not my concern, nor is it my responsibility

While understanding your point of view, I am afraid that it is not one with which I can agree - but that discussion is best taken elsewhere. :(

Thanks for the Help file suggestions - I will see how they can be inserted. I have already added some explanatory text to the <Using Autoit - Compiling Scripts with Aut2Exe> section.

Mobius,

 

The A3X is written as a standalone application which is no good for inclusion in its raw form in another script

But that is exactly what you can do now - 3.3.10.0+ has the ability to include .a3x as well as .au3 files.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Ascend4nt,

Yes, thankyou for all that ;)

So its a case of "I wrote it because I can", nothing wrong with that at all.

However unlike code that rescues the overlay (pre 3.3.10.0) from the large array of tools that don't support it, which serves an important purpose, extraction of the a3x component from the resource table does not.

One might argue that the extracted a3x of a standalone could indeed be included in another script (which it could from a development standpoint) , said standalone would have to be written unlike a normal standalone because the source from the a3x and the parent script would undoubtedly conflict at runtime, further reducing feasibility.

You are right about 3rd party decompilers, but whose talking about them, I was talking about the once supported official decompiler, a tool that the author of a standalone might use to retrieve their source (or even a tool that one might give to a client so they could validate the product) , which would lend weight to the idea (need) of extracting the a3x from the resource.

As for someone using your code maliciously; no not really, for obvious reasons, one of which you mention yourself.

Anyway, nice example script showing resource manipulation :) keep at it.

@Melba23

This I am aware of, however once included by Aut2exe is it added in its raw binary form to the a3x structure in much the same way as FileInstall, so it can be executed as a separate entity much like a function, or is the sourcecode extracted from the a3x by Aut2exe which it then adds to the main source like including would normally, I pray the prior but I think the latter. ;)

Vlad

Edited by Mobius

wtfpl-badge-1.png

Link to post
Share on other sites

However unlike code that rescues the overlay (pre 3.3.10.0) from the large array of tools that don't support it, which serves an important purpose, extraction of the a3x component from the resource table does not.

Mobius,

Are you saying that A3X extraction doesn't serve any purpose, or just some subjective 'important' purpose?  If its the former, then I'd be calling you out on failure of imagination.  

I'll just give two simple scenarios:

  1. You compile a script to executable, but also want an a3x compile target.  Should you be forced to edit the compiler options (thereby modifying the original script), and rerun Obfuscator + Aut2Exe for each script?  This is something you absolutely have to do - you can't compile to both A3X and Exe. It's one or the other.

    Solution? Use a simple A3X-Extract script on the resulting executable - perhaps as a 'Run after' command

     

  2. You have an executable but not the original script at hand, and find that you need the smaller footprint that A3X provides.. If AutoIt is installed or available locally, you can simply extract the A3X file and delete the executable (assuming there's no resources or metadata you want to keep from the executable).

There's of course other things you can do with A3X scripts that you can't with executables, some of which has been covered..

One example is using /AutoIt3ExecuteScript to run A3X thats embedded in any other type of file (bitmap, for example).  Its of course a bit of a suspicious thing to do, but nonetheless interesting.

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Exit
      Au3toCmd  ---  Avoid false positives
      Since many virus scanners sometimes prevent a "compiled autoit EXE" from being executed as "false positive", the "*.A3X" format is a suitable format to avoid this problem.
      In order to simplify this procedure, I wrote the Au3toCmd script. Here a *.Cmd file is generated from a *.Au3 file. The necessary files Autoit3.exe and *.A3x are added to the "*.Cmd" file as "alternate data streams".
      Now the Autoit Script can be called by clicking on the cmd file and the anti-virus scanners do not recognize the "false positive".
      If the short-term flashing of the CMD window bothers you, you can click the desktop shutcut that runs in a minimized window.
      Unfortunately, because of the "alternate data streams", this CMD file cannot be distributed via FTP or email.
      Only a USB stick or removable disk formatted with NTFS can be used.
      To solve this problem, Au3toCmd can be used to create a ZIP/EXE  file that is email and FTP compatible. 
      Transfer this file to the target directory on the target system.
      Expand the ZIP file on the target system and execute the "*.ADS.Run-me-first.cmd" script.
      or
      Execute the self extracting Setup.exe.

      The original CMD file is created again and the auxiliary files are deleted.
      Edit (2020.05.16)  The new version also accepts A3X and EXE files. This means that A3X and EXE files that have been compiled with special options can be used. As a side effect, other EXE files can also be included in the CMD file and therefore not detectable by virus scanners.
      Edit (2020.07.18)  Desktop shortcuts created automatically. Just delete them, if you don't like them.
      Edit (2020.07.22)  Using codepage 1252 
      Edit (2020.12.07) Self extracting Setup.exe added 
      Edit (2020.12.12) 32 Bit Windows enabled. ANSI console enabled. 
      Edit (2020.12.21) Input of remote system target directory added. 
      Edit (2021.05.13) Adapted to the new www.7-zip.org directory structure. No functional changes. 
      Edit (2021.05.15) Fixed bug in Setup.exe processing. No functional changes. 
      Edit (2021.05.17) Fixed bug when using Windows7. No functional changes. 
      Here the source of Au3toCmd.au3 
      This is a nice example of peaceful interaction between Autoit (*. au3), Dos (*. cmd), Powershell(*.ps1) and VSBasic (*. vbs)
      ;============================================================================================================== ; Script Name: Au3toCmd.au3 ; Description: Creates a CMD file from any AU3/A3X/EXE file. ; The CMD file will contain the compiled version (A3X) of the AU3 input file ; and the AUTOIT3.EXE file as alternate data streams. ; Alternativly it will contain any EXE file. ; This avoids the problem with the false positives of the virus scanners. ; To avoid the short-term flashing of the CMD window, a shortcut is created on the desktop ; that runs in a minimized window. ; ; Syntax: Au3toCmd (input-file) ; Default: none ; Parameter: Name of an AU3/A3X/EXE file (optional) ; Example: Au3toCmd testfile.au3 ; ; Author: Exit ( http://www.autoitscript.com/forum/user/45639-exit ) ; SourceCode: http://www.autoitscript.com/forum/index.php?showtopic=201562 Version: 2021.05.17 ; COPYLEFT: © 2020 Freeware by "Exit" ; ALL WRONGS RESERVED ;============================================================================================================== Global $Debug = 0 ; change to '1' for debugging informations on output console #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #pragma compile(inputboxres, true) #include <File.au3> #include <String.au3> #include <WinAPIGdi.au3> #include <WinAPIFiles.au3> #include <WinAPIHObj.au3> #include <WinAPIError.au3> Global $iMB_Answer, $rc, $sSourcepath, $sTargetpath, $aPathSplit, $sDrive, $sDir, $sFileName, $sExtension, $sIconPath = "", $iIconNumber = 0, $sRDir Exit _Main() Func _Main() If @Compiled Then Exit MsgBox(16 + 262144, Default, "Au3toCmd can only be executed in a non-compiled version.", 0) __DebugInfo() FileDelete(@ScriptFullPath & ".console.txt") If Not _Sourcepath() Then Return SetError(1, 0, 0) If Not _IconPath() Then Return SetError(2, 0, 0) If Not _Targetpath() Then Return SetError(3, 0, 0) $iMB_Answer = MsgBox(3 + 32 + 512 + 262144, Default, $sTargetpath & " and " & @LF & @DesktopDir & "\" & $sFileName & ".lnk created." & @LF & @LF & "Create a portable EXE/ZIP file? " & @LF & @LF & "YES --> Create a SETUP.EXE file" & @LF & @LF & "NO --> Create a ZIP file" & @LF & @LF & "Cancel --> None" & @LF & @LF, 0) __CW("Er/Ex/Line: " & @error & "/" & @extended & "/" & @ScriptLineNumber & " $iMB_Answer: " & $iMB_Answer & @LF) If $iMB_Answer <> 2 Then If Not _CreateZip() Then Return SetError(4, 0, 0) EndIf ;~ If MsgBox(4 + 32 + 256 + 262144, Default, "Run " & $sTargetpath & " ?", 0) = 6 Then ShellExecute(@DesktopDir & "\" & $sFileName & ".lnk") EndFunc ;==>_Main Func _Sourcepath() If StringInStr(@ScriptFullPath, " ") Then Return SetError(7, MsgBox(16 + 262144, Default, "Sorry: Script-Pathnames with embedded blanks not yet supported.", 0), 0) If $cmdline[0] > 0 Then $sSourcepath = $cmdline[1] If Not StringInStr("|.au3|.a3x|.exe|", StringRight($sSourcepath, 4)) Then $sSourcepath &= ".au3" If Not FileExists($sSourcepath) Then Beep(1000, 100) $sSourcepath = FileOpenDialog("Enter AU3/A3X/EXE Inputfile ", "", "Autoit Files(*.au3;*.a3x;*.exe)", 3) If @error Then Return SetError(5, MsgBox(16 + 262144, Default, "Error: No Inputfile given", 0), 0) EndIf $sSourcepath = _PathFull($sSourcepath) $aPathSplit = _PathSplit($sSourcepath, $sDrive, $sDir, $sFileName, $sExtension) If StringInStr($sSourcepath, " ") Then Return SetError(7, MsgBox(16 + 262144, Default, "Sorry: Pathnames with embedded blanks not yet supported.", 0), 0) FileChangeDir($sDrive & $sDir) __CW("Sourcepath: " & $sSourcepath & @LF) Return 1 EndFunc ;==>_Sourcepath Func _IconPath() Local $aTemp If $sExtension = ".exe" Then $sIconPath = $sSourcepath ElseIf FileExists($sDrive & $sDir & $sFileName & ".ico") Then $sIconPath = $sDrive & $sDir & $sFileName & ".ico" Else $aTemp = _StringBetween(FileRead($sSourcepath), "#", ".ico") If Not @error Then $aTemp = StringSplit($aTemp[0], "=, ") If FileExists($aTemp[$aTemp[0]] & ".ico") Then $sIconPath = $sDrive & $sDir & $aTemp[$aTemp[0]] & ".ico" ElseIf FileExists($sDrive & $sDir & $sFileName & ".ico") Then $sIconPath = $sDrive & $sDir & $sFileName & ".ico" Else $sIconPath = @WindowsDir & "\system32\shell32.dll" $iIconNumber = 71 EndIf EndIf EndIf __CW("IconNumber: " & $iIconNumber & " IconPath: " & $sIconPath & @CRLF) Return 1 EndFunc ;==>_IconPath Func _Targetpath() Local $sA3Dir $sTargetpath = $sDrive & $sDir & $sFileName & ".cmd" FileDelete($sTargetpath) If Not FileWriteLine($sTargetpath, _ '@echo on & cd /D %~dp0 ' & @CRLF & _ "for /f ""delims="" %%F in ('dir /R %~nx0 ^| find /C ""$DATA"" ') do set mycount=%%F" & @CRLF & _ 'if .%mycount% == .0 echo Invalid copy of %~nx0. No ADS found. & pause & goto :eof ' & @CRLF & _ 'if .%mycount% == .1 wmic process call create ''"%~f0:prog" %*'' ' & @CRLF & _ 'if .%mycount% == .2 wmic process call create ''"%~f0:prog" "%~f0:a3x" %*'' ') Then _ Return SetError(8, MsgBox(16 + 262144, Default, "Error: Cannot write to output file '" & $sTargetpath & "'", 0), 0) $sA3Dir = RegRead("HKLM\SOFTWARE" & ((@OSArch = 'X64') ? "\Wow6432Node" : "") & "\AutoIt v3\AutoIt", "InstallDir") If Not (FileExists($sA3Dir & "\autoit3.exe") And FileExists($sA3Dir & "\au3check.exe") And FileExists($sA3Dir & "\Aut2Exe\Aut2exe.exe")) Then Return SetError(9, MsgBox(16 + 262144, Default, "Error: Autoit not installed on this system.", 0), 0) Switch $sExtension Case ".au3" If ShellExecuteWait($sA3Dir & "\au3check.exe", ' -q "' & $sSourcepath & '"', "", "", @SW_HIDE) Then Return SetError(10, MsgBox(16 + 262144, Default, "Error: Input file """ & $sSourcepath & """ has Errors.", 0), 0) If ShellExecuteWait($sA3Dir & "\Aut2Exe\Aut2exe.exe", "/In " & $sSourcepath & " /out " & $sTargetpath & ":a3x") Then Return SetError(11, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ":a3x""", 0), 0) If Not FileCopy($sA3Dir & "\Autoit3.exe", $sTargetpath & ":prog") Then Return SetError(12, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ":prog""", 0), 0) Case ".a3x" If Not FileCopy($sSourcepath, $sTargetpath & ":a3x") Then Return SetError(13, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ":a3x""", 0), 0) If Not FileCopy($sA3Dir & "\Autoit3.exe", $sTargetpath & ":prog") Then Return SetError(14, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ":prog""", 0), 0) Case ".exe" If Not FileCopy($sSourcepath, $sTargetpath & ":prog") Then Return SetError(15, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ":prog""", 0), 0) EndSwitch If Not FileCreateShortcut($sTargetpath, @DesktopDir & "\" & $sFileName & ".lnk", $sDrive & $sDir, "", "", $sIconPath, "", $iIconNumber, 7) Then Return SetError(16, MsgBox(16 + 262144, Default, "Unable to create shortcut", 0), 0) FileSetTime($sTargetpath, "", 0) ; to erase old modification time of ADS files FileSetTime($sTargetpath, "", 1) ; to erase old creation time of ADS files FileSetTime($sTargetpath, "", 2) ; to erase old access time of ADS files __Run("dir /R """ & @ScriptFullPath & "*.*""") __Run("dir /R """ & $sTargetpath & "*.*""") __CW("$sTargetpath: " & $sTargetpath & @LF) Return 1 EndFunc ;==>_Targetpath Func _CreateZip() Local $s7za, $sRemExe If Not _Download_7z() Then Return SetError(17, 0, 0) If Not __RemoteTargetDir() Then Return SetError(17, 0, 0) $sRemExe = (StringRight($sSourcepath, 4) = ".exe") ? "rem " : "" FileDelete($sTargetpath & ".~_~.Run-me-first.cmd") If Not FileWriteLine($sTargetpath & ".~_~.Run-me-first.cmd", _ "@echo off && net file 1>NUL 2>NUL" & @CRLF & _ "if not .%errorlevel%. == .0. (powershell Start-Process -FilePath '%~f0 ' -ArgumentList '%* ' -verb runas && goto :eof) else (cd /d %~dp0)" & @CRLF & _ 'echo ' & (Eval('Debug') ? 'On' : 'Off') & @CRLF & _ 'rem pause ' & @CRLF & _ '%~d0 & cd %~dp0' & @CRLF & _ 'chcp 1252' & @CRLF & _ 'set name1=%~n0' & @CRLF & _ 'set name1=%name1:~0,-21%' & @CRLF & _ 'set compare1=%cd% ' & @CRLF & _ 'set compare2=%compare1:AppData\Local\Temp=other% ' & @CRLF & _ 'if .%compare1%==.%compare2% goto :skip' & @CRLF & _ '@mode con lines=7 cols=100' & @CRLF & _ '@echo:xN|choice 2>&1>NUL' & @CRLF & _ '@echo on & cls ' & @CRLF & _ 'echo. ' & @CRLF & _ 'echo Please extract ALL files from ZIP file first and then run this CMD again. Press any key to exit.' & @CRLF & _ 'Pause > NUL: & goto :eof' & @CRLF & _ ':skip ' & @CRLF & _ 'set sRDir="' & $sRDir & '"' & @CRLF & _ 'if NOT .%sRDir%.==."1". goto :skip1 ' & @CRLF & _ 'set olddir="%cd%"' & @CRLF & _ 'cd ..' & @CRLF & _ 'set sRDir=%cd%' & @CRLF & _ 'cd %olddir%' & @CRLF & _ 'goto :skipend ' & @CRLF & _ ':skip1 ' & @CRLF & _ 'if NOT .%sRDir%.==."2". goto :skip2 ' & @CRLF & _ 'rem handle "2" here' & @CRLF & _ 'set sRDir=%ProgramFiles%\%name1%' & @CRLF & _ 'goto :skipend ' & @CRLF & _ ':skip2 ' & @CRLF & _ 'if NOT .%sRDir%.==."3". goto :skip3 ' & @CRLF & _ 'rem handle "3" here' & @CRLF & _ 'set sRDir=%UserProfile%\%name1%' & @CRLF & _ 'goto :skipend ' & @CRLF & _ ':skip3 ' & @CRLF & _ 'if NOT .%sRDir%.==."4". goto :skip4 ' & @CRLF & _ 'rem handle "4" here' & @CRLF & _ 'set sRDir=%UserProfile%\Desktop\%name1%' & @CRLF & _ 'goto :skipend ' & @CRLF & _ ':skip4 ' & @CRLF & _ 'rem handle entered path here' & @CRLF & _ 'set sRDir=%sRDir:"=%' & @CRLF & _ ':skipend ' & @CRLF & _ 'echo sRDir: %sRDir% ' & @CRLF & _ 'rem pause ' & @CRLF & _ 'ren %name1%.cmd.~_~.cmd %name1%.cmd~' & @CRLF & _ 'ren %name1%.cmd.~_~.ico %name1%.ico~' & @CRLF & _ $sRemExe & 'type %name1%.cmd.~_~.a3x > %name1%.cmd~:a3x' & @CRLF & _ $sRemExe & 'del %name1%.cmd.~_~.a3x' & @CRLF & _ 'type %name1%.cmd.~_~.prog > %name1%.cmd~:prog' & @CRLF & _ 'del %name1%.cmd.~_~.prog' & @CRLF & _ 'move /Y %name1%.cmd~ ..' & @CRLF & _ 'move /Y %name1%.ico~ ..' & @CRLF & _ 'cd .. ' & @CRLF & _ 'dir /R %name1%.* ' & @CRLF & _ 'mkdir "%sRDir%" ' & @CRLF & _ 'move /Y %name1%.cmd "%sRDir%" ' & @CRLF & _ 'move /Y %name1%.cmd~ "%sRDir%\%name1%.cmd" ' & @CRLF & _ 'move /Y %name1%.ico~ "%sRDir%\%name1%.ico" ' & @CRLF & _ 'echo Set oWS = WScript.CreateObject("WScript.Shell") > ~~.vbs' & @CRLF & _ 'echo Set oLink = oWS.CreateShortcut("%userprofile%\desktop\%name1%.lnk") >> ~~.vbs' & @CRLF & _ 'echo oLink.TargetPath = "%sRDir%\%name1%.cmd" >> ~~.vbs' & @CRLF & _ 'if exist "%sRDir%\%name1%.ico" echo oLink.IconLocation = "%sRDir%\%name1%.ico" >> ~~.vbs' & @CRLF & _ 'if not exist "%sRDir%\%name1%.ico" echo oLink.IconLocation = "' & $sIconPath & ',' & $iIconNumber & '" >> ~~.vbs' & @CRLF & _ 'echo oLink.WindowStyle = "7" >> ~~.vbs' & @CRLF & _ 'echo oLink.Save >> ~~.vbs' & @CRLF & _ 'rem cscript ~~.vbs >NUL: ' & @CRLF & _ 'cscript ~~.vbs ' & @CRLF & _ 'rem pause ' & @CRLF & _ 'del ~~.vbs ' & @CRLF & _ 'if not exist "%userprofile%\desktop\%name1%.lnk" set _M1=%userprofile%\desktop\%name1%.lnk NOT created due to targetdir invalid. ' & @CRLF & _ 'if not exist "%sRDir%\%name1%.cmd" set _M2=%sRDir%\%name1%.cmd NOT created due to targetdir invalid.' & @CRLF & _ 'rem set _m & pause' & @CRLF & _ 'if exist "%userprofile%\desktop\%name1%.lnk" set _M1=%userprofile%\desktop\%name1%.lnk created. ' & @CRLF & _ 'if exist "%sRDir%\%name1%.cmd" set _M2=%sRDir%\%name1%.cmd created. ' & @CRLF & _ 'rem set _m & pause' & @CRLF & _ 'rem mode con lines=1 cols=16' & @CRLF & _ ' start mshta.exe vbscript:Execute("msgbox ""%_M1% ""&Chr(10)&"" %_M2% "",64+4096,"" End of %name1%.cmd installation"":close") ' & @CRLF & _ 'del .\%name1%.cmd.~_~.zip' & @CRLF & _ 'del .\%name1%.zip' & @CRLF & _ 'dir /R %name1%.* ' & @CRLF & _ 'rem Pause' & @CRLF & _ ' start PING -n 2 127.0.0.1^> & rd /S /Q %name1% ' & @CRLF & _ ' start PING -n 2 127.0.0.1^> & rd /S /Q %name1%.cmd.~_~ ' & @CRLF & _ ' start PING -n 2 127.0.0.1^> & rd /S /Q ~_~ ' & @CRLF & _ 'rem echo:xN|choice 2>&1>NUL' & @CRLF & _ 'rem Pause' & @CRLF & _ 'rem End of script' & @CRLF) Then Return SetError(18, MsgBox(16 + 262144, Default, 'Unable to write >' & $sTargetpath & '.~_~.Run-me-first.cmd<', 0), 0) If Not $sRemExe Then If Not _ExtractADS($sTargetpath & ":a3x", $sTargetpath & ".~_~", ":a3x") Then Return SetError(19, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ".~_~.a3x""", 0), 0) EndIf If Not FileWrite($sTargetpath & ".~_~.cmd", FileRead($sTargetpath)) Then Return SetError(20, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ".~_~.cmd""", 0), 0) If Not _ExtractADS($sTargetpath & ":prog", $sTargetpath & ".~_~", ":prog") Then Return SetError(21, MsgBox(16 + 262144, Default, "Error: Cannot create target file """ & $sTargetpath & ".~_~.prog""", 0), 0) _CreateIconfile() __Run("dir /R """ & $sTargetpath & "*.*""") While FileExists($sDrive & $sDir & $sFileName & ".zip") $rc = FileDelete($sDrive & $sDir & $sFileName & ".zip") __CW("Er/Ex/L: " & @error & "/" & @extended & "/" & @ScriptLineNumber & " RC: " & $rc & @LF) Sleep(500) WEnd While FileExists($sTargetpath & ".~_~.zip") $rc = FileDelete($sTargetpath & ".~_~.zip") __CW("Er/Ex/Line: " & @error & "/" & @extended & "/" & @ScriptLineNumber & " Delete-RC: " & $rc & @LF) Sleep(500) WEnd $s7za = _TempFile(Default, Default, "exe") _ExtractADS(@ScriptFullPath & ":7za.exe", $s7za) __Run($s7za & ' a -mx=0 ' & ($iMB_Answer = 7 ? "" : "-t7z ") & """" & $sTargetpath & ".~_~.zip"" """ & $sTargetpath & ".~_~.*""") FileDelete($s7za) If Not FileExists($sTargetpath & ".~_~.zip") Then Return SetError(22, MsgBox(16 + 262144, Default, "Error creating """ & $sTargetpath & ".~_~.zip"" .", 0), 0) FileDelete($sTargetpath & ".~_~.a3x") FileDelete($sTargetpath & ".~_~.cmd") FileDelete($sTargetpath & ".~_~.prog") FileDelete($sTargetpath & ".~_~.ico") FileDelete($sTargetpath & ".~_~.Run-me-first.cmd") While FileExists($sDrive & $sDir & $sFileName & ".zip") $rc = FileDelete($sDrive & $sDir & $sFileName & ".zip") __CW("Er/Ex/Line: " & @error & "/" & @extended & "/" & @ScriptLineNumber & " Delete-RC: " & $rc & @LF) Sleep(500) WEnd FileMove($sTargetpath & ".~_~.zip", $sDrive & $sDir & $sFileName & ".zip", 1) __Run("dir /R """ & $sDrive & $sDir & $sFileName & ".*.*""") If $iMB_Answer = 7 Then Return SetError(23, MsgBox(64 + 262144, Default, $sDrive & $sDir & $sFileName & ".zip created.", 0), 0) _CreateSfx() Return 1 EndFunc ;==>_CreateZip Func _CreateSfx() Local $sCommand FileDelete($sFileName & ".Setup.exe") If Not FileWriteLine(@ScriptFullPath & ".config.txt", _ ';!@Install@!UTF-8!' & @CRLF & _ 'Title="' & $sFileName & '.cmd Installation"' & @CRLF & _ 'BeginPrompt="Should ' & $sFileName & '.cmd be installed?"' & @CRLF & _ 'InstallPath="~_~"' & @CRLF & _ 'Directory="."' & @CRLF & _ 'ExecuteFile="hidcon:' & $sFileName & '.cmd.~_~.Run-me-first.cmd"' & @CRLF & _ ';Delete="~_~"' & @CRLF & _ ';Delete="debug.log"' & @CRLF & _ 'SelfDelete="1"' & @CRLF & _ ';!@InstallEnd@!' & @CRLF) Then Return SetError(24, MsgBox(16 + 262144, Default, "Error: Cannot create " & @ScriptFullPath & ".config.txt", 0), 0) _ExtractADS(@ScriptFullPath & ":7zSDMod.sfx", @ScriptFullPath & ".7zSDMod.sfx") $sCommand = "copy /b """ & @ScriptFullPath & ".7zSDMod.sfx""" & " + """ & @ScriptFullPath & ".config.txt""" & " + """ & $sDrive & $sDir & $sFileName & ".zip"" """ & $sDrive & $sDir & $sFileName & ".Setup.exe""" __Run($sCommand) FileDelete(@ScriptFullPath & ".7zSDMod.sfx") FileDelete(@ScriptFullPath & ".config.txt") While FileExists($sDrive & $sDir & $sFileName & ".zip") $rc = FileDelete($sDrive & $sDir & $sFileName & ".zip") __CW("Er/Ex/L: " & @error & "/" & @extended & "/" & @ScriptLineNumber & " RC: " & $rc & @LF) Sleep(300) WEnd If Not FileExists($sFileName & ".Setup.exe") Then Return SetError(25, MsgBox(16 + 262144, Default, "Error creating """ & $sFileName & ".Setup.exe"".", 0), 0) MsgBox(64 + 262144, Default, $sDrive & $sDir & $sFileName & ".Setup.exe created.", 0) Return 1 EndFunc ;==>_CreateSfx Func _CreateIconfile() Local $hIcon, $hHelp, $sData, $sComp1, $sComp2 $hIcon = _WinAPI_ExtractIcon($sIconPath, $iIconNumber) _WinAPI_SaveHICONToFile($sTargetpath & ".~_~.ico", $hIcon) _WinAPI_DestroyIcon($hIcon) $sComp1 = "0x6AFFA79F6BFFD1BDBCFFE6E6E7FFF4F7F9FFCBCB" $sComp2 = "0xD4FFE4DED3FFBCB7AFFFA9A49DFFA4A099FFE1E0" $hHelp = FileOpen($sTargetpath & ".~_~.ico", 16) FileSetPos($hHelp, 2800, 0) $sData = FileRead($hHelp, 20) FileClose($hHelp) If $sData = $sComp1 Or $sData = $sComp2 Then FileDelete($sTargetpath & ".~_~.ico") EndIf EndFunc ;==>_CreateIconfile Func _ExtractADS($From = @ScriptFullPath, $To = @ScriptFullPath & ".", $Stream = 0) ; =========================================================================================== ; Title ...............: $Stream = 0 ; File Name............: _ExtractADS.au3 ; Description .........: Extract alternate data streams to standard files ; ; Syntax ..............: _ExtractADS([$From = Inputfile], [$To = Outputfile], [$Stream = index or name of ADS]) ; Default .............: $From = @ScriptFullPath ; $To = @ScriptFullPath & "." ; $Stream = 0 ; ; Return Value(s) .....: 1 @error=0 @extended=number of copied ADS ; 0 @error=1 no dataset/ADS found ; 0 @error=2 no ADS found in dataset ; Example .............: ; #include <WinAPIFiles.au3> ; #include <WinAPIHObj.au3> ; FileWrite(@ScriptFullPath & ":ADStest1.txt", "This is ADSTest1") ; FileWrite(@ScriptFullPath & ":ADStest2.txt", "This is ADSTest2") ; _ExtractADS() ; extract all ADS from @ScriptFullPath ; Run(@ComSpec & " /k dir /R " & StringTrimRight(@ScriptFullPath, 4) & "*.*") ; ; Author ..............: Exit ( http://www.autoitscript.com/forum/user/45639-exit ) ; CopyLeft ............: © Freeware by "Exit" ( all wrongs reserved ) ; =========================================================================================== ; needs #include <WinAPIFiles.au3> ; needs #include <WinAPIHObj.au3> Local $sFile, $iOffset, $hFile, $pData, $iBytes, $sToFile, $iCount If $From = "" Or $From = Default Then $From = @ScriptFullPath If $To = "" Or $To = Default Then $To = @ScriptFullPath & "." $sFile = $From $iOffset = StringInStr($From, ":", 1, 1, 3) If $iOffset Then $sFile = StringLeft($From, $iOffset - 1) $Stream = StringTrimLeft($From, $iOffset) EndIf ; Enumerate all existing streams in the file Local $aData = _WinAPI_EnumFileStreams($sFile) If @error Then Return SetError(26, MsgBox(16 + 262144, Default, "Error reading ADS stream """ & $sFile & ":" & $Stream & """ .", 0), 0) ;~ _ArrayDisplay($aData, '_WinAPI_EnumFileStreams') ; Read data from each stream $iCount = 0 For $i = 2 To $aData[0][0] If $Stream <> 0 Then If $i - 1 <> $Stream Then If ":" & $Stream & ":$DATA" <> $aData[$i][0] Then ContinueLoop EndIf EndIf $pData = _WinAPI_CreateBuffer($aData[$i][1]) $hFile = _WinAPI_CreateFile($sFile & $aData[$i][0], 2, 2, 6) _WinAPI_ReadFile($hFile, $pData, $aData[$i][1], $iBytes) _WinAPI_CloseHandle($hFile) $sToFile = $sFile & "." & StringTrimLeft(StringTrimRight($aData[$i][0], 6), 1) If $To <> @ScriptFullPath & "." Then $sToFile = $To If $Stream = 0 Then $sToFile &= "." & StringTrimLeft(StringTrimRight($aData[$i][0], 6), 1) EndIf $hFile = _WinAPI_CreateFile($sToFile, 1) _WinAPI_WriteFile($hFile, $pData, $aData[$i][1], $iBytes) _WinAPI_CloseHandle($hFile) _WinAPI_FreeMemory($pData) $iCount += 1 Next If Not $iCount Then Return SetError(2, 0, 0) ; no defined ads found Return SetError(0, $iCount, 1) EndFunc ;==>_ExtractADS Func _Download_7z() Local $iSV, $s7zr, $s7za, $s7zaOut, $s7zSDMod, $s7zSDModOut, $n = @ScriptFullPath If FileExists($n & ":7zr.exe") And FileExists($n & ":7za.exe") And FileExists($n & ":7zSDMod.sfx") Then Return 1 ; latest stable version $iSV = 19 ; latest stable version __CW("Latest stable 7z version: " & $iSV & @CRLF) ; get root 7zr.exe (needed to extract the other *.7z files) ; "https://7-zip.org/a/7zr.exe" $s7zr = _TempFile(Default, Default, "exe") InetGet("https://www.7-zip.org/a/7zr.exe", $s7zr) If @error Then FileDelete($s7zr) MsgBox(16 + 262144, Default, "Cannot access 'www.7-zip.org/a/7zr.exe'" & @LF & @LF & "Check internet connection.", 0) __CW("Cannot access 'www.7-zip.org/a/7zr.exe'" ) Return SetError(1, 0, 0) EndIf FileCopy($s7zr, @ScriptFullPath & ":7zr.exe") ; get $s7za.exe ; https://7-zip.org/a/7z1900-extra.7z $s7za = _TempFile(Default, Default, "7z") $s7zaOut = _TempFile(Default, Default, "exe") InetGet("https://7-zip.org/a/7z" & $iSV & "00-extra.7z", $s7za) If @error Then FileDelete($s7za) FileDelete($s7zaOut) MsgBox(16 + 262144, Default, "Cannot access 'https://7-zip.org/a/7z" & $iSV & "00-extra.7z'" & @LF & @LF & "Check internet connection.", 0) __CW("Cannot access 'https://7-zip.org/a/7z" & $iSV & "00-extra.7z'") Return SetError(1, 0, 0) EndIf __Run($s7zr & ' e ' & $s7za & " -o" & $s7zaOut & " -y -i!7za.exe") FileCopy($s7zaOut & "\7za.exe", @ScriptFullPath & ":7za.exe") ; get $s7zSDMod.sfx ; https://web.archive.org/web/20160311112737if_/http://7zsfx.info/files/7zsd_150_2712.7z ; for more info see --> https://web.archive.org/web/20160423225741/http://7zsfx.info/en/ $s7zSDMod = _TempFile(Default, Default, "7z") $s7zSDModOut = _TempFile(Default, Default, "Out") InetGet("http://web.archive.org/web/20160311112737if_/http://7zsfx.info/files/7zsd_150_2712.7z", $s7zSDMod) If @error Then FileDelete($s7zSDMod) FileDelete($s7zSDModOut) MsgBox(16 + 262144, Default, "Cannot access 'http://web.archive.org'" & @LF & @LF & "Check internet connection.", 0) __CW("Cannot access 'http://web.archive.org/web/20160311112737if_/http://7zsfx.info/files/7zsd_150_2712.7z'") Return SetError(1, 0, 0) EndIf __Run($s7zr & ' l ' & $s7zSDMod ) __Run($s7zr & ' e ' & $s7zSDMod & " -o" & $s7zSDModOut & " -y -ir!*.sfx") __Run("dir /s /R " & $s7zSDModOut) FileCopy($s7zSDModOut & "..\7zsd.sfx", @ScriptFullPath & ":7zSDMod.sfx") If Not FileCopy($s7zSDModOut & "\7zSD.sfx", @ScriptFullPath & ":7zSDMod.sfx") Then MsgBox(16 + 262144, Default, "'7zSD.sfx' missing'" , 0) __CW("'7zsd.sfx' missing'" ) Return SetError(1, 0, 0) EndIf FileSetTime(@ScriptFullPath, "", 0) ; to erase old modification time of ADS files FileSetTime(@ScriptFullPath, "", 1) ; to erase old creation time of ADS files FileSetTime(@ScriptFullPath, "", 2) ; to erase old access time of ADS files FileDelete($s7zr) FileDelete($s7za) FileDelete($s7zSDMod) DirRemove($s7zaOut, 1) DirRemove($s7zSDModOut, 1) __Run("dir /R """ & StringTrimRight(@ScriptFullPath, 4) & "*.*""") Return 1 EndFunc ;==>_Download_7z Func __Run($sCommand, $CopyToConsole = Default) Local $iPID, $sTmp, $aTmp, $iEr, $iEx If Not ($CopyToConsole = 0 Or $CopyToConsole = 1) Then $CopyToConsole = Eval("Debug") $iPID = Run(@ComSpec & " /c chcp 1252 & " & $sCommand, "", @SW_HIDE, 8) ; $STDERR_MERGED(8) ProcessWaitClose($iPID) $iEr = @error $iEx = @extended $sTmp = StdoutRead($iPID) StdioClose($iPID) $aTmp = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sTmp, 'str', '') $sTmp = $aTmp[2] If $CopyToConsole Then __CW("Run command: >" & $sCommand & "<" & @CRLF & $sTmp & @CRLF & "Exit code: " & $iEx & @CRLF) Return SetError($iEx, $iEr, $sTmp) EndFunc ;==>__Run Func __CW($sText) If Not Eval("Debug") Then Return ;~ FileWriteLine(@ScriptFullPath & ".console.txt", $sText) ConsoleWrite($sText & @CRLF) EndFunc ;==>__CW Func __DebugInfo() If Not Eval("Debug") Then Return __CW("============ Start of DebugInfo ===============") __CW("@ScriptFullPath: " & @ScriptFullPath) __CW("Sourceversion: " & __SourceVersion()) __CW("@AutoItExe: " & @AutoItExe) __CW("@AutoItVersion: " & @AutoItVersion) __CW("@AutoItX64: " & @AutoItX64) __CW("@CPUArch: " & @CPUArch) __CW("@OSArch: " & @OSArch) __CW("@OSBuild: " & @OSBuild) __CW("@OSLang: " & @OSLang) __CW("@OSType: " & @OSType) __CW("@OSVersion: " & @OSVersion) __CW("@UserName: " & @UserName) __CW("@UserProfileDir: " & @UserProfileDir) __CW("============ End of DebugInfo ===============") EndFunc ;==>__DebugInfo Func __SourceVersion() Local $SourceVersion = _StringBetween(FileRead(@ScriptFullPath)," Version:",@crlf) Return $SourceVersion[0] EndFunc ;==>__DebugInfo Func __FileDelete($sFilePath) Local $iError, $sMsg, $iRet $iRet = _WinAPI_DeleteFile($sFilePath) $iError = _WinAPI_GetLastError() $sMsg = _WinAPI_GetLastErrorMessage() If $iRet Then Return MsgBox(64 + 262144, Default, $sFilePath & " deleted", 0) MsgBox(64 + 262144, Default, "Delete: " & $sFilePath & @CRLF & "iRet: " & $iRet & " Error: " & $iError & @CRLF & $sMsg, 0) Return 1 EndFunc ;==>__FileDelete Func __RemoteTargetDir() Local $T1 = @TAB, $T2 = @TAB & @TAB, $T5 = @TAB & @TAB & @TAB & @TAB & @TAB $sRDir = InputBox('Specify remote target directory', 'Enter 1, 2, 3 or remote system target directory string: (e.g. "C:\Test\Data")' & @LF & @LF & _ '1 = "."' & $T5 & 'Targetsystem current directory (where ZIP/EXE are stored) = Default' & @LF & _ '2 = "%ProgramFiles%\' & $sFileName & '"' & $T2 & 'Targetsystem programfiles directory' & @LF & _ '3 = "%UserProfile%\' & $sFileName & '"' & $T2 & 'Targetsystem profile directory' & @LF & _ '4 = "%UserProfile%\Desktop\' & $sFileName & '"' & $T1 & 'Targetsystem desktop directory' & @LF & _ '...', "1", " M", 600, 220) $sRDir = StringReplace($sRDir, '"', '') If Not StringInStr("1234%", StringLeft($sRDir, 1)) Then If StringRight($sRDir, 1) = "\" Then $sRDir = StringTrimRight($sRDir, 1) If Not StringInStr($sRDir, ":\") Then MsgBox(16 + 262144, Default, "Invalid target directory: " & $sRDir, 0) __CW("$sRDir is invalid: >" & $sRDir & "<" & @CRLF) Return SetError(27, 0, 0) EndIf EndIf __CW("$sRDir: >" & $sRDir & "<" & @CRLF) Return SetError(0, 0, 1) EndFunc ;==>__RemoteTargetDir ; End of Au3toCmd.au3 script The script can be called with a file name of an AU3 script as a parameter.
      If no name is entered, a query is made.
      Suggestions for improvement and bug reports are welcome.
    • By SWSSSM
      Hi there,
      maybe someone can help me.
      If automated a script that should xcopy from various paths (all within C:\*\...) to a external Disk (HDD). (Backup data of users who get new pcs win10)
      I tried it several times with windows 10 home/pro any clients and never got any failure. (after the testing was done)
      But when i tried to run it shortly ago on a windows 7  pro x64 client, the script started (as i saw in taskmanagr.exe) but i didn't performed any of the actions when i came down to the xcopy part.
      (in the systemtray, it showd the scipt to start, but it was marked as "paused" and i couldn't stop this. No plan why)
       i inserted/attached the script down here.
      Does anyone know why? any ideas?backup-scrp.au3
      PS:  the tray debug line just added by today (i re-try it tomorrow when i've set up another win7 client to test with)
      PPS: i know my coding-style isn't very optimized
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By Colduction
      Hi again guys!, i had COVID-19 for twice and i couldn't check the forum since 3 or 4 months ago till now! i hope you will get better if you're fighting for beat COVID-19

      I have two question, first is about extracting all of the IP Address from an IP Ranges, for e.g: 192.168.1.1-192.255.255.255 (Start and End are variable and will be defined by the user) and for second one, i have a friend that he is Python programmer, he made a IP Parser that it can support large txt files (1TB) and it can parse all of them under 10min and it also supports low-end PCs that have 1 GB RAM!

      The list that his program parses are:
      #1765497 192.168.1.1 8082 #1765496 192.168.1.1 8084 #1965493 192.168.1.1 8089 #9565495 192.168.1.1 8086 #2565492 192.168.1.1 8081 and it converts very very fast to this:
      192.168.1.1:8082 192.168.1.1:8084 192.168.1.1:8089 192.168.1.1:8086 192.168.1.1:8081 I wonder how to do this via AutoIt, if you can help me in this way, i will be happy✌❤

      Thanks for your helps.

      FIRST_QUESTION_TEST.au3
    • By learner123
      Hi All,
      So I have created a small autoIT script to enter pin into a RSA token(app which generate new code every 30 second), and copy the generated code.
      I have a java application which requires this code so every time my java-code requires this RSA code, it runs the autoIT script and the copied generated code is then used in my java application. 
      I have deployed this code on a windows server and it works fine when I am logged in and the window is on focus, But as soon as I schedule task and disconnect the server (not logged out only disconnect), or even minimize the server window, the autoIT scripts fails and its not able to copy the value.
       
      Please find below the code for AUTOIT.
       
      WinActivate("rsa - RSA SecurID Token") ; activates the window that has old in the tilte bar
      WinWaitActive("rsa - RSA SecurID Token") ; waits until the window is the active window
      Send("1111") ; simulates pressing the Home key, enters password to get the code
      Send("{ENTER}") ; simulates pressing the Enter key
      Sleep(1000) ;
      Send("^c") ; simulates pressing the CTRL+c keys (copy)
       
      Also I saw some post regarding that WINACTIVE only works when window is active. But my below AUTO IT script to handle windows pop up  works perfectly fine when the server is disconnected. 
       
      Opt("WinTitleMatchMode", 1)
      WinWait("https://url","","10")
      WinWaitActive("https://url","","10")
      Sleep(2000)
      Send("userid")
      Sleep(1000)
      Send("{TAB}")
      Sleep(1000)
      Send("passwrd")
      Send("{TAB}")
      Sleep(500)
      Send("{ENTER}")
       
       
×
×
  • Create New...