Benign powershell Download

install.ps1

Invokes PowerShell HTTP request cmdletCalls a provider property setter cmdlet
SHA-256eb29cbebac0c464b01a7d473ccacc1aa6aff63eef3dda68c230d366f8a99dc69

Evidence

Comment line documents piped eval lines 1–10
1# turnout installer for Windows:
2# irm https://raw.githubusercontent.com/lacodda/turnout/main/tools/install.ps1 | iex
3$ErrorActionPreference = "Stop"
4
5$repo = "lacodda/turnout"
6
7# The tag comes from the /releases/latest redirect rather than the REST API:
8# unauthenticated API calls are capped at 60 per hour per IP, and an installer
9# that fails because someone else on the same address ran it is no installer.
10# $env:TURNOUT_VERSION p …
References the .NET HttpWebRequest class lines 11–18
11:2… tag = $env:TURNOUT_VERSION
12if (-not $tag) {
13 $request = [Net.HttpWebRequest]::Create("https://github.com/$repo/releases/latest")
14 $request.AllowAutoRedirect = $false
15 $request.UserAgent = "turnout-installer"
16 try {
17 $response = $request.GetResponse()
18 $tag = ($response.Headers["Location"] -split …
Invokes PowerShell HTTP request cmdlet lines 25–46
25:103… .Y.Z)"
26}
27
28$name = "turnout-$tag-x86_64-pc-windows-msvc"
29$url = "https://github.com/$repo/releases/download/$tag/$name.zip"
30$dir = if ($env:TURNOUT_INSTALL_DIR) { $env:TURNOUT_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA "Programs\turnout" }
31$tmp = Join-Path ([IO.Path]::GetTempPath()) "turnout-install-$([guid]::NewGuid())"
32New-Item -ItemType Directory -Force $tmp | Out-Null
33
34$binary = Join-Path $dir "turnout.exe"
35$alias = Join-Path $dir "tn.exe"
36# Asked before anything moves: an alias of ours that steps aside below must
37# not make another `tn` further down the PATH look like the one that answers.
38$existing = Get-Command tn -ErrorAction SilentlyContinue
39try {
40 Write-Host "Downloading $url"
41 Invoke-WebRequest $url -OutFile (Join-Path $tmp "turnout.zip")
42 Expand-Archive (Join-Path $tmp "turnout.zip") -DestinationPath $tmp -Force
43 New-Item -ItemType Directory -Force $dir | Out-Null
44 # A running turnout.exe cannot be overwritten or deleted, but it can be
45 # renamed: the old one steps aside, so an update does not fail while a
46 # gateway or a dev server runs. tn.ex …
PowerShell Remove-Item with -Recurse switch lines 48–59
48:34… by the next install once it no longer runs.
49 foreach ($old in $binary, $alias) {
50 if (Test-Path $old) {
51 Move-Item $old "$old.old-$([guid]::NewGuid())" -Force
52 }
53 }
54 Copy-Item (Join-Path $tmp "$name\turnout.exe") $binary -Force
55} finally {
56 Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
57}
58# What stepped aside, and the copies updates left before the alias became a
59# link. One …
Windows per-user Environment registry key lines 74–78
74:13… he binary is in place, the user is told where.
75try {
76 $key = Get-Item "HKCU:\Environment"
77 $raw = [string]$key.GetValue("Path", "", "DoNotExpandEnvironmentNames")
78 $entries = @($raw -split ";" | Where-Object { …

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.