Lua
Adversaries may abuse Lua commands and scripts for execution. Lua is a cross-platform scripting and programming language primarily designed for embedded use in applications. Lua can be executed on the command-line via the standalone lua interpreter, via scripts (.lua), or from Lua-embedded programs. Adversaries may incorporate, abuse, or replace existing Lua interpreters to execute malicious code. Notable examples include EvilBunny (malware instrumented by Lua), Remsec/ProjectSauron (modular Lua-based APT), Line Runner (Cisco device implant using Lua), PoetRAT (Lua interpreter for Windows), and RedLine Stealer (Lua bytecode for evasion).
let LuaPatterns = dynamic([
"lua.exe", "lua5", "luajit", "luac",
".lua", "dofile(", "loadfile(", "loadstring(",
"require(", "os.execute(", "io.popen(",
"os.remove(", "os.rename(", "io.open(",
"socket.tcp", "socket.connect",
"http.request", "ltn12.pump"
]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName has_any ("lua", "luajit", "luac") or ProcessCommandLine has_any (LuaPatterns)
| extend OsExec = ProcessCommandLine has_any ("os.execute(", "io.popen(")
| extend NetworkActivity = ProcessCommandLine has_any ("socket.tcp", "socket.connect", "http.request")
| extend DynamicLoad = ProcessCommandLine has_any ("loadstring(", "loadfile(", "dofile(")
| extend ScriptFromTemp = ProcessCommandLine has_any ("\\Temp\\", "/tmp/", "AppData")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine,
OsExec, NetworkActivity, DynamicLoad, ScriptFromTemp
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Game engines and applications with embedded Lua scripting (World of Warcraft, Roblox, Redis, Nginx)
- Network monitoring tools using Lua for packet inspection (Wireshark, Nmap NSE scripts)
- Configuration management tools with Lua-based configurations (OpenResty, Kong API Gateway)
References (6)
- https://attack.mitre.org/techniques/T1059/011/
- https://www.lua.org/start.html
- https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2018/03/07190154/The-ProjectSauron-APT_research_KL.pdf
- https://blog.talosintelligence.com/poetrat-update/
- https://blog.talosintelligence.com/arcanedoor-new-espionage-focused-campaign-found-targeting-perimeter-network-devices/
- https://www.mcafee.com/blogs/other-blogs/mcafee-labs/redline-stealer-new-variant-uses-lua-bytecode/
Unlock Pro Content
Get the full detection package for T1059.011 including response playbook, investigation guide, and atomic red team tests.