powershell-pro-obfuscator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 16a4bdd321a68a2ecfd70bf1a03067947a104471176732c7df1d2b823d6ad1af
4
+ data.tar.gz: 854028a6d0e35eeaef75de5e5974607c7bbe122fd2ede1a2710502bad4cff8fd
5
+ SHA512:
6
+ metadata.gz: 769bde19efafea59a826e612dc7c447f0567a432faa1d3fcc7d48b407d3693e3180acff421f47995b7b5b92fbac47d5544d35e668781eb67ade8ea3a52410e6f
7
+ data.tar.gz: bd9c2c401f7cfd36b1ca1e9d1640fc9c3166c2dcdabb3e5a4af3625091b04de473c8929128017b016915d9a39aeac27e5d37d45fdcba211dd676e41039b7897b
data/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Copyright 2026 Bartosz Wójcik
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright [yyyy] [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,418 @@
1
+ # PowerShell Pro Obfuscator — Obfuscate & Virtualize PowerShell Code
2
+
3
+ **PowerShell Pro Obfuscator** protects proprietary `.ps1` scripts with renaming, polymorphic string and integer encryption, control-flow flattening, finite-state automata (FSA), a VM engine, self-defending integrity checks, a protection linker, and anti-debugging probes.
4
+
5
+ Obfuscate, virtualize & protect PowerShell `.ps1` scripts with polymorphic string encryption, VM engine, finite-state automata transforms, self-integrity & anti-debugging checks — via GUI, CLI, online tool, or API.
6
+
7
+ More technical details, downloads, documentation available at:
8
+
9
+ https://www.pelock.com/products/powershell-pro-obfuscator
10
+
11
+ ![PowerShell Pro Obfuscator Windows Client](images/powershell-pro-obfuscator-virtualizer-1-0-main.png)
12
+
13
+ It's available for Windows & Linux:
14
+
15
+ * https://www.pelock.com/products/powershell-pro-obfuscator/download
16
+
17
+ Multiple programming APIs available:
18
+
19
+ * https://www.pelock.com/products/powershell-pro-obfuscator/api
20
+
21
+ An online obfuscator interface:
22
+
23
+ * https://www.pelock.com/powershell-pro-obfuscator/
24
+
25
+ ## Why PowerShell scripts need obfuscation?
26
+
27
+ Scripts are typically distributed as plain `.ps1` files or embedded in modules. That convenience means anyone with file access can read the full logic, hunt for credentials or API keys in strings, and steal your algorithms unless you take extra steps to hide intent.
28
+
29
+ [PowerShell](https://learn.microsoft.com/powershell/) is a cross-platform shell and scripting language built on .NET. It is widely used for automation, configuration, DevOps pipelines, and endpoint management on Windows and Linux.
30
+
31
+ ## Obfuscation strategies
32
+
33
+ PowerShell Pro Obfuscator comes with many advanced obfuscation, virtualization & protection strategies. You can easily tune protection versus size and performance.
34
+
35
+ ![PowerShell Obfuscation options](images/powershell-pro-obfuscator-virtualizer-1-0-options.png)
36
+
37
+ ### ![Obfuscation](images/obfuscation-32.png) Powerful obfuscation
38
+
39
+ PowerShell Pro Obfuscator uses state-of-the-art obfuscation strategies such as polymorphic string encryption, integers & floats encryption, and decoy noise. The result conceals literals and structure while preserving tested runtime behaviour.
40
+
41
+ ### ![Processor](images/processor-32.png) Code virtualization
42
+
43
+ Selected statements are lifted into a random generated VM engine opcodes with shuffled switch cases, decoy opcodes, and an obfuscated dispatcher loop. Analysts must interpret the virtual machine instead of reading plain PowerShell.
44
+
45
+ ### ![Node](images/node-32.png) Finite-state automata (FSA)
46
+
47
+ Finite-state automata (FSA) obfuscation rewrites linear PowerShell statement blocks into dual-state automata with opaque schedulers and shuffled dispatch handlers. Instead of reading code top to bottom, analysts must follow numeric states, transition tables, and decoy paths to reconstruct the original order.
48
+
49
+ ### ![Bug](images/bug-32.png) Anti-debugging
50
+
51
+ Anti-debugging protection inserts polymorphic probes that detect attached debuggers, PowerShell breakpoints, debug preference and tracing modes, and related host signals. When a check fires, the obfuscated script exits silently instead of revealing protected logic under interactive analysis.
52
+
53
+ ### ![System monitor](images/system-monitor-32.png) Self-integrity checks
54
+
55
+ A bootstrap probe verifies on-disk script shape (function counts and integrity tokens) and sets a tamper key when the file no longer matches the obfuscated build. String decryptors consume that key, so patched scripts return garbage instead of plaintext. This self-defending layer raises the cost of casual deobfuscation and file edits.
56
+
57
+ ### ![Brick link](images/brick-link-32.png) Protection linker
58
+
59
+ A late pass wires honeypot resolvers, bogus helper calls with random arguments, and shallow-stack tripwires that stay active only before bootstrap completes. Extracted snippets keep noisy call surfaces that look real under static review. Normal execution after a successful integrity check remains unchanged.
60
+
61
+ ## Before and after obfuscation
62
+
63
+ Look at this example — the same script becomes harder to read at a glance after obfuscation.
64
+
65
+ ### Sample PowerShell script before obfuscation
66
+
67
+ ```powershell
68
+ function Get-Greeting {
69
+ param([string]$Name)
70
+ Write-Host "Hello World from $Name!"
71
+ }
72
+ Get-Greeting "PowerShell Pro Obfuscator"
73
+ ```
74
+
75
+ ### After obfuscation
76
+
77
+ ```powershell
78
+ $script:_HnJTskg = 0
79
+ $jwNTQ = 297 * 400 + 36
80
+ $x4e8bfda = [Math]::Abs($jwNTQ - 8074)
81
+ $_EvKocNn = [Math]::Max($jwNTQ, $x4e8bfda) - [Math]::Min($jwNTQ, $x4e8bfda)
82
+ [void]$_EvKocNn
83
+ $script:_jUoXkBYh = 0
84
+ function gnJjzMCN3V8P {
85
+ param([int]$slot, [int]$salt, [int]$guard)
86
+ if (-not ((Get-Variable -Name _HnJTskg -Scope Script -ErrorAction SilentlyContinue).Value)) { return '' }
87
+ @('JFE', 'm0ao', 'R8Ysw') | ForEach-Object { $_.ToUpper() } | Out-Null
88
+ if ((((($slot * 31) + $salt) -band 65535) -ne $guard)) { return '' }
89
+ $tk = (Get-Variable -Name _jUoXkBYh -Scope Script -ErrorAction SilentlyContinue).Value
90
+ $IEm39CSpDOEFp = @{ 'Ouj1' = 455; 'vjzO' = 170; 'IQNV' = 291 }
91
+ $IEm39CSpDOEFp['R5LrM'] = $IEm39CSpDOEFp['Ouj1'] + $IEm39CSpDOEFp['vjzO']
92
+ $YWxSO = ($IEm39CSpDOEFp.Values | Measure-Object -Sum).Sum
93
+ [void]$YWxSO
94
+ if ($null -eq $tk) { [long]$tk = 0 }
95
+ $v93a130f2e4 = 508
96
+ switch ($v93a130f2e4) {
97
+ 524 { $_GYF7IA14Go = 'H1Vph' }
98
+ 561 { $_GYF7IA14Go = 'HAWoB' }
99
+ default { $_GYF7IA14Go = $v93a130f2e4 * 2 }
100
+ }
101
+ [void]$_GYF7IA14Go
102
+ $dk = (Get-Variable -Name vb6a18ffee4 -Scope Script -ErrorAction SilentlyContinue).Value
103
+ try { $xgLN5KZyEusFo7 = [Math]::Sqrt(850) } finally { [void]$xgLN5KZyEusFo7 }
104
+ if ($null -eq $dk) { [long]$dk = 0 }
105
+ $d = @(46866, 46865)
106
+ if ((((-not 113))-and(([int](272 -ne 272) -eq 21)))-and(([Math]::Sign(-12) -eq 4))) { $w4iTzi2hooy1GW = @(711, 562, 665); $w4iTzi2hooy1GW = ($w4iTzi2hooy1GW | Measure-Object -Sum).Sum }
107
+ $r = ''
108
+ for ($s9qOSpiZzufQlVyV = 0; $s9qOSpiZzufQlVyV -lt $d.Length; $s9qOSpiZzufQlVyV++) {
109
+ [long]$v = [long]$d[$s9qOSpiZzufQlVyV]
110
+ for ($jL9gL7PEtQeIS = 2; $jL9gL7PEtQeIS -ge 0; $jL9gL7PEtQeIS--) {
111
+ for ($PsbomDHxAy = 2; $PsbomDHxAy -ge 0; $PsbomDHxAy--) {
112
+ [long]$v = [long]$v + ([long](230))
113
+ }
114
+ }
115
+ for ($zhH33vzxjIzegl9 = 0; $zhH33vzxjIzegl9 -ge 0; $zhH33vzxjIzegl9--) {
116
+ [long]$v = [long]$v + ([long]([int]((((((236 + (-3 * $s9qOSpiZzufQlVyV) + (3 * $zhH33vzxjIzegl9))) % 256) + 256) % 256))))
117
+ [long]$v = [long]$v -bxor ([long](53766))
118
+ }
119
+ [long]$v = [long]$v - ([long]($salt + $slot + $tk + $dk + 0))
120
+ if ([long]$v -ge 0 -and [long]$v -le 0xFFFF) { $r += [char][int][long]$v }
121
+ elseif ([long]$v -ge 0x10000 -and [long]$v -le 0x10FFFF) { $r += [System.Char]::ConvertFromUtf32([int][long]$v) }
122
+ }
123
+ return $r
124
+ }
125
+ and more...
126
+ ```
127
+
128
+ Would you still recognise the original intent if you only had the obfuscated text and no prior copy of the script?
129
+
130
+ ![Obfuscated PowerShell script](images/powershell-pro-obfuscator-virtualizer-1-0-obfuscated.png)
131
+
132
+ ### How does PowerShell Pro Obfuscator work?
133
+
134
+ The engine parses PowerShell source into an AST tree, then applies selectable transforms: identifier renaming, control-flow flattening, finite-state automata (FSA), VM virtualization, polymorphic string and integer encryption, noise and decoy insertion, self-defending integrity probes, the protection linker, and anti-debugging checks. Many techniques are specific to this product; some ideas are shared with our other protection tools.
135
+
136
+ ![PowerShell Pro Obfuscator Pipeline](images/powershell-pro-obfuscator-pipeline.png)
137
+
138
+ When all passes finish, the engine emits a new `.ps1`. Edge cases in the PowerShell grammar and hosting environments mean you should always test the output in your target runtime.
139
+
140
+ ## Protect your PowerShell scripts & algorithms
141
+
142
+ Take no chances, use **PowerShell Pro Obfuscator** to obfuscate, virtualize and protect your PowerShell scripts and algorithms.
143
+
144
+ Our company has a long history in obfuscation technologies and code obfuscators (see our [x86 Assembly](https://www.pelock.com/products/obfuscator), [AutoIt](https://www.pelock.com/products/autoit-obfuscator) & [Java](https://www.pelock.com/products/jobfuscator) obfuscators).
145
+
146
+ We actively bugfix, research and develop new obfuscation strategies for our tools.
147
+
148
+ You can count on our expertise and support in this field.
149
+
150
+ ### Installation
151
+
152
+ The preferred way to install the Web API SDK is via RubyGems.
153
+
154
+ ```bash
155
+ gem install powershell-pro-obfuscator
156
+ ```
157
+
158
+ ```ruby
159
+ require "powershell-pro-obfuscator"
160
+ ```
161
+
162
+ The gem is published at https://rubygems.org/gems/powershell-pro-obfuscator
163
+
164
+ ## Usage examples
165
+
166
+ ### Example — `login.rb`
167
+
168
+ ```ruby
169
+ # frozen_string_literal: true
170
+
171
+ ###############################################################################
172
+ #
173
+ # PowerShell Pro Obfuscator WebApi interface usage example.
174
+ #
175
+ # In this example we will verify our activation key status.
176
+ #
177
+ # Version : v1.0.0
178
+ # Language : Ruby
179
+ # Author : Bartosz Wójcik
180
+ # Web page : https://www.pelock.com
181
+ #
182
+ ###############################################################################
183
+
184
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
185
+ require "powershell-pro-obfuscator"
186
+
187
+ result = PowerShellProObfuscator.new("ABCD-ABCD-ABCD-ABCD").login
188
+ if result
189
+ puts "Demo version status - #{result['demo']}"
190
+ puts "Usage credits left - #{result['credits_left']}"
191
+ puts "Total usage credits - #{result['credits_total']}"
192
+ puts "Max. source code size - #{result['string_limit']}"
193
+ else
194
+ warn "Something unexpected happen while trying to login to the service."
195
+ end
196
+ ```
197
+
198
+ ### Example — `options.rb`
199
+
200
+ ```ruby
201
+ # frozen_string_literal: true
202
+
203
+ ###############################################################################
204
+ #
205
+ # PowerShell Pro Obfuscator WebApi interface usage example.
206
+ #
207
+ # In this example we will obfuscate sample source with custom options.
208
+ #
209
+ # Version : v1.0.0
210
+ # Language : Ruby
211
+ # Author : Bartosz Wójcik
212
+ # Web page : https://www.pelock.com
213
+ #
214
+ ###############################################################################
215
+
216
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
217
+ require "powershell-pro-obfuscator"
218
+
219
+ client = PowerShellProObfuscator.new("ABCD-ABCD-ABCD-ABCD")
220
+
221
+ # should the source code be compressed (both input & compressed)
222
+ client.enable_compression = false
223
+
224
+ #
225
+ # global obfuscation options
226
+ #
227
+ # you can disable a particular obfuscation strategy globally if it
228
+ # fails or you don't want to use it without modifying the source codes
229
+ #
230
+ # by default all obfuscation strategies are enabled
231
+ #
232
+
233
+ # protection against tampering with protected code (integrity verification)
234
+ client.self_defending = true
235
+
236
+ # protection linker (decoy call graph)
237
+ client.protection_linker = true
238
+
239
+ # rename variable names to random string values
240
+ client.rename_variables = true
241
+
242
+ # rename parameter names to random string values
243
+ client.rename_parameters = true
244
+
245
+ # rename function names to random string values
246
+ client.rename_functions = true
247
+
248
+ # shuffle function order in the output source
249
+ client.shuffle_functions = true
250
+
251
+ # change linear code execution flow via control-flow flattening
252
+ client.control_flow_flatten = true
253
+
254
+ # rewrite statement blocks into finite-state automata (state-machine obfuscation)
255
+ client.state_machine = true
256
+
257
+ # lift selected statements into a VM engine (virtualized statements)
258
+ client.vm_strategy = true
259
+
260
+ # encrypt integers
261
+ client.encrypt_integers = true
262
+
263
+ # split strings into concatenated chunks
264
+ client.split_strings = true
265
+
266
+ # encrypt strings using randomly generated polymorphic encryption algorithms
267
+ client.encrypt_strings = true
268
+
269
+ # move integers to arrays
270
+ client.integers_to_arrays = true
271
+
272
+ # move floats to arrays
273
+ client.floats_to_arrays = true
274
+
275
+ # insert dead code
276
+ client.insert_dead_code = true
277
+
278
+ # replace boolean conditions with equivalent complex expressions
279
+ client.complexify_booleans = true
280
+
281
+ # represent integers via floating-point math
282
+ client.integers_to_floating = true
283
+
284
+ # encrypt floating point numbers
285
+ client.encrypt_floating = true
286
+
287
+ # insert decoy functions
288
+ client.decoy_functions = true
289
+
290
+ # insert anti-debugging detections
291
+ client.detect_debugger = true
292
+
293
+ # insert fake dot-source comment markers
294
+ client.fake_dot_source_markers = true
295
+
296
+ # insert opaque predicate branches
297
+ client.opaque_branches = true
298
+
299
+ # insert scriptblock decoys
300
+ client.scriptblock_decoys = true
301
+
302
+ # insert here-string padding
303
+ client.literal_padding = true
304
+
305
+ # use indirect command invocation
306
+ client.reflect_invoke_commands = true
307
+
308
+ # store string fragments in char-code array vaults
309
+ client.string_char_array_vault = true
310
+
311
+ # wrap code in try/finally blocks with dead noise
312
+ client.try_finally_noise = true
313
+
314
+ # apply redundant xor / affine integer masks
315
+ client.affine_integer_mask = true
316
+
317
+ # insert dead event/timer stubs
318
+ client.event_stub = true
319
+
320
+ # strip comments from the output source
321
+ client.remove_comments = true
322
+
323
+ source = <<~PS
324
+ function Get-Greeting {
325
+ param([string]$Name)
326
+ Write-Host "Hello World from $Name!"
327
+ }
328
+ Get-Greeting "PowerShell Pro Obfuscator"
329
+ PS
330
+
331
+ result = client.obfuscate_script_source(source)
332
+ if result && result["error"] == PowerShellProObfuscator::ERROR_SUCCESS
333
+ puts result["output"]
334
+ else
335
+ warn "An error occurred, error code: #{result && result['error']}"
336
+ end
337
+ ```
338
+
339
+ ### Example — `simple.rb`
340
+
341
+ ```ruby
342
+ # frozen_string_literal: true
343
+
344
+ ###############################################################################
345
+ #
346
+ # PowerShell Pro Obfuscator WebApi interface usage example.
347
+ #
348
+ # In this example we will obfuscate sample source with default options.
349
+ #
350
+ # Version : v1.0.0
351
+ # Language : Ruby
352
+ # Author : Bartosz Wójcik
353
+ # Web page : https://www.pelock.com
354
+ #
355
+ ###############################################################################
356
+
357
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
358
+ require "powershell-pro-obfuscator"
359
+
360
+ client = PowerShellProObfuscator.new("ABCD-ABCD-ABCD-ABCD")
361
+
362
+ source = <<~PS
363
+ function Get-Greeting {
364
+ param([string]$Name)
365
+ Write-Host "Hello World from $Name!"
366
+ }
367
+ Get-Greeting "PowerShell Pro Obfuscator"
368
+ PS
369
+
370
+ result = client.obfuscate_script_source(source)
371
+ if result && result["error"] == PowerShellProObfuscator::ERROR_SUCCESS
372
+ puts result["output"]
373
+ else
374
+ warn "An error occurred, error code: #{result && result['error']}"
375
+ end
376
+ ```
377
+
378
+ See the `examples/` directory in this repository for complete samples.
379
+
380
+ ## Use PowerShell Pro Obfuscator Online
381
+
382
+ Online interface for PowerShell Pro Obfuscator is available at:
383
+
384
+ https://www.pelock.com/powershell-pro-obfuscator/
385
+
386
+ ## Windows GUI client and command line version
387
+
388
+ #### PowerShell Pro Obfuscator comes also with full GUI version for Windows:
389
+
390
+ ![PowerShell Pro Obfuscator Windows Client](images/powershell-pro-obfuscator-virtualizer-1-0-main.png)
391
+
392
+ #### Obfuscation options:
393
+
394
+ ![PowerShell Obfuscation options](images/powershell-pro-obfuscator-virtualizer-1-0-options.png)
395
+
396
+ #### Obfuscated PowerShell script:
397
+
398
+ ![Obfuscated PowerShell script](images/powershell-pro-obfuscator-virtualizer-1-0-obfuscated.png)
399
+
400
+ ## Download
401
+
402
+ You can download it at:
403
+
404
+ https://www.pelock.com/products/powershell-pro-obfuscator/download
405
+
406
+ Installation package contains an additional command line interface:
407
+
408
+ ![PowerShell Pro Obfuscator command-line interface](images/powershell-pro-obfuscator-obfuscation-1-0-console-comand-line.png)
409
+
410
+ PowerShell Pro Obfuscator ships with a command-line interface for Windows and Linux automation.
411
+
412
+ Use it to integrate obfuscation into build servers, CI jobs, or batch packaging.
413
+
414
+ Bartosz Wójcik
415
+
416
+ * Visit my site at — https://www.pelock.com
417
+ * X — https://x.com/PELock
418
+ * GitHub — https://github.com/PELock
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "base64"
4
+ require "json"
5
+ require "zlib"
6
+
7
+ class PowerShellProObfuscator
8
+ API_URL = "https://www.pelock.com/api/powershell-pro-obfuscator/v1"
9
+ ERROR_SUCCESS = 0
10
+ ERROR_INPUT_SIZE = 1
11
+ ERROR_INPUT = 2
12
+ ERROR_PARSING = 3
13
+ ERROR_OBFUSCATION = 4
14
+ ERROR_OUTPUT = 5
15
+ USER_AGENT = "PELock PowerShell Pro Obfuscator"
16
+
17
+ FLAG_PARAMS = {
18
+ self_defending: "self_defending",
19
+ protection_linker: "protection_linker",
20
+ rename_variables: "rename_variables",
21
+ rename_parameters: "rename_parameters",
22
+ rename_functions: "rename_functions",
23
+ shuffle_functions: "shuffle_functions",
24
+ control_flow_flatten: "control_flow_flatten",
25
+ state_machine: "state_machine",
26
+ vm_strategy: "vm_strategy",
27
+ encrypt_integers: "encrypt_integers",
28
+ split_strings: "split_strings",
29
+ encrypt_strings: "encrypt_strings",
30
+ integers_to_arrays: "integers_to_arrays",
31
+ floats_to_arrays: "floats_to_arrays",
32
+ insert_dead_code: "insert_dead_code",
33
+ complexify_booleans: "complexify_booleans",
34
+ integers_to_floating: "integers_to_floating",
35
+ encrypt_floating: "encrypt_floating",
36
+ decoy_functions: "decoy_functions",
37
+ detect_debugger: "detect_debugger",
38
+ fake_dot_source_markers: "fake_dot_source_markers",
39
+ opaque_branches: "opaque_branches",
40
+ scriptblock_decoys: "scriptblock_decoys",
41
+ literal_padding: "literal_padding",
42
+ reflect_invoke_commands: "reflect_invoke_commands",
43
+ string_char_array_vault: "string_char_array_vault",
44
+ try_finally_noise: "try_finally_noise",
45
+ affine_integer_mask: "affine_integer_mask",
46
+ event_stub: "event_stub",
47
+ remove_comments: "remove_comments"
48
+ }.freeze
49
+
50
+ attr_accessor :enable_compression, *FLAG_PARAMS.keys
51
+
52
+ def initialize(api_key = nil)
53
+ @api_key = api_key
54
+ @enable_compression = false
55
+ FLAG_PARAMS.each_key { |name| instance_variable_set("@#{name}", true) }
56
+ end
57
+
58
+ def login(return_as_object = true)
59
+ post_request({ "command" => "login" }, return_as_object)
60
+ end
61
+
62
+ def obfuscate_script_file(script_file_path, return_as_object = true)
63
+ source = File.read(script_file_path, encoding: "UTF-8")
64
+ return nil if source.nil? || source.empty?
65
+
66
+ obfuscate_script_source(source, return_as_object)
67
+ rescue StandardError
68
+ nil
69
+ end
70
+
71
+ def obfuscate_script_source(script_source, return_as_object = true)
72
+ post_request({ "command" => "obfuscate", "source" => script_source }, return_as_object)
73
+ end
74
+
75
+ private
76
+
77
+ def post_request(params_array, return_as_object)
78
+ params = params_array.dup
79
+ params["key"] = @api_key unless @api_key.nil? || @api_key.to_s.empty?
80
+
81
+ FLAG_PARAMS.each do |name, key|
82
+ params[key] = "1" if instance_variable_get("@#{name}")
83
+ end
84
+
85
+ if @enable_compression && params["source"]
86
+ params["source"] = Base64.strict_encode64(Zlib::Deflate.deflate(params["source"], 9))
87
+ params["compression"] = "1"
88
+ end
89
+
90
+ body = Http.post_multipart(API_URL, params, user_agent: USER_AGENT)
91
+ return nil if body.nil? || body.empty?
92
+
93
+ result = Http.parse_json(body)
94
+ return nil if result.nil?
95
+
96
+ depacked = false
97
+ if @enable_compression && result["error"] == ERROR_SUCCESS && result["output"]
98
+ begin
99
+ result["output"] = Zlib::Inflate.inflate(Base64.decode64(result["output"]))
100
+ depacked = true
101
+ rescue StandardError
102
+ return nil
103
+ end
104
+ end
105
+
106
+ return result if return_as_object
107
+ return JSON.generate(result) if depacked
108
+
109
+ body
110
+ end
111
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "net/http"
5
+ require "securerandom"
6
+ require "uri"
7
+
8
+ class PowerShellProObfuscator
9
+ # Stdlib HTTP helper. Multipart for API form posts.
10
+ module Http
11
+ class << self
12
+ def post_multipart(url, fields, user_agent:)
13
+ boundary = "----PELock#{SecureRandom.hex(16)}"
14
+ body = build_multipart(fields, boundary)
15
+ request(url, body, user_agent, "multipart/form-data; boundary=#{boundary}")
16
+ end
17
+
18
+ def parse_json(body)
19
+ return nil if body.nil? || body.to_s.empty?
20
+
21
+ JSON.parse(body)
22
+ rescue JSON::ParserError
23
+ nil
24
+ end
25
+
26
+ def request(url, body, user_agent, content_type)
27
+ uri = URI.parse(url)
28
+ http = Net::HTTP.new(uri.host, uri.port)
29
+ http.use_ssl = uri.scheme == "https"
30
+ http.open_timeout = 30
31
+ http.read_timeout = 180
32
+ req = Net::HTTP::Post.new(uri.request_uri)
33
+ req["User-Agent"] = user_agent
34
+ req["Content-Type"] = content_type
35
+ req.body = body
36
+ http.request(req).body
37
+ rescue StandardError
38
+ nil
39
+ end
40
+
41
+ def build_multipart(fields, boundary)
42
+ body = String.new(encoding: Encoding::ASCII_8BIT)
43
+ fields.each do |name, value|
44
+ next if value.nil?
45
+
46
+ body << "--#{boundary}\r\n"
47
+ body << "Content-Disposition: form-data; name=\"#{name}\"\r\n\r\n"
48
+ body << value.to_s.dup.force_encoding(Encoding::UTF_8).b
49
+ body << "\r\n"
50
+ end
51
+ body << "--#{boundary}--\r\n"
52
+ body
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PowerShellProObfuscator
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "powershell-pro-obfuscator/version"
4
+ require_relative "powershell-pro-obfuscator/http"
5
+ require_relative "powershell-pro-obfuscator/client"
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: powershell-pro-obfuscator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bartosz Wójcik
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ email:
13
+ - support@pelock.com
14
+ executables: []
15
+ extensions: []
16
+ extra_rdoc_files: []
17
+ files:
18
+ - LICENSE
19
+ - README.md
20
+ - lib/powershell-pro-obfuscator.rb
21
+ - lib/powershell-pro-obfuscator/client.rb
22
+ - lib/powershell-pro-obfuscator/http.rb
23
+ - lib/powershell-pro-obfuscator/version.rb
24
+ homepage: https://www.pelock.com/products/powershell-pro-obfuscator
25
+ licenses:
26
+ - Apache-2.0
27
+ metadata:
28
+ homepage_uri: https://www.pelock.com/products/powershell-pro-obfuscator
29
+ source_code_uri: https://github.com/PELock/PowerShell-Pro-Obfuscator-Ruby
30
+ bug_tracker_uri: https://www.pelock.com
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 2.7.0
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 4.0.20
46
+ specification_version: 4
47
+ summary: PowerShell Pro Obfuscator Web API Ruby SDK
48
+ test_files: []