Skip to content

Oxidize mettle? #209

@sempervictus

Description

@sempervictus

There aren't a lot of us out there who can write in C, and fewer still who can screw with the complex ecosystem in here effectively. This results in reduced community contribution because even skilled contributors have to block off significant slices of time to "get into" the work, unless its something they do often (and the commit log indicates no such person exists).

The reason we moved away from the old merged codebase is because the original POSIX meterpreter was an unsupported (mostly) codebase, relying on RTLD tricks from a version of Bionic which couldn't get pthreads right by the end and devolved into a tire fire. Mettle brought us a stable stack to build and run - MUSL is carried with the payload to give us our own ABI-compatible libc on-target. Nowadays, the modality implemented by @acammack-r7 and @busterb for the libc component is common in the Rust toolchain.

What if we rewrote Mettle in Rust? It would greatly simplify the dependency tracking which is likely going to be the achilles heel of the current codebase with @busterb having moved on from R7, it produces static code on the MUSL toolchain just like Mettle does now, and it has all of the low-level interfaces we get with raw C, with with semantics and idioms much more acceptable by the current generation of hackers (face it OGs, we really are old). Rust should bring new interest from the community, get more developers on-board from their ecosystem, and generally make rapid post-exp development a lot faster. Moreover, the feature-based compilation targets would allow us to have massive entropy in our payloads - blue team can scan memory for a byte sequence of op codes known to be present in extension X all they want - if the user didn't want that function (such as file write for forensic integrity or anything that can even alter atime), it's not there, and defenders can pound sand looking for it. Lastly, there's the rich and rapidly evolving Rust ecosystem to which we would immediately have access for all sorts of on-target data and functional tasks.

My Rust-fu is not great yet, but picking up as i go. I'm never the first one to the party though around these parts so i'm guessing a few of the folks reading this might already be way ahead of me. The trickiest parts i can forsee right now is handling the in-memory libload from a session stream and picking up execution from stage0. The former might require some cajoling of the compiler, hopefully not, the latter i figure that it can be done because Redox boots off an unsafe raw context... Having a TLV-parsing crate would also be very useful for the defensive world - Suricata and such could directly include it. Lastly, if we get it right, we could potentially reunify meterpreter altogether and reduce the amount of parity work required in two codebases to adopt common features.

Who owns this repo nowadays? Any thoughts from maintainers and community folks?
Ping @acammack-r7 @OJ @busterb @timwr @zeroSteiner (@smcintyre-r7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions