Benign powershell Download

install.ps1

Invokes PowerShell HTTP request cmdletInvokes PowerShell REST request cmdlet
SHA-25610cb2f4dd80b4fdb5478e6d025b171d7e9df3a7fb825199f736e277209f633fa

Evidence

Comment line documents piped eval lines 1–15
1# grafel one-line installer for Windows.
2#
3# Usage:
4# irm https://raw.githubusercontent.com/cajasmota/grafel/main/install.ps1 | iex
5#
6# Environment variables:
7# GRAFEL_VERSION Release tag to install (default: latest, e.g. v0.1.0)
8# GRAFEL_FORCE If "1", overwrite an existing install without warning.
9# GRAFEL_PREFIX Install prefix (default: $env:USERPROFILE\.grafel)
10# GRAFEL_ARCHIVE Path to a LOCAL release .zip to install from, instead of
11# downloading one. Skips version resolution, download and
12# checksum verification — you are asserting you trust the
13# file you just pointed at. Exists so CI can execute this
14# script end-to-end against a freshly built binary (see
15# …
Defines Pass/Fail/Bad helper functions lines 16–33
16:21… an offline install from a hand-downloaded release asset.
17
18#Requires -Version 5.1
19
20$ErrorActionPreference = 'Stop'
21[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
22
23$Repo = 'cajasmota/grafel'
24$Prefix = if ($env:GRAFEL_PREFIX) { $env:GRAFEL_PREFIX } else { Join-Path $env:USERPROFILE '.grafel' }
25$BinDir = Join-Path $Prefix 'bin'
26$TmpDir = Join-Path $env:TEMP ("grafel-install-" + [Guid]::NewGuid().ToString('N'))
27
28function Write-Info($msg) { Write-Host $msg }
29function Fail($msg) { Write-Error $msg; exit 1 }
30
31function Get-Arch {
32 $procArch = $env:PROCESSOR_ARCHITECTURE
33 if ($env:PROCESSOR_ARCH …
Invokes PowerShell REST request cmdlet lines 71–77
71:40… iable than scraping a redirect header.
72 try {
73 $api = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -UseBasicParsing -ErrorAction Stop
74 if ($api -and $api.tag_name) { $ver = $api.tag_name.Trim() }
75 } catch {
76 $ver = $null
77 } …
Invokes PowerShell HTTP request cmdlet lines 80–86
80:24… te-limited.
81 if (-not (Test-Version $ver)) {
82 $url = "https://github.com/$Repo/releases/latest"
83 try {
84 $resp = Invoke-WebRequest -Uri $url -UseBasicParsing -MaximumRedirection 0 -ErrorAction SilentlyContinue
85 } catch {
86 $resp = $_.Exception.Re …
Downloads a file with PowerShell lines 110–123
110:43… {
111 for ($i = 1; $i -le 3; $i++) {
112 try {
113 Invoke-WebRequest -Uri $Uri -OutFile $OutFile -UseBasicParsing
114 return
115 } catch {
116 if ($i -eq 3) { Fail "failed to download $Uri : $_" }
117 Start-Sleep -Seconds 2
118 }
119 }
⋯4 lines

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.