# Author: Scott Sutherland, NetSPI (@_nullbind / nullbind) # Define the function to extract username and password from a jboss-cli.xml file and return an object function Get-JbossCredentials { param ( [string]$FilePath ) # Check if the file exists if (-not (Test-Path -Path $FilePath)) { Write-Error "File not found: $FilePath" return $null } # Load the XML file [xml]$jbossCliXml = Get-Content -Path $FilePath # Extract the username and password $username = $jbossCliXml."jboss-cli".authentication.username $password = $jbossCliXml."jboss-cli".authentication.password # Return a PowerShell object with the username and password return [pscustomobject]@{ Username = $username Password = $password } } # Example usage $xmlFilePath = "c:\temp\configs\jboss-cli.xml" $credentials = Get-JbossCredentials -FilePath $xmlFilePath # Output the returned object (optional for testing) $credentials <# jboss-cli.xml 127.0.0.1 9990 admin password false true 500 #>