LoginSignup
6
2

More than 3 years have passed since last update.

DFIR用のツール「Velociraptor」を使用してみる

Last updated at Posted at 2020-02-25

Velociraptor とは

アーティファクトを収集し、指定したサーバにアップロードする
👉公式サイト
開発者SANSの講師っぽい
image.png

一般的なデジタルフォレンジックの一例

保全した端末でアーティファクトを収集するツールを実行し、HDD/SSD等の外部記憶媒体または、クラウドストレージにコピーし、調査用のPCで解析を行う
image.png

Velociraptor の場合

予め生成したコンフィグをもとに実行ファイルを保全PC内で実行し、Velociraptorサーバで操作を行うことでパースされたアーティファクトがアップロードされる
解析作業を行う人はWEB GUI上で操作を行う
image.png

ライセンス

👉GNU Affero General Public License
商業利用できそう
👉AGPLについて

動作検証

動作環境

ソフトウェアバージョンは2020年2月25日時点で最新の👉v0.3.9を使用します

サーバ
- Linux Mint 19.1

クライアント
- Windows10 Pro

セットアップ

$ wget https://github.com/Velocidex/velociraptor/releases/download/v0.3.9/velociraptor-v0.3.9-linux-amd64
$ mv velociraptor-v0.3.9-linux-amd64 velociraptor 
$ chmod +x velociraptor
$ ./velociraptor config generate -i
? 
Welcome to the Velociraptor configuration generator
---------------------------------------------------

I will be creating a new deployment configuration for you. I will
begin by identifying what type of deployment you need.

  [Use arrows to move, type to filter]
> Self Signed SSL
  Automatically provision certificates with Lets Encrypt
  Authenticate users with Google OAuth SSO

とりあえずオレオレ証明書

? Enter the frontend port to listen on. 8000
? What is the public DNS name of the Frontend (e.g. www.example.com): 10.0.2.12※各自の環境に合わせて
? Path to the datastore directory. /tmp
? Path to the logs directory. /tmp
? GUI Username or email address to authorize (empty to end): testuser
? Password *****
? Where should i write the server config file? server.config.yaml
? Where should i write the client config file? client.config.yaml

とりあえずtestuserとパスワードを作成
するとserver.config.yamlとclient.config.yamlが作成される

client.config.yamlを共有フォルダ等を使用しコピーしておきましょう
WEB GUIをlocalhost以外からアクセスする場合bind_addressの変更

server.config.yaml
GUI:
  bind_address: 127.0.0.1
  bind_port: 8889
👇例
GUI:
  bind_address: 0.0.0.0
  bind_port: 8889

実行

$ ./velociraptor --config server.config.yaml frontend -v

ブラウザで「https://10.0.2.12:8889」を開きます※各自の環境に合わせて
オレオレ証明書なので「安全な接続ではありません」が無視して次へ
image.png

認証画面になりさきほど作成したアカウントを入れます
image.png

この画面になればサーバ側の設定は一旦終わりです
image.png

検証①

インシデント内容

Maldocを開いてしまいEmotetに感染してしまった

適当にany.runのPublic submissionsから「emotet」でタグ検索をかけて検体をダウンロードしましょう
👉検体今回はこれを使います
image.png

Enable Contentをクリックし実行します
image.png

👉VelociraptorのWindows実行ファイルをダウンロードしましょう
サーバのセットアップ時に生成されたclient.config.yamlを引数に以下のように実行します

.\velociraptor-v0.3.9-windows-amd64.exe --config client.config.yaml client -v

ここからはWEB GUIの操作になります
Hunt Managerより
image.png

Windows.と入力するとWindowsで取得できるアーティファクトの一覧がでます
image.png

今回は
- Prefetch
- SRUM
- MFT
- Windows Event Log(PS)
- AppCompatCache(Shimcache)
- Amcache
- Startup
を取得しようと思います
image.png

取得したいアーティファクトをAddしたらNextを押します
hunt_descriptionに日付など入れて分かるようにしましょう
HuntConditionは今回はWindowsなのでOperating SystemよりWindowsを選択します
最後にCreate Huntを押してDone押して完了です

実行したい行を選択し をクリックし実行します
image.png

結果

収集が終わるとResultタブより各プルダウンすることでアーティファクトの結果が見られます
プルダウンの下にSearch:の入力ボックスがあるので検索することも可能です
(例1 Prefetch
しっかり98.EXE-6B674017.pfがありますね!ただし、読み込んだDLL等の情報まではパースされないみたいです
image.png

(例2 Startupにありましたね!
image.png

OverviewタブのPrepare Downloadよりアーティファクトをダウンロードする準備します
Available Downloadsでダウンロードできます
image.png

パースされたアーティファクトがCSVであります
image.png

検証②

インシデント内容

Pass the Hashされてしまった※

※唐突な内容ですが、攻撃内容というよりもカスタムイベントログのための説明です

検証②ではWindows Event LogのPass the Hash攻撃の痕跡を見つけたいです
しかし、プリセットのアーティファクトリストにはありません
velociraptorではカスタムアーティファクトを作成できます
View Artifactの➕を押して作成します
image.png

入力画面で以下のように入力し Save Artifactします
image.png

name: Custom.Windows.EventLogs.PasstheHash
description: |
  Pass the Hash

parameters:
  - name: securityLogFile
    default: C:/Windows/System32/Winevt/Logs/Security.evtx

sources:
  - queries:
      - SELECT EventData.IpAddress AS IpAddress,
               EventData.IpPort AS Port,
               EventData.ProcessName AS ProcessName,
               EventData.SubjectUserSid AS SubjectUserSid,
               EventData.SubjectUserName AS SubjectUserName,
               EventData.SubjectDomainName AS SubjectDomainName,
               EventData.TargetUserName AS TargetUserName,
               EventData.TargetServerName AS TargetServerName,
               EventData.TargetDomainName AS TargetDomainName,
               EventData.LogonProcessName AS LogonProcessName,
               EventData.LogonType AS LogonType,
               EventData.AuthenticationPackageName AS AuthenticationPackageName,
               EventData.WorkstationName AS WorkstationName,
               System.TimeCreated.SystemTime AS LogonTime
        FROM parse_evtx(filename=securityLogFile)
        WHERE System.EventID.Value = 4624
        AND EventData.LogonType = 9
        AND EventData.AuthenticationPackageName = "Negotiate"
        AND EventData.LogonProcessName = "seclogo"

EventData.System.のあとのパラメタですがevtx_dump.pyにて確認できます

$ sudo apt install python-evtx
evtx_dump.py Security.evtx
...
<Task>12544</Task>
<Opcode>0</Opcode>
<Keywords>0x8020000000000000</Keywords>
<TimeCreated SystemTime="2020-01-24 17:37:22.497969"></TimeCreated>
<EventRecordID>2467</EventRecordID>
<Correlation ActivityID="{38eed94e-d2d8-0000-e1d9-ee38d8d2d501}" RelatedActivityID=""></Correlation>
<Execution ProcessID="628" ThreadID="7444"></Execution>
<Channel>Security</Channel>
<Computer>PC1.TEST.local</Computer>
<Security UserID=""></Security>
</System>
<EventData><Data Name="SubjectUserSid">S-1-5-21-2779522552-3569681238-1483158904-1001</Data>
<Data Name="SubjectUserName">victim1</Data>
<Data Name="SubjectDomainName">PC1</Data>
<Data Name="SubjectLogonId">0x000000000009a96f</Data>
<Data Name="TargetUserSid">S-1-5-21-2779522552-3569681238-1483158904-1001</Data>
<Data Name="TargetUserName">victim1</Data>
<Data Name="TargetDomainName">PC1</Data>
<Data Name="TargetLogonId">0x00000000002a14c1</Data>
<Data Name="LogonType">9</Data>
<Data Name="LogonProcessName">seclogo</Data>
<Data Name="AuthenticationPackageName">Negotiate</Data>
<Data Name="WorkstationName">-</Data>
<Data Name="LogonGuid">{00000000-0000-0000-0000-000000000000}</Data>
<Data Name="TransmittedServices">-</Data>
<Data Name="LmPackageName">-</Data>
<Data Name="KeyLength">0</Data>
<Data Name="ProcessId">0x0000000000001b4c</Data>
<Data Name="ProcessName">C:\Windows\System32\svchost.exe</Data>
<Data Name="IpAddress">::1</Data>
<Data Name="IpPort">0</Data>
<Data Name="ImpersonationLevel">%%1833</Data>
<Data Name="RestrictedAdminMode">-</Data>
<Data Name="TargetOutboundUserName">victim2</Data>
<Data Name="TargetOutboundDomainName">TEST.LOCAL</Data>
<Data Name="VirtualAccount">%%1843</Data>
<Data Name="TargetLinkedLogonId">0x0000000000000000</Data>
<Data Name="ElevatedToken">%%1842</Data>
</EventData>
...

結果

保存したら検証①と同様にHunt Managerに登録し実行します
きちんと収集できてますね!
image.png

プリセットで収集できるアーティファクトの一覧

> ./velociraptor artifacts list
Admin.Client.Upgrade
Admin.Events.PostProcessUploads
Admin.System.CompressUploads
Demo.Plugins.Fifo
Demo.Plugins.GUI
Elastic.Events.Clients
Elastic.Flows.Upload
Generic.Applications.Office.Keywords
Generic.Client.Info
Generic.Client.Stats
Generic.Forensic.Carving.URLs
Generic.Forensic.Timeline
Linux.Applications.Chrome.Extensions
Linux.Applications.Chrome.Extensions.Upload
Linux.Applications.Docker.Info
Linux.Applications.Docker.Version
Linux.Debian.AptSources
Linux.Debian.Packages
Linux.Events.ProcessExecutions
Linux.Events.SSHBruteforce
Linux.Events.SSHLogin
Linux.Mounts
Linux.Proc.Arp
Linux.Proc.Modules
Linux.Search.FileFinder
Linux.Ssh.AuthorizedKeys
Linux.Ssh.KnownHosts
Linux.Ssh.PrivateKeys
Linux.Sys.ACPITables
Linux.Sys.CPUTime
Linux.Sys.Crontab
Linux.Sys.LastUserLogin
Linux.Sys.Maps
Linux.Sys.SUID
Linux.Sys.Users
Linux.Syslog.SSHLogin
MacOS.Detection.Autoruns
MacOS.System.Users
Network.ExternalIpAddress
Reporting.Hunts.Details
Server.Alerts.PsExec
Server.Alerts.WinPmem
Server.Hunts.List
Server.Hunts.Results
Server.Information.Clients
Server.Information.Users
Server.Internal.ArtifactDescription
Server.Internal.Interrogate
Server.Monitor.Health
Server.Monitor.Shell
Server.Monitor.VeloMetrics
Server.Monitoring.ClientCount
Server.Powershell.EncodedCommand
System.Flow.Completion
System.Hunt.Participation
System.VFS.DownloadFile
System.VFS.ListDirectory
Triage.Collection.Upload
Triage.Collection.UploadTable
Windows.Analysis.EvidenceOfExecution
Windows.Applications.ChocolateyPackages
Windows.Applications.Chrome.Cookies
Windows.Applications.Chrome.Extensions
Windows.Applications.Chrome.History
Windows.Applications.OfficeMacros
Windows.Attack.ParentProcess
Windows.Attack.Prefetch
Windows.Collectors.File
Windows.Collectors.VSS
Windows.Detection.Impersonation
Windows.Detection.Mutants
Windows.Detection.ProcessMemory
Windows.Detection.PsexecService
Windows.Detection.PsexecService.Kill
Windows.Detection.RemoteYara.Process
Windows.Detection.Service.Upload
Windows.Detection.Thumbdrives.List
Windows.Detection.Thumbdrives.OfficeKeywords
Windows.Detection.Thumbdrives.OfficeMacros
Windows.Detection.WMIProcessCreation
Windows.EventLogs.AlternateLogon
Windows.EventLogs.DHCP
Windows.EventLogs.Kerbroasting
Windows.EventLogs.PowershellScriptblock
Windows.EventLogs.ServiceCreationComspec
Windows.Events.DNSQueries
Windows.Events.FailedLogBeforeSuccess
Windows.Events.Kerbroasting
Windows.Events.ProcessCreation
Windows.Events.ServiceCreation
Windows.Forensics.Bam
Windows.Forensics.FilenameSearch
Windows.Forensics.Prefetch
Windows.Forensics.RecentApps
Windows.Forensics.SRUM
Windows.Forensics.Timeline
Windows.KapeFiles.Targets
Windows.Memory.Acquisition
Windows.NTFS.I30
Windows.NTFS.MFT
Windows.NTFS.Recover
Windows.Network.ArpCache
Windows.Network.InterfaceAddresses
Windows.Network.ListeningPorts
Windows.Network.Netstat
Windows.Network.NetstatEnriched
Windows.Packs.Autoexec
Windows.Packs.LateralMovement
Windows.Packs.Persistence
Windows.Persistence.Debug
Windows.Persistence.PermanentWMIEvents
Windows.Persistence.PowershellRegistry
Windows.Persistence.Wow64cpu
Windows.Registry.AppCompatCache
Windows.Registry.EnableUnsafeClientMailRules
Windows.Registry.EnabledMacro
Windows.Registry.MountPoints2
Windows.Registry.NTUser
Windows.Registry.NTUser.Upload
Windows.Registry.PortProxy
Windows.Registry.Sysinternals.Eulacheck
Windows.Registry.UserAssist
Windows.Search.FileFinder
Windows.Sys.AppcompatShims
Windows.Sys.CertificateAuthorities
Windows.Sys.DiskInfo
Windows.Sys.Drivers
Windows.Sys.FirewallRules
Windows.Sys.Interfaces
Windows.Sys.PhysicalMemoryRanges
Windows.Sys.Programs
Windows.Sys.StartupItems
Windows.Sys.Users
Windows.Sysinternals.Autoruns
Windows.Sysinternals.SysmonInstall
Windows.System.Amcache
Windows.System.CriticalServices
Windows.System.DLLs
Windows.System.Handles
Windows.System.Pslist
Windows.System.SVCHost
Windows.System.Services
Windows.System.TaskScheduler
Windows.System.UntrustedBinaries
Windows.System.VAD
Windows.Triage.ProcessMemory
Windows.Utils.DownloadBinaries
Windows.Utils.FetchBinary
Windows.Utils.UpdatePublicHashes
mint@mint-VirtualBox:~/dfir$ 
mint@mint-VirtualBox:~/dfir$ ./velociraptor artifacts list
Admin.Client.Upgrade
Admin.Events.PostProcessUploads
Admin.System.CompressUploads
Demo.Plugins.Fifo
Demo.Plugins.GUI
Elastic.Events.Clients
Elastic.Flows.Upload
Generic.Applications.Office.Keywords
Generic.Client.Info
Generic.Client.Stats
Generic.Forensic.Carving.URLs
Generic.Forensic.Timeline
Linux.Applications.Chrome.Extensions
Linux.Applications.Chrome.Extensions.Upload
Linux.Applications.Docker.Info
Linux.Applications.Docker.Version
Linux.Debian.AptSources
Linux.Debian.Packages
Linux.Events.ProcessExecutions
Linux.Events.SSHBruteforce
Linux.Events.SSHLogin
Linux.Mounts
Linux.Proc.Arp
Linux.Proc.Modules
Linux.Search.FileFinder
Linux.Ssh.AuthorizedKeys
Linux.Ssh.KnownHosts
Linux.Ssh.PrivateKeys
Linux.Sys.ACPITables
Linux.Sys.CPUTime
Linux.Sys.Crontab
Linux.Sys.LastUserLogin
Linux.Sys.Maps
Linux.Sys.SUID
Linux.Sys.Users
Linux.Syslog.SSHLogin
MacOS.Detection.Autoruns
MacOS.System.Users
Network.ExternalIpAddress
Reporting.Hunts.Details
Server.Alerts.PsExec
Server.Alerts.WinPmem
Server.Hunts.List
Server.Hunts.Results
Server.Information.Clients
Server.Information.Users
Server.Internal.ArtifactDescription
Server.Internal.Interrogate
Server.Monitor.Health
Server.Monitor.Shell
Server.Monitor.VeloMetrics
Server.Monitoring.ClientCount
Server.Powershell.EncodedCommand
System.Flow.Completion
System.Hunt.Participation
System.VFS.DownloadFile
System.VFS.ListDirectory
Triage.Collection.Upload
Triage.Collection.UploadTable
Windows.Analysis.EvidenceOfExecution
Windows.Applications.ChocolateyPackages
Windows.Applications.Chrome.Cookies
Windows.Applications.Chrome.Extensions
Windows.Applications.Chrome.History
Windows.Applications.OfficeMacros
Windows.Attack.ParentProcess
Windows.Attack.Prefetch
Windows.Collectors.File
Windows.Collectors.VSS
Windows.Detection.Impersonation
Windows.Detection.Mutants
Windows.Detection.ProcessMemory
Windows.Detection.PsexecService
Windows.Detection.PsexecService.Kill
Windows.Detection.RemoteYara.Process
Windows.Detection.Service.Upload
Windows.Detection.Thumbdrives.List
Windows.Detection.Thumbdrives.OfficeKeywords
Windows.Detection.Thumbdrives.OfficeMacros
Windows.Detection.WMIProcessCreation
Windows.EventLogs.AlternateLogon
Windows.EventLogs.DHCP
Windows.EventLogs.Kerbroasting
Windows.EventLogs.PowershellScriptblock
Windows.EventLogs.ServiceCreationComspec
Windows.Events.DNSQueries
Windows.Events.FailedLogBeforeSuccess
Windows.Events.Kerbroasting
Windows.Events.ProcessCreation
Windows.Events.ServiceCreation
Windows.Forensics.Bam
Windows.Forensics.FilenameSearch
Windows.Forensics.Prefetch
Windows.Forensics.RecentApps
Windows.Forensics.SRUM
Windows.Forensics.Timeline
Windows.KapeFiles.Targets
Windows.Memory.Acquisition
Windows.NTFS.I30
Windows.NTFS.MFT
Windows.NTFS.Recover
Windows.Network.ArpCache
Windows.Network.InterfaceAddresses
Windows.Network.ListeningPorts
Windows.Network.Netstat
Windows.Network.NetstatEnriched
Windows.Packs.Autoexec
Windows.Packs.LateralMovement
Windows.Packs.Persistence
Windows.Persistence.Debug
Windows.Persistence.PermanentWMIEvents
Windows.Persistence.PowershellRegistry
Windows.Persistence.Wow64cpu
Windows.Registry.AppCompatCache
Windows.Registry.EnableUnsafeClientMailRules
Windows.Registry.EnabledMacro
Windows.Registry.MountPoints2
Windows.Registry.NTUser
Windows.Registry.NTUser.Upload
Windows.Registry.PortProxy
Windows.Registry.Sysinternals.Eulacheck
Windows.Registry.UserAssist
Windows.Search.FileFinder
Windows.Sys.AppcompatShims
Windows.Sys.CertificateAuthorities
Windows.Sys.DiskInfo
Windows.Sys.Drivers
Windows.Sys.FirewallRules
Windows.Sys.Interfaces
Windows.Sys.PhysicalMemoryRanges
Windows.Sys.Programs
Windows.Sys.StartupItems
Windows.Sys.Users
Windows.Sysinternals.Autoruns
Windows.Sysinternals.SysmonInstall
Windows.System.Amcache
Windows.System.CriticalServices
Windows.System.DLLs
Windows.System.Handles
Windows.System.Pslist
Windows.System.SVCHost
Windows.System.Services
Windows.System.TaskScheduler
Windows.System.UntrustedBinaries
Windows.System.VAD
Windows.Triage.ProcessMemory
Windows.Utils.DownloadBinaries
Windows.Utils.FetchBinary
Windows.Utils.UpdatePublicHashes

まとめ

今回はオープンソースのDFIRツールで超簡単なシナリオのもと実際にマルウェアを動かしアーティファクトの収集を行った
プリセットにないアーティファクトはカスタムアーティファクトとして作成し収集できる

所感

  • オンラインでアーティファクトをアップロードするのは便利
  • Windowsのアーティファクトは充実してるがLinuxやMacは少ない
  • Windows Event Logの収集が弱い
    • 収集設定はカスタマイズできそうなので4624/4625とか4648とかとかの収集もできそう
  • まだ開発中なので今後に期待!
  • アップロードするときインターネットに接続しないといけない問題
    • マルウェアに感染したPCを業務ネットワークには接続できない👉テザリング?
    • 素のネットワークだとマルウェアも通信可能なため情報流出するおそれ👉宛先をVelociraptorにしぼる?
6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2