mirror of
https://github.com/ivre/masscanned.git
synced 2025-10-02 06:38:21 +00:00
Add test for issue GH#50
This commit is contained in:
parent
b8fd84bf94
commit
d6b6de7d3f
1 changed files with 51 additions and 0 deletions
|
@ -188,6 +188,57 @@ mod tests {
|
|||
assert!(tcp_repl.get_acknowledgement() == seq + 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tcp_fin_ack_wrap() {
|
||||
let masscanned = Masscanned {
|
||||
mac: MacAddr(0, 0, 0, 0, 0, 0),
|
||||
ip_addresses: None,
|
||||
synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f],
|
||||
iface: None,
|
||||
log: MetaLogger::new(),
|
||||
};
|
||||
/* reference */
|
||||
let ip_src = IpAddr::V4(Ipv4Addr::new(27, 198, 143, 1));
|
||||
let ip_dst = IpAddr::V4(Ipv4Addr::new(90, 64, 122, 203));
|
||||
let tcp_sport = 65500;
|
||||
let tcp_dport = 80;
|
||||
let seq = 0xffffffff;
|
||||
let ack = 0xffffffff;
|
||||
let mut client_info = ClientInfo {
|
||||
mac: ClientInfoSrcDst {
|
||||
src: None,
|
||||
dst: None,
|
||||
},
|
||||
ip: ClientInfoSrcDst {
|
||||
src: Some(ip_src),
|
||||
dst: Some(ip_dst),
|
||||
},
|
||||
transport: None,
|
||||
port: ClientInfoSrcDst {
|
||||
src: Some(tcp_sport),
|
||||
dst: Some(tcp_dport),
|
||||
},
|
||||
cookie: None,
|
||||
};
|
||||
let mut tcp_req =
|
||||
MutableTcpPacket::owned(vec![0; MutableTcpPacket::minimum_packet_size()]).unwrap();
|
||||
tcp_req.set_source(tcp_sport);
|
||||
tcp_req.set_destination(tcp_dport);
|
||||
tcp_req.set_sequence(seq);
|
||||
tcp_req.set_acknowledgement(ack);
|
||||
tcp_req.set_flags(TcpFlags::FIN | TcpFlags::ACK);
|
||||
let some_tcp_repl = repl(&tcp_req.to_immutable(), &masscanned, &mut client_info);
|
||||
if some_tcp_repl == None {
|
||||
panic!("expected a reply, got none");
|
||||
}
|
||||
let tcp_repl = some_tcp_repl.unwrap();
|
||||
/* check reply flags */
|
||||
assert!(tcp_repl.get_flags() == (TcpFlags::FIN | TcpFlags::ACK));
|
||||
/* check reply seq and ack */
|
||||
assert!(tcp_repl.get_sequence() == ack);
|
||||
assert!(tcp_repl.get_acknowledgement() == seq.wrapping_add(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_synack_cookie_ipv4() {
|
||||
let masscanned = Masscanned {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue