Skip to content

Instantly share code, notes, and snippets.

@R0rt1z2
Last active January 5, 2023 12:07
Show Gist options
  • Save R0rt1z2/f91883518b5d63eedc8412eebb433ce7 to your computer and use it in GitHub Desktop.
Save R0rt1z2/f91883518b5d63eedc8412eebb433ce7 to your computer and use it in GitHub Desktop.
Automated Ghidra Installer for Windows
#
# Invoke-WebRequest https://gist.githubusercontent.com/R0rt1z2/f91883518b5d63eedc8412eebb433ce7/raw/947dedc0455b778b7fd7e8a8c5d2266d86ed5ff0/GetGhidra.ps1 | Invoke-Expression
#
$ProgressPreference = 'SilentlyContinue'
$installPath = "C:\Program Files"
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "[-] This script must be run as Administrator." -ForegroundColor Red
exit
}
$latestVersion = (Invoke-WebRequest https://api.github.com/repos/NationalSecurityAgency/ghidra/releases/latest | ConvertFrom-Json).assets.browser_download_url
Write-Host "[+] Downloading Ghidra..." -ForegroundColor Green
Invoke-WebRequest -Uri $latestVersion -OutFile "$installPath\ghidra.zip"
Write-Host "[+] Extracting Ghidra..." -ForegroundColor Green
Expand-Archive -Path "$installPath\ghidra.zip" -DestinationPath $installPath
Remove-Item "$installPath\ghidra.zip"
Move-Item "$installPath\ghidra*" "$installPath\Ghidra"
$desktopPath = "$env:USERPROFILE\Desktop"
$desktopShortcut = New-Object -ComObject WScript.Shell
$desktopShortcutShortcut = $desktopShortcut.CreateShortcut("$desktopPath\Ghidra.lnk")
$desktopShortcutShortcut.TargetPath = "$installPath\Ghidra\ghidraRun.bat"
$desktopShortcutShortcut.IconLocation = "$installPath\Ghidra\support\ghidra.ico"
$desktopShortcutShortcut.Save()
$startMenuPath = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs"
$startMenuShortcut = New-Object -ComObject WScript.Shell
$startMenuShortcutShortcut = $startMenuShortcut.CreateShortcut("$startMenuPath\Ghidra.lnk")
$startMenuShortcutShortcut.TargetPath = "$installPath\Ghidra\ghidraRun.bat"
$startMenuShortcutShortcut.IconLocation = "$installPath\Ghidra\support\ghidra.ico"
$startMenuShortcutShortcut.Save()
$contextMenuPath = "$env:APPDATA\Microsoft\Windows\SendTo"
$contextMenuShortcut = New-Object -ComObject WScript.Shell
$contextMenuShortcutShortcut = $contextMenuShortcut.CreateShortcut("$contextMenuPath\Ghidra.lnk")
$contextMenuShortcutShortcut.TargetPath = "$installPath\Ghidra\ghidraRun.bat"
$contextMenuShortcutShortcut.IconLocation = "$installPath\Ghidra\support\ghidra.ico"
$contextMenuShortcutShortcut.Save()
Write-Host "[+] Ghidra has been installed." -ForegroundColor Green
Read-Host -Prompt "Press Enter to continue..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment