diff --git a/atomics/T1546.007/T1546.007.yaml b/atomics/T1546.007/T1546.007.yaml index 11864424..685b2d58 100644 --- a/atomics/T1546.007/T1546.007.yaml +++ b/atomics/T1546.007/T1546.007.yaml @@ -4,15 +4,30 @@ atomic_tests: - name: Netsh Helper DLL Registration auto_generated_guid: 3244697d-5a3a-4dfc-941c-550f69f91a4d description: | - Netsh interacts with other operating system components using dynamic-link library (DLL) files + You can register a "helper dll" with Netsh as a persistance mechanism. The code in the dll is executed every time netsh.exe is called. + The NetshHelper.dll provided with the atomic will simply launch notepad when netsh.exe is run. + + [Blog](https://htmlpreview.github.io/?https://github.com/MatthewDemaske/blogbackup/blob/master/netshell.html) + [Sample DLL code](https://github.com/outflanknl/NetshHelperBeacon) supported_platforms: - windows input_arguments: helper_file: description: Path to DLL type: Path - default: C:\Path\file.dll + default: PathToAtomicsFolder\T1546.007\bin\NetshHelper.dll + dependencies: + - description: | + Helper DLL must exist on disk at specified location (#{helper_file}) + prereq_command: | + if (Test-Path "#{helper_file}") { exit 0} else { exit 1} + get_prereq_command: | + New-Item -Type Directory (split-path #{helper_file}) -ErrorAction ignore | Out-Null + Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1546.007/bin/NetshHelper.dll" -OutFile "#{helper_file}" executor: command: | netsh.exe add helper #{helper_file} - name: command_prompt \ No newline at end of file + cleanup_command: | + netsh.exe delete helper #{helper_file} + name: command_prompt + elevation_required: true \ No newline at end of file diff --git a/atomics/T1546.007/bin/NetshHelper.dll b/atomics/T1546.007/bin/NetshHelper.dll new file mode 100644 index 00000000..3173cd14 Binary files /dev/null and b/atomics/T1546.007/bin/NetshHelper.dll differ diff --git a/atomics/T1546.007/src/NetshHelper.sln b/atomics/T1546.007/src/NetshHelper.sln new file mode 100644 index 00000000..f1147410 --- /dev/null +++ b/atomics/T1546.007/src/NetshHelper.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetshHelper", "NetshHelper\NetshHelper.vcxproj", "{3BB0CD58-487C-4FEC-8001-607599477158}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3BB0CD58-487C-4FEC-8001-607599477158}.Debug|Win32.ActiveCfg = Debug|Win32 + {3BB0CD58-487C-4FEC-8001-607599477158}.Debug|Win32.Build.0 = Debug|Win32 + {3BB0CD58-487C-4FEC-8001-607599477158}.Debug|x64.ActiveCfg = Debug|x64 + {3BB0CD58-487C-4FEC-8001-607599477158}.Debug|x64.Build.0 = Debug|x64 + {3BB0CD58-487C-4FEC-8001-607599477158}.Release|Win32.ActiveCfg = Release|Win32 + {3BB0CD58-487C-4FEC-8001-607599477158}.Release|Win32.Build.0 = Release|Win32 + {3BB0CD58-487C-4FEC-8001-607599477158}.Release|x64.ActiveCfg = Release|x64 + {3BB0CD58-487C-4FEC-8001-607599477158}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/atomics/T1546.007/src/NetshHelper/NetshHelper.cpp b/atomics/T1546.007/src/NetshHelper/NetshHelper.cpp new file mode 100644 index 00000000..6eebf94f --- /dev/null +++ b/atomics/T1546.007/src/NetshHelper/NetshHelper.cpp @@ -0,0 +1,12 @@ +#include +#include // only required if you want to pop calc + +// define the DLL handler 'InitHelpderDll' as required by netsh. +// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms708327(v=vs.85).aspx +extern "C" __declspec(dllexport) DWORD InitHelperDll(DWORD dwNetshVersion, PVOID pReserved) +{ + system ("start notepad"); + + // return NO_ERROR is required + return 0; +} \ No newline at end of file diff --git a/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj b/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj new file mode 100644 index 00000000..aa90c43e --- /dev/null +++ b/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3BB0CD58-487C-4FEC-8001-607599477158} + Win32Proj + NetshHelperBeacon + NetshHelper + + + + DynamicLibrary + true + Unicode + v143 + + + DynamicLibrary + true + Unicode + v143 + + + DynamicLibrary + false + true + Unicode + v143 + + + DynamicLibrary + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;NETSHHELPERBEACON_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;NETSHHELPERBEACON_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;NETSHHELPERBEACON_EXPORTS;InitHelperDLL;WIN_X86;%(PreprocessorDefinitions) + MultiThreaded + + + Windows + true + true + true + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;NETSHHELPERBEACON_EXPORTS;InitHelperDLL;WIN_X64;%(PreprocessorDefinitions) + MultiThreaded + + + Windows + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj.filters b/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj.filters new file mode 100644 index 00000000..bb8bcba1 --- /dev/null +++ b/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj.user b/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj.user new file mode 100644 index 00000000..ace9a86a --- /dev/null +++ b/atomics/T1546.007/src/NetshHelper/NetshHelper.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file