Commit Graph

106 Commits

Author SHA1 Message Date
Will 97382c215d Merge pull request #226 from joncave/dn_commas
Support for DNs containing commas
2017-04-26 14:08:32 -07:00
Will 0bbc9db5ab Merge pull request #227 from joncave/dfs_domain
The DFS subfunctions only accept a single $Domain
2017-04-26 14:08:01 -07:00
Lee Christensen 834a80fef3 Set explicit LDAP SecurityMask settings
Changed the LDAP SecurityMasks settings so that you can change the Owner/DACL if you only have WriteOwner/WriteDacl permissions on the object (Default SecurityMasks is "Owner, Group, Dacl")
2017-04-17 15:30:06 -07:00
Jon Cave 08b30627d9 Support for DNs containing commas
If an object's distinguished name contains a comma then it ends up quoted:

    CN=Smith\, John,OU=Admins,DC=example,DC=com

This breaks a number of functions which attempt to identify DOMAIN\name
by matching on a \ anywhere in the specified identity before checking if
the identity was a DN (or SID or GUID).

For example, attempting to list members of "Domain Admins" using
Get-DomainGroupMember gives the following:

    VERBOSE: [Convert-ADName] Error initializing translation for 'CN=Smith\, John,OU=Admins,DC=example,DC=com' : Exception calling "InvokeMember" with "5" argument(s): "The specified domain either does not exist or could not be contacted. (Exception from HRESULT: 0x8007054B)"
    VERBOSE: [Convert-ADName] Error translating 'CN=Smith\, John,OU=Admins,DC=example,DC=com' : The specified domain either does not exist or could not be contacted. (Exception from HRESULT: 0x8007054B)
    VERBOSE: [Get-DomainObject] Get-DomainObject filter string: (objectClass=*)

The fix implemented here is to perform more specific pattern matching
prior to falling back to looking for a \. The order is SID, DN, GUID,
qualified name (DOMAIN\name), and then plain name.
2017-04-05 14:05:51 +01:00
Jon Cave f2a9cb2ecc The DFS subfunctions only accept a single $Domain
Specifying the type as an array of strings results in an error when
passing on the parameter to Get-DomainSearcher:

    C:\> Get-DomainDFSShare -Domain test
    Get-DomainSearcher : Cannot process argument transformation on parameter 'Domain'. Cannot convert value to type System.String.
    At PowerView.ps1:10242 char:46
2017-04-05 13:15:54 +01:00
HarmJ0y 445f7b2510 Changed -KerberosPreauthNotRequired to -PreauthNotRequired 2017-01-16 23:52:19 -05:00
HarmJ0y 454e04005d Standardized output from Find-InterestingDomainAcl 2017-01-11 20:39:57 -05:00
HarmJ0y ea60b0e0a4 Merge branch 'dev' of github.com:PowerShellMafia/PowerSploit into dev 2017-01-11 20:16:20 -05:00
HarmJ0y 510cba8bcd Added displayname to the default filter set for Get-DomainObject[ACL] 2017-01-11 20:16:01 -05:00
HarmJ0y 1dd560b371 Merge pull request #210 from leechristensen/patch-3
Fixed KerberosPreauthNotRequired
2017-01-11 16:16:25 -08:00
HarmJ0y 8a2e1daaa3 Parenthesis for additional LDAP functions 2017-01-11 19:04:56 -05:00
HarmJ0y fa1baa64a8 Parenthesis escaping for Get-DomainObject DN searches 2017-01-11 18:00:27 -05:00
HarmJ0y d4166f80d4 bug fix for Get-DomainObject/Get-DomainObjectACL 2017-01-11 15:55:35 -05:00
HarmJ0y 6c113b7956 Fixed bug in Convert-ADName that output an array including null values instead of a string 2017-01-11 14:03:46 -05:00
Lee Christensen e08432954e Fixed KerberosPreauthNotRequired 2017-01-11 08:09:49 -08:00
HarmJ0y ce19ebd9ed Merge branch 'dev' of github.com:PowerShellMafia/PowerSploit into dev 2017-01-10 18:32:07 -05:00
HarmJ0y 9ea5c5b7f5 Couple of fixes for Get-DomainSPNTicket 2017-01-10 18:31:30 -05:00
Lee Christensen aecb0b57a4 Words :P 2017-01-09 22:18:36 -08:00
HarmJ0y 3f7a32d623 Get-DomainSPNTicket/Invoke-Kerberoast now include 'real' user data in the hash output.
Added a bit more error handling when requesting the SPN kerberos ticket.
2017-01-08 22:28:51 -05:00
Mike Brancato d1060930c7 Fix errors gathering the forest SID
Pull the SID directly from the 'krbtgt' user to avoid errors in ConvertTo-SID
2017-01-04 23:23:25 -05:00
HarmJ0y 96ae5e3f61 type correction 2016-12-20 23:13:46 -05:00
HarmJ0y 9853900578 Type fix.
Added -TrustedToAuth to Get-DomainUser
2016-12-15 19:04:53 -05:00
HarmJ0y 831dde1268 Bug fix for the Find-DomainUserLocation bug fix :) 2016-12-15 12:45:18 -05:00
HarmJ0y 601ad0cf3f Logic bug fix in Get-DomainFileServer
-Domain bug fix in Find-DomainUserLocation stealth
2016-12-15 12:32:17 -05:00
HarmJ0y ad32d6c75b For ./Recon/ :
-(More) PSScriptAnalyzering
    -Tweaking of synopsis blocks in order to support platyPS
    -Code standardization
    -Generated docs
2016-12-14 19:23:28 -05:00
HarmJ0y 85b374c05b -Fixes for PSScriptAnalyzer compatibility
-More error handling
2016-12-14 13:39:50 -05:00
HarmJ0y f00e3fc6c4 Added Set-DomainObjectOwner to modify an object's owner
Modified Convert-LDAPProperty to break out sections of ntsecuritydescriptor
2016-12-13 17:21:10 -05:00
HarmJ0y f4f5fb1460 Added Set-DomainUserPassword to reset a particular user's password.
Reformatted documentation.
2016-12-13 16:00:28 -05:00
HarmJ0y 7f10db7827 Added spacing to prep for platyPS doc generation. 2016-12-12 21:00:43 -05:00
HarmJ0y 6aca12a956 Typo correction and Recon README.md update 2016-12-12 20:36:42 -05:00
HarmJ0y 32bd21e335 bug fix in Get-DomainSearcher 2016-12-12 19:02:26 -05:00
HarmJ0y 7c32bf69f3 -Complete ground-up rewrite of PowerView
-Lots of function cleanup/code rot removal and standardization
    -Additional options added to Get-DomainSearcher in order to support new param sets
    -Expanded parameter validation
    -XML help format standardized
    -PSScriptAnalyzer fixups- passes PS script analyzer now!
    -Nearly all functions should tag custom types to output objectsx
-Identity supported by all appropriate functions
-Transformed all filters to functions
-Expanded the formats for Convert-ADName
-Get-SPNTicket returns enc part automatically now, and Hashcat output format added
-Write-Verbose/Write-Warning/Throw messages now have the function name tagged in the message
-Verb-Domain* functions now all include a -FindOne function to return one result
-Get-DomainUserEvent now uses -XPathFilter for a massive speedup
-ALL Verb-Domain* (LDAP) functions now return full data objects (no more -FullData). Use -Properties for paring down.
-Lots of bug fixes
-"Required Dependencies" for each function completed
-Fixed logic bugs for -ComputerIdentity in Get-DomainGPO, now enumerates domain-linked GPOs as well
-Added -UserIdentity to Get-DomainGPO to enumerate GPOs applied to a given user identity

New function naming scheme with proper Verb-PrefixNoun syntax to better match the 'real' AD cmdlets:
    Verbs:
        Get     - retrieve full raw data sets
        Find    - 'find' specific data entries in a data set or execute threaded computer enumeration
        Add     - add a new object to a destination
        Set     - modify a given object
        Invoke  - lazy catch-all
    Prefixes now give an indication of the data source:
        Verb-DomainX    -   LDAP/.NET AD connections (e.g. Get-DomainUser)
        Verb-WMIX       -   Uses WMI for connections/enumeration of a specific host (e.g. Get-WMIRegLastLoggedOn)
        Verb-NetX       -   API access (e.g. Get-NetSession)
    Nouns have been renamed to be more descriptive
    Big gotcha:
        Get-NetLocalGroup - now returns local *groups* themselves
        Get-NetLocalGroupMember - returns local group *members* (old Get-NetLocalGroup)

-Parameter sets standardized - parameters shared as appropriate across functions
    -Identity -> replaces -UserName/-GroupName/etc. Accepts samAccountName, GUID, distinguishedName, SID
        -these can be used in tandem -> Get-DomainUser "S-1-5-21-890171859-3433809279-3366196753-1108","administrator"
    -Properties -> return only the specified properties (i.e. Get-DomainUser -Properties samAccountName,lastLogon
    -LDAPFilter replaces -Filter, -SearchBase replaces -ADSPath, -Server replaces -DomainController
    -ServerTimeLimit, -SearchScope, -Tombstone, -SecurityMasks added for most functions

All functions (as appropriate) now support -Credential:
    -Verb-Domain* (LDAP) functions use alternate creds for a DirectorySearcher through Get-DomainSearcher
    -COM methods (i.e. Convert-ADName) use appropriate initializations
    -Verb-WMI methods pass the -Credential through as appropriate
    -Verb-Net* (API) functions use Invoke-UserImpersonation/Invoke-RevertToSelf implicitly for token impersonation

Removed functions:
    Get-ComputerProperty, Get-UserProperty, Find-ComputerField, Find-UserField
    Get-NameField (translated to ValueFromPipelineByPropertyName calls)
    Invoke-DowngradeAccount - not used
    Add-NetUser - split into New-DomainUser/others
    Add-NetGroupUser - split into Add-DomainGroupMember/others
    New-GPOImmediateTask - inconsistent and better done manually
    Invoke-StealthUserHunter - combined into Find-DomainUserLocation
    Get-ExploitableSystem

Added helper functions:
    Get-PrincipalContext - helper to return a DirectoryServices.AccountManagement.PrincipalContext
    Get-ForestSchemaClass - returns the forest schema for a specified object class

Added exported functions:
    Add-RemoteConnection - 'mounts' a remote UNC path using WNetAddConnection2W
    Remove-RemoteConnection - 'unmounts' a remote UNC path using WNetCancelConnection2
    Invoke-UserImpersonation - creates a new "runas /netonly" type logon and impersonates the token in the current thread
    Invoke-RevertToSelf - reverts any token impersonation
    Invoke-Kerberoast - automates Kerberoasting
    Find-DomainObjectPropertyOutlier - finds user/group/computer objects in AD that have 'outlier' properties sets
    New-DomainUser - creates a new domain user
    New-DomainGroup - creates a new domain group
    Add-DomainGroupMember - adds a domain user (or group) to an existing domain group
    Get-NetLocalGroup - now returns local *groups* themselves
    Get-NetLocalGroupMember - returns local group *members* (old Get-NetLocalGroup)

Renamed functions (aliases created for old functions):
    Get-IPAddress -> Resolve-IPAddress
    Convert-NameToSid -> ConvertTo-SID
    Convert-SidToName -> ConvertFrom-SID
    Request-SPNTicket -> Get-DomainSPNTicket
    Get-DNSZone -> Get-DomainDNSZone
    Get-DNSRecord -> Get-DomainDNSRecord
    Get-NetDomain -> Get-Domain
    Get-NetDomainController -> Get-DomainController
    Get-NetForest -> Get-Forest
    Get-NetForestDomain -> Get-ForestDomain
    Get-NetForestCatalog -> Get-ForestGlobalCatalog
    Get-NetUser -> Get-DomainUser
    Get-UserEvent -> Get-DomainUserEvent
    Get-NetComputer -> Get-DomainComputer
    Get-ADObject -> Get-DomainObject
    Set-ADObject -> Set-DomainObject
    Get-ObjectAcl -> Get-DomainObjectAcl
    Add-ObjectAcl -> Add-DomainObjectAcl
    Invoke-ACLScanner -> Find-InterestingDomainAcl
    Get-GUIDMap -> Get-DomainGUIDMap
    Get-NetOU -> Get-DomainOU
    Get-NetSite -> Get-DomainSite
    Get-NetSubnet -> Get-DomainSubnet
    Get-NetGroup -> Get-DomainGroup
    Find-ManagedSecurityGroups -> Get-DomainManagedSecurityGroup
    Get-NetGroupMember -> Get-DomainGroupMember
    Get-NetFileServer -> Get-DomainFileServer
    Get-DFSshare -> Get-DomainDFSShare
    Get-NetGPO -> Get-DomainGPO
    Get-NetGPOGroup -> Get-DomainGPOLocalGroup
    Find-GPOLocation -> Get-DomainGPOUserLocalGroupMapping
    Find-GPOComputerAdmin -> Get-DomainGPOComputerLocalGroupMappin
    Get-LoggedOnLocal -> Get-RegLoggedOn
    Test-AdminAccess -> Invoke-CheckLocalAdminAccess
    Get-SiteName -> Get-NetComputerSiteName
    Get-Proxy -> Get-WMIRegProxy
    Get-LastLoggedOn -> Get-WMIRegLastLoggedOn
    Get-CachedRDPConnection -> Get-WMIRegCachedRDPConnection
    Get-RegistryMountedDrive -> Get-WMIRegMountedDrive
    Get-NetProcess -> Get-WMIProcess
    Invoke-ThreadedFunction -> New-ThreadedFunction
    Invoke-UserHunter -> Find-DomainUserLocation
    Invoke-ProcessHunter -> Find-DomainProcess
    Invoke-EventHunter -> Find-DomainUserEvent
    Invoke-ShareFinder -> Find-DomainShare
    Invoke-FileFinder -> Find-InterestingDomainShareFile
    Invoke-EnumerateLocalAdmin -> Find-DomainLocalGroupMember
    Get-NetDomainTrust -> Get-DomainTrust
    Get-NetForestTrust -> Get-ForestTrust
    Find-ForeignUser -> Get-DomainForeignUser
    Find-ForeignGroup -> Get-DomainForeignGroupMember
    Invoke-MapDomainTrust -> Get-DomainTrustMapping
2016-12-12 14:35:05 -05:00
Antonio Quina 7b49e54eec Updated Get-ExploitableSystem
Removed *_netapi from Vista/2008 in Get-ExploitableSystem as they are not vulnerable
2016-12-01 09:19:54 +01:00
HarmJ0y 67dab8651c Merge pull request #187 from Meatballs1/filter_getnetfileservers
Add disabled and present searches to get-netfileservers
2016-12-01 01:03:38 -05:00
HarmJ0y 520bf436ce Merge pull request #174 from Meatballs1/securitygroups
Retrieve Security groups by default
2016-12-01 01:03:11 -05:00
Meatballs a70bbe6164
Add disabled and present searches to get-netfileservers 2016-11-01 14:11:44 +00:00
Nick Landers 8e41548e65 Break on ticket capture 2016-09-13 16:59:03 -06:00
HarmJ0y 5e2200bab7 Merge pull request #173 from joncave/user_polling
PowerView: Invoke-UserHunter -Poll
2016-09-06 13:45:45 -07:00
Matan Hart 432cc017ba Add the EncPart param to Request-SPNTicket
Adds the ability to return the encrypted part of the ticket. 
This portion is the encrypted data that can be brute-forced with Kerberoast/Hashcat/JtR
2016-08-25 12:27:15 +03:00
Meatballs 917a095a81
Modify dependent functions 2016-08-13 20:26:29 +01:00
Meatballs 462c6e83cb
Retrieve Security groups by default 2016-08-13 20:21:23 +01:00
Jon Cave 9b365e82b1 Continuously collect output from background threads
The PowerShell.BeginInvoke<TInput, TOutput>(PSDataCollection<TInput>,
 PSDataCollection<TOutput>) method[1] is used to collect output from
each job into a buffer. This can be read whilst the jobs are still
running. Being able to return partial results is particularly useful for
long running background threads, such as Invoke-UserHunter -Poll.

PowerShell 2.0 doesn't play nicely with generic methods. The technique
described in [2] is used to allow this version of BeginInvoke() to be
used.

[1] https://msdn.microsoft.com/en-us/library/dd182440(v=vs.85).aspx
[2] http://www.leeholmes.com/blog/2007/06/19/invoking-generic-methods-on-non-generic-classes-in-powershell/
2016-08-13 12:14:35 +01:00
Jon Cave fda456338f Add a polling mode to Invoke-UserHunter
Repeatedly poll a set of target computers for user sessions. This could
be a useful technique for building a much better picture of current
sessions, but without having to communicate with every host.

The -Poll parameter is used to specify the duration for which polling
should occur. Each target computer is dedicated with a thread with
-Delay and -Jitter specifying how long to sleep between each session
enumeration attempt of an individual host.
2016-08-13 12:00:44 +01:00
Harmj0y 038adce56e type 2016-07-15 17:34:23 -04:00
Harmj0y b74e515198 Fix for issue #167 2016-07-15 17:33:04 -04:00
Jon Cave 325cc849d7 Use correct variable 2016-06-27 17:53:59 +02:00
Jon Cave 5a05a024b6 Fix Get-GroupsXML for multiple <Group> tags
Select all <Group> nodes and iterate through them, not just the root
<Groups> node.
2016-06-27 17:52:28 +02:00
Harmj0y 81ac124f22 Changed Get-NetGroup and Get-NetGroupMember to search for samaccountname instead of name 2016-06-24 16:51:16 -04:00
Harmj0y 3049211f53 Fixed Find-LocalAdminAccess to properly check for the object output from Invoke-CheckLocalAdminAccess...whoops 2016-06-24 16:11:20 -04:00
Harmj0y cd1e10b8fd Turned Get-GptTmpl and Get-GroupsXML into filters 2016-06-24 16:07:26 -04:00