Created
November 16, 2021 15:25
-
-
Save awakecoding/bb1379865111e994cc71257c0707cc1a to your computer and use it in GitHub Desktop.
npcap-install.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $NpcapVersion = "1.31" | |
| $NpcapInstallerFile = "npcap-$NpcapVersion.exe" | |
| $NpcapDownloadUrl = "https://nmap.org/npcap/dist/$NpcapInstallerFile" | |
| if (-Not (Test-Path -Path $NpcapInstallerFile)) { | |
| Invoke-WebRequest -Uri $NpcapDownloadUrl -OutFile $NpcapInstallerFile | |
| } | |
| $NpcapInstallerDir = "$PWD\npcap-$NpcapVersion" | |
| Remove-Item -Path $NpcapInstallerDir -Recurse -ErrorAction SilentlyContinue -Force | Out-Null | |
| & '7z' 'x' ".\$NpcapInstallerFile" "-o$NpcapInstallerDir" "-aot" | |
| Get-ChildItem "$NpcapInstallerDir\*_1.*" -Recurse | ForEach-Object { | |
| Move-Item -Path $($_ -Replace "_1", "") -Destination $($_ -Replace "_1", "_0") | |
| } | |
| # Install-Module Pscx -Scope AllUsers -AllowClobber | |
| Get-ChildItem $NpcapInstallerDir -Include @("*_*.dll","*_*.exe") -Recurse | ForEach-Object { | |
| $PEHeader = Get-PEHeader $_ | |
| if ($PEHeader.Type -ne 'PE64') { | |
| Remove-Item $_.FullName | |
| } | |
| } | |
| Get-ChildItem $NpcapInstallerDir -Include @("*_0.dll","*_0.exe") -Recurse | ForEach-Object { | |
| Move-Item -Path $_ -Destination $($_ -Replace "_0", "") # TODO: better regex | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment