forked from danielbohannon/Invoke-Obfuscation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Invoke-Obfuscation.psm1
129 lines (106 loc) · 4.7 KB
/
Invoke-Obfuscation.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# This file is part of Invoke-Obfuscation.
#
# Copyright 2017 Daniel Bohannon <@danielhbohannon>
# while at Mandiant <http://www.mandiant.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Get location of this script no matter what the current directory is for the process executing this script.
$ScriptDir = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
Write-Host "`n[*] Invoke-Obfuscation.psm1 has been decomissioned." -ForegroundColor Red
Write-Host "[*] Please run" -NoNewLine -ForegroundColor Red
Write-Host " Import-Module $ScriptDir\Invoke-Obfuscation.psd1 " -NoNewLine -ForegroundColor Yellow
Write-Host "instead." -ForegroundColor Red
<#
.SYNOPSIS
PowerShell module file for importing all required modules for the Invoke-Obfuscation framework.
Invoke-Obfuscation Module Loader
Author: Daniel Bohannon (@danielhbohannon)
License: Apache License, Version 2.0
Required Dependencies: None
Optional Dependencies: None
.DESCRIPTION
PowerShell module file for importing all required modules for the Invoke-Obfuscation framework.
.EXAMPLE
C:\PS> Import-Module .\Invoke-Obfuscation.psm1
.NOTES
PowerShell module file for importing all required modules for the Invoke-Obfuscation framework.
This is a personal project developed by Daniel Bohannon while an employee at MANDIANT, A FireEye Company.
.LINK
http://www.danielbohannon.com
#>
<#
# Confirm all necessary commands are loaded and import appropriate .ps1 files in current directory if necessary.
Write-Host "`n[*] Validating necessary commands are loaded into current PowerShell session.`n"
$RequiredFunctions = @()
$RequiredFunctions += 'Out-ObfuscatedTokenCommand'
$RequiredFunctions += 'Out-ObfuscatedStringCommand'
$RequiredFunctions += 'Out-EncodedAsciiCommand'
$RequiredFunctions += 'Out-EncodedHexCommand'
$RequiredFunctions += 'Out-EncodedOctalCommand'
$RequiredFunctions += 'Out-EncodedBinaryCommand'
$RequiredFunctions += 'Out-SecureStringCommand'
$RequiredFunctions += 'Out-EncodedBXORCommand'
$RequiredFunctions += 'Out-PowerShellLauncher'
$RequiredFunctions += 'Invoke-Obfuscation'
# Get location of this script no matter what the current directory is for the process executing this script.
$ScriptDir = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
$UnloadedFunctionExists = $FALSE
ForEach($Function in $RequiredFunctions)
{
# Check if $Function is loaded.
If(!(Get-Command * | Where-Object {$_.Name -like $Function}))
{
# Validate that appropriate .ps1 file exists.
If(Test-Path $ScriptDir\$Function.ps1)
{
# Import module.
Import-Module $ScriptDir\$Function.ps1
# Re-check if $Function is loaded.
If((Get-Command * | Where-Object {$_.Name -like $Function}).Name)
{
Write-Host "[*] Function Loaded :: $Function" -ForegroundColor Green
}
Else
{
Write-Host "[*] Function Not Loaded :: $Function (After running Import-Module $ScriptDir\$Function.ps1)" -ForegroundColor Red
$UnloadedFunctionExists = $TRUE
}
}
Else {
Write-Host "[*] Function Not Loaded :: $Function (Cannot locate $ScriptDir\$Function.ps1)" -ForegroundColor Red
$UnloadedFunctionExists = $TRUE
}
}
Else {
Write-Host "[*] Function Already Loaded :: $Function" -ForegroundColor Green
}
}
# Show error and warning if any functions were not properly loaded.
If($UnloadedFunctionExists)
{
Write-Host "`n[*] One or more above functions are not loaded." -ForegroundColor Red
Write-Host " Ensure Invoke-Obfuscation.psm1 is in the same directory as above scripts.`n" -ForegroundColor Red
}
Else
{
Write-Host "`n[*] All modules loaded and ready to run " -NoNewLine
# Write output below string in interactive format.
ForEach($Char in [Char[]]'Invoke-Obfuscation')
{
Write-Host $Char -NoNewline -ForegroundColor Green
Start-Sleep -Milliseconds (Get-Random -Input @(25..200))
}
Start-Sleep -Milliseconds 500
Write-Host "`n"
}
#>