Skip to content

Nmap OEM 7.95 installer does not use "Nmap OEM" product name. Uninstaller fails. #2982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmiller-nmap opened this issue Dec 3, 2024 · 2 comments

Comments

@dmiller-nmap
Copy link

The build for Nmap OEM 7.95 installer defined the NMAP_NAME constant twice, so the second one was ignored, leading to an installer that installs the "Nmap" product but has an uninstaller expecting the "Nmap OEM" product name. This leads to the uninstaller failing to actually uninstall anything.

Future installers will have to be able to detect this situation and modify the installation to use the correct product name, otherwise users will be left with an uninstallable Nmap installation.

@dmiller-nmap
Copy link
Author

dmiller-nmap commented Dec 11, 2024

As a workaround, we have created a powershell script to repair existing installations (to be run as Administrator):

# Problem: Nmap OEM is installed using a standard Nmap install name.
# To diagnose: Test the product name of a file under a standard Nmap install. If it is "Nmap OEM" then the problem is present.
# Fix: Rename the install registry keys to "Nmap OEM"

$uninst_key = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
if ([System.Environment]::Is64BitProcess) {
	$uninst_key = $uninst_key.Replace("SOFTWARE", "SOFTWARE\Wow6432Node")
}
$software_key = "HKCU:\SOFTWARE"

# Check for a valid Nmap OEM install first:
if (Test-Path "$uninst_key\Nmap OEM") {
	# Valid Nmap OEM install
	Write-Host "Valid install found. Nothing to fix."
	exit
}

# Now check for a standard Nmap install
if (-not (Test-Path "$uninst_key\Nmap")) {
	Write-Host "No install found. Nothing to fix."
	exit
}
$old_dir = $null
if (Test-Path "$software_key\Nmap") {
	$old_dir = (Get-Item -Path "$software_key\Nmap").GetValue("")
}
if (-not $old_dir) {
	$old_dir = (Get-Item -Path "$uninst_key\Nmap").GetValue("UninstallString").Trim('"')
	$old_dir = Split-Path -Path $old_dir
}

# Check the product name for the uninstaller
$versioninfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$old_dir\Uninstall.exe")

if ($versioninfo.ProductName -ne "Nmap OEM") {
	# Valid standard Nmap install
	Write-Host "No invalid install found. Nothing to fix."
	exit
}

Write-Host "Modifying Nmap OEM installation at `"$old_dir`""
# Rename 2 registry keys
Start-Transaction
Rename-Item -UseTransaction -Path "$software_key\Nmap" -NewName "Nmap OEM"
Rename-Item -UseTransaction -Path "$uninst_key\Nmap" -NewName "Nmap OEM"
Set-ItemProperty -UseTransaction -Path "$uninst_key\Nmap OEM" -Name "DisplayName" -Value "Nmap OEM"
Set-ItemProperty -UseTransaction -Path "$uninst_key\Nmap OEM" -Name "DisplayVersion" -Value $versioninfo.FileVersion
Complete-Transaction
$status = (Get-Transaction).Status
if ($status -eq "Committed") {
	Write-Host "Succeeded."
}
else {
	Write-Host "Failed."
}

nmap-bot pushed a commit that referenced this issue Dec 17, 2024
@dmiller-nmap
Copy link
Author

Fixed in Nmap 7.96. Running the Nmap 7.96 installer (OEM or non-OEM) will fix the issue in the Registry, repairing the old installation even if the user does not choose to uninstall the buggy Nmap 7.95 OEM installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant