Skip to content

Commit

Permalink
Modified to receive SEQ and ACK numbers as command-line parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ezequielpereira committed May 12, 2020
1 parent 602a08b commit e3c797d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub struct Arguments {
pub interface: String,
pub src: SocketAddrV4,
pub dst: SocketAddrV4,
pub seq: u32,
pub ack: u32,
pub reset: bool,
pub send_null: bool,
pub quiet: u8,
Expand All @@ -35,6 +37,14 @@ shijack credited cyclozine for inspiration."#)
.required(true)
.help("The destination of the connection")
)
.arg(Arg::with_name("seq")
.required(true)
.help("Initial seq number")
)
.arg(Arg::with_name("ack")
.required(true)
.help("Initial ack number")
)
.arg(Arg::with_name("reset")
.short("r")
.long("reset")
Expand All @@ -56,6 +66,8 @@ shijack credited cyclozine for inspiration."#)
let interface = matches.value_of("interface").unwrap();
let src = matches.value_of("src").unwrap();
let dst = matches.value_of("dst").unwrap();
let seq = matches.value_of("seq").unwrap().parse::<u32>().unwrap();
let ack = matches.value_of("ack").unwrap().parse::<u32>().unwrap();
let reset = matches.occurrences_of("reset") > 0;
let send_null = matches.occurrences_of("send-null") > 0;
let quiet = matches.occurrences_of("quiet") as u8;
Expand All @@ -67,6 +79,8 @@ shijack credited cyclozine for inspiration."#)
interface: interface.into(),
src,
dst,
seq,
ack,
reset,
send_null,
quiet,
Expand Down
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::thread;
use args::Arguments;
use net::TcpFlags;

use std::net::SocketAddrV4;

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

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

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

0 comments on commit e3c797d

Please sign in to comment.