mirror of
https://github.com/ivre/masscanned.git
synced 2025-10-02 14:48:22 +00:00
Tests: fix IPv6 warnings from Scapy
This commit is contained in:
parent
96b82bdce2
commit
b5fb589361
2 changed files with 18 additions and 6 deletions
|
@ -15,6 +15,7 @@
|
||||||
# along with Masscanned. If not, see <http://www.gnu.org/licenses/>.
|
# along with Masscanned. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from socket import AF_INET6
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from scapy.compat import raw
|
from scapy.compat import raw
|
||||||
|
@ -29,6 +30,7 @@ from scapy.layers.inet6 import (
|
||||||
IPv6,
|
IPv6,
|
||||||
)
|
)
|
||||||
from scapy.layers.l2 import ARP, Ether
|
from scapy.layers.l2 import ARP, Ether
|
||||||
|
from scapy.pton_ntop import inet_pton
|
||||||
from scapy.packet import Raw
|
from scapy.packet import Raw
|
||||||
from scapy.volatile import RandInt
|
from scapy.volatile import RandInt
|
||||||
|
|
||||||
|
@ -815,9 +817,12 @@ def test_ipv6_udp_stun(iface):
|
||||||
assert (
|
assert (
|
||||||
tid == b"\x00" * 12
|
tid == b"\x00" * 12
|
||||||
), "expected tid 0x000000000000000000000000, got {:x}".format(tid)
|
), "expected tid 0x000000000000000000000000, got {:x}".format(tid)
|
||||||
assert data == bytes.fromhex("000100140002") + struct.pack(
|
expected_data = (
|
||||||
">H", sport
|
bytes.fromhex("000100140002")
|
||||||
) + bytes.fromhex("00000000" * 4), "unexpected data: {}".format(data)
|
+ struct.pack(">H", sport)
|
||||||
|
+ inet_pton(AF_INET6, "2001:41d0::1234:5678")
|
||||||
|
)
|
||||||
|
assert data == expected_data, "unexpected data: {}".format(data)
|
||||||
|
|
||||||
|
|
||||||
@test
|
@test
|
||||||
|
@ -898,9 +903,14 @@ def test_ipv6_udp_stun_change_port(iface):
|
||||||
assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), (
|
assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), (
|
||||||
"expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid
|
"expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid
|
||||||
)
|
)
|
||||||
assert data == bytes.fromhex("000100140002") + struct.pack(
|
expected_data = (
|
||||||
">H", sport
|
bytes.fromhex("000100140002")
|
||||||
) + bytes.fromhex("00000000" * 4)
|
+ struct.pack(">H", sport)
|
||||||
|
+ inet_pton(AF_INET6, "2001:41d0::1234:5678")
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
data == expected_data
|
||||||
|
), f"unexpected data {data!r} != {expected_data!r}"
|
||||||
|
|
||||||
|
|
||||||
@test
|
@test
|
||||||
|
|
|
@ -68,9 +68,11 @@ conf.iface = resolve_iface(IFACE)
|
||||||
|
|
||||||
# set interface
|
# set interface
|
||||||
subprocess.check_call(["ip", "addr", "add", "dev", IFACE, "192.0.0.0/31"])
|
subprocess.check_call(["ip", "addr", "add", "dev", IFACE, "192.0.0.0/31"])
|
||||||
|
subprocess.check_call(["ip", "addr", "add", "dev", IFACE, "2001:41d0::1234:5678/96"])
|
||||||
subprocess.check_call(["ip", "link", "set", IFACE, "up"])
|
subprocess.check_call(["ip", "link", "set", IFACE, "up"])
|
||||||
subprocess.check_call(["ip", "route", "add", "1.2.3.4/32", "via", IPV4_ADDR])
|
subprocess.check_call(["ip", "route", "add", "1.2.3.4/32", "via", IPV4_ADDR])
|
||||||
conf.route.resync()
|
conf.route.resync()
|
||||||
|
conf.route6.resync()
|
||||||
|
|
||||||
# start capture
|
# start capture
|
||||||
if TCPDUMP:
|
if TCPDUMP:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue