NOTE:
Group memberships of the current user
Existing users and groups
Operating system, version and architecture
Interesting Files
To search for files
Copy where /r C:\Users\ *.txt
where /r C:\ *.uac
where /r C:\ *.dll
dir C:\
where /r C:\ local.txt proof.txt
# Display hidden files
dir \a
To find specific files
Copy Get-ChildItem -Path C:\Users -Include *.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx,*ini,*.log,*.ps1 -File -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path C:\Users -Include *.txt,*.pdf,*.kdbx -File -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path C:\ -Include SAM,SYSTEM -File -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path C:\ -Include local.txt,proof.txt -File -Recurse -ErrorAction SilentlyContinue
# Display hidden files
ls -Force
User Permissions
Username
User information
NOTE: The above command consists of the following
User Enumeration
Get all user in the current machine
Get information on a particular user
Copy net user <Username> [/domain]
Get groups on domain
Get users in a particular group
Copy Get-LocalGroupMember "<Group Name>"
Get information on a particular group in the domain
Copy net group <Group Name> /domain
Get local administrators
Copy net localgroup administrators
Get SMB shares
Get password requirements
Script
Copy notepad "<Path/to/script.ps1>"
Copy function LDAPSearch {
param (
[string]$LDAPQuery
)
$PDC = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().PdcRoleOwner.Name
$DistinguishedName = ([adsi]'').distinguishedName
$DirectoryEntry = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$PDC/$DistinguishedName")
$DirectorySearcher = New-Object System.DirectoryServices.DirectorySearcher($DirectoryEntry, $LDAPQuery)
return $DirectorySearcher.FindAll()
}
Load the module into powershell
Copy Import-Module .\script.ps1
To enumeration users
Copy LDAPSearch -LDAPQuery "(samAccountType=805306368)"
To enumerate groups
Copy LDAPSearch -LDAPQuery "(objectclass=group)"
To display members of each group
Copy foreach ($group in $(LDAPSearch -LDAPQuery "(objectCategory=group)")) {$group.properties | select {$_.cn}, {$_.member}}
To display detailed members of a particular group
Copy $group = LDAPSearch -LDAPQuery "(&(objectCategory=group)(cn=<Group Name>))"
$group.properties.member
To display detailed information of a particular member
Copy $user = LDAPSearch -LDAPQuery "(&(objectCategory=user)(cn=<Username>))"
$user.properties
System Enumeration
Get important information
Copy systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type" /C:"Domain" /C:"Network Card"
Get port information
Get network information
Get current console
Copy (dir 2>&1 *`|echo CMD);&<# rem #>echo PowerShell
Installed programs
Copy Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname
Copy Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname
Web Root Directory
Copy dir C:\inetpub\wwwroot
dir C:\xampp\htdocs
dir C:\<Directory Name>\xampp\htdocs
NOTE: Indication of Web Director:
Get History
Copy (Get-PSReadlineOption).HistorySavePath
PowerView
NOTE: Remember to run the following
Copy powershell -ep bypass
Copy Import-Module .\PowerView.ps1
Enumerate Users in the Domain
To get filtered result
Copy Get-NetUser | select <Field Name> ...
EXAMPLE:
Get-NetUser | select samaccountname, cn, pwdlastset, lastlogon
To get specific information of a particular user
Copy Get-NetUser <Username>
Enumerate Groups in the Domain
To get filtered result
Copy Get-NetGroup | select <Field name> ...
EXAMPLE:
Get-NetGroup | select cn
To get specific information of a particular group
Copy Get-NetGroup <Group Name>
Get SPN users
Copy Get-NetUser -SPN | select <Field name> ...
EXAMPLE:
Get-NetUser -SPN | select samaccountname, serviceprincipalname
Enumerate Computers in the Domain
To get filtered result
Copy Get-NetComputer | select <Field name> ...
EXAMPLE:
Get-NetComputer | select operatingsystem, dnshostname
To get specific information of a particular computer
Copy Get-NetComputer <DNS Host Name>
To look for administrative rights on other computer for the current user
Copy Find-LocalAdminAccess
To look for logged on users on target machine
Copy Get-NetSession -ComputerName <Computer Name> -Verbose
NOTE: If something is not right check for permission.
Permissions for NetSessionEnum are defined in SrvsvcSessionInfo registry key (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\DefaultSecurity)
Alternatives
Copy C:\Tools\PSTools\PsLoggedon.exe \\<Host Name>
NOTE: Remote machine must have Remote Registry service enabled
To check for permission
Copy Get-Acl -Path <Registery Hive>:<Registry Path> | fl
EXAMPLE:
Get-Acl -Path HKLM:SYSTEM\CurrentControlSet\Services\LanmanServer\DefaultSecurity\ | fl
To enumerate Service Principal Name
Copy Get-NetUser -SPN | select samaccountname, serviceprincipalname
To enumerate ACEs
Copy Get-ObjectAcl -Identity "<Username | Group Name>"
NOTE: Look out for ActiveDirectoryRights and SecurityIdentifier
To enumerate interesting ACL
Copy Find-InterestingDomainAcl | select identityreferencename,activedirectoryrights,acetype,objectdn | ?{$_.IdentityReferenceName -NotContains "DnsAdmins"} | ft
To enumerate all user that has ActiveDirectoryRights = GenericAll under a group
Copy Get-ObjectAcl -Identity "<Group Name>" | ? {$_.ActiveDirectoryRights -eq "GenericAll"} | select SecurityIdentifier, ActiveDirectoryRights
To enumerate all ActiveDirectoryRights = GenericWrite under a group
Copy Get-ObjectAcl -Identity "<Group Name>" | ?{$_.ActiveDirectoryRights -eq "GenericWrite"} | select SecurityIdentifier, ActiveDirectoryRights
To convert SID to Name in bulk
Copy "<SID>", "<SID>", "<SID>", "<SID>", "<SID>" | Convert-SidToName
To convert SID to Name individually
Copy Convert-SidToName "<SID>"
Add user into group in domain
Copy net group "<Group Name>" <Username> /add /domain
To enumerate all shares on Domain
To enumerate shares available to current user
Copy Find-DomainShare -CheckShareAccess
BloodHound
To import BloodHound
Copy Import-Module C:\Tools\Bloodhound.ps1
To begin enumerationg on BloodHound
Copy Invoke-BloodHound -CollectionMethod All -OutputDirectory <Path> -OutputPrefix "corp audit"
On kali:
NOTE: Head over to http://localhost:7474
Username: neo4j
Password: arctic-iris-zipper-prism-courage-7161