首页/安全/应急响应速查/登录脚本持久化排查(profile 与 bashrc)
本包目录(168 条)

登录脚本持久化排查(profile 与 bashrc)

把 curl | bash 或反弹命令塞进 /etc/profile、bashrc,每次登录都触发:排查用户会话时不可跳过的一站。

应急响应速查安全更新于 2026-10-12
系统级/etc/profile、/etc/profile.d/*、/etc/bash.bashrc
用户级~/.bashrc、~/.profile、~/.bash_profile
特征curl/wget/base64 与 /dev/tcp 组合
注意zsh 用户还要看 .zshrc

扫描登录脚本注入

扫描登录脚本注入
grep -rEn 'curl|wget|base64|/dev/tcp|python -c' /etc/profile /etc/profile.d/ /etc/bash.bashrc /root/.bashrc /root/.profile 2>/dev/null | head -n 40
ls -lt /etc/profile.d/ | head
改这些文件影响所有新会话:先记录原文与时间,再清理并验证新登录正常。

易错点

  • 只看 root 家目录:普通用户与 www 用户的 rc 文件一样被利用
  • 漏掉 /etc/profile.d:目录化脚本更容易被忽略

数据来源与参考

  • bash(1) 手册:启动文件顺序
  • MITRE ATT&CK T1546.004 Unix Shell 配置修改

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌