Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / PERSISTENCE

Startup Script Abuse

This note documents detection patterns related to Startup Script Abuse on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
/etc/rc.localNew command entryBoot-time persistenceCriticalClassic startup persistence artifact.
/etc/init.d/New scriptLegacy init persistenceCriticalStill relevant on many systems.
/etc/profileShell-wide startup commandUser session persistenceCriticalExecutes for interactive shells.
/etc/bash.bashrcGlobal shell startup modificationSession-triggered persistenceCriticalCommon stealth location.
~/.bashrcUser shell startup commandPer-user persistenceCriticalOften tied to compromised account.
~/.profileUser login startupPer-user login persistenceCriticalTriggered on login.
~/.bash_profileLogin shell persistencePer-user persistenceCriticalOften overlooked.
Startup scriptcurl, wgetRemote payload retrievalCriticalStrong malicious automation signal.
Startup scriptbash, sh, pythonScript executionCriticalCommon payload trigger.
Startup script/tmp, /dev/shmTemp payload executionCriticalHigh-confidence malicious path.
Shell historyedit startup filesInteractive persistence insertionCriticalStrong operator evidence.
auditdwrite to startup filesProcess attributionCriticalBest attribution if enabled.
File timestampsrecent startup file modificationTimeline anchorCriticalCorrelates with intrusion window.
journalctlboot execution evidenceStartup execution confirmationHighUseful after reboot events.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Startup file modified after SSH footholdStabilization after accessCriticalCommon attacker progression.
Hidden command appended at file endMinimal stealth insertionCriticalFrequently missed in long profiles.
Startup file calls external scriptSecondary payloadCriticalOften hidden elsewhere.
Root startup file modifiedPrivileged persistenceCriticalHigh severity.
User shell starts outbound connectionCallback on loginCriticalStrong malicious signal.
Profile references deleted pathCleanup after insertionHighIncomplete cleanup clue.
Startup plus cron/service persistenceRedundant persistenceCriticalStrong operator discipline.
Startup under dormant accountSilent persistenceCriticalOften unnoticed.
Startup file ownership anomalyUnexpected ownerHighReveals attacker mistake.
Minimal file change but strong behavior shiftSmall persistence line insertedHighRequires diff-style inspection.

Common Tools

ToolUsage
echo >> ~/.bashrcAppend persistence quickly.
sed -iSilent inline modification.
nano, vim, viInteractive startup file editing.
Direct file overwriteReplace startup logic fully.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
System startup/etc/rc.localCriticalBoot persistence.
Legacy init scripts/etc/init.d/CriticalOlder service persistence path.
Global shell profile/etc/profileCriticalGlobal login persistence.
Global bash config/etc/bash.bashrcCriticalInteractive shell persistence.
User bashrc~/.bashrcCriticalPer-user shell persistence.
User profile~/.profileCriticalLogin-trigger persistence.
User bash profile~/.bash_profileCriticalLogin shell persistence.
Shell history.bash_history, .zsh_historyCriticalEdit commands.
Audit logs/var/log/audit/audit.logCriticalFile write attribution.
JournaldjournalctlHighExecution after boot/login.

MITRE ATT&CK References

  • T1037 Boot or Logon Initialization Scripts
  • T1037.004 RC Scripts
  • T1059 Command and Scripting Interpreter

Decision Tree

  1. Are startup files modified?

    • Enumerate system and user startup files.
  2. Which account or context triggers persistence?

    • System boot, root shell, user login.
  3. What executes?

    • Inspect command, path, interpreter.
  4. Has startup already triggered?

    • Correlate boot/login times.
  5. Is payload present?

    • Inspect referenced files.
  6. Pivot

    • Startup file → payload path.
    • Payload → timestamps and hashes.
    • User → login timeline.
  7. Confirm persistence

    • Unknown startup command + suspicious path + intrusion timing = malicious persistence.

Example Detection Templates

Grep

grep -R "curl\|wget\|bash\|python\|/tmp\|/dev/shm" /etc/rc.local /etc/profile /etc/bash.bashrc /etc/init.d /home/*/.bashrc /home/*/.profile /home/*/.bash_profile /root/.bashrc /root/.profile 2>/dev/null
grep -R "rc.local\|bashrc\|profile" /home/*/.bash_history /root/.bash_history 2>/dev/null
grep -R "echo .*bashrc\|echo .*profile" /home /root 2>/dev/null

Journalctl

journalctl | grep -E "rc.local|profile|bashrc"

File Inspection

find /etc/rc.local /etc/profile /etc/bash.bashrc /etc/init.d /home -name ".bashrc" -o -name ".profile" -o -name ".bash_profile" 2>/dev/null -printf '%TY-%Tm-%Td %TT %p\n' | sort
stat /etc/rc.local

Sigma

title: Linux Startup Script Abuse
id: linux-startup-script-abuse
status: experimental
description: Detects suspicious modifications to startup scripts and shell initialization files
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'rc.local'
      - '.bashrc'
      - '.profile'
      - 'curl'
      - 'wget'
  condition: selection_keywords
fields:
  - message
  - hostname
falsepositives:
  - Legitimate profile customization
level: high
tags:
  - attack.persistence
  - attack.t1037

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
File baselineInventory startup filesCriticalUnknown additions should stand out.
File monitoringWatch startup pathsCriticalStrong invariant detection.
Least privilegeRestrict startup file modificationHighReduces persistence insertion.
AuditdMonitor writes to startup filesHighStrong attribution.
Temp execution controlPrevent startup execution from temp pathsCriticalStops common abuse.
Login reviewInspect user startup changes regularlyHighImportant for per-user stealth persistence.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Any suspicious startup lines?grep startup filesImmediate persistence check.
Which file changed recently?inspect timestampsTimeline anchor.
Does startup call temp file?inspect pathsHigh-confidence suspicion.
Has payload executed?correlate login/boot logsRuntime proof.
Is payload still present?inspect referenced pathPayload analysis.
Was startup modified post-login?correlate timestampsIntrusion chain.

High Value Grep Strings

PatternWhy It Matters
curlRemote retrieval.
wgetRemote retrieval.
bashShell execution.
pythonInterpreter execution.
/tmpTemp payload path.
/dev/shmStealth path.
@rebootSometimes chained with cron logic.

Analyst Notes

ScenarioInterpretation
.bashrc calls temp shellStrong user persistence signal.
/etc/profile modifiedGlobal persistence high severity.
rc.local starts hidden scriptBoot persistence likely malicious.
Startup plus cron/serviceRedundant persistence.
Startup file references deleted payloadCleanup after insertion likely.
Minimal one-line appendEasy to miss without full file review.