Skip to content

Commit

Permalink
Update PowerUpSQL.ps1
Browse files Browse the repository at this point in the history
Add optional sql link crawl to invoke-sqldumpinfo.
  • Loading branch information
nullbind authored May 21, 2024
1 parent 3179bd7 commit a83cad2
Showing 1 changed file with 40 additions and 19 deletions.
59 changes: 40 additions & 19 deletions PowerUpSQL.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
File: PowerUpSQL.ps1
Author: Scott Sutherland (@_nullbind), NetSPI - 2023
Major Contributors: Antti Rantasaari and Eric Gruber
Version: 1.128
Version: 1.129
Description: PowerUpSQL is a PowerShell toolkit for attacking SQL Server.
License: BSD 3-Clause
Required Dependencies: PowerShell v.2
Expand Down Expand Up @@ -12625,9 +12625,9 @@ Function Get-SQLStoredProcedureCLR
# Check count
$CLRCount = $TblAssemblyFiles.Rows.Count
if ($CLRCount -gt 0){
Write-Verbose "$Instance : Found $CLRCount CLR stored procedures"
Write-Verbose "$Instance : - Found $CLRCount CLR stored procedures"
}else{
Write-Verbose "$Instance : No CLR stored procedures found."
Write-Verbose "$Instance : - No CLR stored procedures found."
}

# Return data
Expand Down Expand Up @@ -26810,7 +26810,12 @@ Function Invoke-SQLDumpInfo

[Parameter(Mandatory = $false,
HelpMessage = 'Write output to csv files.')]
[switch]$csv
[switch]$csv,

[Parameter(Mandatory = $false,
HelpMessage = 'Crawl available SQL Server links.')]
[switch]$CrawlLinks

)

Begin
Expand Down Expand Up @@ -27071,20 +27076,6 @@ Function Invoke-SQLDumpInfo
$Results | Export-Csv -NoTypeInformation $OutPutPath
}

# Getting Server Links
Write-Verbose -Message "$Instance - Getting server links..."
$Results = Get-SQLServerLink -Instance $Instance -Username $Username -Password $Password -Credential $Credential -SuppressVerbose
if($xml)
{
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.xml'
$Results | Export-Clixml $OutPutPath
}
else
{
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.csv'
$Results | Export-Csv -NoTypeInformation $OutPutPath
}

# Getting Server Credentials
Write-Verbose -Message "$Instance - Getting server credentials..."
$Results = Get-SQLServerCredential -Instance $Instance -Username $Username -Password $Password -Credential $Credential -SuppressVerbose
Expand Down Expand Up @@ -27350,7 +27341,37 @@ Function Invoke-SQLDumpInfo
{
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_oledbproviders.csv'
$Results | Export-Csv -NoTypeInformation $OutPutPath
}
}

# Getting Server Links
Write-Verbose -Message "$Instance - Getting server links..."
$Results = Get-SQLServerLink -Instance $Instance -Username $Username -Password $Password -Credential $Credential -SuppressVerbose
if($xml)
{
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.xml'
$Results | Export-Clixml $OutPutPath
}
else
{
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.csv'
$Results | Export-Csv -NoTypeInformation $OutPutPath
}

# Getting Server Links via Crawl
if($CrawlLinks){
Write-Verbose -Message "$Instance - Crawling linked servers..."
$Results = Get-SQLServerLinkCrawl -Instance $Instance -Username $Username -Password $Password -Credential $Credential -Export2
if($xml)
{
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links_crawl.xml'
$Results | Export-Clixml $OutPutPath
}
else
{
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links_crawl.csv'
$Results | Export-Csv -NoTypeInformation $OutPutPath
}
}

Write-Verbose -Message "$Instance - END"
}
Expand Down

0 comments on commit a83cad2

Please sign in to comment.