Uproot:使用powershell編寫基于主機的IDS
原文 http://www.freebuf.com/tools/88609.html
概述
Uproot是一款基于主機的入侵檢測系統(HIDS),其利用持續運行的Windows管理規范服務(WMI)事件訂閱,在一個網絡中檢測惡意行為。更多有關WMI事件訂閱可以參見 WMIEventing Module
為達到最佳效果,建議使用Uproot的AS_GenericHTTP consumer以及Uproot Listening Post提取事件,將系統日志聚合一起,再用Splunk進行處理。
注意:Uproot最好是在powershell版本>=v3環境下使用,當然你也可以在PowerShell v2下使用,只是功能方面會大打折扣。微軟從Windows NT 4.0和Windows 95時代一來一貫堅持著可恨又可愛的WMI,正因如此對于Windows NT 4.0之后的版本我們都可以使用Uproot
Cmdlets
簽名設置 - 預建的filters,consumers,subscriptions設置
Install-UprootSignature - 在指定計算機上增加預建的簽名(設置filters和consumers).
Uproot Listening Post
Uproot項目包括了一個可用作Listening Post(在網絡中聚合并轉發事件)的服務執行,Listening Post接收HTTP POST請求,將接收到的數據轉換為系統日志,然后將數據轉發到特定位置(例如Splunk)
在你的網絡載荷分布,或使用的防火墻限制允許的情況下你可以部署多個Listening Posts。
下面為使用Cmdlets安裝/配置Uproot Listening Post的清單:
Get-UprootLP - 在本地或遠程計算機列出Uproot Listening Posts. New-UprootLP - 在本地或遠程計算機創建一個新的Uproot Listening Post. Remove-UprootLP - 在本地或遠程計算機移除Uproot Listening Post. Restart-UprootLP - 在本地或遠程計算機上重置Uproot Listening Post. Start-UprootLP - 在本地或遠程計算機上開啟Uproot Listening Post. Stop-UprootLP - 在本地或遠程計算機上停止Uproot Listening Post.
注意:為了避免造成特權提升漏洞,我們建議在使用New-UprootLP命令前將uprootd.exe移動到C:\Windows\system32\
簽名
只要有可能,使用Extrinsic事件替換Intrinsic事件。Intrinsic事件請求輪詢,相對于Extrinsic事件需要更多的資源。
過濾
DriverCreation - Intrinsic事件監控系統驅動的創建/注冊 LoggedOnUserCreation - NetworkConnectionCreation - ProcessCreation - Intrinsic事件監控進程的創建 ProcessStartTrace - Extrinsic事件監控進程的創建 ScheduledJobCreation - Intrinsic事件監控"AT"的創建/注冊 ServerConnectionCreation - ServiceCreation - ShadowCopyCreation - Intrinsic事件監控卷備份的創建 ShareCreation - Intrinsic事件監控文件分享的創建 StartupCommandCreation - UserCreation - Intrinsic事件監控本地用戶的創建 UserProfileCreation -
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?寫了一篇十分優秀的文章來 介紹如何安裝模塊 ,借著這篇優秀的文章我們應用到Uproot上。
打開瀏覽器,并來到 Uproot github page ,你需要下載并提取模塊到你的模塊目錄下。
如果你使用IE下載這些存檔,在提取前你需要先打開存檔,否則當你導入的時候Powershell就會開始罷工了喲。如果你使用的是PowerShell 3.0或更新版本,那你可以使用Unblock-File命令來進行操作:
Unblock-File -Path "$env:UserProfile\Downloads\Uproot-master.zip"
使用老版本PowerShell的你,則需要手動打開文件。到下載目錄中右鍵單擊Uproot-master.zip并選擇“屬性”,在常規選項卡中單擊開啟。
打開你的模塊目錄,再創建一個名為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文件夾,完成這一步之后你應該可以在文件夾下看到這些文件:
開啟一個新的PowerShell會話,然后使用以下命令導入Uproot模塊
Get-Module -ListAvailable -Name Uproot Import-Module Uproot Get-Command -Module Uproot
從現在開始你就可以使用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-UprootLP Stop-UprootLP Remove-UprootLP
移除遠程Listening Post
Get-UprootLP -ComputerName LPHost Stop-UprootLP -ComputerName LPHost Remove-UprootLP -ComputerName LPHost
*參考來源: github ,編譯/FB小編鳶尾,轉載請注明來自FreeBuf黑客與極客(FreeBuf.COM)