GithubHelp home page GithubHelp logo

trickster0 / coffee Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hakaioffsec/coffee

1.0 1.0 0.0 44 KB

A COFF loader made in Rust

Home Page: https://labs.hakaioffsec.com/coffee-a-coff-loader-made-in-rust/

License: GNU General Public License v3.0

Rust 100.00%

coffee's Introduction

Coffee

Coffee is a custom implementation of the original Cobalt Strike's beacon_inline_execute. It is written in Rust and supports most of the features of the Cobalt Strike compatibility layer. Coffee is structured so it can be used as a library in other projects too.

The original blog post can be found here: https://labs.hakaioffsec.com/coffee-a-coff-loader-made-in-rust/

Usage

$ coffee.exe -h
Coffee: A COFF loader made in Rust

Usage: coffee.exe [OPTIONS] --bof-path <BOF_PATH> [-- <ARGS>...]

Arguments:
  [ARGS]...  Arguments to the BOF passed after the "--" delimiter, supported types are: str, wstr, int, short

Options:
  -b, --bof-path <BOF_PATH>      Path to the Beacon Object File (BOF)
  -e, --entrypoint <ENTRYPOINT>  The entrypoint name to execute in case of a custom entrypoint name [default: go]
  -v, --verbosity <VERBOSITY>    Verbosity level, 0 = ERROR, 1 = WARN, 2 = INFO, 3 = DEBUG, 4 = TRACE [default: 0]
  -h, --help                     Print help
  -V, --version                  Print version

Arguments

Arguments for the BOF can be passed after the -- delimiter. Each argument must be prefixed with the type of the argument followed by a colon (:). The following types are supported:

  • str - A null-terminated string
  • wstr - A wide null-terminated string
  • int - A signed 32-bit integer
  • short - A signed 16-bit integer

Example

Using the dir.x64.o BOF from the trustedsec/CS-Situational-Awareness-BOF repository and passing arguments to the BOF:

coffee.exe --bof-path .\dir.x64.o -- wstr:"C:\\Windows\\System32"

Usage as library

cargo add coffee-ldr

Coffee can be used as a library in other projects. The following example shows how to use Coffee to load a BOF and execute the BOF:

use coffee_ldr::loader::Coffee;

fn main() {
    let whoami_bof: [u8; 6771] = [
        0x64, 0x86, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x14, 0x00, 0x00, 0x33, 0x00, 0x00,
        ...
    ];

    let _ = Coffee::new(&whoami_bof).unwrap().execute(None, None, None);
}

The example above will execute the BOF passed as an array of bytes and show the output in console.

The detailed documentation can be found at: https://docs.rs/coffee-ldr/latest/coffee_ldr/loader/struct.Coffee.html

Building from source

  1. Install Rust from https://rustup.rs/
  2. Clone the repository
  3. Build the project using
cargo build --release

License

Coffee is licensed under the GNU GPLv3 license. See LICENSE for more information.

Contributing

Pull requests are welcome. Please open an issue first to discuss what you would like to change.

References

Thanks to the amazing people who have written about COFF loaders and helped me understand the format:

coffee's People

Contributors

b1scoito avatar

Stargazers

 avatar

Watchers

 avatar

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.