# infosecn1nja/maliciousmacromsbuild architecture

> Architecture diagram of the GitHub repository infosecn1nja/maliciousmacromsbuild, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/infosecn1nja/maliciousmacromsbuild
- Repository: https://github.com/infosecn1nja/maliciousmacromsbuild

## Overview

##### Project Type and Purpose
- This is a specialized Python command-line tool designed for adversary simulation and red teaming. Its primary function is to generate Malicious Macro files by embedding payloads (shellcode, PowerShell scripts, or custom MSBuild XML) into preconfigured MSBuild project templates.
- The README clearly states its red teaming purpose and provides various options (e.g., AMSI bypass, environmental keying for sandbox evasion, kill date) that indicate the tool’s logic for processing input payloads and generating output macro files.

##### File Structure and Its Implications
- The project is organized very simply:
- LICENSE and README.md for project documentation.
- m3-gen.py as the main executable script that handles argument parsing, payload injection, and the generation of the macro.
- A templates folder containing at least two MSBuild project template files (one for PowerShell and one for shellcode) which the script likely uses to generate the final malicious macro based on the chosen payload.
- This simple file tree indicates there isn’t a complex multi-tier architecture (like separate frontends/backends) but rather a linear command-line processing pipeline.

##### How to Represent the Architecture
a. Main Components:
- Command-Line Interface (CLI) / User Input:
- This is where the user provides parameters like input payload file, payload type (shellcode, powershell, custom), and additional options like AMSI bypass, domain for sandbox evasion, or a kill date.
- Main Processing Engine (m3-gen.py):
- Acts as the central controller: it parses the CLI arguments, reads the chosen input file, selects the appropriate MSBuild template, applies modifications (embed payload, adjust options, apply kill date or domain checks), and generates the output macro file.
- Template Module:
- The templates folder contains the two key configuration files:
 MSBuild_powershell.csproj – used when the payload is “powershell”.
 MSBuild_shellcode.csproj – used when the payload is “shellcode”.
- Output Generation:
- The final component is the generation and saving of the macro (output file) with the payload embedded into MSBuild projects for execution bypass.

b. Relationships and Data Flow:
- m3-gen.py then reads the provided payload file and, based on the “-p” parameter, decides which template (PowerShell or Shellcode MSBuild project file) to load from the templates folder.
- After processing and embedding the payload along with other optional parameters (like AMSI bypass, kill date, and environmental domain checking), the script writes the output macro file.

c. Architectural Patterns and Design Principles:
- This is essentially a pipeline or a script-driven code generation tool.
- Separation of concerns: argument parsing, template selection, payload integration, and final output generation.

d. Key Technologies and Frameworks:
- Python as the core programming language (shown as m3-gen.py).
- MSBuild project files (.csproj) used as template files, which form the backbone for generating the malicious macro.
- The use of command-line parsing (likely via Python’s argparse or similar library) can be noted as part of the design.

##### Instructing What
- Clearly label every component with names like “User CLI Input”, “Argument Parser (m3-gen.py)”, “Payload Reader”, “Template Selector (MSBuild_powershell.csproj / MSBuild_shellcode.csproj)”, and “Macro Output Generator”.
- From the CLI to the Processing Engine indicating “Input Parameters”.
- From the Processing Engine to the Template Files Module, labeled “Load template based on payload”.
- Input mechanisms (user-provided parameters) from processing logic (m3-gen.py operations) and static assets (template files).

- M3-gen.py processing engine that performs argument parsing, reads the payload file, selects the correct MSBuild template, and embeds the payload.
- Two distinct template files which are the sources for generating the final malicious macro.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UI["User CLI Input"]:::input
    PE["Processing Engine (m3-gen.py)"]:::processing
    decision{"Determine Payload Type?"}:::decision
    PS["Template Selector: MSBuild_powershell.csproj"]:::template
    SC["Template Selector: MSBuild_shellcode.csproj"]:::template
    OUT["Macro Output Generator"]:::output

    UI -->|"InputParameters"| PE
    PE -->|"ParseArguments"| decision
    decision -->|"powershell"| PS
    decision -->|"shellcode"| SC
    PE -->|"customPayload"| OUT
    PS -->|"EmbedPayload"| OUT
    SC -->|"EmbedPayload"| OUT

    click UI "https://github.com/infosecn1nja/maliciousmacromsbuild/blob/master/m3-gen.py"
    click PE "https://github.com/infosecn1nja/maliciousmacromsbuild/blob/master/m3-gen.py"
    click PS "https://github.com/infosecn1nja/maliciousmacromsbuild/blob/master/templates/MSBuild_powershell.csproj"
    click SC "https://github.com/infosecn1nja/maliciousmacromsbuild/blob/master/templates/MSBuild_shellcode.csproj"

    classDef input fill:#a2d5f2,stroke:#333,stroke-width:2px;
    classDef processing fill:#f7a072,stroke:#333,stroke-width:2px;
    classDef decision fill:#f3e9a9,stroke:#333,stroke-width:2px;
    classDef template fill:#d3f9b5,stroke:#333,stroke-width:2px;
    classDef output fill:#b9fbc0,stroke:#333,stroke-width:2px;
```
