feat: added modified TCP packet parser

checksum generation code is different, to allow for
some sneaky tricks with regards to identifying the sparse
session but binding to the same port multiple times
This commit is contained in:
Andrew Rioux
2023-09-18 01:29:05 -04:00
parent 25948a17f4
commit e5f6c2aa7e
9 changed files with 137 additions and 21 deletions

View File

@@ -3,6 +3,11 @@ use std::net::Ipv4Addr;
use anyhow::anyhow;
use nl_sys::{netlink, route};
use packets::EthernetPacket;
struct TcpConnection {
packets_to_ack: Vec<EthernetPacket>,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
@@ -27,7 +32,7 @@ async fn main() -> anyhow::Result<()> {
(ifname, srcip, srcmac, dstmac)
};
let mut interface = pcap_sys::new_aggregate_interface(false)?;
let mut interface = pcap_sys::Interface::<pcap_sys::DevDisabled>::new(&ifname)?;
interface.set_buffer_size(8192)?;
interface.set_non_blocking(true)?;
@@ -36,9 +41,14 @@ async fn main() -> anyhow::Result<()> {
let mut interface = interface.activate()?;
interface.set_filter("inbound and tcp port 54249", true, None)?;
let port: u16 = loop {
let port = rand::random();
if port > 30_000 {
break port;
}
};
interface.prune(|_, interface| interface.datalink() != pcap_sys::consts::DLT_EN10MB);
interface.set_filter(&format!("inbound and tcp port {}", port), true, None)?;
Ok(())
}