Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions sflock/ident.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,32 @@ def nodejs(f):
if count >= 3:
return "nodejs"

autoit_patterns = {
# Word boundaries matter: "EndFunc"/"SetError" etc. are substrings of
# unrelated identifiers like "appendFunction"/"resetError".
"Func Block Syntax": rb"\bEndFunc\b",
"AutoIt-only Builtins": (
rb"\b(?:DllStruct(?:Create|SetData|GetData)|FileInstall|"
rb"AdlibRegister|HotKeySet|StringToBinary|BinaryToString|SetError)\b"
),
"Macro Syntax": (
rb"@(?:(?:Temp|Script|Windows|System|AppData|ProgramFiles)Dir|Comspec|OSVersion)\b"
),
}
autoit_compiled_patterns = {category: re.compile(pattern, re.I) for category, pattern in autoit_patterns.items()}


def autoit(f):
"""Detect decompiled/plaintext AutoIt v3 source regardless of extension."""
if not f.contents:
return

hits = sum(1 for pattern in autoit_compiled_patterns.values() if pattern.search(f.contents))

if hits >= 2:
return "autoit"


def javascript(f):
JS_STRS = [
b"var ",
Expand Down Expand Up @@ -726,6 +752,7 @@ def identify(f, check_shellcode: bool = False):
office_webarchive,
office_activemime,
hta,
autoit,
powershell,
nodejs,
javascript,
Expand Down