powershell-pro-obfuscator 1.0.0__py3-none-any.whl
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.
- examples/PowerShellProObfuscatorExample.py +236 -0
- examples/PowerShellProObfuscatorExampleIsDemo.py +52 -0
- examples/PowerShellProObfuscatorExampleSimple.py +72 -0
- powershell_pro_obfuscator-1.0.0.dist-info/METADATA +629 -0
- powershell_pro_obfuscator-1.0.0.dist-info/RECORD +9 -0
- powershell_pro_obfuscator-1.0.0.dist-info/WHEEL +5 -0
- powershell_pro_obfuscator-1.0.0.dist-info/top_level.txt +2 -0
- powershellproobfuscator/__init__.py +1 -0
- powershellproobfuscator/powershellproobfuscator.py +414 -0
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: powershell-pro-obfuscator
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: PowerShell Pro Obfuscator Web API interface can help you obfuscate, virtualize and protect PowerShell .ps1 scripts against analysis, reverse engineering and technology theft. PowerShell Pro Obfuscator provides advanced PowerShell source code parsing based on AST trees, multiple advanced obfuscation, virtualization and protection strategies are available.
|
|
5
|
+
Author-email: Bartosz Wójcik <support@pelock.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://www.pelock.com
|
|
8
|
+
Keywords: powershell,ps1,obfuscator,obfuscation,obfuscate,virtualization,virtualizer,vm,anti-debug,self-defending,protection,script
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
11
|
+
Classifier: Topic :: Security
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: requests
|
|
17
|
+
|
|
18
|
+
# PowerShell Pro Obfuscator — Obfuscate & Virtualize PowerShell Code
|
|
19
|
+
|
|
20
|
+
**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.
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
More technical details, downloads, documentation available at:
|
|
25
|
+
|
|
26
|
+
https://www.pelock.com/products/powershell-pro-obfuscator
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
It's available for Windows & Linux:
|
|
31
|
+
|
|
32
|
+
* https://www.pelock.com/products/powershell-pro-obfuscator/download
|
|
33
|
+
|
|
34
|
+
Multiple programming APIs available:
|
|
35
|
+
|
|
36
|
+
* https://www.pelock.com/products/powershell-pro-obfuscator/api
|
|
37
|
+
|
|
38
|
+
An online obfuscator interface:
|
|
39
|
+
|
|
40
|
+
* https://www.pelock.com/powershell-pro-obfuscator/
|
|
41
|
+
|
|
42
|
+
## Why PowerShell scripts need obfuscation?
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
[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.
|
|
47
|
+
|
|
48
|
+
## Obfuscation strategies
|
|
49
|
+
|
|
50
|
+
PowerShell Pro Obfuscator comes with many advanced obfuscation, virtualization & protection strategies. You can easily tune protection versus size and performance.
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
###  Powerful obfuscation
|
|
55
|
+
|
|
56
|
+
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.
|
|
57
|
+
|
|
58
|
+
###  Code virtualization
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
###  Finite-state automata (FSA)
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
###  Anti-debugging
|
|
67
|
+
|
|
68
|
+
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.
|
|
69
|
+
|
|
70
|
+
###  Self-integrity checks
|
|
71
|
+
|
|
72
|
+
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.
|
|
73
|
+
|
|
74
|
+
###  Protection linker
|
|
75
|
+
|
|
76
|
+
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.
|
|
77
|
+
|
|
78
|
+
## Before and after obfuscation
|
|
79
|
+
|
|
80
|
+
Look at this example — the same script becomes harder to read at a glance after obfuscation.
|
|
81
|
+
|
|
82
|
+
### Sample PowerShell script before obfuscation
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
function Get-Greeting {
|
|
86
|
+
param([string]$Name)
|
|
87
|
+
Write-Host "Hello World from $Name!"
|
|
88
|
+
}
|
|
89
|
+
Get-Greeting "PowerShell Pro Obfuscator"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### After obfuscation
|
|
93
|
+
|
|
94
|
+
```powershell
|
|
95
|
+
$script:_HnJTskg = 0
|
|
96
|
+
$jwNTQ = 297 * 400 + 36
|
|
97
|
+
$x4e8bfda = [Math]::Abs($jwNTQ - 8074)
|
|
98
|
+
$_EvKocNn = [Math]::Max($jwNTQ, $x4e8bfda) - [Math]::Min($jwNTQ, $x4e8bfda)
|
|
99
|
+
[void]$_EvKocNn
|
|
100
|
+
$script:_jUoXkBYh = 0
|
|
101
|
+
function gnJjzMCN3V8P {
|
|
102
|
+
param([int]$slot, [int]$salt, [int]$guard)
|
|
103
|
+
if (-not ((Get-Variable -Name _HnJTskg -Scope Script -ErrorAction SilentlyContinue).Value)) { return '' }
|
|
104
|
+
@('JFE', 'm0ao', 'R8Ysw') | ForEach-Object { $_.ToUpper() } | Out-Null
|
|
105
|
+
if ((((($slot * 31) + $salt) -band 65535) -ne $guard)) { return '' }
|
|
106
|
+
$tk = (Get-Variable -Name _jUoXkBYh -Scope Script -ErrorAction SilentlyContinue).Value
|
|
107
|
+
$IEm39CSpDOEFp = @{ 'Ouj1' = 455; 'vjzO' = 170; 'IQNV' = 291 }
|
|
108
|
+
$IEm39CSpDOEFp['R5LrM'] = $IEm39CSpDOEFp['Ouj1'] + $IEm39CSpDOEFp['vjzO']
|
|
109
|
+
$YWxSO = ($IEm39CSpDOEFp.Values | Measure-Object -Sum).Sum
|
|
110
|
+
[void]$YWxSO
|
|
111
|
+
if ($null -eq $tk) { [long]$tk = 0 }
|
|
112
|
+
$v93a130f2e4 = 508
|
|
113
|
+
switch ($v93a130f2e4) {
|
|
114
|
+
524 { $_GYF7IA14Go = 'H1Vph' }
|
|
115
|
+
561 { $_GYF7IA14Go = 'HAWoB' }
|
|
116
|
+
default { $_GYF7IA14Go = $v93a130f2e4 * 2 }
|
|
117
|
+
}
|
|
118
|
+
[void]$_GYF7IA14Go
|
|
119
|
+
$dk = (Get-Variable -Name vb6a18ffee4 -Scope Script -ErrorAction SilentlyContinue).Value
|
|
120
|
+
try { $xgLN5KZyEusFo7 = [Math]::Sqrt(850) } finally { [void]$xgLN5KZyEusFo7 }
|
|
121
|
+
if ($null -eq $dk) { [long]$dk = 0 }
|
|
122
|
+
$d = @(46866, 46865)
|
|
123
|
+
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 }
|
|
124
|
+
$r = ''
|
|
125
|
+
for ($s9qOSpiZzufQlVyV = 0; $s9qOSpiZzufQlVyV -lt $d.Length; $s9qOSpiZzufQlVyV++) {
|
|
126
|
+
[long]$v = [long]$d[$s9qOSpiZzufQlVyV]
|
|
127
|
+
for ($jL9gL7PEtQeIS = 2; $jL9gL7PEtQeIS -ge 0; $jL9gL7PEtQeIS--) {
|
|
128
|
+
for ($PsbomDHxAy = 2; $PsbomDHxAy -ge 0; $PsbomDHxAy--) {
|
|
129
|
+
[long]$v = [long]$v + ([long](230))
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for ($zhH33vzxjIzegl9 = 0; $zhH33vzxjIzegl9 -ge 0; $zhH33vzxjIzegl9--) {
|
|
133
|
+
[long]$v = [long]$v + ([long]([int]((((((236 + (-3 * $s9qOSpiZzufQlVyV) + (3 * $zhH33vzxjIzegl9))) % 256) + 256) % 256))))
|
|
134
|
+
[long]$v = [long]$v -bxor ([long](53766))
|
|
135
|
+
}
|
|
136
|
+
[long]$v = [long]$v - ([long]($salt + $slot + $tk + $dk + 0))
|
|
137
|
+
if ([long]$v -ge 0 -and [long]$v -le 0xFFFF) { $r += [char][int][long]$v }
|
|
138
|
+
elseif ([long]$v -ge 0x10000 -and [long]$v -le 0x10FFFF) { $r += [System.Char]::ConvertFromUtf32([int][long]$v) }
|
|
139
|
+
}
|
|
140
|
+
return $r
|
|
141
|
+
}
|
|
142
|
+
and more...
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Would you still recognise the original intent if you only had the obfuscated text and no prior copy of the script?
|
|
146
|
+
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
### How does PowerShell Pro Obfuscator work?
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+

|
|
154
|
+
|
|
155
|
+
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.
|
|
156
|
+
|
|
157
|
+
## Protect your PowerShell scripts & algorithms
|
|
158
|
+
|
|
159
|
+
Take no chances, use **PowerShell Pro Obfuscator** to obfuscate, virtualize and protect your PowerShell scripts and algorithms.
|
|
160
|
+
|
|
161
|
+
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).
|
|
162
|
+
|
|
163
|
+
We actively bugfix, research and develop new obfuscation strategies for our tools.
|
|
164
|
+
|
|
165
|
+
You can count on our expertise and support in this field.
|
|
166
|
+
|
|
167
|
+
### Installation
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
The preferred way of WebApi interface installation is via [pip](https://pypi.org/project/pip/).
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
Run:
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
pip install powershell-pro-obfuscator
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
or
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
python3 -m pip install powershell-pro-obfuscator
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
And then add this import to your source code:
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
|
|
201
|
+
from powershellproobfuscator import PowerShellProObfuscator
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
Installation package is available at https://pypi.org/project/powershell-pro-obfuscator/
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
### Example of obfuscating PowerShell script source code using default options
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
|
|
216
|
+
#!/usr/bin/env python
|
|
217
|
+
|
|
218
|
+
###############################################################################
|
|
219
|
+
#
|
|
220
|
+
# PowerShell Pro Obfuscator WebApi interface usage example.
|
|
221
|
+
#
|
|
222
|
+
# In this example we will obfuscate sample source with default options.
|
|
223
|
+
#
|
|
224
|
+
# Version : v1.0.0
|
|
225
|
+
# Language : Python
|
|
226
|
+
# Author : Bartosz Wójcik
|
|
227
|
+
# Web page : https://www.pelock.com
|
|
228
|
+
#
|
|
229
|
+
###############################################################################
|
|
230
|
+
|
|
231
|
+
#
|
|
232
|
+
# include PowerShell Pro Obfuscator module
|
|
233
|
+
#
|
|
234
|
+
from powershellproobfuscator import PowerShellProObfuscator
|
|
235
|
+
|
|
236
|
+
#
|
|
237
|
+
# if you don't want to use Python module, you can import directly from the file
|
|
238
|
+
#
|
|
239
|
+
#from pelock.powershellproobfuscator import PowerShellProObfuscator
|
|
240
|
+
|
|
241
|
+
#
|
|
242
|
+
# create PowerShell Pro Obfuscator class instance (we are using our activation key)
|
|
243
|
+
#
|
|
244
|
+
myPowerShellProObfuscator = PowerShellProObfuscator("ABCD-ABCD-ABCD-ABCD")
|
|
245
|
+
|
|
246
|
+
#
|
|
247
|
+
# source code in PowerShell format
|
|
248
|
+
#
|
|
249
|
+
scriptSourceCode = """function Get-Greeting {
|
|
250
|
+
param([string]$Name)
|
|
251
|
+
Write-Host "Hello World from $Name!"
|
|
252
|
+
}
|
|
253
|
+
Get-Greeting "PowerShell Pro Obfuscator\""""
|
|
254
|
+
|
|
255
|
+
#
|
|
256
|
+
# by default all obfuscation options are enabled, so we can just simply call
|
|
257
|
+
#
|
|
258
|
+
result = myPowerShellProObfuscator.obfuscate_script_source(scriptSourceCode)
|
|
259
|
+
|
|
260
|
+
#
|
|
261
|
+
# it's also possible to pass a PowerShell script file path instead of a string with the source e.g.
|
|
262
|
+
#
|
|
263
|
+
# result = myPowerShellProObfuscator.obfuscate_script_file("/path/to/project/script.ps1")
|
|
264
|
+
|
|
265
|
+
#
|
|
266
|
+
# result[] array holds the obfuscation results as well as other information
|
|
267
|
+
#
|
|
268
|
+
# result["error"] - error code
|
|
269
|
+
# result["output"] - obfuscated code
|
|
270
|
+
# result["demo"] - was it used in demo mode (invalid or empty activation key was used)
|
|
271
|
+
# result["credits_left"] - usage credits left after this operation
|
|
272
|
+
# result["credits_total"] - total number of credits for this activation code
|
|
273
|
+
# result["expired"] - if this was the last usage credit for the activation key it will be set to True
|
|
274
|
+
#
|
|
275
|
+
if result and "error" in result:
|
|
276
|
+
|
|
277
|
+
# display obfuscated code
|
|
278
|
+
if result["error"] == PowerShellProObfuscator.ERROR_SUCCESS:
|
|
279
|
+
|
|
280
|
+
# format output code for HTML display
|
|
281
|
+
print(result["output"])
|
|
282
|
+
|
|
283
|
+
else:
|
|
284
|
+
print(f'An error occurred, error code: {result["error"]}')
|
|
285
|
+
|
|
286
|
+
else:
|
|
287
|
+
print("Something unexpected happen while trying to obfuscate the code.")
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### An example of obfuscating PowerShell script source code with customized obfuscation strategies
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
#!/usr/bin/env python
|
|
295
|
+
|
|
296
|
+
###############################################################################
|
|
297
|
+
#
|
|
298
|
+
# PowerShell Pro Obfuscator WebApi interface usage example.
|
|
299
|
+
#
|
|
300
|
+
# In this example we will obfuscate sample source with custom options.
|
|
301
|
+
#
|
|
302
|
+
# Version : v1.0.0
|
|
303
|
+
# Language : Python
|
|
304
|
+
# Author : Bartosz Wójcik
|
|
305
|
+
# Web page : https://www.pelock.com
|
|
306
|
+
#
|
|
307
|
+
###############################################################################
|
|
308
|
+
|
|
309
|
+
#
|
|
310
|
+
# include PowerShell Pro Obfuscator module
|
|
311
|
+
#
|
|
312
|
+
from powershellproobfuscator import PowerShellProObfuscator
|
|
313
|
+
|
|
314
|
+
#
|
|
315
|
+
# if you don't want to use Python module, you can import directly from the file
|
|
316
|
+
#
|
|
317
|
+
#from pelock.powershellproobfuscator import PowerShellProObfuscator
|
|
318
|
+
|
|
319
|
+
#
|
|
320
|
+
# create PowerShell Pro Obfuscator class instance (we are using our activation key)
|
|
321
|
+
#
|
|
322
|
+
myPowerShellProObfuscator = PowerShellProObfuscator("ABCD-ABCD-ABCD-ABCD")
|
|
323
|
+
|
|
324
|
+
#
|
|
325
|
+
# should the source code be compressed (both input & compressed)
|
|
326
|
+
#
|
|
327
|
+
myPowerShellProObfuscator.enableCompression = False
|
|
328
|
+
|
|
329
|
+
#
|
|
330
|
+
# global obfuscation options
|
|
331
|
+
#
|
|
332
|
+
# you can disable a particular obfuscation strategy globally if it
|
|
333
|
+
# fails or you don't want to use it without modifying the source codes
|
|
334
|
+
#
|
|
335
|
+
# by default all obfuscation strategies are enabled
|
|
336
|
+
#
|
|
337
|
+
|
|
338
|
+
#
|
|
339
|
+
# protection against tampering with protected code (integrity verification)
|
|
340
|
+
#
|
|
341
|
+
myPowerShellProObfuscator.selfDefending = True
|
|
342
|
+
|
|
343
|
+
#
|
|
344
|
+
# protection linker (decoy call graph)
|
|
345
|
+
#
|
|
346
|
+
myPowerShellProObfuscator.protectionLinker = True
|
|
347
|
+
|
|
348
|
+
#
|
|
349
|
+
# rename variable names to random string values
|
|
350
|
+
#
|
|
351
|
+
myPowerShellProObfuscator.renameVariables = True
|
|
352
|
+
|
|
353
|
+
#
|
|
354
|
+
# rename parameter names to random string values
|
|
355
|
+
#
|
|
356
|
+
myPowerShellProObfuscator.renameParameters = True
|
|
357
|
+
|
|
358
|
+
#
|
|
359
|
+
# rename function names to random string values
|
|
360
|
+
#
|
|
361
|
+
myPowerShellProObfuscator.renameFunctions = True
|
|
362
|
+
|
|
363
|
+
#
|
|
364
|
+
# shuffle function order in the output source
|
|
365
|
+
#
|
|
366
|
+
myPowerShellProObfuscator.shuffleFunctions = True
|
|
367
|
+
|
|
368
|
+
#
|
|
369
|
+
# change linear code execution flow via control-flow flattening
|
|
370
|
+
#
|
|
371
|
+
myPowerShellProObfuscator.controlFlowFlatten = True
|
|
372
|
+
|
|
373
|
+
#
|
|
374
|
+
# rewrite statement blocks into finite-state automata (state-machine obfuscation)
|
|
375
|
+
#
|
|
376
|
+
myPowerShellProObfuscator.stateMachine = True
|
|
377
|
+
|
|
378
|
+
#
|
|
379
|
+
# lift selected statements into a VM engine (virtualized statements)
|
|
380
|
+
#
|
|
381
|
+
myPowerShellProObfuscator.vmStrategy = True
|
|
382
|
+
|
|
383
|
+
#
|
|
384
|
+
# encrypt integers
|
|
385
|
+
#
|
|
386
|
+
myPowerShellProObfuscator.encryptIntegers = True
|
|
387
|
+
|
|
388
|
+
#
|
|
389
|
+
# split strings into concatenated chunks
|
|
390
|
+
#
|
|
391
|
+
myPowerShellProObfuscator.splitStrings = True
|
|
392
|
+
|
|
393
|
+
#
|
|
394
|
+
# encrypt strings using randomly generated polymorphic encryption algorithms
|
|
395
|
+
#
|
|
396
|
+
myPowerShellProObfuscator.encryptStrings = True
|
|
397
|
+
|
|
398
|
+
#
|
|
399
|
+
# move integers to arrays
|
|
400
|
+
#
|
|
401
|
+
myPowerShellProObfuscator.integersToArrays = True
|
|
402
|
+
|
|
403
|
+
#
|
|
404
|
+
# move floats to arrays
|
|
405
|
+
#
|
|
406
|
+
myPowerShellProObfuscator.floatsToArrays = True
|
|
407
|
+
|
|
408
|
+
#
|
|
409
|
+
# insert dead code
|
|
410
|
+
#
|
|
411
|
+
myPowerShellProObfuscator.insertDeadCode = True
|
|
412
|
+
|
|
413
|
+
#
|
|
414
|
+
# replace boolean conditions with equivalent complex expressions
|
|
415
|
+
#
|
|
416
|
+
myPowerShellProObfuscator.complexifyBooleans = True
|
|
417
|
+
|
|
418
|
+
#
|
|
419
|
+
# represent integers via floating-point math
|
|
420
|
+
#
|
|
421
|
+
myPowerShellProObfuscator.integersToFloating = True
|
|
422
|
+
|
|
423
|
+
#
|
|
424
|
+
# encrypt floating point numbers
|
|
425
|
+
#
|
|
426
|
+
myPowerShellProObfuscator.encryptFloating = True
|
|
427
|
+
|
|
428
|
+
#
|
|
429
|
+
# insert decoy functions
|
|
430
|
+
#
|
|
431
|
+
myPowerShellProObfuscator.decoyFunctions = True
|
|
432
|
+
|
|
433
|
+
#
|
|
434
|
+
# insert anti-debugging detections
|
|
435
|
+
#
|
|
436
|
+
myPowerShellProObfuscator.detectDebugger = True
|
|
437
|
+
|
|
438
|
+
#
|
|
439
|
+
# insert fake dot-source comment markers
|
|
440
|
+
#
|
|
441
|
+
myPowerShellProObfuscator.fakeDotSourceMarkers = True
|
|
442
|
+
|
|
443
|
+
#
|
|
444
|
+
# insert opaque predicate branches
|
|
445
|
+
#
|
|
446
|
+
myPowerShellProObfuscator.opaqueBranches = True
|
|
447
|
+
|
|
448
|
+
#
|
|
449
|
+
# insert scriptblock decoys
|
|
450
|
+
#
|
|
451
|
+
myPowerShellProObfuscator.scriptblockDecoys = True
|
|
452
|
+
|
|
453
|
+
#
|
|
454
|
+
# insert here-string padding
|
|
455
|
+
#
|
|
456
|
+
myPowerShellProObfuscator.literalPadding = True
|
|
457
|
+
|
|
458
|
+
#
|
|
459
|
+
# use indirect command invocation
|
|
460
|
+
#
|
|
461
|
+
myPowerShellProObfuscator.reflectInvokeCommands = True
|
|
462
|
+
|
|
463
|
+
#
|
|
464
|
+
# store string fragments in char-code array vaults
|
|
465
|
+
#
|
|
466
|
+
myPowerShellProObfuscator.stringCharArrayVault = True
|
|
467
|
+
|
|
468
|
+
#
|
|
469
|
+
# wrap code in try/finally blocks with dead noise
|
|
470
|
+
#
|
|
471
|
+
myPowerShellProObfuscator.tryFinallyNoise = True
|
|
472
|
+
|
|
473
|
+
#
|
|
474
|
+
# apply redundant xor / affine integer masks
|
|
475
|
+
#
|
|
476
|
+
myPowerShellProObfuscator.affineIntegerMask = True
|
|
477
|
+
|
|
478
|
+
#
|
|
479
|
+
# insert dead event/timer stubs
|
|
480
|
+
#
|
|
481
|
+
myPowerShellProObfuscator.eventStub = True
|
|
482
|
+
|
|
483
|
+
#
|
|
484
|
+
# strip comments from the output source
|
|
485
|
+
#
|
|
486
|
+
myPowerShellProObfuscator.removeComments = True
|
|
487
|
+
|
|
488
|
+
#
|
|
489
|
+
# source code in PowerShell format
|
|
490
|
+
#
|
|
491
|
+
scriptSourceCode = """function Get-Greeting {
|
|
492
|
+
param([string]$Name)
|
|
493
|
+
Write-Host "Hello World from $Name!"
|
|
494
|
+
}
|
|
495
|
+
Get-Greeting "PowerShell Pro Obfuscator\""""
|
|
496
|
+
|
|
497
|
+
#
|
|
498
|
+
# by default all obfuscation options are enabled, so we can just simply call
|
|
499
|
+
#
|
|
500
|
+
result = myPowerShellProObfuscator.obfuscate_script_source(scriptSourceCode)
|
|
501
|
+
|
|
502
|
+
#
|
|
503
|
+
# it's also possible to pass a PowerShell script file path instead of a string with the source e.g.
|
|
504
|
+
#
|
|
505
|
+
# result = myPowerShellProObfuscator.obfuscate_script_file("/path/to/project/script.ps1")
|
|
506
|
+
|
|
507
|
+
#
|
|
508
|
+
# result[] array holds the obfuscation results as well as other information
|
|
509
|
+
#
|
|
510
|
+
# result["error"] - error code
|
|
511
|
+
# result["output"] - obfuscated code
|
|
512
|
+
# result["demo"] - was it used in demo mode (invalid or empty activation key was used)
|
|
513
|
+
# result["credits_left"] - usage credits left after this operation
|
|
514
|
+
# result["credits_total"] - total number of credits for this activation code
|
|
515
|
+
# result["expired"] - if this was the last usage credit for the activation key it will be set to True
|
|
516
|
+
#
|
|
517
|
+
if result and "error" in result:
|
|
518
|
+
|
|
519
|
+
# display obfuscated code
|
|
520
|
+
if result["error"] == PowerShellProObfuscator.ERROR_SUCCESS:
|
|
521
|
+
|
|
522
|
+
# format output code for HTML display
|
|
523
|
+
print(result["output"])
|
|
524
|
+
|
|
525
|
+
else:
|
|
526
|
+
print(f'An error occurred, error code: {result["error"]}')
|
|
527
|
+
|
|
528
|
+
else:
|
|
529
|
+
print("Something unexpected happen while trying to obfuscate the code.")
|
|
530
|
+
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### Check activation key status
|
|
534
|
+
|
|
535
|
+
```python
|
|
536
|
+
#!/usr/bin/env python
|
|
537
|
+
|
|
538
|
+
###############################################################################
|
|
539
|
+
#
|
|
540
|
+
# PowerShell Pro Obfuscator WebApi interface usage example.
|
|
541
|
+
#
|
|
542
|
+
# In this example we will verify our activation key status.
|
|
543
|
+
#
|
|
544
|
+
# Version : v1.0.0
|
|
545
|
+
# Language : Python
|
|
546
|
+
# Author : Bartosz Wójcik
|
|
547
|
+
# Web page : https://www.pelock.com
|
|
548
|
+
#
|
|
549
|
+
###############################################################################
|
|
550
|
+
|
|
551
|
+
#
|
|
552
|
+
# include PowerShell Pro Obfuscator module
|
|
553
|
+
#
|
|
554
|
+
from powershellproobfuscator import PowerShellProObfuscator
|
|
555
|
+
|
|
556
|
+
#
|
|
557
|
+
# if you don't want to use Python module, you can import directly from the file
|
|
558
|
+
#
|
|
559
|
+
#from pelock.powershellproobfuscator import PowerShellProObfuscator
|
|
560
|
+
|
|
561
|
+
#
|
|
562
|
+
# create PowerShell Pro Obfuscator class instance (we are using our activation key)
|
|
563
|
+
#
|
|
564
|
+
myPowerShellProObfuscator = PowerShellProObfuscator("ABCD-ABCD-ABCD-ABCD")
|
|
565
|
+
|
|
566
|
+
#
|
|
567
|
+
# login to the service
|
|
568
|
+
#
|
|
569
|
+
result = myPowerShellProObfuscator.login()
|
|
570
|
+
|
|
571
|
+
#
|
|
572
|
+
# result[] array holds the information about the license
|
|
573
|
+
#
|
|
574
|
+
# result["demo"] - is it a demo mode (invalid or empty activation key was used)
|
|
575
|
+
# result["credits_left"] - usage credits left after this operation
|
|
576
|
+
# result["credits_total"] - total number of credits for this activation code
|
|
577
|
+
# result["string_limit"] - max. source code size allowed (it's 1000 bytes for demo mode)
|
|
578
|
+
#
|
|
579
|
+
if result:
|
|
580
|
+
|
|
581
|
+
print(f'Demo version status - {"True" if result["demo"] else "False"}')
|
|
582
|
+
print(f'Usage credits left - {result["credits_left"]}')
|
|
583
|
+
print(f'Total usage credits - {result["credits_total"]}')
|
|
584
|
+
print(f'Max. source code size - {result["string_limit"]}')
|
|
585
|
+
|
|
586
|
+
else:
|
|
587
|
+
print("Something unexpected happen while trying to login to the service.")
|
|
588
|
+
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
## Use PowerShell Pro Obfuscator Online
|
|
592
|
+
|
|
593
|
+
Online interface for PowerShell Pro Obfuscator is available at:
|
|
594
|
+
|
|
595
|
+
https://www.pelock.com/powershell-pro-obfuscator/
|
|
596
|
+
|
|
597
|
+
## Windows GUI client and command line version
|
|
598
|
+
|
|
599
|
+
#### PowerShell Pro Obfuscator comes also with full GUI version for Windows:
|
|
600
|
+
|
|
601
|
+

|
|
602
|
+
|
|
603
|
+
#### Obfuscation options:
|
|
604
|
+
|
|
605
|
+

|
|
606
|
+
|
|
607
|
+
#### Obfuscated PowerShell script:
|
|
608
|
+
|
|
609
|
+

|
|
610
|
+
|
|
611
|
+
## Download
|
|
612
|
+
|
|
613
|
+
You can download it at:
|
|
614
|
+
|
|
615
|
+
https://www.pelock.com/products/powershell-pro-obfuscator/download
|
|
616
|
+
|
|
617
|
+
Installation package contains an additional command line interface:
|
|
618
|
+
|
|
619
|
+

|
|
620
|
+
|
|
621
|
+
PowerShell Pro Obfuscator ships with a command-line interface for Windows and Linux automation.
|
|
622
|
+
|
|
623
|
+
Use it to integrate obfuscation into build servers, CI jobs, or batch packaging.
|
|
624
|
+
|
|
625
|
+
Bartosz Wójcik
|
|
626
|
+
|
|
627
|
+
* Visit my site at — https://www.pelock.com
|
|
628
|
+
* X — https://x.com/PELock
|
|
629
|
+
* GitHub — https://github.com/PELock
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
examples/PowerShellProObfuscatorExample.py,sha256=YYAlKT7cTl_UIY_9tcoZbEQApLwhaYsqae3u4ppQwP0,5841
|
|
2
|
+
examples/PowerShellProObfuscatorExampleIsDemo.py,sha256=svM2R5qcZFBEkSSIlU0c8bsNUyEn0IFBFnmJ27CiQR8,1735
|
|
3
|
+
examples/PowerShellProObfuscatorExampleSimple.py,sha256=mYlikdEQp4hD4SUxNAUnygLXfx_0cwJjUWKh2BXDCKE,2387
|
|
4
|
+
powershellproobfuscator/__init__.py,sha256=MDF4NNekRgYXk6mlS6Veg6YVAqDkTkLzhaMdOGOaeo0,63
|
|
5
|
+
powershellproobfuscator/powershellproobfuscator.py,sha256=zZ4pa1P49DhO8CkN2kSoi8qyt5UnJZ1rzObRoIphBP8,12920
|
|
6
|
+
powershell_pro_obfuscator-1.0.0.dist-info/METADATA,sha256=eBAqDeZQ-_ybQx-8N2a4qPQtwSW1AMfirF0lvRuCOnQ,21643
|
|
7
|
+
powershell_pro_obfuscator-1.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
8
|
+
powershell_pro_obfuscator-1.0.0.dist-info/top_level.txt,sha256=uoWaUjU7YdSF66W0mU3jwaEjT9xKof0_YcDEAb13IHQ,33
|
|
9
|
+
powershell_pro_obfuscator-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from powershellproobfuscator.powershellproobfuscator import *
|