Today I Learned - Instrument ClamAV to extract AutoIT scripts

Table of Contents


A customer contacted us because they intend to use SimpleLAPS-GUI in their company. However, multiple AV vendors flag the precompiled binary (SimpleLapsGui.exe) as malicious (see here). According to the FAQ on the GitHub repository from SimpleLAPS-GUI:

Does the exe version contains viruses? It is reported on “”.
No it doesn’t. This happens because of the AutoIT v3 executable used as wrapper. You can download the PowerShell version instead. (Please note that the PowerShell script doesn’t hide its window.)

Let’s analyze the binary and extract the AutoIT script 🤓

AutoIT malware is not a new topic (see here for a recent report from the Splunk team). Multiple tools and scripts exist to extract the AutoIT script from a binary to analyze the script’s functionality. One of the more prominent examples of these tools is the Universal AutoIT Extractor and De-obfuscator, which worked fine in this case.


However, we can use ClamAV to extract AutoIT scripts from binaries! ClamAV creates temporary directories during the scanning phase of binaries, saving extracted files and scripts to disk for further analysis (i.e. scanning). With the parameter –leave-temps we instruct ClamAV not to clean up these temporary directories and files, and with the parameter –tempdir we tell ClamAV where to put the temporary files. Here is an example:

# clamscan --leave-temps --tempdir=/tmp/autoit
/tmp/ OK
/tmp/ OK
/tmp/SimpleLapsGui.exe: OK

----------- SCAN SUMMARY -----------
Known viruses: 8692897
Engine version: 0.103.11
Scanned directories: 1
Scanned files: 3
Infected files: 0
Data scanned: 2.04 MB
Data read: 1.56 MB (ratio 1.30:1)
Time: 33.115 sec (0 m 33 s)
Start Date: 2024:05:17 07:42:17
End Date:   2024:05:17 07:42:50

ClamAV created several files and directories in the specified location (/tmp/autoit). Following the truncated output of the generated files and folders:

/tmp/autoit# find .

The files autoit.001 and autoit.002 looks promising. autoit.002 is the same PowerShell script as hosted on GitHub (same hash). autoit.001 is the actual AutoIT script. Following the beginning of the file, which ClamAV extracted:

# head autoit.001
##AutoIt3Wrapper_Res_Description=Simple gui script for LAPS. 
##AutoIt3Wrapper_Res_ProductName=Simple LAPS GUI 
##AutoIt3Wrapper_Res_CompanyName=htcfreek (Heiko Horwedel) 

And here is the end of the file:

# tail autoit.001
$STEMPNAME &= CHR ( RANDOM ( 0x00000061 , 0x0000007a , 0x00000001 ) ) 
$TNAME = _TEMPFILE( "" , "" , "_SimpleLapsGui.ps1" ) 
FILEINSTALL ( ".\SimpleLapsGui.ps1" , $TNAME ) 
RUNWAIT ( "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -STA -File "" & $TNAME & """ , @SYSTEMDIR , @SW_HIDE ) 

The content of this file matches the PS1Wrapper.au3 file hosted on the GitHub repository:


Figure 1: PS1Wrapper

autoit-ripper (better safe than sorry)

Here is another technique we could use to extract the AutoIT script. Install the Python module autoit-ripper:

# python3 -m pip install autoit-ripper

And point it to our executable:

# autoit-ripper SimpleLapsGui.exe autoit_ripper_output/
INFO:root:Storing result in autoit_ripper_output/script.au3
INFO:root:Storing result in autoit_ripper_output/SimpleLapsGui.ps1

Same procedure as before. Checking the beginning of the file:

# head script.au3 

#AutoIt3Wrapper_Res_Description=Simple gui script for LAPS.
#AutoIt3Wrapper_Res_ProductName=Simple LAPS GUI
#AutoIt3Wrapper_Res_CompanyName=htcfreek (Heiko Horwedel)

And the end of the file:

# tail script.au3 
$STEMPNAME &= Chr ( Random ( 97 , 122 , 1 ) )
Until Not FileExists ( $STEMPNAME )
$TNAME = _TEMPFILE ( "" , "" , "_SimpleLapsGui.ps1" )
FileInstall ( ".\SimpleLapsGui.ps1" , $TNAME )
RunWait ( "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -STA -File """ & $TNAME & """" , @SystemDir , @SW_HIDE )
FileDelete ( $TNAME )

Looks good, too! Excellent - we used two different ways to extract AutoIT scripts and were not dependent on a Windows binary, which might be handy for automation tasks.

What I learned today: Short blog posts about novel information for me.