Skip to content

Commit e3c797d

Browse files
Modified to receive SEQ and ACK numbers as command-line parameters
1 parent 602a08b commit e3c797d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/args.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub struct Arguments {
1010
pub interface: String,
1111
pub src: SocketAddrV4,
1212
pub dst: SocketAddrV4,
13+
pub seq: u32,
14+
pub ack: u32,
1315
pub reset: bool,
1416
pub send_null: bool,
1517
pub quiet: u8,
@@ -35,6 +37,14 @@ shijack credited cyclozine for inspiration."#)
3537
.required(true)
3638
.help("The destination of the connection")
3739
)
40+
.arg(Arg::with_name("seq")
41+
.required(true)
42+
.help("Initial seq number")
43+
)
44+
.arg(Arg::with_name("ack")
45+
.required(true)
46+
.help("Initial ack number")
47+
)
3848
.arg(Arg::with_name("reset")
3949
.short("r")
4050
.long("reset")
@@ -56,6 +66,8 @@ shijack credited cyclozine for inspiration."#)
5666
let interface = matches.value_of("interface").unwrap();
5767
let src = matches.value_of("src").unwrap();
5868
let dst = matches.value_of("dst").unwrap();
69+
let seq = matches.value_of("seq").unwrap().parse::<u32>().unwrap();
70+
let ack = matches.value_of("ack").unwrap().parse::<u32>().unwrap();
5971
let reset = matches.occurrences_of("reset") > 0;
6072
let send_null = matches.occurrences_of("send-null") > 0;
6173
let quiet = matches.occurrences_of("quiet") as u8;
@@ -67,6 +79,8 @@ shijack credited cyclozine for inspiration."#)
6779
interface: interface.into(),
6880
src,
6981
dst,
82+
seq,
83+
ack,
7084
reset,
7185
send_null,
7286
quiet,

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use std::thread;
3030
use args::Arguments;
3131
use net::TcpFlags;
3232

33+
use std::net::SocketAddrV4;
3334

3435
fn run() -> Result<()> {
3536
let arguments = Arguments::parse().chain_err(|| "failed to parse arguments")?;
@@ -45,7 +46,12 @@ fn run() -> Result<()> {
4546
eprintln!("Waiting for SEQ/ACK to arrive from the srcip to the dstip.");
4647
eprintln!("(To speed things up, try making some traffic between the two, /msg person asdf)");
4748

48-
let mut connection = net::getseqack(&arguments.interface, &arguments.src, &arguments.dst)?;
49+
let mut connection = net::Connection::new(
50+
SocketAddrV4::new(*arguments.src.ip(), arguments.src.port()),
51+
SocketAddrV4::new(*arguments.dst.ip(), arguments.dst.port()),
52+
arguments.seq,
53+
arguments.ack,
54+
);
4955
eprintln!("[+] Got packet! SEQ = 0x{:x}, ACK = 0x{:x}", connection.get_seq(), connection.get_ack());
5056

5157
let (mut tx, _rx) = net::create_socket()?;

0 commit comments

Comments
 (0)