This detection identifies adversaries who manipulate installation scripts by injecting malicious pre- and post-installation hooks to establish persistence or execute initial payloads within Azure Sentinel-monitored environments. Proactive hunting for this behavior is critical because such hook modifications often occur silently during routine software updates, allowing attackers to evade standard signature-based defenses while gaining early foothold access before broader system compromise occurs.
rule SUSP_LNX_ARCH_Install_Hook_Jun26 {
meta:
description = "Detects suspicious pre and post hooks in Arch install files"
author = "Marius Benthin"
date = "2026-06-15"
reference = "https://aur.archlinux.org/cgit/aur.git/commit/?h=hearthstone-linux-gui-bin&id=ecf810ac853e7149abd4e0c793b2517e9737edb8"
reference2 = "https://aur.archlinux.org/cgit/aur.git/commit/?h=python-django-js-asset&id=af09b1cf1b59"
hash = "47c076099e6715ffb0bd357b6832175741e77b88972033cd1f9b55b6ff7e5519"
hash = "ef735bca8cb2acafe70831e33ed468a3046a61147af694000761970415c7eef1"
score = 70
strings:
$sa1 = "pre_install() {"
$sa2 = "post_install() {"
$sa3 = "pre_upgrade() {"
$sa4 = "post_upgrade() {"
$sa5 = "pre_remove() {"
$sa6 = "post_remove() {"
$sb1 = "npm install "
$sb2 = "&& 'b''u''n'"
$fp1 = "#!/bin/sh"
condition:
filesize < 5KB
and 1 of ($sa*)
and 1 of ($sb*)
and not 1 of ($fp*)
}
This YARA rule can be deployed in the following contexts:
This rule contains 9 string patterns in its detection logic.
Here are 4 specific false positive scenarios for the rule “Detects suspicious pre and post hooks in Arch install files,” along with suggested filters or exclusions:
Scenario: Automated Package Maintenance via pacman Hooks
cron to execute pacman -Syu, which triggers the default /etc/pacman.d/hooks/ directory. Common legitimate hooks like 01-pacman-remove-hooks.hook (cleaning up old kernel packages) or 02-pacman-install-hooks.hook (restarting services upon package install) are frequently executed during routine updates.pacman and the hook file path matches known standard patterns, specifically: /etc/pacman.d/hooks/*.hook containing keywords like “remove”, “install”, or “upgrade” in the filename.Scenario: Configuration Management Tools (Ansible/Puppet)
pacman with specific flags, causing the execution of standard pre-install and post-install hooks defined in the configuration management repository.ansible-runner, puppet-agent, or salt-minion, provided the hook file being executed resides within a managed directory (e.g., /etc/pacman.d/hooks/managed_*.hook).Scenario: Kernel Updates and System Reboots
mkinitcpio) or updating bootloader configurations (e