Fix bug in HTTP segmented test + clean

This commit is contained in:
_Frky 2022-02-16 12:07:48 +01:00
parent b74d891385
commit c6118e1448
4 changed files with 10 additions and 9 deletions

View file

@ -20,7 +20,6 @@ use std::convert::TryInto;
use std::time::SystemTime; use std::time::SystemTime;
use crate::client::ClientInfo; use crate::client::ClientInfo;
use crate::logger::MetaLogger;
use crate::proto::TCPControlBlock; use crate::proto::TCPControlBlock;
use crate::Masscanned; use crate::Masscanned;

View file

@ -76,7 +76,7 @@ def test_ipv4_tcp_http():
@test @test
def test_ipv4_tcp_http_segmented(): def test_ipv4_tcp_http_segmented():
sport = 24592 sport = 24593
dports = [80, 443, 5000, 53228] dports = [80, 443, 5000, 53228]
for dport in dports: for dport in dports:
seq_init = int(RandInt()) seq_init = int(RandInt())
@ -120,7 +120,9 @@ def test_ipv4_tcp_http_segmented():
assert resp is not None, "expecting answer, got nothing" assert resp is not None, "expecting answer, got nothing"
check_ip_checksum(resp) check_ip_checksum(resp)
assert TCP in resp, "expecting TCP, got %r" % resp.summary() assert TCP in resp, "expecting TCP, got %r" % resp.summary()
assert resp[TCP].flags == "A" assert resp[TCP].flags == "A", (
'expecting TCP flag "A", got %r' % resp[TCP].flags
)
req = ( req = (
Ether(dst=MAC_ADDR) Ether(dst=MAC_ADDR)
/ IP(dst=IPV4_ADDR) / IP(dst=IPV4_ADDR)

View file

@ -63,11 +63,11 @@ def test_rpc_nmap():
assert port["service_name"] in { assert port["service_name"] in {
"rpcbind", "rpcbind",
"nfs", "nfs",
}, f"Unexpected service_name: {port['service_name']}" }, f"Unexpected service_name: {port['service_name']}"
assert port["service_extrainfo"] in { assert port["service_extrainfo"] in {
"RPC #100000", "RPC #100000",
"RPC #100003", "RPC #100003",
}, f"Unexpected service_extrainfo: {port['service_extrainfo']}" }, f"Unexpected service_extrainfo: {port['service_extrainfo']}"
assert ( assert (
len(port["scripts"]) == 1 len(port["scripts"]) == 1
), f"Expected 1 script, got {len(port['scripts'])}" ), f"Expected 1 script, got {len(port['scripts'])}"

View file

@ -127,9 +127,9 @@ def test_ipv4_udp_stun_change_port():
assert UDP in resp, "no UDP layer found" assert UDP in resp, "no UDP layer found"
udp = resp[UDP] udp = resp[UDP]
assert ( assert (
udp.sport == (dport + 1) % 2**16 udp.sport == (dport + 1) % 2 ** 16
), "expected answer from UDP/{}, got it from UDP/{}".format( ), "expected answer from UDP/{}, got it from UDP/{}".format(
(dport + 1) % 2**16, udp.sport (dport + 1) % 2 ** 16, udp.sport
) )
assert ( assert (
udp.dport == sport udp.dport == sport
@ -170,9 +170,9 @@ def test_ipv6_udp_stun_change_port():
assert UDP in resp, "expecting UDP layer in answer, got nothing" assert UDP in resp, "expecting UDP layer in answer, got nothing"
udp = resp[UDP] udp = resp[UDP]
assert ( assert (
udp.sport == (dport + 1) % 2**16 udp.sport == (dport + 1) % 2 ** 16
), "expected answer from UDP/{}, got it from UDP/{}".format( ), "expected answer from UDP/{}, got it from UDP/{}".format(
(dport + 1) % 2**16, udp.sport (dport + 1) % 2 ** 16, udp.sport
) )
assert ( assert (
udp.dport == sport udp.dport == sport