跳到主內容

【AD】【列舉】PowerView.ps1

下載:

https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1

教學:

https://bookstack.treemanou.com/books/treemanoscp/page/ch21-active-directory-introduction-and-enumeration#bkmrk-21.3-manual-enumerat

Get-NetComputer

##############################################
# 載入記憶體
PS C:\Tools> Import-Module .\PowerView.ps1

##############################################
# 提供有關域的基本信息
PS C:\Tools> Get-NetDomain

Forest                  : corp.com
DomainControllers       : {DC1.corp.com}
Children                : {}
DomainMode              : Unknown
DomainModeLevel         : 7
Parent                  :
PdcRoleOwner            : DC1.corp.com
RidRoleOwner            : DC1.corp.com
InfrastructureRoleOwner : DC1.corp.com
Name                    : corp.com

##############################################
# 獲取域中所有用戶的列表
PS C:\Tools> Get-NetUser

logoncount             : 113
iscriticalsystemobject : True
description            : Built-in account for administering the computer/domain
distinguishedname      : CN=Administrator,CN=Users,DC=corp,DC=com
objectclass            : {top, person, organizationalPerson, user}
lastlogontimestamp     : 9/13/2022 1:03:47 AM
name                   : Administrator
##############################################
# 獲取域中所有用戶的列表
PS C:\Tools> Get-NetUser | select cn,pwdlastset,lastlogon

cn            pwdlastset            lastlogon
--            ----------            ---------
Administrator 8/16/2022 5:27:22 PM  9/14/2022 2:37:15 AM
Guest         12/31/1600 4:00:00 PM 12/31/1600 4:00:00 PM
krbtgt        9/2/2022 4:10:48 PM   12/31/1600 4:00:00 PM
dave          9/7/2022 9:54:57 AM   9/14/2022 2:57:28 AM
stephanie     9/2/2022 4:23:38 PM   12/31/1600 4:00:00 PM

##############################################
# 列舉群組
PS C:\Tools> Get-NetGroup | select cn

cn
--
...
Key Admins

##############################################
# 列舉群組("Sales Department")
PS C:\Tools> Get-NetGroup "Sales Department" | select member

member
------
{CN=Development Department,DC=corp,DC=com, CN=pete,CN=Users,
DC=corp,DC=com, CN=stephanie,CN=Users,DC=corp,DC=com}

##############################################
# 搜索操作系統和主機名
PS C:\Tools> Get-NetComputer | select dnshostname,operatingsystem,operatingsystemversion

dnshostname       operatingsystem              dnshostnameoperatingsystemversion
-----------       ---------------              -----------
Windows Server 2022 Standard-----------
DC1.corp.com      Windows Server 2022 Standard 10.0 (20348)
web04.corp.com    Windows Server 2022 Standard 10.0 (20348)
FILES04.corp.com  Windows Server 2022 Standard 10.0 (20348)
client74.corp.com Windows 11 Pro               10.0 (22000)
client75.corp.com Windows 11 Pro               10.0 (22000)
CLIENT76.corp.com Windows 10 Pro               10.0 (16299)

##############################################
# 掃描網絡,試圖確定我們當前用戶是否在域中的任何計算機上具有管理權限
PS C:\Tools> Find-LocalAdminAccess
client74.corp.com

##############################################
# 查找域中的一些機器,看看我們是否能找到任何已登錄的用戶
# 失敗
PS C:\Tools> Get-NetSession -ComputerName web04 -Verbose
VERBOSE: [Get-NetSession] Error: Access is denied
# 成功
PS C:\Tools> Get-NetSession -ComputerName client74
CName        : \\192.168.50.75
UserName     : stephanie
Time         : 8
IdleTime     : 0
ComputerName : client74