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:
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
pcap-sys = { path = "../../pcap-sys" }
|
||||
packets = { path = "../../packets" }
|
||||
nl-sys = { path = "../../nl-sys" }
|
||||
rand = "0.8.5"
|
||||
tokio = { version = "1.32.0", features = ["full"] }
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user