Category: Security

AzureSecurity

Find Java Based Azure App Services

A quick Azure PowerShell command to locate any Java based Azure App Services and Functions so you can check if they are vulnerable to the CVE-2021-44228 Apache Log4j2 vulnerability. Get-AzWebApp | ForEach-Object{ Get-AzWebApp -ResourceGroupName $_.ResourceGroup -Name $_.Name | Select-Object -Property Name, @{l='JavaVersion';e={$_.SiteConfig.JavaVersion}}, ResourceGroup, Id } | Format-Table
RemotingSecurity

Run PSExec From PowerShell

PowerShell remoting help in a lot of areas, but there are times when you need to use PSExec. For those instances, I’ve created a function that you can use to run a command on a remote machine using PSExec. Function ExecutePsExec($computer, $command){ $ping = Test-Connection $computer -Count 1 -Quiet if($ping){ $StdOutput = (Join-path $env:temp "$($computer).txt") Start-Process -FilePath $psexec -ArgumentList "-s...
Security

Expand Shortened URLs

# Create Web Request Object $request = [System.Net.WebRequest]::Create($url) # Make it think we are using Edge on Windows 10. Required for some shorteners. $request.UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246' # Get the expanded URL $request.GetResponse().ResponseUri.AbsoluteUri
Security

Elevate Script to Run As Administrator

# Request elevation with administration rights If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $arguments = "& '" + $myinvocation.mycommand.definition + "'" Start-Process powershell -Verb runAs -ArgumentList $arguments Break } else { # Code to run elevated here }