33 File: PowerUpSQL.ps1
44 Author: Scott Sutherland (@_nullbind), NetSPI - 2016
55 Major Contributors: Antti Rantasaari and Eric Gruber
6- Version: 1.103.2
6+ Version: 1.103.3
77 Description: PowerUpSQL is a PowerShell toolkit for attacking SQL Server.
88 License: BSD 3-Clause
99 Required Dependencies: PowerShell v.2
@@ -7008,27 +7008,30 @@ Function Get-SQLDomainObject
70087008 $ServerInfo = Get-SQLServerInfo -Instance $Instance -Username $Username -Password $Password -Credential $Credential -SuppressVerbose
70097009 $DomainName = $ServerInfo.DomainName
70107010 $IsSysadmin = $ServerInfo.IsSysadmin
7011+ $ServiceAccount = $ServerInfo.ServiceAccount
70117012 $SQLServerMajorVersion = $ServerInfo.SQLServerMajorVersion
70127013 $SQLServerEdition = $ServerInfo.SQLServerEdition
70137014 $SQLServerVersionNumber = $ServerInfo.SQLServerVersionNumber
70147015 $SQLCurrentLogin = $ServerInfo.Currentlogin
70157016
70167017 # Status user
70177018 If (-not($SuppressVerbose)){
7019+ Write-Verbose -Message "$instance : Login: $SQLCurrentLogin"
70187020 Write-Verbose -Message "$Instance : Domain: $DomainName"
70197021 Write-Verbose -Message "$Instance : Version: SQL Server $SQLServerMajorVersion $SQLServerEdition ($SQLServerVersionNumber)"
70207022 }
70217023
70227024 if($IsSysadmin -eq "No")
70237025 {
70247026 If (-not($SuppressVerbose)){
7027+ Write-Verbose -Message "$Instance : Sysadmin: No"
70257028 Write-Verbose -Message "$Instance : This command requires sysadmin privileges. Exiting."
70267029 }
70277030 return
70287031 }else{
70297032
70307033 If (-not($SuppressVerbose)){
7031- Write-Verbose -Message "$Instance : You have sysadmin privileges. "
7034+ Write-Verbose -Message "$Instance : Sysadmin: Yes "
70327035 }
70337036 }
70347037
@@ -7055,16 +7058,26 @@ Function Get-SQLDomainObject
70557058 # Check if adsi is installed and can run in process
70567059 $CheckEnabled = Get-SQLOleDbProvder -Instance $Instance -Username $Username -Password $Password -SuppressVerbose | Where ProviderName -like "ADsDSOObject" | Select-Object AllowInProcess -ExpandProperty AllowInProcess
70577060 if ($CheckEnabled -ne 1){
7061+ Write-Verbose -Message "$Instance : ADsDSOObject provider allowed to run in process: No"
70587062 Write-Verbose -Message "$Instance : The ADsDSOObject provider is not allowed to run in process. Stopping operation."
70597063 return
70607064 }else{
7061- Write-Verbose -Message "$Instance : The ADsDSOObject provider is allowed to run in process. "
7065+ Write-Verbose -Message "$Instance : ADsDSOObject provider allowed to run in process: Yes "
70627066 }
70637067
70647068 # Determine query type
70657069 if($UseAdHoc){
7066- If (-not($SuppressVerbose)){
7067- Write-Verbose -Message "$Instance : Executing in AdHoc mode using OpenRowSet."
7070+ If (-not($SuppressVerbose)){
7071+
7072+ if ($SQLCurrentLogin -like "*\*"){
7073+ Write-Verbose -Message "$Instance : Executing in AdHoc mode using OpenRowSet as '$SQLCurrentLogin'."
7074+ }else{
7075+ if(-not $LinkUsername){
7076+ Write-Verbose -Message "$Instance : Executing in AdHoc mode using OpenRowSet as the SQL Server service account ($ServiceAccount)."
7077+ }else{
7078+ Write-Verbose -Message "$Instance : Executing in AdHoc mode using OpenRowSet as '$LinkUsername'."
7079+ }
7080+ }
70687081 }
70697082 }else{
70707083 If (-not($SuppressVerbose)){
@@ -7120,7 +7133,7 @@ Function Get-SQLDomainObject
71207133
71217134 # Status user
71227135 If (-not($SuppressVerbose)){
7123- Write-Verbose -Message "$Instance : Associating current login with ADSI SQL Server link named $RandomLinkName."
7136+ Write-Verbose -Message "$Instance : Associating '$SQLCurrentLogin' with ADSI SQL Server link named $RandomLinkName."
71247137 }
71257138
71267139 $QueryAssociateLogin = "
@@ -7154,7 +7167,7 @@ Function Get-SQLDomainObject
71547167
71557168 # Status user
71567169 If (-not($SuppressVerbose)){
7157- Write-Verbose -Message "$Instance : Enabled 'Show Advanced Options'"
7170+ Write-Verbose -Message "$Instance : Enabling 'Show Advanced Options'"
71587171 }
71597172 }else{
71607173 If (-not($SuppressVerbose)){
@@ -7170,7 +7183,7 @@ Function Get-SQLDomainObject
71707183
71717184 # Status user
71727185 If (-not($SuppressVerbose)){
7173- Write-Verbose -Message "$Instance : Enabled 'Ad Hoc Distributed Queries'"
7186+ Write-Verbose -Message "$Instance : Enabling 'Ad Hoc Distributed Queries'"
71747187 }
71757188 }else{
71767189 If (-not($SuppressVerbose)){
0 commit comments