跳转至

T1552-001-linux-文件中的凭据

来自ATT&CK的描述

攻击者可能会在本地文件系统和远程文件共享中搜索包含不安全存储的凭据的文件。这些文件可以是用户创建的用于存储自己的凭据的文件,一组个人的共享凭据存储,包含系统或服务密码的配置文件或包含嵌入式密码的源代码/二进制文件。

可以通过OS Credential Dumping从备份或保存的虚拟机中提取密码。也可以从Windows域控制器上存储的组策略首选项中获取密码。

在云环境中,经过身份验证的用户凭据通常存储在本地配置和凭据文件中。在某些情况下,可以将这些文件复制并在另一台机器上重复使用,或者可以读取内容,然后将其用于身份验证,而无需复制任何文件。

测试案例

grep -riP password #{想要查找的文件路径}

grep -riP password /

检测日志

linux audit日志 (值得注意的是:Ubuntu默认情况下没有audit,需要下载安装并配置相关策略)

bash历史记录

测试复现

icbc@icbc:/$ grep -riP passwd /etc/passwd

测试留痕

audit日志

icbc@icbc:/$ gedit /var/log/audit/audit.log

type=SYSCALL msg=audit(1563526266.080:744): arch=c000003e syscall=59 success=yes exit=0 a0=55f3435691b0 a1=55f3434345d0 a2=55f343573580 a3=8 items=2 ppid=2031 pid=4855 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts0 ses=3 comm="grep" exe="/usr/bin/grep" key="auditcmd"
type=EXECVE msg=audit(1563526266.080:744): argc=5 a0="grep" a1="--color=auto" a2="-riP" a3="passwd" a4="/etc/passwd"
type=CWD msg=audit(1563526266.080:744): cwd="/"
type=PATH msg=audit(1563526266.080:744): item=0 name="/usr/bin/grep" inode=2228723 dev=08:01 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0

值得注意的是:这里只提取出了异常日志,故省略了很多日志细节。

bash历史记录

icbc@icbc:/$ history

1 grep -riP passwd /etc/passwd

检测规则/思路

splunk规则

audit日志

index=linux sourcetype=linux_audit type=execve a0=grep   a0="grep" a1="--color=auto" a2="-riP" a3="passwd"

splunk规则

bash 历史记录

index=linux sourcetype="bash_history" grep password | table host,user_name,bash_command

sigma规则

值得注意的是:你需要自行配置Audit审核规则

title: 攻击者查看linux下可能包含用户账户密码的文件
description: Ubuntu18.04
references: https://github.com/12306Bro/Threathunting/blob/master/T1081-linux-文件中的凭证.md
tags: T1552-001
status: experimental
author: 12306Bro
logsource:
  product: linux
  service: audit(需要自行配置audit规则)
detection:
  keywords:
​    - comm="grep" exe="/bin/grep" key="audit_110"
  condition: keywords

logsource:
  product: linux
  service: history
detection:
  selection:
  keywords:
​    - grep * passwd
  condition: keywords
level: medium

建议

暂无

相关TIP

[[T1552-001-win-文件中的凭证]] [[T1552-002-win-注册表中的凭证]] [[T1552-003-linux-Bash历史]] [[T1552-004-linux-私钥]] [[T1552-006-win-GPP-凭证转储]]

参考推荐

MITRE-ATT&CK-T1552-001

https://attack.mitre.org/techniques/T1552/001