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

Bash Profile Persistence

This note documents detection patterns related to Bash Profile Persistence on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
Shell artifact.bashrc modifiedInteractive shell persistenceCriticalMost common user-shell persistence path.
Shell artifact.profile modifiedLogin shell persistenceCriticalExecutes on login.
Shell artifact.bash_profile modifiedLogin persistenceCriticalCommon in privileged accounts.
Shell historyecho command >> .bashrcManual persistence insertionCriticalDirect attacker action.
Shell historycurl ... >> .bashrcPayload persistenceCriticalStrong malicious signal.
Shell historyexport PATH=PATH hijack persistenceCriticalCommon stealth method.
Shell historyalias sudo=Command hijackHighOperator trick / persistence.
Hidden command in shell profilesilent payloadCriticalStrong stealth indicator.
Reverse shell in profilecallback persistenceCriticalHigh severity.
File timestampsrecent profile modificationTimeline anchorCriticalStrong forensic truth.
auditdwrite to profile filesProcess attributionCriticalBest attribution if enabled.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Profile modified after root shellPersistence after escalationCriticalStrong hostile sequence.
Profile plus hidden payload pathLinked persistence chainCriticalStrong operator discipline.
Profile change then outbound connectionCallback persistenceCriticalVery strong signal.
PATH altered unexpectedlyHijack possibilityCriticalStrong privilege abuse clue.
Alias added silentlyCommand interceptionHighSubtle persistence.

Common Tools

ToolUsage
echoAppend persistence command.
cat >>Inject block into profile.
sed -iInline modification.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
.bashrcuser shell persistenceCriticalPrimary artifact.
.profilelogin persistenceCriticalPrimary artifact.
.bash_profilelogin persistenceCriticalCommon root target.
File timestampsstatCriticalTimeline truth.
Shell history.bash_historyCriticalModification evidence.

MITRE ATT&CK References

  • T1546 Event Triggered Execution
  • T1546.004 Unix Shell Configuration Modification

Decision Tree

  1. Which profile changed?
  2. What command inserted?
  3. Does it trigger callback / payload?
  4. Which account affected?
  5. Was cleanup attempted?

Example Detection Templates

Grep

grep -R "bashrc\|bash_profile\|profile" /home/*/.bash_history /root/.bash_history 2>/dev/null

Journalctl

journalctl | grep bash

File Inspection

find /home /root -name ".bashrc" -o -name ".profile" -o -name ".bash_profile" -exec stat {} \; 2>/dev/null
grep -R "curl\|wget\|nc\|bash -i\|python" /home/*/.bashrc /home/*/.profile /root/.bashrc /root/.profile 2>/dev/null

Sigma

title: Linux Bash Profile Persistence
id: linux-bash-profile-persistence
status: experimental
description: Detects suspicious shell profile modification used for persistence
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - '.bashrc'
      - '.profile'
      - '.bash_profile'
  condition: selection_keywords
level: high
tags:
  - attack.persistence
  - attack.t1546.004

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Profile reviewBaseline shell startup filesCriticalDetect rogue inserts.
AuditdTrack profile writesHighStrong attribution.
Least privilegeRestrict shell write abuseHighReduces persistence paths.