From e23791d4bbb20c142f5ba2e5b151d5f1a51ae707 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sun, 11 Dec 2022 18:36:38 +0100 Subject: [PATCH] finally working, much more reverse ingenerring to do --- .gitignore | 1 + src/main.rs | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 3ca43ae..3bb9346 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb +pkts.txt \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 0ba61b7..5ad5d56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -142,7 +142,7 @@ fn main() { let interfaces = pnet_datalink::interfaces(); let interface = interfaces.into_iter().next().unwrap(); // let (mut tx, mut rx) = match transport_channel(1500, Layer3(IpNextHeaderProtocols::Udp)) { - let (mut tx, mut rx) = match transport_channel(1500, Layer3(pnet_packet::ip::IpNextHeaderProtocols::Icmp)) { + let (mut tx, mut rx) = match transport_channel(1500, Layer3(pnet_packet::ip::IpNextHeaderProtocols::Ipv4)) { // let (mut tx, mut rx) = match transport_channel(1500, Layer4(Ipv4(Icmp))) { Ok((tx, rx)) => (tx, rx), Err(e) => panic!("An error occurred when creating transport channel: {}", e), @@ -156,8 +156,8 @@ fn main() { let mut recv = icmp_packet_iter(&mut rx); // Create a new mutable ICMP packet - let mut binding = [4;64]; - let mut packet = icmp::MutableIcmpPacket::new(&mut binding).expect("Couldn't create packet"); + // let mut binding = [4;64]; + // let mut packet = icmp::MutableIcmpPacket::new(&mut binding).expect("Couldn't create packet"); // let mut packet = pnet_packet::ipv4::MutableIpv4Packet::new(&mut binding).expect("Couldn't create packet"); // // Set the ICMP packet type and code to the appropriate values for a ping request // packet.set_icmp_type(icmp::IcmpTypes::EchoRequest); @@ -165,12 +165,19 @@ fn main() { // // let frozen = binding.clone(); // packet.set_checksum(pnet_packet::icmp::checksum(&packet.to_immutable())); // // Get a `Packet` object representing the ping request packet - let ping_request_packet = packet.packet(); - let IDENT_NUM: u16 = 111; + // let ping_request_packet = packet.packet(); + // let IDENT_NUM: u16 = 111; // Create a new mutable Ethernet packet containaing the ICMP packet let mut binding = [3; 64+32]; - let mut ethernet_packet = MutableEthernetPacket::new(&mut binding).unwrap(); - // let mut ethernet_packet = pnet_packet::ipv4::MutableIpv4Packet::new(&mut binding).unwrap(); + let mut binding = [/*0x44 ,0xd4 ,0x53 ,0x93 ,0x8a ,0x90 ,0x54 ,0xaf ,0x97 ,0x4d ,0x13 ,0xbf ,0x08 ,0x00 ,*/0x45 ,0x00, + 0x00 ,0x54 ,0xcd ,0xdf ,0x40 ,0x00 ,0x40 ,0x01 ,0xe9 ,0x74 ,0xc0 ,0xa8 ,0x01 ,0x03 ,0xc0 ,0xa8, + 0x01 ,0x01 ,0x08 ,0x00 ,0xba ,0x4c ,0x00 ,0x02 ,0x00 ,0x02 ,0xed ,0x04 ,0x95 ,0x63 ,0x00 ,0x00, + 0x00 ,0x00 ,0xf6 ,0x73 ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x10 ,0x11 ,0x12 ,0x13 ,0x14 ,0x15, + 0x16 ,0x17 ,0x18 ,0x19 ,0x1a ,0x1b ,0x1c ,0x1d ,0x1e ,0x1f ,0x20 ,0x21 ,0x22 ,0x23 ,0x24 ,0x25, + 0x26 ,0x27 ,0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,0x30 ,0x31 ,0x32 ,0x33 ,0x34 ,0x35, 0x36, 0x37]; + + // let mut ethernet_packet = MutableEthernetPacket::new(&mut binding).unwrap(); + let mut ethernet_packet = pnet_packet::ipv4::MutableIpv4Packet::new(&mut binding).unwrap(); // ethernet_packet.set_icmp_type(); // Set the destination and source MAC addresses