# Windows Blue Team --- [TOC] --- ## 核心概念 - 系統更新修補到最新 - 系統非必要帳戶全關 - 服務帳號權限最小化降低 - 帳號密碼變更禁弱密碼 - 第三方軟體更新到最新 - 安裝防毒及EDR軟體 ## 指令 CheatSheet | 指令 | 功能 | |:-------------------------------------------------------- |:---------------------------------------------- | | Hostname / echo %computer% | 確認目前主機名稱。 | | Whoami / echo %username% | 確認目前帳戶。 | | Query user | 確認目前在線帳戶。 | | Net user / lusrmgr.msc / compmgmt.msc | 列出系統帳戶。 | | Net localgroup administrators | 確認高權限帳戶。 | | Net localgroup "Remote Desktop Users" | 確認可遠端登入帳戶。 | | Net user guest /active:no | 停用不必要帳戶。 | | Net user administrator @newpass | 變更安全密碼。 | | Set | 查看系統環境變數。 | | Systeminfo | 查看系統基本資訊、網卡網域資訊及安裝的Hotfix。 | | Wmic qfe list | 查看系統安全Hotfix。 | | msinfo32 | 查看系統摘要及軟體環境資訊。 | | type c:\windows\system32\Drivers\etc\hosts | 確認IP對應檔。 | | Ipconfig -All / control ncpa.cpl | 確認目前網卡及IP資訊。 | | Arp -a | 確認mac跟連線IP關聯。 | | Tasklist / ProcessExplorer | 確認目前執行程式與網路相關列表。 | | Netstat –ano / CurrPorts | 確認網路連線及Port活動與程式連動。 | | Control firewall.cpl | 啟動防火牆管理介面。 | | Netsh advfirewall firewall show rule name=all > C:\L.txt | 紀錄防火牆資訊。 | | Netsh advfirewall export C:\temp.wfw | 匯出防火牆設定。 | | Netsh advfirewall reset | 重置防火牆回系統預設。 | | Netsh Advfirewall show allprofiles | 顯示防火牆設定檔啟用狀態。 | | NetSh Advfirewall set allprofiles state on | 啟用全域防火牆。 | | Net use | 列出網路連線資源。 | | Net share | 列出本機網路共享資源。 | | Net start | 列出目前啟用服務。 | | Services.msc | 檢查本機系統服務。 | | schtasks / taskschd.msc / at | 檢查工作排程管理。 | | msconfig / Autoruns | 系統啟動及服務啟動項等檢查。 | | Control update | 系統修補更新服務。 | | Certutil -hashfile malware.exe MD5 | 惡意程式MD5採樣。 | ## 重要路徑 | 路徑 | 備註 | | --------------------------------------- | --------------- | | %systemroot% | | | %systemroot%\system32 | | | %SystemRoot%\Prefetch\ | WinPrefetchView | | %SystemRoot%\appcompat\Programs\Install | | | %systemroot%\temp | | | %temp% | | | %appdata% | | | %userprofile%\Download | | ## 重要機碼 - 開機執行 ``` HKLM\Software\Microsoft\Windows\CurrentVersion\Run HKLM\Software\Microsoft\Windows\CurrentVersion\Runonce HKCU\Software\Microsoft\Windows\CurrentVersion\run HKCU\Software\Microsoft\WindowsNT\CurrentVersion\Windows\load ``` ## Windoes事件檢視器(eventvwr.exe) - 日誌檔所在位置 ``` %SystemRoot%\System32\Winevt\Logs\System.evtx %SystemRoot%\System32\Winevt\Logs\Security.evtx %SystemRoot%\System32\Winevt\Logs\Application.evtx ``` - 重點日誌ID代碼 | code | 意思 | | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | 4624 | 帳戶已成功登入 | | 4625 | 帳戶無法登入 | | 4634 | 帳戶已登出 | | 4647 | 使用者啟動的登出 | | 4672 | 指派至新登入的特殊許可權 | | 4688 | 已建立新的處理序([必須啟用](https://docs.microsoft.com/zh-tw/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing)) | | 4720 | 已建立使用者帳戶 | ## Microsoft Defender - 移至程式所在目錄 ```=cmd CD %ProgramData%\Microsoft\Windows Defender\Platform\4.18* ``` - 檔案掃描 ```=cmd MpCmdRun -Scan -ScanType 3 -File C:\Users\username\Downloads ``` - 開機磁區掃描 ```=cmd MpCmdRun -Scan -ScanType –BootSectorScan ``` - 列出隔離檔案 ```=cmd MpCmdRun -Restore –ListAll ``` - 還原隔離檔案 ```=cmd MpCmdRun -Restore -Name app.exe -FilePath C:\Users\username\Downloads ``` - 設定為預設防毒服務 ```=cmd sc config WinDefend start= auto sc start WinDefend ``` ## Advance Firewall ``` Netsh advfirewall Netsh advfirewall show allprofiles Netsh advfirewall export C:\temp.wfw Netsh advfirewall reset Netsh advfirewall import C:\temp.wfw Netsh advfirewall firewall show rule name=all | select-string -pattern "(本機連接埠.*162)|(啟用.*否)" -context 9,4 ``` ## 常用工具 - CurrPorts: 監控網路連線狀況,除了監測程式連線外,賽時用來查測惡意程式及異常連線,並可用來找出記分板伺服器,據以加固防火牆。 :::spoiler 圖片 ![](https://i.imgur.com/7Wa1fpZ.png) ::: - TCPView: 監控網路連線狀況,除了監測程式連線外,賽時用來查測惡意程式及異常連線,並可用來找出記分板伺服器,據以加固防火牆。 :::spoiler 圖片 ![](https://i.imgur.com/q5O9iB3.png) ::: - Autoruns: 管理Windows中的啟動程式、檔案管理、IE套件、驅動程式、排程工作……等20類的設定。 :::spoiler 圖片 ![](https://i.imgur.com/3y3Tp6J.png) ::: - ProcessExplorer: 進階版工作管理員,方便快速查找惡意程式或DLL。 :::spoiler 圖片 ![](https://i.imgur.com/i8biknA.png) ::: - PeStudio: PE程式快速靜態分析鑑識工具,快速找出具有惡意特徵的執行檔。 :::spoiler 圖片 ![](https://i.imgur.com/bRzRQsx.png) ::: - WinPEAS: Windows安全性檢查工具