Uproot:使用powershell編寫基于主機的IDS
概述
Uproot是一款基于主機的入侵檢測系統(tǒng)(HIDS),其利用持續(xù)運行的Windows管理規(guī)范服務(wù)(WMI)事件訂閱,在一個網(wǎng)絡(luò)中檢測惡意行為。更多有關(guān)WMI事件訂閱可以參見WMIEventing Module
為達到最佳效果,建議使用Uproot的AS_GenericHTTP consumer以及Uproot Listening Post提取事件,將系統(tǒng)日志聚合一起,再用Splunk進行處理。
注意:Uproot最好是在powershell版本>=v3環(huán)境下使用,當然你也可以在PowerShell v2下使用,只是功能方面會大打折扣。微軟從Windows NT 4.0和Windows 95時代一來一貫堅持著可恨又可愛的WMI,正因如此對于Windows NT 4.0之后的版本我們都可以使用Uproot
Cmdlets
簽名設(shè)置 - 預(yù)建的filters,consumers,subscriptions設(shè)置
Install-UprootSignature - 在指定計算機上增加預(yù)建的簽名(設(shè)置filters和consumers).
Uproot Listening Post
Uproot項目包括了一個可用作Listening Post(在網(wǎng)絡(luò)中聚合并轉(zhuǎn)發(fā)事件)的服務(wù)執(zhí)行,Listening Post接收HTTP POST請求,將接收到的數(shù)據(jù)轉(zhuǎn)換為系統(tǒng)日志,然后將數(shù)據(jù)轉(zhuǎn)發(fā)到特定位置(例如Splunk)
在你的網(wǎng)絡(luò)載荷分布,或使用的防火墻限制允許的情況下你可以部署多個Listening Posts。
下面為使用Cmdlets安裝/配置Uproot Listening Post的清單:
Get-UprootLP - 在本地或遠程計算機列出Uproot Listening Posts. New-UprootLP - 在本地或遠程計算機創(chuàng)建一個新的Uproot Listening Post. Remove-UprootLP - 在本地或遠程計算機移除Uproot Listening Post. Restart-UprootLP - 在本地或遠程計算機上重置Uproot Listening Post. Start-UprootLP - 在本地或遠程計算機上開啟Uproot Listening Post. Stop-UprootLP - 在本地或遠程計算機上停止Uproot Listening Post.
注意:為了避免造成特權(quán)提升漏洞,我們建議在使用New-UprootLP命令前將uprootd.exe移動到C:\Windows\system32\
簽名
只要有可能,使用Extrinsic事件替換Intrinsic事件。Intrinsic事件請求輪詢,相對于Extrinsic事件需要更多的資源。
過濾
ActiveScriptEventConsumers
AS_GenericHTTP - Generic ActiveScriptEventConsumer for All Events (this is the recommended consumer)
AS_ExtrinsicHTTP - Generic ActiveScriptEventConsumer for Extrinsic Events (Win32_ProcessStartTrace)
AS_IntrinsicHTTP - Generic ActiveScriptEventConsumer for Intrinsic Events (Win32_ProcessCreation)
LogFileEventConsumers
LF_ProcessCreation_CSV_PSv2
LF_ProcessCreation_txt
Prebuilt Sigs
Basic - An example signature file
安裝模塊
Jakub Jareš寫了一篇十分優(yōu)秀的文章來介紹如何安裝模塊,借著這篇優(yōu)秀的文章我們應(yīng)用到Uproot上。
打開瀏覽器,并來到Uproot github page,你需要下載并提取模塊到你的模塊目錄下。
如果你使用IE下載這些存檔,在提取前你需要先打開存檔,否則當你導(dǎo)入的時候Powershell就會開始罷工了喲。如果你使用的是PowerShell 3.0或更新版本,那你可以使用Unblock-File命令來進行操作:
Unblock-File -Path "$env:UserProfile\Downloads\Uproot-master.zip"
使用老版本PowerShell的你,則需要手動打開文件。到下載目錄中右鍵單擊Uproot-master.zip并選擇“屬性”,在常規(guī)選項卡中單擊開啟。
打開你的模塊目錄,再創(chuàng)建一個名為Uproot的文件夾。使用下面的腳本你看毫無壓力的打開正確的文件夾:
function Get-UserModulePath { $Path = $env:PSModulePath -split ";" -match $env:USERNAME if (-not (Test-Path -Path $Path)) { New-Item -Path $Path -ItemType Container | Out-Null } $Path }Invoke-Item (Get-UserModulePath)
將文檔提取到Uproot文件夾,完成這一步之后你應(yīng)該可以在文件夾下看到這些文件:
開啟一個新的PowerShell會話,然后使用以下命令導(dǎo)入Uproot模塊
Get-Module -ListAvailable -Name UprootImport-Module UprootGet-Command -Module Uproot
從現(xiàn)在開始你就可以使用Uproot PowerShell模塊了。
栗子
安裝簽名文件
Install-UprootSignature -ComputerName (Get-Content .\hostlist.txt) -SigFile Basic
安裝本地Listening Post
Copy-Item $PSModulePath\Uproot\bin\uprootd.exe C:\windows\System32\uprootd.exe New-UprootLP -BinaryPathName C:\windows\System32\uprootd.exe Start-UprootLP -Server 192.168.1.100
安裝遠程Listening Post
Copy-Item $PSModulePath\Uproot\bin\uprootd.exe \\LPHost\C$\windows\System32\uprootd.exe New-UprootLP -ComputerName LPHost -BinaryPathName C:\windows\System32\uprootd.exe Start-UprootLP -ComputerName LPHost -Server 192.168.1.100
移除本地Listening Post
Get-UprootLPStop-UprootLPRemove-UprootLP
移除遠程Listening Post
Get-UprootLP -ComputerName LPHostStop-UprootLP -ComputerName LPHostRemove-UprootLP -ComputerName LPHost
DriverCreation - Intrinsic事件監(jiān)控系統(tǒng)驅(qū)動的創(chuàng)建/注冊
LoggedOnUserCreation -
NetworkConnectionCreation -
ProcessCreation - Intrinsic事件監(jiān)控進程的創(chuàng)建
ProcessStartTrace - Extrinsic事件監(jiān)控進程的創(chuàng)建
ScheduledJobCreation - Intrinsic事件監(jiān)控"AT"的創(chuàng)建/注冊
ServerConnectionCreation -
ServiceCreation -
ShadowCopyCreation - Intrinsic事件監(jiān)控卷備份的創(chuàng)建
ShareCreation - Intrinsic事件監(jiān)控文件分享的創(chuàng)建
StartupCommandCreation -
UserCreation - Intrinsic事件監(jiān)控本地用戶的創(chuàng)建
UserProfileCreation -