From ef0e95bf50d126b592449b47bf6097127755df25 Mon Sep 17 00:00:00 2001 From: Andrew Beers Date: Thu, 21 May 2020 17:12:16 -0500 Subject: [PATCH] T1500 - Dynamic C# Compile (#1008) * write test * use input arg in command Co-authored-by: Carrie Roberts --- atomics/T1500/T1500.yaml | 32 ++++++++++++++- atomics/T1500/bin/T1500_DynamicCompile.exe | Bin 0 -> 6656 bytes atomics/T1500/src/DynamicCompile.cs | 43 +++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 atomics/T1500/bin/T1500_DynamicCompile.exe create mode 100644 atomics/T1500/src/DynamicCompile.cs diff --git a/atomics/T1500/T1500.yaml b/atomics/T1500/T1500.yaml index 5d5c0d02..6e54bfad 100644 --- a/atomics/T1500/T1500.yaml +++ b/atomics/T1500/T1500.yaml @@ -30,7 +30,6 @@ atomic_tests: New-Item -Type Directory (split-path #{input_file}) -ErrorAction ignore | Out-Null Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1500/src/calc.cs" -OutFile "#{input_file}" - executor: name: command_prompt elevation_required: false @@ -38,3 +37,34 @@ atomic_tests: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /out:#{output_file} #{input_file} cleanup_command: | del #{output_file} >nul 2>&1 + +- name: Dynamic C# Compile + description: | + When C# is compiled dynamically, a .cmdline file will be created as a part of the process. + Certain processes are not typically observed compiling C# code, but can do so without touching disk. This can be used to unpack a payload for execution. + The exe file that will be executed is named as T1500_DynamicCompile.exe is containted in the 'bin' folder of this atomic, and the source code to the file is in the 'src' folder. + Upon execution, the exe will print 'T1500 Dynamic Compile'. + + supported_platforms: + - windows + + input_arguments: + input_file: + description: exe program containing dynamically compiled C# code + type: Path + default: PathToAtomicsFolder\T1500\bin\T1500_DynamicCompile.exe + + dependency_executor_name: powershell + dependencies: + - description: | + exe file must exist on disk at specified location (#{input_file}) + prereq_command: | + if (Test-Path #{input_file}) {exit 0} else {exit 1} + get_prereq_command: | + Invoke-WebRequest https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1500/bin/T1500_DynamicCompile.exe -OutFile #{input_file} + + executor: + name: powershell + elevation_required: false + command: | + Invoke-Expression #{input_file} diff --git a/atomics/T1500/bin/T1500_DynamicCompile.exe b/atomics/T1500/bin/T1500_DynamicCompile.exe new file mode 100644 index 0000000000000000000000000000000000000000..deb3f676356f20e07acdb1f5e65574d4c3fe6352 GIT binary patch literal 6656 zcmeHLU2Ggz6+W};*p3rB@!I)M+Q}wq^XK*2aef;o{#iS98#|77?UK~Oot?d2Pcu8S zotbsLp{Y_3kt#qm4d5b{XTPGcZV_5Te^FuQI`&#fAo`DPwSj7Ct81-mZ?|Dq(_;sT+LCpIS!`-6ZTZp;th#TrGXwr_ zHXWk+gYn4zZD1v^(m?vD0fn_fV;{};B$A0E$s=7S8MB5=z&Qxo^D@!z@xC2JKkYe& zm3NtA0cRt_xXCpAdab_&d(KUcq(Hle@iav588GcEGowL-a&A+EKqC6La)e+FuMQ=d z2LJkFC|KEgrZbJ`1I5?0o~|e#MC$2X3BOLijBKFIm|9P7QwsPog<+?JZ%OzC32#gI zC&}}D`XhL5N*I&)f6)eD+~|o&6MZh?0FFn$1*iko(<^iWFds<)GZona|9v&W_#07P z>x_gqq~rsU6H;AYSKqrEDH$=SAGRtquCgsR>1-s6(NBZXWtxMP_vGlt*1M3&LKJ#B zx|Z%n6l^8qwgEQL0lOxMw5awb)_w1S}rvzRASE(-F6 z4QMW=m5f}!hmR&(@&u(swv^9nS*%dOVe*vW8jEn@`WeHkWv!qcEhh?^bEPUJqd9ru z4I{~j7wuX?IA<7UO$o<^@zq%&anQDAjeN<`*f-0`DdFmlQCv*)jg~VegsCmap1XYV zxPu+hz2$^KyI6LN{M?G9LQ%8I)j1O-%QFgs*Tgzm!!*1a>PnlD5DOyQ_h5D+upa@8 z{5VEXjuUghNTZrzRVInq;IIVD)zcGf@Q5{Q)2N|4wrkINiNW-o<`l_)@mYcJc_Swr zoT{8i*@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