Adversarial C2 Protocol Implemented in Zig
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix issue returning stack pointer

+8 -5
+8 -5
src/Client.zig
··· 124 124 return p; 125 125 } 126 126 127 - pub fn sendInitialConnection(payload: []const u8, initial_port: u16) !*SaprusMessage { 127 + pub fn sendInitialConnection( 128 + payload: []const u8, 129 + output_bytes: []align(@alignOf(SaprusMessage)) u8, 130 + initial_port: u16, 131 + ) !*SaprusMessage { 128 132 const dest_port = randomPort(); 129 - var buf: [max_message_size]u8 align(@alignOf(SaprusMessage)) = undefined; 130 - const msg_bytes = buf[0..try SaprusMessage.calcSize( 133 + const msg_bytes = output_bytes[0..try SaprusMessage.calcSize( 131 134 .connection, 132 135 base64Enc.calcSize(payload.len), 133 136 )]; ··· 161 164 try sock.setReadTimeout(1 * std.time.us_per_s); 162 165 try sock.bind(bind_addr); 163 166 164 - const msg = try sendInitialConnection(payload, initial_port); 167 + var sent_msg_bytes: [max_message_size]u8 align(@alignOf(SaprusMessage)) = undefined; 168 + const msg = try sendInitialConnection(payload, &sent_msg_bytes, initial_port); 165 169 166 170 var response_buf: [max_message_size]u8 align(@alignOf(SaprusMessage)) = undefined; 167 171 _ = try sock.receive(&response_buf); // Ignore message that I sent. 168 172 const len = try sock.receive(&response_buf); 169 173 170 - std.debug.print("response bytes: {x}\n", .{response_buf[0..len]}); 171 174 initial_conn_res = try .networkBytesAsValue(response_buf[0..len]); 172 175 173 176 // Complete handshake after awaiting response