From ea5b58556fb02dd61dc666368a6e73801940c890 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 8 Dec 2021 21:47:32 +0100 Subject: [PATCH 001/317] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 8f5a1f6..0dd352b 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,15 @@ $ cargo build ... ``` +## Use it + +A good use of **masscanned** is to deploy it on a VPS with one or more public IP addresses. + +To use the results, the best way is to capture all network traffic on the interface **masscanned** is listening to/responding on. +The pcaps can then be analyzed using [zeek](https://zeek.org/) and the output files can typically be pushed in an instance of **IVRE**. + +A documentation on how to deploy an instance of **masscanned** on a VPS is coming (see [Issue #2](https://github.com/ivre/masscanned/issues/2)). + ## Protocols ### Layer 2 From 12aa60b848ccfff1cc27682f4a4fc2dfb0f1056f Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 8 Dec 2021 22:50:05 +0100 Subject: [PATCH 002/317] CI: add build workflow --- .github/workflows/test.yml | 82 ++++++++++++++++++++++++++++++++++++++ .gitignore | 2 + README.md | 2 + test/requirements.txt | 2 + test/src/all.py | 17 +++++--- test/test_masscanned.py | 11 +++-- 6 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 test/requirements.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5c16b63 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,82 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +name: Build masscanned + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: Git checkout + uses: actions/checkout@v2 + + - name: Get Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Run cargo build + uses: actions-rs/cargo@v1 + with: + command: build + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + - name: Create build archive + run: tar cf masscanned.tar target/debug/masscanned + + - name: Upload binary + uses: actions/upload-artifact@v2 + with: + name: masscanned.tar + path: masscanned.tar + + test: + needs: build + runs-on: ubuntu-latest + steps: + + - name: Git checkout + uses: actions/checkout@v2 + + - name: Get binary + uses: actions/download-artifact@v2 + with: + name: masscanned.tar + + - name: Extract build archive + run: tar xf masscanned.tar + + - name: Use Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install dependencies + run: sudo pip install -r test/requirements.txt + + - name: Run tests + run: sudo python test/test_masscanned.py + + - name: Display logs + run: echo STDOUT; cat test/res/masscanned.stdout && echo && echo STDERR && cat test/res/masscanned.stderr + if: failure() diff --git a/.gitignore b/.gitignore index f07cd65..3feaee7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ Cargo.lock # Vim temporary files *.swp *.swo +# Emacs temporary files +*~ *__pycache__* test/res/* diff --git a/README.md b/README.md index 8f5a1f6..cc8491f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build masscanned](https://github.com/ivre/masscanned/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ivre/masscanned/actions/workflows/test.yml?branch=master) + # Masscanned **Masscanned** (name inspired, of course, by [masscan](https://github.com/robertdavidgraham/masscan)) diff --git a/test/requirements.txt b/test/requirements.txt new file mode 100644 index 0000000..ebda39b --- /dev/null +++ b/test/requirements.txt @@ -0,0 +1,2 @@ +scapy +requests diff --git a/test/src/all.py b/test/src/all.py index e031228..bd121ed 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -29,20 +29,22 @@ LOG = logging.getLogger(__name__) LOG.setLevel(logging.DEBUG) LOG.addHandler(ch) -tests = list() +tests = [] +errors = [] # decorator to automatically add a function to tests def test(f): + global errors, tests OK = "\033[1mOK\033[0m" KO = "\033[1m\033[1;%dmKO\033[0m" % 31 - global tests fname = f.__name__.ljust(50, '.') def w(iface): try: f(iface) LOG.info("{}{}".format(fname, OK)) except AssertionError as e: - LOG.info("{}{}: {}".format(fname, KO, e)) + LOG.error("{}{}: {}".format(fname, KO, e)) + errors.append(fname) tests.append(w) return w @@ -80,7 +82,7 @@ def check_ipv6_checksum(pkt): @test def test_arp_req(iface): ##### ARP ##### - arp_req = Ether()/ARP(psrc='192.0.0.2', pdst=IPV4_ADDR) + arp_req = Ether(dst=ETHER_BROADCAST)/ARP(psrc='192.0.0.2', pdst=IPV4_ADDR) arp_repl = iface.sr1(arp_req, timeout=1) assert(arp_repl is not None), "expecting answer, got nothing" assert(ARP in arp_repl), "no ARP layer found" @@ -425,7 +427,8 @@ def test_ipv4_udp_stun(iface): assert(length == 12), "expected length 12, got {}".format(length) assert(magic == 0x2112a442), "expected magic 0x2112a442, got 0x{:08x}".format(magic) assert(tid == b'\x00' * 12), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - assert(data == bytes.fromhex("000100080001") + struct.pack(">H", sport) + bytes.fromhex("00000000")), "unexpected data" + assert(data[:8] == bytes.fromhex("000100080001") + struct.pack(">H", sport)), f"unexpected data {data!r}" + assert(len(data) == 12), f"unexpected data {data!r}" @test def test_ipv6_udp_stun(iface): @@ -474,7 +477,8 @@ def test_ipv4_udp_stun_change_port(iface): assert(type_ == 0x0101), "expected type 0X0101, got 0x{:04x}".format(type_) assert(length == 12), "expected length 12, got {}".format(length) assert(tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c")), "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid - assert(data == bytes.fromhex("000100080001") + struct.pack(">H", sport) + bytes.fromhex("00000000")), "unexpected data" + assert(data[:8] == bytes.fromhex("000100080001") + struct.pack(">H", sport)), f"unexpected data {data!r}" + assert(len(data) == 12), f"unexpected data {data!r}" @test def test_ipv6_udp_stun_change_port(iface): @@ -591,3 +595,4 @@ def test_all(iface): # execute tests for t in tests: t(iface) + return len(errors) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 7384005..f3f973a 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -42,7 +42,8 @@ LOG = logging.getLogger(__name__) LOG.setLevel(logging.INFO) LOG.addHandler(ch) -conf.iface = 'tap0' +IFACE = "tap0" + conf.verb = 0 # prepare configuration file for masscanned @@ -52,7 +53,8 @@ with open(ipfile, "w") as f: f.write("{}\n".format(IPV6_ADDR)) # create test interface -tap = TunTapInterface(resolve_iface(conf.iface)) +tap = TunTapInterface(IFACE) +conf.iface = resolve_iface(IFACE) # set interface subprocess.run("ip a a dev {} 192.0.0.2".format(conf.iface), shell=True) @@ -67,12 +69,13 @@ masscanned = subprocess.Popen("RUST_BACKTRACE=1 ./target/debug/masscanned -vvvvv sleep(1) try: - test_all(tap) + result = test_all(tap) except AssertionError: - pass + result = -1 # terminate masscanned masscanned.kill() # terminate capture sleep(2) tcpdump.kill() +sys.exit(result) From 9fb050188d9446090dfca3f165a86af45ef34b07 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 8 Dec 2021 23:35:26 +0100 Subject: [PATCH 003/317] Clean-up Python test script --- test/test_masscanned.py | 75 ++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index f3f973a..49a99ef 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -16,56 +16,68 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . -from scapy.all import * -from time import sleep -from tempfile import _get_candidate_names as gen_tmp_filename -from tempfile import gettempdir -import subprocess import logging -import sys import os +import subprocess +import sys +from time import sleep +from tempfile import NamedTemporaryFile + +from scapy.config import conf +from scapy.interfaces import resolve_iface +from scapy.layers.tuntap import TunTapInterface from src.all import test_all from src.conf import * -# if args in CLI, they are passed to masscanned -if len(sys.argv) > 1: - args = " ".join(sys.argv[1:]) -else: - args = "" - -fmt = logging.Formatter("%(levelname)s\t%(message)s") -ch = logging.StreamHandler() -ch.setFormatter(fmt) -ch.setLevel(logging.INFO) -LOG = logging.getLogger(__name__) -LOG.setLevel(logging.INFO) -LOG.addHandler(ch) +def setup_logs(): + ch = logging.StreamHandler() + ch.setFormatter(logging.Formatter("%(levelname)s\t%(message)s")) + ch.setLevel(logging.INFO) + log = logging.getLogger(__name__) + log.setLevel(logging.INFO) + log.addHandler(ch) + return log +LOG = setup_logs() IFACE = "tap0" - conf.verb = 0 # prepare configuration file for masscanned -ipfile = os.path.join(gettempdir(), next(gen_tmp_filename())) -with open(ipfile, "w") as f: - f.write("{}\n".format(IPV4_ADDR)) - f.write("{}\n".format(IPV6_ADDR)) +with NamedTemporaryFile(delete=False, mode="w") as ipfile: + ipfile.write(f"{IPV4_ADDR}\n") + ipfile.write(f"{IPV6_ADDR}\n") # create test interface tap = TunTapInterface(IFACE) conf.iface = resolve_iface(IFACE) # set interface -subprocess.run("ip a a dev {} 192.0.0.2".format(conf.iface), shell=True) -subprocess.run("ip link set {} up".format(conf.iface), shell=True) +subprocess.check_call(["ip", "addr", "add", "dev", IFACE, "192.0.0.2"]) +subprocess.check_call(["ip", "link", "set", IFACE, "up"]) # start capture -tcpdump = subprocess.Popen("tcpdump -enli {} -w {}".format(conf.iface, os.path.join(OUTDIR, "test_capture.pcap")), shell=True, - stdin=None, stdout=None, stderr=None, close_fds=True) +tcpdump = subprocess.Popen( + ["tcpdump", "-enli", IFACE, "-w", os.path.join(OUTDIR, "test_capture.pcap")] +) # run masscanned -masscanned = subprocess.Popen("RUST_BACKTRACE=1 ./target/debug/masscanned -vvvvv -i {} -f {} -a {} {}".format(conf.iface, ipfile, MAC_ADDR, args), shell=True, - stdin=None, stdout=open("test/res/masscanned.stdout", "w"), stderr=open("test/res/masscanned.stderr", "w"), close_fds=True) +masscanned = subprocess.Popen( + [ + "./target/debug/masscanned", + "-vvvvv", + "-i", + IFACE, + "-f", + ipfile.name, + "-a", + MAC_ADDR, + ] + # if args in CLI, they are passed to masscanned + + sys.argv[1:], + env=dict(os.environ, RUST_BACKTRACE="1"), + stdout=open("test/res/masscanned.stdout", "w"), + stderr=open("test/res/masscanned.stderr", "w"), +) sleep(1) try: @@ -75,7 +87,8 @@ except AssertionError: # terminate masscanned masscanned.kill() +masscanned.wait() # terminate capture -sleep(2) tcpdump.kill() +tcpdump.wait() sys.exit(result) From 70eae9bc0cd45b80d5ff705d1291763e76083453 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 12:08:19 +0100 Subject: [PATCH 004/317] Tests: clean Python code, add linting to CI --- .github/workflows/test.yml | 11 +- test/src/all.py | 862 ++++++++++++++++++++++++++----------- test/src/conf.py | 2 +- test/test_masscanned.py | 4 +- 4 files changed, 636 insertions(+), 243 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c16b63..ed34ff7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,7 +72,16 @@ jobs: python-version: 3.9 - name: Install dependencies - run: sudo pip install -r test/requirements.txt + run: sudo pip install -U -r test/requirements.txt + + - name: Install linting tools + run: sudo pip install -U flake8 black + + - name: Run black + run: black -t py36 --check test/test_masscanned.py test/src/ + + - name: Run flake8 + run: flake8 --ignore=E266,E501,W503 test/test_masscanned.py test/src/all.py - name: Run tests run: sudo python test/test_masscanned.py diff --git a/test/src/all.py b/test/src/all.py index bd121ed..10af976 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -14,40 +14,60 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . -from scapy.all import * -import requests -import requests.packages.urllib3.util.connection as urllib3_cn import logging +import struct -from .conf import * +from scapy.compat import raw +from scapy.data import ETHER_BROADCAST +from scapy.layers.inet import ICMP, IP, TCP, UDP +from scapy.layers.inet6 import ( + ICMPv6EchoReply, + ICMPv6EchoRequest, + ICMPv6ND_NA, + ICMPv6ND_NS, + ICMPv6NDOptDstLLAddr, + IPv6, +) +from scapy.layers.l2 import ARP, Ether +from scapy.packet import Raw -fmt = logging.Formatter("%(levelname)s\t%(message)s") -ch = logging.StreamHandler() -ch.setFormatter(fmt) -ch.setLevel(logging.DEBUG) -LOG = logging.getLogger(__name__) -LOG.setLevel(logging.DEBUG) -LOG.addHandler(ch) +from .conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR + + +def setup_logs(): + ch = logging.StreamHandler() + ch.setFormatter(logging.Formatter("%(levelname)s\t%(message)s")) + ch.setLevel(logging.DEBUG) + log = logging.getLogger(__name__) + log.setLevel(logging.DEBUG) + log.addHandler(ch) + return log + + +LOG = setup_logs() +TESTS = [] +ERRORS = [] -tests = [] -errors = [] # decorator to automatically add a function to tests def test(f): - global errors, tests + global ERRORS, TESTS OK = "\033[1mOK\033[0m" KO = "\033[1m\033[1;%dmKO\033[0m" % 31 - fname = f.__name__.ljust(50, '.') + fname = f.__name__.ljust(50, ".") + def w(iface): try: f(iface) LOG.info("{}{}".format(fname, OK)) except AssertionError as e: LOG.error("{}{}: {}".format(fname, KO, e)) - errors.append(fname) - tests.append(w) + ERRORS.append(fname) + + TESTS.append(w) return w + def multicast(ip6): a, b = ip6.split(":")[-2:] mac = ["33", "33", "ff"] @@ -65,150 +85,276 @@ def multicast(ip6): mac.append("00") return ":".join(mac) + def check_ip_checksum(pkt): - assert(IP in pkt), "no IP layer found" + assert IP in pkt, "no IP layer found" ip_pkt = pkt[IP] chksum = ip_pkt.chksum del ip_pkt.chksum - assert(IP(raw(ip_pkt)).chksum == chksum), "bad IPv4 checksum" + assert IP(raw(ip_pkt)).chksum == chksum, "bad IPv4 checksum" + def check_ipv6_checksum(pkt): - assert(IPv6 in pkt), "no IP layer found" + assert IPv6 in pkt, "no IP layer found" ip_pkt = pkt[IPv6] chksum = ip_pkt.chksum del ip_pkt.chksum - assert(IPv6(raw(ip_pkt)).chksum == chksum), "bad IPv6 checksum" + assert IPv6(raw(ip_pkt)).chksum == chksum, "bad IPv6 checksum" + @test def test_arp_req(iface): ##### ARP ##### - arp_req = Ether(dst=ETHER_BROADCAST)/ARP(psrc='192.0.0.2', pdst=IPV4_ADDR) + arp_req = Ether(dst=ETHER_BROADCAST) / ARP(psrc="192.0.0.2", pdst=IPV4_ADDR) arp_repl = iface.sr1(arp_req, timeout=1) - assert(arp_repl is not None), "expecting answer, got nothing" - assert(ARP in arp_repl), "no ARP layer found" + assert arp_repl is not None, "expecting answer, got nothing" + assert ARP in arp_repl, "no ARP layer found" arp_repl = arp_repl[ARP] # check answer ## op is "is-at" - assert(arp_repl.op == 2), "unexpected ARP op: {}".format(arp_repl.op) + assert arp_repl.op == 2, "unexpected ARP op: {}".format(arp_repl.op) ## answer for the requested IP - assert(arp_repl.psrc == arp_req.pdst), "unexpected ARP psrc: {}".format(arp_repl.psrc) - assert(arp_repl.pdst == arp_req.psrc), "unexpected ARP pdst: {}".format(arp_repl.pdst) + assert arp_repl.psrc == arp_req.pdst, "unexpected ARP psrc: {}".format( + arp_repl.psrc + ) + assert arp_repl.pdst == arp_req.psrc, "unexpected ARP pdst: {}".format( + arp_repl.pdst + ) ## answer is expected MAC address - assert(arp_repl.hwsrc == MAC_ADDR), "unexpected ARP hwsrc: {}".format(arp_repl.hwsrc) + assert arp_repl.hwsrc == MAC_ADDR, "unexpected ARP hwsrc: {}".format(arp_repl.hwsrc) + @test def test_arp_req_other_ip(iface): ##### ARP ##### - arp_req = Ether()/ARP(psrc='192.0.0.2', pdst='1.2.3.4') + arp_req = Ether() / ARP(psrc="192.0.0.2", pdst="1.2.3.4") arp_repl = iface.sr1(arp_req, timeout=1) - assert(arp_repl is None), "responding to ARP requests for other IP addresses" + assert arp_repl is None, "responding to ARP requests for other IP addresses" + @test def test_ipv4_req(iface): ##### IP ##### - ip_req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR, id=0x1337)/ICMP(type=8, code=0) + ip_req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, id=0x1337) / ICMP(type=8, code=0) ip_repl = iface.sr1(ip_req, timeout=1) - assert(ip_repl is not None), "expecting answer, got nothing" + assert ip_repl is not None, "expecting answer, got nothing" check_ip_checksum(ip_repl) - assert(IP in ip_repl), "no IP layer in response" + assert IP in ip_repl, "no IP layer in response" ip_repl = ip_repl[IP] - assert(ip_repl.id == 0), "IP identification unexpected" - + assert ip_repl.id == 0, "IP identification unexpected" + + @test def test_eth_req_other_mac(iface): #### ETH #### - ip_req = Ether(dst="00:00:00:11:11:11")/IP(dst=IPV4_ADDR)/ICMP(type=8, code=0) + ip_req = Ether(dst="00:00:00:11:11:11") / IP(dst=IPV4_ADDR) / ICMP(type=8, code=0) ip_repl = iface.sr1(ip_req, timeout=1) - assert(ip_repl is None), "responding to other MAC addresses" + assert ip_repl is None, "responding to other MAC addresses" + @test def test_ipv4_req_other_ip(iface): ##### IP ##### - ip_req = Ether(dst=MAC_ADDR)/IP(dst="1.2.3.4")/ICMP(type=8, code=0) + ip_req = Ether(dst=MAC_ADDR) / IP(dst="1.2.3.4") / ICMP(type=8, code=0) ip_repl = iface.sr1(ip_req, timeout=1) - assert(ip_repl is None), "responding to other IP addresses" + assert ip_repl is None, "responding to other IP addresses" + @test def test_icmpv4_echo_req(iface): ##### ICMPv4 ##### - icmp_req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/ICMP(type=8, code=0)/Raw("idrinkwaytoomuchcoffee") + icmp_req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / ICMP(type=8, code=0) + / Raw("idrinkwaytoomuchcoffee") + ) icmp_repl = iface.sr1(icmp_req, timeout=1) - assert(icmp_repl is not None), "expecting answer, got nothing" + assert icmp_repl is not None, "expecting answer, got nothing" check_ip_checksum(icmp_repl) - assert(ICMP in icmp_repl) + assert ICMP in icmp_repl icmp_repl = icmp_repl[ICMP] # check answer ## type is "echo-reply" - assert(icmp_repl.type == 0) - assert(icmp_repl.code == 0) + assert icmp_repl.type == 0 + assert icmp_repl.code == 0 ## data is the same as sent - assert(icmp_repl.load == icmp_req.load) + assert icmp_repl.load == icmp_req.load + @test def test_icmpv6_neighbor_solicitation(iface): ##### IPv6 Neighbor Solicitation ##### - for mac in ["ff:ff:ff:ff:ff:ff", "33:33:00:00:00:01", MAC_ADDR, multicast(IPV6_ADDR)]: - nd_ns = Ether(dst=mac)/IPv6()/ICMPv6ND_NS(tgt=IPV6_ADDR) + for mac in [ + "ff:ff:ff:ff:ff:ff", + "33:33:00:00:00:01", + MAC_ADDR, + multicast(IPV6_ADDR), + ]: + nd_ns = Ether(dst=mac) / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) nd_na = iface.sr1(nd_ns, timeout=1) - assert(nd_na is not None), "expecting answer, got nothing" - assert(ICMPv6ND_NA in nd_na) + assert nd_na is not None, "expecting answer, got nothing" + assert ICMPv6ND_NA in nd_na nd_na = nd_na[ICMPv6ND_NA] # check answer content - assert(nd_na.code == 0) - assert(nd_na.R == 0) - assert(nd_na.S == 1) - assert(nd_na.O == 1) - assert(nd_na.tgt == IPV6_ADDR) + assert nd_na.code == 0 + assert nd_na.R == 0 + assert nd_na.S == 1 + assert nd_na.O == 1 # noqa: E741 + assert nd_na.tgt == IPV6_ADDR # check ND Option - assert(nd_na.haslayer(ICMPv6NDOptDstLLAddr)) - assert(nd_na.getlayer(ICMPv6NDOptDstLLAddr).lladdr == MAC_ADDR) + assert nd_na.haslayer(ICMPv6NDOptDstLLAddr) + assert nd_na.getlayer(ICMPv6NDOptDstLLAddr).lladdr == MAC_ADDR for mac in ["00:00:00:00:00:00", "33:33:33:00:00:01"]: - nd_ns = Ether(dst="ff:ff:ff:ff:ff:ff")/IPv6()/ICMPv6ND_NS(tgt=IPV6_ADDR) + nd_ns = Ether(dst="ff:ff:ff:ff:ff:ff") / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) nd_na = iface.sr1(nd_ns, timeout=1) - assert(nd_na is not None), "expecting no answer, got one" + assert nd_na is not None, "expecting no answer, got one" + @test def test_icmpv6_neighbor_solicitation_other_ip(iface): ##### IPv6 Neighbor Solicitation ##### - nd_ns = Ether(dst="ff:ff:ff:ff:ff:ff")/IPv6()/ICMPv6ND_NS(tgt="2020:4141:3030:2020::bdbd") + nd_ns = ( + Ether(dst="ff:ff:ff:ff:ff:ff") + / IPv6() + / ICMPv6ND_NS(tgt="2020:4141:3030:2020::bdbd") + ) nd_na = iface.sr1(nd_ns, timeout=1) - assert(nd_na is None), "responding to ND_NS for other IP addresses" + assert nd_na is None, "responding to ND_NS for other IP addresses" + @test def test_icmpv6_echo_req(iface): ##### IPv6 Ping ##### - echo_req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/ICMPv6EchoRequest(data="waytoomanynapkins") + echo_req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / ICMPv6EchoRequest(data="waytoomanynapkins") + ) echo_repl = iface.sr1(echo_req, timeout=1) - assert(echo_repl is not None), "expecting answer, got nothing" - assert(ICMPv6EchoReply in echo_repl) + assert echo_repl is not None, "expecting answer, got nothing" + assert ICMPv6EchoReply in echo_repl echo_repl = echo_repl[ICMPv6EchoReply] # check answer content - assert(echo_repl.code == 0) - assert(echo_repl.data == echo_req.data) + assert echo_repl.code == 0 + assert echo_repl.data == echo_req.data + @test def test_tcp_syn(iface): ##### SYN-ACK ##### # test a list of ports, randomly generated once ports_to_test = [ - 1152, 2003, 2193, 3709, 4054, 6605, 6737, 6875, 7320, 8898, 9513, 9738, 10623, 10723, - 11253, 12125, 12189, 12873, 14648, 14659, 16242, 16243, 17209, 17492, 17667, 17838, - 18081, 18682, 18790, 19124, 19288, 19558, 19628, 19789, 20093, 21014, 21459, 21740, - 24070, 24312, 24576, 26939, 27136, 27165, 27361, 29971, 31088, 33011, 33068, 34990, - 35093, 35958, 36626, 36789, 37130, 37238, 37256, 37697, 37890, 38958, 42131, 43864, - 44420, 44655, 44868, 45157, 46213, 46497, 46955, 49049, 49067, 49452, 49480, 50498, - 50945, 51181, 52890, 53301, 53407, 53417, 53980, 55827, 56483, 58552, 58713, 58836, - 59362, 59560, 60534, 60555, 60660, 61615, 62402, 62533, 62941, 63240, 63339, 63616, - 64380, 65438, - ] + 1152, + 2003, + 2193, + 3709, + 4054, + 6605, + 6737, + 6875, + 7320, + 8898, + 9513, + 9738, + 10623, + 10723, + 11253, + 12125, + 12189, + 12873, + 14648, + 14659, + 16242, + 16243, + 17209, + 17492, + 17667, + 17838, + 18081, + 18682, + 18790, + 19124, + 19288, + 19558, + 19628, + 19789, + 20093, + 21014, + 21459, + 21740, + 24070, + 24312, + 24576, + 26939, + 27136, + 27165, + 27361, + 29971, + 31088, + 33011, + 33068, + 34990, + 35093, + 35958, + 36626, + 36789, + 37130, + 37238, + 37256, + 37697, + 37890, + 38958, + 42131, + 43864, + 44420, + 44655, + 44868, + 45157, + 46213, + 46497, + 46955, + 49049, + 49067, + 49452, + 49480, + 50498, + 50945, + 51181, + 52890, + 53301, + 53407, + 53417, + 53980, + 55827, + 56483, + 58552, + 58713, + 58836, + 59362, + 59560, + 60534, + 60555, + 60660, + 61615, + 62402, + 62533, + 62941, + 63240, + 63339, + 63616, + 64380, + 65438, + ] for p in ports_to_test: - syn = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="S", dport=p) + syn = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="S", dport=p) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") + assert syn_ack.flags == "SA" + @test def test_ipv4_tcp_psh_ack(iface): @@ -216,30 +362,40 @@ def test_ipv4_tcp_psh_ack(iface): sport = 26695 port = 445 # send PSH-ACK first - psh_ack = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="PA", dport=port)/Raw("payload") + psh_ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", sport=sport, dport=port) + / Raw("payload") + ) syn_ack = iface.sr1(psh_ack, timeout=1) - assert(syn_ack is None), "no answer expected, got one" + assert syn_ack is None, "no answer expected, got one" # test the anti-injection mechanism - syn = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="S", dport=port) + syn = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="S", dport=port) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="A", dport=port) + assert syn_ack.flags == "SA" + ack = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="A", dport=port) # should fail because no ack given - psh_ack = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="PA", dport=port) + psh_ack = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="PA", dport=port) ack = iface.sr1(psh_ack, timeout=1) - assert(ack is None), "no answer expected, got one" + assert ack is None, "no answer expected, got one" # should get an answer this time - psh_ack = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="PA", dport=port, ack=syn_ack.seq + 1) + psh_ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", dport=port, ack=syn_ack.seq + 1) + ) ack = iface.sr1(psh_ack, timeout=1) - assert(ack is not None), "expecting answer, got nothing" + assert ack is not None, "expecting answer, got nothing" check_ip_checksum(ack) - assert(TCP in ack) + assert TCP in ack ack = ack[TCP] - assert(ack.flags == "A") + assert ack.flags == "A" + @test def test_ipv6_tcp_psh_ack(iface): @@ -247,162 +403,252 @@ def test_ipv6_tcp_psh_ack(iface): sport = 26695 port = 445 # send PSH-ACK first - psh_ack = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="PA", dport=port)/Raw("payload") + psh_ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", sport=sport, dport=port) + / Raw("payload") + ) syn_ack = iface.sr1(psh_ack, timeout=1) - assert(syn_ack is None), "no answer expected, got one" + assert syn_ack is None, "no answer expected, got one" # test the anti-injection mechanism - syn = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="S", dport=port) + syn = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="S", dport=port) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="A", dport=port) + assert syn_ack.flags == "SA" + ack = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="A", dport=port) # should fail because no ack given - psh_ack = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="PA", dport=port) + psh_ack = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="PA", dport=port) ack = iface.sr1(psh_ack, timeout=1) - assert(ack is None), "no answer expected, got one" + assert ack is None, "no answer expected, got one" # should get an answer this time - psh_ack = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="PA", dport=port, ack=syn_ack.seq + 1) + psh_ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", dport=port, ack=syn_ack.seq + 1) + ) ack = iface.sr1(psh_ack, timeout=1) - assert(ack is not None), "expecting answer, got nothing" + assert ack is not None, "expecting answer, got nothing" check_ipv6_checksum(ack) - assert(TCP in ack) + assert TCP in ack ack = ack[TCP] - assert(ack.flags == "A") + assert ack.flags == "A" + @test def test_ipv4_tcp_http(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - syn = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="S", sport=sport, dport=dport) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport) + ) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + ) _ = iface.sr1(ack, timeout=1) - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport)/Raw("GET / HTTP/1.1\r\n\r\n") + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert(TCP in resp) + assert TCP in resp tcp = resp[TCP] - assert(tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n")) + assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + @test def test_ipv6_tcp_http(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - syn = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="S", sport=sport, dport=dport) + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=dport) + ) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + ) _ = iface.sr1(ack, timeout=1) - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport)/Raw("GET / HTTP/1.1\r\n\r\n") + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert(TCP in resp) + assert TCP in resp tcp = resp[TCP] - assert(tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n")) + assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + @test def test_ipv4_udp_http(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/UDP(sport=sport, dport=dport)/Raw("GET / HTTP/1.1\r\n\r\n") + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert(UDP in resp) + assert UDP in resp udp = resp[UDP] - assert(udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n")) + assert udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + @test def test_ipv6_udp_http(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/UDP(sport=sport, dport=dport)/Raw("GET / HTTP/1.1\r\n\r\n") + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert(UDP in resp) + assert UDP in resp udp = resp[UDP] - assert(udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n")) + assert udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + @test def test_ipv4_tcp_http_ko(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - syn = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="S", sport=sport, dport=dport) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport) + ) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + ) _ = iface.sr1(ack, timeout=1) - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport)/Raw(bytes.fromhex("4f5054494f4e53")) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert(TCP in resp) - assert("P" not in resp[TCP].flags) - assert(len(resp[TCP].payload) == 0) + assert TCP in resp + assert "P" not in resp[TCP].flags + assert len(resp[TCP].payload) == 0 + @test def test_ipv4_udp_http_ko(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/UDP(sport=sport, dport=dport)/Raw(bytes.fromhex("4f5054494f4e53")) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) resp = iface.sr1(req, timeout=1) - assert(resp is None), "expecting no answer, got one" + assert resp is None, "expecting no answer, got one" + @test def test_ipv6_tcp_http_ko(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - syn = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="S", sport=sport, dport=dport) + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=dport) + ) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + ) _ = iface.sr1(ack, timeout=1) - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport)/Raw(bytes.fromhex("4f5054494f4e53")) + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert(TCP in resp) - assert("P" not in resp[TCP].flags) - assert(len(resp[TCP].payload) == 0) + assert TCP in resp + assert "P" not in resp[TCP].flags + assert len(resp[TCP].payload) == 0 + @test def test_ipv6_udp_http_ko(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/UDP(sport=sport, dport=dport)/Raw(bytes.fromhex("4f5054494f4e53")) + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) resp = iface.sr1(req, timeout=1) - assert(resp is None), "expecting no answer, got one" + assert resp is None, "expecting no answer, got one" + @test def test_ipv4_udp_stun(iface): @@ -411,24 +657,36 @@ def test_ipv4_udp_stun(iface): payload = bytes.fromhex("000100002112a442000000000000000000000000") for sport in sports: for dport in dports: - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/UDP(sport=sport, dport=dport)/Raw(payload) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert(UDP in resp), "no UDP layer found" + assert UDP in resp, "no UDP layer found" udp = resp[UDP] - assert(udp.sport == dport), "unexpected UDP sport: {}".format(udp.sport) - assert(udp.dport == sport), "unexpected UDP dport: {}".format(udp.dport) + assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) + assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) resp_payload = udp.payload.load type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) tid = resp_payload[8:20] data = resp_payload[20:] - assert(type_ == 0x0101), "expected type 0X0101, got 0x{:04x}".format(type_) - assert(length == 12), "expected length 12, got {}".format(length) - assert(magic == 0x2112a442), "expected magic 0x2112a442, got 0x{:08x}".format(magic) - assert(tid == b'\x00' * 12), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - assert(data[:8] == bytes.fromhex("000100080001") + struct.pack(">H", sport)), f"unexpected data {data!r}" - assert(len(data) == 12), f"unexpected data {data!r}" + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 12, "expected length 12, got {}".format(length) + assert ( + magic == 0x2112A442 + ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) + assert ( + tid == b"\x00" * 12 + ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) + assert data[:8] == bytes.fromhex("000100080001") + struct.pack( + ">H", sport + ), f"unexpected data {data!r}" + assert len(data) == 12, f"unexpected data {data!r}" + @test def test_ipv6_udp_stun(iface): @@ -437,23 +695,35 @@ def test_ipv6_udp_stun(iface): payload = bytes.fromhex("000100002112a442000000000000000000000000") for sport in sports: for dport in dports: - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/UDP(sport=sport, dport=dport)/Raw(payload) + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert(UDP in resp) + assert UDP in resp udp = resp[UDP] - assert(udp.sport == dport) - assert(udp.dport == sport) + assert udp.sport == dport + assert udp.dport == sport resp_payload = udp.payload.load type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) tid = resp_payload[8:20] data = resp_payload[20:] - assert(type_ == 0x0101), "expected type 0X0101, got 0x{:04x}".format(type_) - assert(length == 24), "expected length 24, got {}".format(length) - assert(magic == 0x2112a442), "expected magic 0x2112a442, got 0x{:08x}".format(magic) - assert(tid == b'\x00' * 12), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - assert(data == bytes.fromhex("000100140002") + struct.pack(">H", sport) + bytes.fromhex("00000000" * 4)), "unexpected data: {}".format(data) + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 24, "expected length 24, got {}".format(length) + assert ( + magic == 0x2112A442 + ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) + assert ( + tid == b"\x00" * 12 + ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) + assert data == bytes.fromhex("000100140002") + struct.pack( + ">H", sport + ) + bytes.fromhex("00000000" * 4), "unexpected data: {}".format(data) + @test def test_ipv4_udp_stun_change_port(iface): @@ -462,23 +732,39 @@ def test_ipv4_udp_stun_change_port(iface): payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") for sport in sports: for dport in dports: - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/UDP(sport=sport, dport=dport)/Raw(payload) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert(UDP in resp), "no UDP layer found" + assert UDP in resp, "no UDP layer found" udp = resp[UDP] - assert(udp.sport == (dport + 1) % 2**16), "expected answer from UDP/{}, got it from UDP/{}".format((dport + 1) % 2**16, udp.sport) - assert(udp.dport == sport), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) + assert ( + udp.sport == (dport + 1) % 2 ** 16 + ), "expected answer from UDP/{}, got it from UDP/{}".format( + (dport + 1) % 2 ** 16, udp.sport + ) + assert ( + udp.dport == sport + ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) resp_payload = udp.payload.load type_, length = struct.unpack(">HH", resp_payload[:4]) tid = resp_payload[4:20] data = resp_payload[20:] - assert(type_ == 0x0101), "expected type 0X0101, got 0x{:04x}".format(type_) - assert(length == 12), "expected length 12, got {}".format(length) - assert(tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c")), "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid - assert(data[:8] == bytes.fromhex("000100080001") + struct.pack(">H", sport)), f"unexpected data {data!r}" - assert(len(data) == 12), f"unexpected data {data!r}" + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 12, "expected length 12, got {}".format(length) + assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( + "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid + ) + assert data[:8] == bytes.fromhex("000100080001") + struct.pack( + ">H", sport + ), f"unexpected data {data!r}" + assert len(data) == 12, f"unexpected data {data!r}" + @test def test_ipv6_udp_stun_change_port(iface): @@ -487,112 +773,208 @@ def test_ipv6_udp_stun_change_port(iface): payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") for sport in sports: for dport in dports: - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/UDP(sport=sport, dport=dport)/Raw(payload) + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - 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] - assert(udp.sport == (dport + 1) % 2**16), "expected answer from UDP/{}, got it from UDP/{}".format((dport + 1) % 2**16, udp.sport) - assert(udp.dport == sport), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) + assert ( + udp.sport == (dport + 1) % 2 ** 16 + ), "expected answer from UDP/{}, got it from UDP/{}".format( + (dport + 1) % 2 ** 16, udp.sport + ) + assert ( + udp.dport == sport + ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) resp_payload = udp.payload.load type_, length = struct.unpack(">HH", resp_payload[:4]) tid = resp_payload[4:20] data = resp_payload[20:] - assert(type_ == 0x0101), "expected type 0X0101, got 0x{:04x}".format(type_) - assert(length == 24), "expected length 12, got {}".format(length) - assert(tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c")), "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid - assert(data == bytes.fromhex("000100140002") + struct.pack(">H", sport) + bytes.fromhex("00000000" * 4)) + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 24, "expected length 12, got {}".format(length) + assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( + "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid + ) + assert data == bytes.fromhex("000100140002") + struct.pack( + ">H", sport + ) + bytes.fromhex("00000000" * 4) + @test def test_ipv4_tcp_ssh(iface): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): - banner = [b"SSH-2.0-AsyncSSH_2.1.0", b"SSH-2.0-PuTTY", b"SSH-2.0-libssh2_1.4.3", b"SSH-2.0-Go", b"SSH-2.0-PUTTY"][i % 5] - syn = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="S", sport=sport, dport=dport) + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport) + ) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + ) _ = iface.sr1(ack, timeout=1) - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport)/Raw(banner + b"\r\n") + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / Raw(banner + b"\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert(TCP in resp) + assert TCP in resp tcp = resp[TCP] - assert("A" in tcp.flags), "expecting ACK flag, not set (%r)" % tcp.flags - assert("P" in tcp.flags), "expecting PSH flag, not set (%r)" % tcp.flags - assert(len(tcp.payload) > 0), "expecting payload, got none" - assert(tcp.payload.load.startswith(b"SSH-2.0-")), "unexpected banner: %r" % tcp.payload.load - assert(tcp.payload.load.endswith(b"\r\n")), "unexpected banner: %r" % tcp.payload.load + assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags + assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags + assert len(tcp.payload) > 0, "expecting payload, got none" + assert tcp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % tcp.payload.load + ) + assert tcp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % tcp.payload.load + ) + @test def test_ipv4_udp_ssh(iface): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): - banner = [b"SSH-2.0-AsyncSSH_2.1.0", b"SSH-2.0-PuTTY", b"SSH-2.0-libssh2_1.4.3", b"SSH-2.0-Go", b"SSH-2.0-PUTTY"][i % 5] - req = Ether(dst=MAC_ADDR)/IP(dst=IPV4_ADDR)/UDP(sport=sport, dport=dport)/Raw(banner + b"\r\n") + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(banner + b"\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert(UDP in resp) + assert UDP in resp udp = resp[UDP] - assert(len(udp.payload) > 0), "expecting payload, got none" - assert(udp.payload.load.startswith(b"SSH-2.0-")), "unexpected banner: %r" % udp.payload.load - assert(udp.payload.load.endswith(b"\r\n")), "unexpected banner: %r" % udp.payload.load + assert len(udp.payload) > 0, "expecting payload, got none" + assert udp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % udp.payload.load + ) + assert udp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % udp.payload.load + ) + @test def test_ipv6_tcp_ssh(iface): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): - banner = [b"SSH-2.0-AsyncSSH_2.1.0", b"SSH-2.0-PuTTY", b"SSH-2.0-libssh2_1.4.3", b"SSH-2.0-Go", b"SSH-2.0-PUTTY"][i % 5] - syn = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="S", sport=sport, dport=dport) + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=dport) + ) syn_ack = iface.sr1(syn, timeout=1) - assert(syn_ack is not None), "expecting answer, got nothing" + assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert(TCP in syn_ack) + assert TCP in syn_ack syn_ack = syn_ack[TCP] - assert(syn_ack.flags == "SA") - ack = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + ) _ = iface.sr1(ack, timeout=1) - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport)/Raw(banner + b"\r\n") + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / Raw(banner + b"\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert(TCP in resp) + assert TCP in resp tcp = resp[TCP] - assert("A" in tcp.flags), "expecting ACK flag, not set (%r)" % tcp.flags - assert("P" in tcp.flags), "expecting PSH flag, not set (%r)" % tcp.flags - assert(len(tcp.payload) > 0), "expecting payload, got none" - assert(tcp.payload.load.startswith(b"SSH-2.0-")), "unexpected banner: %r" % tcp.payload.load - assert(tcp.payload.load.endswith(b"\r\n")), "unexpected banner: %r" % tcp.payload.load + assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags + assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags + assert len(tcp.payload) > 0, "expecting payload, got none" + assert tcp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % tcp.payload.load + ) + assert tcp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % tcp.payload.load + ) + @test def test_ipv6_udp_ssh(iface): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): - banner = [b"SSH-2.0-AsyncSSH_2.1.0", b"SSH-2.0-PuTTY", b"SSH-2.0-libssh2_1.4.3", b"SSH-2.0-Go", b"SSH-2.0-PUTTY"][i % 5] - req = Ether(dst=MAC_ADDR)/IPv6(dst=IPV6_ADDR)/UDP(sport=sport, dport=dport)/Raw(banner + b"\r\n") + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(banner + b"\r\n") + ) resp = iface.sr1(req, timeout=1) - assert(resp is not None), "expecting answer, got nothing" + assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert(UDP in resp) + assert UDP in resp udp = resp[UDP] - assert(len(udp.payload) > 0), "expecting payload, got none" - assert(udp.payload.load.startswith(b"SSH-2.0-")), "unexpected banner: %r" % udp.payload.load - assert(udp.payload.load.endswith(b"\r\n")), "unexpected banner: %r" % udp.payload.load + assert len(udp.payload) > 0, "expecting payload, got none" + assert udp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % udp.payload.load + ) + assert udp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % udp.payload.load + ) + def test_all(iface): - global tests + global TESTS # execute tests - for t in tests: + for t in TESTS: t(iface) - return len(errors) + return len(ERRORS) diff --git a/test/src/conf.py b/test/src/conf.py index f7fbd2b..18affd9 100644 --- a/test/src/conf.py +++ b/test/src/conf.py @@ -16,5 +16,5 @@ IPV4_ADDR = "192.0.0.1" IPV6_ADDR = "2001:41d0::ab32:bdb8" -MAC_ADDR = "52:1c:4e:c2:a4:1f" +MAC_ADDR = "52:1c:4e:c2:a4:1f" OUTDIR = "test/res/" diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 49a99ef..08f58e7 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -28,7 +28,8 @@ from scapy.interfaces import resolve_iface from scapy.layers.tuntap import TunTapInterface from src.all import test_all -from src.conf import * +from src.conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR, OUTDIR + def setup_logs(): ch = logging.StreamHandler() @@ -39,6 +40,7 @@ def setup_logs(): log.addHandler(ch) return log + LOG = setup_logs() IFACE = "tap0" conf.verb = 0 From 4c508ccea6910911d9a43ea56c51af7089247b3d Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 12:32:59 +0100 Subject: [PATCH 005/317] Tests: add routes to prevent wrong values from appearing in packets --- test/test_masscanned.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 08f58e7..2ed9b82 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -57,6 +57,9 @@ conf.iface = resolve_iface(IFACE) # set interface subprocess.check_call(["ip", "addr", "add", "dev", IFACE, "192.0.0.2"]) subprocess.check_call(["ip", "link", "set", IFACE, "up"]) +subprocess.check_call(["ip", "route", "add", "192.0.0.1/32", "dev", IFACE]) +subprocess.check_call(["ip", "route", "add", "1.2.3.4/32", "dev", IFACE]) +conf.route.resync() # start capture tcpdump = subprocess.Popen( From 023b3f9b382eeabcb1f94ed2f51d8b15c565e8f5 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 12:44:51 +0100 Subject: [PATCH 006/317] Tests: fix stun expected data --- test/src/all.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/src/all.py b/test/src/all.py index 10af976..88a257b 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -682,10 +682,12 @@ def test_ipv4_udp_stun(iface): assert ( tid == b"\x00" * 12 ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - assert data[:8] == bytes.fromhex("000100080001") + struct.pack( - ">H", sport - ), f"unexpected data {data!r}" - assert len(data) == 12, f"unexpected data {data!r}" + expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( + ">HBBBB", sport, 192, 0, 0, 2 + ) + assert ( + data == expected_data + ), f"unexpected data {data!r} != {expected_data!r}" @test @@ -760,10 +762,12 @@ def test_ipv4_udp_stun_change_port(iface): assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid ) - assert data[:8] == bytes.fromhex("000100080001") + struct.pack( - ">H", sport - ), f"unexpected data {data!r}" - assert len(data) == 12, f"unexpected data {data!r}" + expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( + ">HBBBB", sport, 192, 0, 0, 2 + ) + assert ( + data == expected_data + ), f"unexpected data {data!r} != {expected_data!r}" @test From db75ffb9c53f2defd82ac07d201d4580f0f72c4f Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 14:52:15 +0100 Subject: [PATCH 007/317] Tests: fix TCP seq # --- test/src/all.py | 219 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 169 insertions(+), 50 deletions(-) diff --git a/test/src/all.py b/test/src/all.py index 88a257b..b0c098a 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -30,6 +30,7 @@ from scapy.layers.inet6 import ( ) from scapy.layers.l2 import ARP, Ether from scapy.packet import Raw +from scapy.volatile import RandInt from .conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR @@ -347,13 +348,22 @@ def test_tcp_syn(iface): 65438, ] for p in ports_to_test: - syn = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="S", dport=p) + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", dport=p, seq=seq_init) + ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( + syn_ack.ack, + seq_init + 1, + ) @test @@ -361,40 +371,56 @@ def test_ipv4_tcp_psh_ack(iface): ##### PSH-ACK ##### sport = 26695 port = 445 + seq_init = int(RandInt()) # send PSH-ACK first psh_ack = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="PA", sport=sport, dport=port) + / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) / Raw("payload") ) syn_ack = iface.sr1(psh_ack, timeout=1) assert syn_ack is None, "no answer expected, got one" # test the anti-injection mechanism - syn = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="S", dport=port) + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=port, seq=seq_init) + ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( + syn_ack.ack, + seq_init + 1, + ) ack = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="A", dport=port) # should fail because no ack given - psh_ack = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="PA", dport=port) + psh_ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) + ) ack = iface.sr1(psh_ack, timeout=1) assert ack is None, "no answer expected, got one" # should get an answer this time psh_ack = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="PA", dport=port, ack=syn_ack.seq + 1) + / TCP( + flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 + ) ) ack = iface.sr1(psh_ack, timeout=1) assert ack is not None, "expecting answer, got nothing" check_ip_checksum(ack) - assert TCP in ack + assert TCP in ack, "expecting TCP, got %r" % ack.summary() ack = ack[TCP] - assert ack.flags == "A" + assert ack.flags == "A", "expecting TCP A, got %r" % syn_ack.flags @test @@ -402,40 +428,55 @@ def test_ipv6_tcp_psh_ack(iface): ##### PSH-ACK ##### sport = 26695 port = 445 + seq_init = int(RandInt()) # send PSH-ACK first psh_ack = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="PA", sport=sport, dport=port) + / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) / Raw("payload") ) syn_ack = iface.sr1(psh_ack, timeout=1) assert syn_ack is None, "no answer expected, got one" # test the anti-injection mechanism - syn = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="S", dport=port) + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=port, seq=seq_init) + ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( + syn_ack.ack, + seq_init + 1, + ) ack = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="A", dport=port) # should fail because no ack given - psh_ack = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="PA", dport=port) + psh_ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) + ) ack = iface.sr1(psh_ack, timeout=1) assert ack is None, "no answer expected, got one" # should get an answer this time psh_ack = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="PA", dport=port, ack=syn_ack.seq + 1) + / TCP( + flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 + ) ) ack = iface.sr1(psh_ack, timeout=1) assert ack is not None, "expecting answer, got nothing" check_ipv6_checksum(ack) - assert TCP in ack + assert TCP in ack, "expecting TCP, got %r" % ack.summary() ack = ack[TCP] - assert ack.flags == "A" + assert ack.flags == "A", "expecting TCP A, got %r" % syn_ack.flags @test @@ -443,33 +484,46 @@ def test_ipv4_tcp_http(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: + seq_init = int(RandInt()) syn = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags ack = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) ) _ = iface.sr1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) / Raw("GET / HTTP/1.1\r\n\r\n") ) resp = iface.sr1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert TCP in resp + assert TCP in resp, "expecting TCP, got %r" % resp.summary() tcp = resp[TCP] assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") @@ -479,33 +533,46 @@ def test_ipv6_tcp_http(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: + seq_init = int(RandInt()) syn = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="S", sport=sport, dport=dport) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] assert syn_ack.flags == "SA" ack = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) ) _ = iface.sr1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) / Raw("GET / HTTP/1.1\r\n\r\n") ) resp = iface.sr1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert TCP in resp + assert TCP in resp, "expecting TCP, got %r" % resp.summary() tcp = resp[TCP] assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") @@ -553,33 +620,46 @@ def test_ipv4_tcp_http_ko(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: + seq_init = int(RandInt()) syn = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] assert syn_ack.flags == "SA" ack = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) ) _ = iface.sr1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) / Raw(bytes.fromhex("4f5054494f4e53")) ) resp = iface.sr1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert TCP in resp + assert TCP in resp, "expecting TCP, got %r" % resp.summary() assert "P" not in resp[TCP].flags assert len(resp[TCP].payload) == 0 @@ -604,33 +684,46 @@ def test_ipv6_tcp_http_ko(iface): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: + seq_init = int(RandInt()) syn = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="S", sport=sport, dport=dport) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] assert syn_ack.flags == "SA" ack = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) ) _ = iface.sr1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) / Raw(bytes.fromhex("4f5054494f4e53")) ) resp = iface.sr1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert TCP in resp + assert TCP in resp, "expecting TCP, got %r" % resp.summary() assert "P" not in resp[TCP].flags assert len(resp[TCP].payload) == 0 @@ -815,6 +908,7 @@ def test_ipv4_tcp_ssh(iface): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): + seq_init = int(RandInt()) banner = [ b"SSH-2.0-AsyncSSH_2.1.0", b"SSH-2.0-PuTTY", @@ -825,30 +919,42 @@ def test_ipv4_tcp_ssh(iface): syn = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] assert syn_ack.flags == "SA" ack = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) ) _ = iface.sr1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) - / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) / Raw(banner + b"\r\n") ) resp = iface.sr1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) - assert TCP in resp + assert TCP in resp, "expecting TCP, got %r" % resp.summary() tcp = resp[TCP] assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags @@ -898,6 +1004,7 @@ def test_ipv6_tcp_ssh(iface): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): + seq_init = int(RandInt()) banner = [ b"SSH-2.0-AsyncSSH_2.1.0", b"SSH-2.0-PuTTY", @@ -908,30 +1015,42 @@ def test_ipv6_tcp_ssh(iface): syn = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="S", sport=sport, dport=dport) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) syn_ack = iface.sr1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) - assert TCP in syn_ack + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() syn_ack = syn_ack[TCP] assert syn_ack.flags == "SA" ack = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="A", sport=sport, dport=dport, ack=syn_ack.seq + 1) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) ) _ = iface.sr1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) - / TCP(flags="PA", ack=syn_ack.seq + 1, sport=sport, dport=dport) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) / Raw(banner + b"\r\n") ) resp = iface.sr1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) - assert TCP in resp + assert TCP in resp, "expecting TCP, got %r" % resp.summary() tcp = resp[TCP] assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags From 1619261ebf45715f14b039e5024774033b9630ab Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 15:01:20 +0100 Subject: [PATCH 008/317] Tests: update addr to use a real network address --- test/src/all.py | 4 ++-- test/test_masscanned.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/src/all.py b/test/src/all.py index b0c098a..9e4f60f 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -776,7 +776,7 @@ def test_ipv4_udp_stun(iface): tid == b"\x00" * 12 ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( - ">HBBBB", sport, 192, 0, 0, 2 + ">HBBBB", sport, 192, 0, 0, 0 ) assert ( data == expected_data @@ -856,7 +856,7 @@ def test_ipv4_udp_stun_change_port(iface): "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid ) expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( - ">HBBBB", sport, 192, 0, 0, 2 + ">HBBBB", sport, 192, 0, 0, 0 ) assert ( data == expected_data diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 2ed9b82..f719007 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -55,10 +55,9 @@ tap = TunTapInterface(IFACE) conf.iface = resolve_iface(IFACE) # set interface -subprocess.check_call(["ip", "addr", "add", "dev", IFACE, "192.0.0.2"]) +subprocess.check_call(["ip", "addr", "add", "dev", IFACE, "192.0.0.0/31"]) subprocess.check_call(["ip", "link", "set", IFACE, "up"]) -subprocess.check_call(["ip", "route", "add", "192.0.0.1/32", "dev", IFACE]) -subprocess.check_call(["ip", "route", "add", "1.2.3.4/32", "dev", IFACE]) +subprocess.check_call(["ip", "route", "add", "1.2.3.4/32", "via", IPV4_ADDR]) conf.route.resync() # start capture From 6efcbbbf59e4285a5374ca2072ee76ffdfabce74 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 15:11:36 +0100 Subject: [PATCH 009/317] Tests: add Zeek to get passiverecon logs --- test/test_masscanned.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index f719007..42f9e8f 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -43,6 +43,8 @@ def setup_logs(): LOG = setup_logs() IFACE = "tap0" +TCPDUMP = bool(os.environ.get("USE_TCPDUMP")) +ZEEK_PASSIVERECON = bool(os.environ.get("USE_ZEEK")) conf.verb = 0 # prepare configuration file for masscanned @@ -61,9 +63,27 @@ subprocess.check_call(["ip", "route", "add", "1.2.3.4/32", "via", IPV4_ADDR]) conf.route.resync() # start capture -tcpdump = subprocess.Popen( - ["tcpdump", "-enli", IFACE, "-w", os.path.join(OUTDIR, "test_capture.pcap")] -) +if TCPDUMP: + tcpdump = subprocess.Popen( + ["tcpdump", "-enli", IFACE, "-w", os.path.join(OUTDIR, "test_capture.pcap")] + ) +if ZEEK_PASSIVERECON: + zeek = subprocess.Popen( + [ + "zeek", + "-C", + "-b", + "-i", + IFACE, + "/usr/share/ivre/zeek/ivre/passiverecon/bare.zeek", + "-e", + "redef tcp_content_deliver_all_resp = T; " + "redef tcp_content_deliver_all_orig = T; " + f"redef PassiveRecon::HONEYPOTS += {{ {IPV4_ADDR}, [{IPV6_ADDR}] }}", + ], + stdout=open("test/res/zeek_passiverecon.stdout", "w"), + stderr=open("test/res/zeek_passiverecon.stderr", "w"), + ) # run masscanned masscanned = subprocess.Popen( [ @@ -93,6 +113,10 @@ except AssertionError: masscanned.kill() masscanned.wait() # terminate capture -tcpdump.kill() -tcpdump.wait() +if TCPDUMP: + tcpdump.kill() + tcpdump.wait() +if ZEEK_PASSIVERECON: + zeek.kill() + zeek.wait() sys.exit(result) From 05a739bdb171516c0fb74cf4a068f1dff1334f8f Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 15:57:02 +0100 Subject: [PATCH 010/317] Tests: find IVRE Zeek module location --- test/test_masscanned.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 42f9e8f..11c75dd 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -23,6 +23,12 @@ import sys from time import sleep from tempfile import NamedTemporaryFile +try: + from ivre.config import guess_prefix +except ImportError: + HAS_IVRE = False +else: + HAS_IVRE = True from scapy.config import conf from scapy.interfaces import resolve_iface from scapy.layers.tuntap import TunTapInterface @@ -44,7 +50,10 @@ def setup_logs(): LOG = setup_logs() IFACE = "tap0" TCPDUMP = bool(os.environ.get("USE_TCPDUMP")) -ZEEK_PASSIVERECON = bool(os.environ.get("USE_ZEEK")) +if HAS_IVRE: + ZEEK_PASSIVERECON = bool(os.environ.get("USE_ZEEK")) +else: + ZEEK_PASSIVERECON = False conf.verb = 0 # prepare configuration file for masscanned @@ -75,7 +84,12 @@ if ZEEK_PASSIVERECON: "-b", "-i", IFACE, - "/usr/share/ivre/zeek/ivre/passiverecon/bare.zeek", + os.path.join( + guess_prefix("zeek"), + "ivre", + "passiverecon", + "bare.zeek", + ), "-e", "redef tcp_content_deliver_all_resp = T; " "redef tcp_content_deliver_all_orig = T; " From d2054ffc05e53ef35fe895e95fd2adaed3f6d171 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 9 Dec 2021 15:57:19 +0100 Subject: [PATCH 011/317] Tests: remove hardcoded addresses --- test/src/all.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/src/all.py b/test/src/all.py index 9e4f60f..f9f2d80 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -106,7 +106,7 @@ def check_ipv6_checksum(pkt): @test def test_arp_req(iface): ##### ARP ##### - arp_req = Ether(dst=ETHER_BROADCAST) / ARP(psrc="192.0.0.2", pdst=IPV4_ADDR) + arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst=IPV4_ADDR) arp_repl = iface.sr1(arp_req, timeout=1) assert arp_repl is not None, "expecting answer, got nothing" assert ARP in arp_repl, "no ARP layer found" @@ -128,7 +128,7 @@ def test_arp_req(iface): @test def test_arp_req_other_ip(iface): ##### ARP ##### - arp_req = Ether() / ARP(psrc="192.0.0.2", pdst="1.2.3.4") + arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst="1.2.3.4") arp_repl = iface.sr1(arp_req, timeout=1) assert arp_repl is None, "responding to ARP requests for other IP addresses" From afe1619b9e48e8cfccd4abcbe735e29d50861c75 Mon Sep 17 00:00:00 2001 From: 0xflotus <0xflotus@gmail.com> Date: Sat, 11 Dec 2021 00:11:07 +0100 Subject: [PATCH 012/317] fix: small typo errors --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 95d2a9f..d9a58a1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Masscanned** (name inspired, of course, by [masscan](https://github.com/robertdavidgraham/masscan)) is a network responder. Its purpose is to provide generic answers to as many protocols as possible, -and with as few asumptions as possible on the client's intentions. +and with as few assumptions as possible on the client's intentions. > *Let them talk first.* @@ -123,7 +123,7 @@ An additionnal requirement is that the next layer protocol is supported - see be #### IPv4 -The following L4 protocols are suppported for an `IPv4` packet: +The following L4 protocols are supported for an `IPv4` packet: * `ICMPv4` * `UDP` @@ -133,7 +133,7 @@ If the next layer protocol is not one of them, the packet is dropped. #### IPv6 -The following L4 protocols are suppported for an `IPv6` packet: +The following L4 protocols are supported for an `IPv6` packet: * `ICMPv6` * `UDP` @@ -159,7 +159,7 @@ code `0` and the same payload as the incoming packet, as specified by [RFC 792]( * the `ICMP` type is `NeighborSol` (`135`) **and**: * no IP (v4 or v6) was speficied for `masscanned` - * **or** the target address of the Neighbor Solicitation is one of `masccanned` + * **or** the target address of the Neighbor Solicitation is one of `masscanned` *In that case, the answer is a `Neighbor Advertisement` (`136`) packet with `masscanned` `MAC` address* From ec8011a6e4d34f6c109c3c1649f5b1c5b7a0699f Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 13 Dec 2021 19:30:40 +0100 Subject: [PATCH 013/317] Tests: add p0f logs --- test/test_masscanned.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 11c75dd..13a8f18 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -54,6 +54,7 @@ if HAS_IVRE: ZEEK_PASSIVERECON = bool(os.environ.get("USE_ZEEK")) else: ZEEK_PASSIVERECON = False +P0F = bool(os.environ.get("USE_P0F")) conf.verb = 0 # prepare configuration file for masscanned @@ -98,6 +99,12 @@ if ZEEK_PASSIVERECON: stdout=open("test/res/zeek_passiverecon.stdout", "w"), stderr=open("test/res/zeek_passiverecon.stderr", "w"), ) +if P0F: + p0f = subprocess.Popen( + ["p0f", "-i", IFACE, "-o", "test/res/p0f_log.txt"], + stdout=open("test/res/p0f.stdout", "w"), + stderr=open("test/res/p0f.stderr", "w"), + ) # run masscanned masscanned = subprocess.Popen( [ @@ -133,4 +140,7 @@ if TCPDUMP: if ZEEK_PASSIVERECON: zeek.kill() zeek.wait() +if P0F: + p0f.kill() + p0f.wait() sys.exit(result) From e65ce63e70f6f99143bb7ae9ae8bf23eccc3f1df Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 13 Dec 2021 19:32:48 +0100 Subject: [PATCH 014/317] Tests: use OUTDIR config value --- test/test_masscanned.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 13a8f18..2697e46 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -96,14 +96,14 @@ if ZEEK_PASSIVERECON: "redef tcp_content_deliver_all_orig = T; " f"redef PassiveRecon::HONEYPOTS += {{ {IPV4_ADDR}, [{IPV6_ADDR}] }}", ], - stdout=open("test/res/zeek_passiverecon.stdout", "w"), - stderr=open("test/res/zeek_passiverecon.stderr", "w"), + stdout=open(os.path.join(OUTDIR, "zeek_passiverecon.stdout"), "w"), + stderr=open(os.path.join(OUTDIR, "zeek_passiverecon.stderr"), "w"), ) if P0F: p0f = subprocess.Popen( - ["p0f", "-i", IFACE, "-o", "test/res/p0f_log.txt"], - stdout=open("test/res/p0f.stdout", "w"), - stderr=open("test/res/p0f.stderr", "w"), + ["p0f", "-i", IFACE, "-o", os.path.join(OUTDIR, "p0f_log.txt")], + stdout=open(os.path.join(OUTDIR, "p0f.stdout"), "w"), + stderr=open(os.path.join(OUTDIR, "p0f.stderr"), "w"), ) # run masscanned masscanned = subprocess.Popen( @@ -120,8 +120,8 @@ masscanned = subprocess.Popen( # if args in CLI, they are passed to masscanned + sys.argv[1:], env=dict(os.environ, RUST_BACKTRACE="1"), - stdout=open("test/res/masscanned.stdout", "w"), - stderr=open("test/res/masscanned.stderr", "w"), + stdout=open(os.path.join(OUTDIR, "masscanned.stdout"), "w"), + stderr=open(os.path.join(OUTDIR, "masscanned.stderr"), "w"), ) sleep(1) From b5fb589361a7dd1e37da68e16e65ea7b37f00367 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 15 Dec 2021 16:01:25 +0100 Subject: [PATCH 015/317] Tests: fix IPv6 warnings from Scapy --- test/src/all.py | 22 ++++++++++++++++------ test/test_masscanned.py | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/test/src/all.py b/test/src/all.py index f9f2d80..761599e 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -15,6 +15,7 @@ # along with Masscanned. If not, see . import logging +from socket import AF_INET6 import struct from scapy.compat import raw @@ -29,6 +30,7 @@ from scapy.layers.inet6 import ( IPv6, ) from scapy.layers.l2 import ARP, Ether +from scapy.pton_ntop import inet_pton from scapy.packet import Raw from scapy.volatile import RandInt @@ -815,9 +817,12 @@ def test_ipv6_udp_stun(iface): assert ( tid == b"\x00" * 12 ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - assert data == bytes.fromhex("000100140002") + struct.pack( - ">H", sport - ) + bytes.fromhex("00000000" * 4), "unexpected data: {}".format(data) + expected_data = ( + bytes.fromhex("000100140002") + + struct.pack(">H", sport) + + inet_pton(AF_INET6, "2001:41d0::1234:5678") + ) + assert data == expected_data, "unexpected data: {}".format(data) @test @@ -898,9 +903,14 @@ def test_ipv6_udp_stun_change_port(iface): assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid ) - assert data == bytes.fromhex("000100140002") + struct.pack( - ">H", sport - ) + bytes.fromhex("00000000" * 4) + expected_data = ( + bytes.fromhex("000100140002") + + 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 diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 2697e46..a902cd9 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -68,9 +68,11 @@ conf.iface = resolve_iface(IFACE) # set interface 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", "route", "add", "1.2.3.4/32", "via", IPV4_ADDR]) conf.route.resync() +conf.route6.resync() # start capture if TCPDUMP: From e533b1ce25acf002647439041ae330fef404e11b Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 16 Dec 2021 01:14:43 +0100 Subject: [PATCH 016/317] CI: check Rust format --- .github/workflows/test.yml | 6 ++++++ src/proto/ssh.rs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed34ff7..09d6bdf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,12 @@ jobs: with: toolchain: stable + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + - name: Run cargo build uses: actions-rs/cargo@v1 with: diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index a14c6d9..49e18b5 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -31,6 +31,9 @@ pub fn repl<'a>( debug!("receiving SSH data"); let repl_data = b"SSH-2.0-1\r\n".to_vec(); debug!("sending SSH answer"); - warn!("SSH server banner to {}", str::from_utf8(&data).unwrap().trim_end()); + warn!( + "SSH server banner to {}", + str::from_utf8(&data).unwrap().trim_end() + ); return Some(repl_data); } From 7427d28d52e8b541c0b928c8c6688d27a0eb4cdc Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 16 Dec 2021 02:00:40 +0100 Subject: [PATCH 017/317] Replace if / else if using a match --- src/proto/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 5094c75..2468bb7 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -118,16 +118,15 @@ pub fn repl<'a>( } } /* proto over else (e.g., UDP) */ - if id == PROTO_HTTP { - return http::repl(data, masscanned, client_info); - } else if id == PROTO_STUN { - return stun::repl(data, masscanned, &mut client_info); - } else if id == PROTO_SSH { - return ssh::repl(data, masscanned, &mut client_info); - } else { - debug!("id: {}", id); + match id { + PROTO_HTTP => http::repl(data, masscanned, client_info), + PROTO_STUN => stun::repl(data, masscanned, &mut client_info), + PROTO_SSH => ssh::repl(data, masscanned, &mut client_info), + _ => { + debug!("id: {}", id); + None + } } - None } #[cfg(test)] From c127fec54c2a5f4510b5fb89cf3638a040450aa6 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 16 Dec 2021 00:47:21 +0100 Subject: [PATCH 018/317] Add Ghost RAT protocol --- Cargo.toml | 1 + src/proto/ghost.rs | 57 +++++++++++++++++++++++++++++++++++++++++++ src/proto/mod.rs | 40 +++++++++++++++++++++++++++++++ test/src/all.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 src/proto/ghost.rs diff --git a/Cargo.toml b/Cargo.toml index 789f87f..211a287 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ lazy_static = "1.4.0" siphasher = "0.3" chrono = "0.4.19" byteorder = "1.4.3" +flate2 = "1.0" [[bin]] name = "masscanned" diff --git a/src/proto/ghost.rs b/src/proto/ghost.rs new file mode 100644 index 0000000..98ca4dd --- /dev/null +++ b/src/proto/ghost.rs @@ -0,0 +1,57 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use log::*; +use std::io::Write; + +use flate2::write::ZlibEncoder; +use flate2::Compression; + +use crate::client::ClientInfo; +use crate::Masscanned; + +pub const GHOST_PATTERN_SIGNATURE: &[u8; 5] = b"Gh0st"; + +pub fn repl<'a>( + _data: &'a [u8], + _masscanned: &Masscanned, + _client_info: &mut ClientInfo, +) -> Option> { + debug!("receiving Gh0st data, sending one null byte payload"); + // Packet structure: + // GHOST_PATTERN_SIGNATURE + [ packet size ] + [ uncompressed payload size ] + payload + let mut result = GHOST_PATTERN_SIGNATURE.to_vec(); + let uncompressed_data = b"\x00"; + let mut compressed_data = ZlibEncoder::new(Vec::new(), Compression::default()); + compressed_data + .write_all(uncompressed_data) + .expect("Ghost: cannot decompress payload"); + let mut compressed_data = compressed_data + .finish() + .expect("Ghost: cannot decompress payload"); + let mut packet_len = compressed_data.len() + GHOST_PATTERN_SIGNATURE.len() + 4 * 2; + for _ in 0..4 { + result.push((packet_len % 256) as u8); + packet_len /= 256; + } + let mut uncompressed_len = uncompressed_data.len(); + for _ in 0..4 { + result.push((uncompressed_len % 256) as u8); + uncompressed_len /= 256; + } + result.append(&mut compressed_data); + Some(result) +} diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 2468bb7..78b65e1 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -33,9 +33,13 @@ use stun::{STUN_PATTERN_CHANGE_REQUEST, STUN_PATTERN_EMPTY, STUN_PATTERN_MAGIC}; mod ssh; use ssh::SSH_PATTERN_CLIENT_PROTOCOL; +mod ghost; +use ghost::GHOST_PATTERN_SIGNATURE; + const PROTO_HTTP: usize = 1; const PROTO_STUN: usize = 2; const PROTO_SSH: usize = 3; +const PROTO_GHOST: usize = 4; struct TCPControlBlock { proto_state: usize, @@ -76,6 +80,11 @@ fn proto_init() -> Smack { PROTO_SSH, SmackFlags::ANCHOR_BEGIN, ); + smack.add_pattern( + GHOST_PATTERN_SIGNATURE, + PROTO_GHOST, + SmackFlags::ANCHOR_BEGIN, + ); smack.compile(); smack } @@ -122,6 +131,7 @@ pub fn repl<'a>( PROTO_HTTP => http::repl(data, masscanned, client_info), PROTO_STUN => stun::repl(data, masscanned, &mut client_info), PROTO_SSH => ssh::repl(data, masscanned, &mut client_info), + PROTO_GHOST => ghost::repl(data, masscanned, &mut client_info), _ => { debug!("id: {}", id); None @@ -235,4 +245,34 @@ mod tests { }; } } + + #[test] + fn test_proto_dispatch_ghost() { + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65000); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + }; + /***** TEST GHOST *****/ + let payloads = [ + b"Gh0st\xad\x00\x00\x00\xe0\x00\x00\x00x\x9cKS``\x98\xc3\xc0\xc0\xc0\x06\xc4\x8c@\xbcQ\x96\x81\x81\tH\x07\xa7\x16\x95e&\xa7*\x04$&g+\x182\x94\xf6\xb000\xac\xa8rc\x00\x01\x11\xa0\x82\x1f\\`&\x83\xc7K7\x86\x19\xe5n\x0c9\x95n\x0c;\x84\x0f3\xac\xe8sch\xa8^\xcf4'J\x97\xa9\x82\xe30\xc3\x91h]&\x90\xf8\xce\x97S\xcbA4L?2=\xe1\xc4\x92\x86\x0b@\xf5`\x0cT\x1f\xae\xaf]\nr\x0b\x03#\xa3\xdc\x02~\x06\x86\x03+\x18m\xc2=\xfdtC,C\xfdL<<==\\\x9d\x19\x88\x00\xe5 \x02\x00T\xf5+\\" + ]; + for payload in payloads.iter() { + let _ghost_resp = + if let Some(r) = repl(&payload.to_vec(), &masscanned, &mut client_info) { + r + } else { + panic!("expected an answer, got nothing"); + }; + } + } } diff --git a/test/src/all.py b/test/src/all.py index 761599e..9dece7c 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -17,6 +17,7 @@ import logging from socket import AF_INET6 import struct +import zlib from scapy.compat import raw from scapy.data import ETHER_BROADCAST @@ -1105,6 +1106,65 @@ def test_ipv6_udp_ssh(iface): ) +@test +def test_ipv4_tcp_ghost(iface): + sport = 37184 + dports = [22, 23874] + for dport in dports: + seq_init = int(RandInt()) + banner = b"Gh0st\xad\x00\x00\x00\xe0\x00\x00\x00x\x9cKS``\x98\xc3\xc0\xc0\xc0\x06\xc4\x8c@\xbcQ\x96\x81\x81\tH\x07\xa7\x16\x95e&\xa7*\x04$&g+\x182\x94\xf6\xb000\xac\xa8rc\x00\x01\x11\xa0\x82\x1f\\`&\x83\xc7K7\x86\x19\xe5n\x0c9\x95n\x0c;\x84\x0f3\xac\xe8sch\xa8^\xcf4'J\x97\xa9\x82\xe30\xc3\x91h]&\x90\xf8\xce\x97S\xcbA4L?2=\xe1\xc4\x92\x86\x0b@\xf5`\x0cT\x1f\xae\xaf]\nr\x0b\x03#\xa3\xdc\x02~\x06\x86\x03+\x18m\xc2=\xfdtC,C\xfdL<<==\\\x9d\x19\x88\x00\xe5 \x02\x00T\xf5+\\" + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = iface.sr1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = iface.sr1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw(banner) + ) + resp = iface.sr1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags + assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags + data = raw(tcp.payload) + assert data, "expecting payload, got none" + assert data.startswith(b"Gh0st"), "unexpected banner: %r" % tcp.payload.load + data_len, uncompressed_len = struct.unpack(" Date: Thu, 16 Dec 2021 22:25:31 +0100 Subject: [PATCH 019/317] Move HTTP tests into a module --- src/proto/http.rs | 229 +++++++++++++++++++++++----------------------- 1 file changed, 117 insertions(+), 112 deletions(-) diff --git a/src/proto/http.rs b/src/proto/http.rs index 8a3da01..a31f924 100644 --- a/src/proto/http.rs +++ b/src/proto/http.rs @@ -267,122 +267,127 @@ WWW-Authenticate: Basic realm=\"Access to admin page\" Some(repl_data) } -#[test] -fn test_http_verb() { - /* all at once */ - for verb in HTTP_VERBS.iter() { - let mut pstate = ProtocolState::new(); - assert!(pstate.state == HTTP_STATE_START); - assert!(pstate.smack_state == BASE_STATE); - assert!(pstate.smack_id == NO_MATCH); - http_parse(&mut pstate, &verb.as_bytes()); - assert!(pstate.state == HTTP_STATE_SPACE); - assert!(pstate.smack_id == (HttpField::Verb as usize)); - assert!(pstate.http_verb == verb.as_bytes()); - } - /* byte by byte */ - for verb in HTTP_VERBS.iter() { - let mut pstate = ProtocolState::new(); - assert!(pstate.state == HTTP_STATE_START); - assert!(pstate.smack_state == BASE_STATE); - assert!(pstate.smack_id == NO_MATCH); - for i in 0..verb.len() { - if i > 0 { - assert!(pstate.state == HTTP_STATE_VERB); - assert!(pstate.smack_id == NO_MATCH); - } - http_parse(&mut pstate, &verb.as_bytes()[i..i + 1]); - } - assert!(pstate.state == HTTP_STATE_SPACE); - assert!(pstate.smack_id == (HttpField::Verb as usize)); - assert!(pstate.http_verb == verb.as_bytes()); - } - /* KO test: XXX */ - let mut pstate = ProtocolState::new(); - assert!(pstate.state == HTTP_STATE_START); - assert!(pstate.smack_state == BASE_STATE); - assert!(pstate.smack_id == NO_MATCH); - http_parse(&mut pstate, "XXX".as_bytes()); - assert!(pstate.state == HTTP_STATE_FAIL); - assert!(pstate.smack_state == UNANCHORED_STATE); - assert!(pstate.smack_id == NO_MATCH); - /* KO test: XGET */ - let mut pstate = ProtocolState::new(); - assert!(pstate.state == HTTP_STATE_START); - assert!(pstate.smack_state == BASE_STATE); - assert!(pstate.smack_id == NO_MATCH); - http_parse(&mut pstate, "XGET".as_bytes()); - assert!(pstate.state == HTTP_STATE_FAIL); - assert!(pstate.smack_state == UNANCHORED_STATE); - assert!(pstate.smack_id == NO_MATCH); - /* KO test: GEX */ - let mut pstate = ProtocolState::new(); - assert!(pstate.state == HTTP_STATE_START); - assert!(pstate.smack_state == BASE_STATE); - assert!(pstate.smack_id == NO_MATCH); - http_parse(&mut pstate, "GEX".as_bytes()); - assert!(pstate.state == HTTP_STATE_FAIL); - assert!(pstate.smack_state == UNANCHORED_STATE); - assert!(pstate.smack_id == NO_MATCH); - /* KO test: GE T */ - let mut pstate = ProtocolState::new(); - assert!(pstate.state == HTTP_STATE_START); - assert!(pstate.smack_state == BASE_STATE); - assert!(pstate.smack_id == NO_MATCH); - http_parse(&mut pstate, "GE T".as_bytes()); - assert!(pstate.state == HTTP_STATE_FAIL); - assert!(pstate.smack_state == UNANCHORED_STATE); - assert!(pstate.smack_id == NO_MATCH); -} +#[cfg(test)] +mod tests { + use super::*; -#[test] -fn test_http_request_line() { - let mut pstate = ProtocolState::new(); - let data = "GET /index.php HTTP/1.1\r\n".as_bytes(); - for i in 0..data.len() { - http_parse(&mut pstate, &data[i..i + 1]); - if i < 2 { - assert!(pstate.state == HTTP_STATE_VERB); - } else if i == 2 { + #[test] + fn test_http_verb() { + /* all at once */ + for verb in HTTP_VERBS.iter() { + let mut pstate = ProtocolState::new(); + assert!(pstate.state == HTTP_STATE_START); + assert!(pstate.smack_state == BASE_STATE); + assert!(pstate.smack_id == NO_MATCH); + http_parse(&mut pstate, &verb.as_bytes()); assert!(pstate.state == HTTP_STATE_SPACE); - } else if 3 <= i && i <= 13 { - assert!(pstate.state == HTTP_STATE_URI); - } else if 14 <= i && i <= 19 { - assert!(pstate.state == HTTP_STATE_H + (i - 14)); - } else if i == 20 { - assert!(pstate.state == HTTP_STATE_VERSION_MAJ); - } else if 21 <= i && i <= 23 { - assert!(pstate.state == HTTP_STATE_VERSION_MIN); - } else if i == 24 { - assert!(pstate.state == HTTP_STATE_FIELD_START); + assert!(pstate.smack_id == (HttpField::Verb as usize)); + assert!(pstate.http_verb == verb.as_bytes()); + } + /* byte by byte */ + for verb in HTTP_VERBS.iter() { + let mut pstate = ProtocolState::new(); + assert!(pstate.state == HTTP_STATE_START); + assert!(pstate.smack_state == BASE_STATE); + assert!(pstate.smack_id == NO_MATCH); + for i in 0..verb.len() { + if i > 0 { + assert!(pstate.state == HTTP_STATE_VERB); + assert!(pstate.smack_id == NO_MATCH); + } + http_parse(&mut pstate, &verb.as_bytes()[i..i + 1]); + } + assert!(pstate.state == HTTP_STATE_SPACE); + assert!(pstate.smack_id == (HttpField::Verb as usize)); + assert!(pstate.http_verb == verb.as_bytes()); + } + /* KO test: XXX */ + let mut pstate = ProtocolState::new(); + assert!(pstate.state == HTTP_STATE_START); + assert!(pstate.smack_state == BASE_STATE); + assert!(pstate.smack_id == NO_MATCH); + http_parse(&mut pstate, "XXX".as_bytes()); + assert!(pstate.state == HTTP_STATE_FAIL); + assert!(pstate.smack_state == UNANCHORED_STATE); + assert!(pstate.smack_id == NO_MATCH); + /* KO test: XGET */ + let mut pstate = ProtocolState::new(); + assert!(pstate.state == HTTP_STATE_START); + assert!(pstate.smack_state == BASE_STATE); + assert!(pstate.smack_id == NO_MATCH); + http_parse(&mut pstate, "XGET".as_bytes()); + assert!(pstate.state == HTTP_STATE_FAIL); + assert!(pstate.smack_state == UNANCHORED_STATE); + assert!(pstate.smack_id == NO_MATCH); + /* KO test: GEX */ + let mut pstate = ProtocolState::new(); + assert!(pstate.state == HTTP_STATE_START); + assert!(pstate.smack_state == BASE_STATE); + assert!(pstate.smack_id == NO_MATCH); + http_parse(&mut pstate, "GEX".as_bytes()); + assert!(pstate.state == HTTP_STATE_FAIL); + assert!(pstate.smack_state == UNANCHORED_STATE); + assert!(pstate.smack_id == NO_MATCH); + /* KO test: GE T */ + let mut pstate = ProtocolState::new(); + assert!(pstate.state == HTTP_STATE_START); + assert!(pstate.smack_state == BASE_STATE); + assert!(pstate.smack_id == NO_MATCH); + http_parse(&mut pstate, "GE T".as_bytes()); + assert!(pstate.state == HTTP_STATE_FAIL); + assert!(pstate.smack_state == UNANCHORED_STATE); + assert!(pstate.smack_id == NO_MATCH); + } + + #[test] + fn test_http_request_line() { + let mut pstate = ProtocolState::new(); + let data = "GET /index.php HTTP/1.1\r\n".as_bytes(); + for i in 0..data.len() { + http_parse(&mut pstate, &data[i..i + 1]); + if i < 2 { + assert!(pstate.state == HTTP_STATE_VERB); + } else if i == 2 { + assert!(pstate.state == HTTP_STATE_SPACE); + } else if 3 <= i && i <= 13 { + assert!(pstate.state == HTTP_STATE_URI); + } else if 14 <= i && i <= 19 { + assert!(pstate.state == HTTP_STATE_H + (i - 14)); + } else if i == 20 { + assert!(pstate.state == HTTP_STATE_VERSION_MAJ); + } else if 21 <= i && i <= 23 { + assert!(pstate.state == HTTP_STATE_VERSION_MIN); + } else if i == 24 { + assert!(pstate.state == HTTP_STATE_FIELD_START); + } } } -} -#[test] -fn test_http_request_field() { - let mut pstate = ProtocolState::new(); - let req = "POST /index.php HTTP/2.0\r\n".as_bytes(); - http_parse(&mut pstate, req); - assert!(pstate.state == HTTP_STATE_FIELD_START); - let field = b"Content-Length"; - http_parse(&mut pstate, field); - assert!(pstate.state == HTTP_STATE_FIELD_NAME); - let dot = b": "; - http_parse(&mut pstate, dot); - assert!(pstate.state == HTTP_STATE_FIELD_VALUE); - let value = b": 0\r\n"; - http_parse(&mut pstate, value); - assert!(pstate.state == HTTP_STATE_FIELD_START); -} + #[test] + fn test_http_request_field() { + let mut pstate = ProtocolState::new(); + let req = "POST /index.php HTTP/2.0\r\n".as_bytes(); + http_parse(&mut pstate, req); + assert!(pstate.state == HTTP_STATE_FIELD_START); + let field = b"Content-Length"; + http_parse(&mut pstate, field); + assert!(pstate.state == HTTP_STATE_FIELD_NAME); + let dot = b": "; + http_parse(&mut pstate, dot); + assert!(pstate.state == HTTP_STATE_FIELD_VALUE); + let value = b": 0\r\n"; + http_parse(&mut pstate, value); + assert!(pstate.state == HTTP_STATE_FIELD_START); + } -#[test] -fn test_http_request_no_field() { - let mut pstate = ProtocolState::new(); - let req = "POST /index.php HTTP/2.0\r\n".as_bytes(); - http_parse(&mut pstate, req); - assert!(pstate.state == HTTP_STATE_FIELD_START); - let crlf = "\r\n".as_bytes(); - http_parse(&mut pstate, crlf); - assert!(pstate.state == HTTP_STATE_CONTENT); + #[test] + fn test_http_request_no_field() { + let mut pstate = ProtocolState::new(); + let req = "POST /index.php HTTP/2.0\r\n".as_bytes(); + http_parse(&mut pstate, req); + assert!(pstate.state == HTTP_STATE_FIELD_START); + let crlf = "\r\n".as_bytes(); + http_parse(&mut pstate, crlf); + assert!(pstate.state == HTTP_STATE_CONTENT); + } } From 920a0a07689d1bb2f529b657dc8d6fb071868aab Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Fri, 17 Dec 2021 17:05:50 +0100 Subject: [PATCH 020/317] Initial documentation --- README.md | 2 +- doc/Makefile | 19 +++++++++ doc/conf.py | 53 ++++++++++++++++++++++++ doc/{ => img}/demo.gif | Bin doc/img/logo.png | Bin 0 -> 3102 bytes doc/index.rst | 35 ++++++++++++++++ doc/usage.rst | 90 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 doc/Makefile create mode 100644 doc/conf.py rename doc/{ => img}/demo.gif (100%) create mode 100644 doc/img/logo.png create mode 100644 doc/index.rst create mode 100644 doc/usage.rst diff --git a/README.md b/README.md index d9a58a1..075e7a0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For example, when it receives network packets: * **masscanned** answers to `TCP SYN` (any port) with `TCP SYN/ACK` on any port, * **masscanned** answers to `HTTP` requests (any verb) over `TCP/UDP` (any port) with a `HTTP 401` web page. -![demo](doc/demo.gif) +![demo](doc/img/demo.gif) **Masscanned** currently supports most common protocols at layers 2-3-4, and a few application protocols: diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..5128596 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 0000000..bbedcb5 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,53 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +from ast import literal_eval +import configparser +import os + +# -- Path setup -------------------------------------------------------------- + +# -- Project information ----------------------------------------------------- + +project = "IVRE" +copyright = "2021, The IVRE project" +html_logo = "img/logo.png" +master_doc = "index" + +def parse_cargo(): + config = configparser.ConfigParser() + config.read(os.path.join("..", "Cargo.toml")) + if "package" not in config: + return None, None, None + package = config["package"] + try: + author = literal_eval(package.get("authors"))[0].split("<", 1)[0].strip() + except KeyError: + authors = None + return literal_eval(package.get("name")), author, literal_eval(package.get("version")) + +project, author, version = parse_cargo() + +# -- General configuration --------------------------------------------------- + +extensions = [] + +autosectionlabel_prefix_document = True + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" diff --git a/doc/demo.gif b/doc/img/demo.gif similarity index 100% rename from doc/demo.gif rename to doc/img/demo.gif diff --git a/doc/img/logo.png b/doc/img/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..b9b5199bbfda4420a774c2d422ac55adef546bbf GIT binary patch literal 3102 zcmV+(4B_*MP)^+RV3M;6K1I;GoCj83j8kPo;29dV=3WTC4D2g)YL8x=Z*#JTa9(dpZ z^7HdqxNsra+1c3bb^s!g2*bm}`2Bu-J|AAMmuNKlzmb!!r$HEX{DK7wC@CqSxVV@{ zAAOXiOP7+F8DEkYiA1=5{W@J;U0l9=nfCT}yk0MgqNF4grL3$>PbC03IXOK0?6a(0 zyOzfudki5&LM=K5Ro8WX`|UTHo11BBYNEftKb1IyQv!q#g2KW=Hf`F(+O=y@RrQ{Z zpYHefiWiEaplKTC&!6YisZ+GIwWUGC09033^VCyMq3e2FE&tCy|K#xD!-T`(2@WnS zEaa6}UP05exRj#nI$d2|96frJbLY+_Gw3G=grX?q=H^meT}@?W<*d4%nDe%8-;S!P z6Rw$;m&ehgM<)P^=Uy~TqrJVILx&D={rdH!fDp-0!86Z1!{?uWPGx0f+$xwHh+}E% z-RbMySyH^F>pF^}P+D5b{{8!T_0?C$Gh+DUA-CqMbMNx3MTiSIB^{eED)d{`g}G3kywou%V%$83VZ)LD%VYvS-g8 zDk>@rt1M+eD2l?WRjc^mgAZ7+V1X$RbX}j;*|Fc5Wf>V6?AWn`O`A4Z4nwsPLUD01 zyLay%FGHA?V$6^gMIsS%9i*yk*|G(IlP6DF7RZHF5SA@l#;#qvOoyN-3J*Q>(3I+$ zH*X#V1qJ4}R#oM#x8CCU=byJs8J2*^%gbZeu3d50g=U-nKKbO6Qv!0k-Q?%zTM}UH zc01d)ZDZA{RhGao9YjV(2JgJ{4vQ8ovZUo`n#QF|m!^ylJv}`$2J%ELGc%K&J9n~p z@nX|q3$t5mb#*l>SFW@y?bCIg%a<=to4#JTa>ddC*`h^@*tv73>E#g9?l_hqS)E~M zn#RS87pHW@OusYpIajP$!RF1I6B-X$24dd4dF!=^p2Fsqfk_S$PKUcA^+2k5#^Z*T9kj@EUZzP>(FTk1^ZkhkA{JGDR* z6cn&=<3`KN0lKc^^Z91{n`ku3;NYO;s<7E?tXQ#v_3PK00zP37LI~b?vw8DoY&Ki+LAYEl)~#D7tvD9X=SVBm2|+#hi-8wQd zGNiWlcpg?p*?O`n5}jvB7=%nU=(^6pz`%?xUf1>U^-Ho$RaHt$OUcQ}G3*b+AoBC` zS-EnhR5c6^4${)nGNY5D(I}@+pO&f$0EffDnl)<-f37g9hSjTAOMTEk{`iC4yLaES zwQHJ2V`C!+4<3{nv{hAQ_3G7fK>$;hqOGz!ckb~1`|s1!(-W6-bzSGX@4n;Mv18I! zWY}yrii?X4k0}h@r4WLmq9Q5rArgsj`0(LbS5-AluTei%Q zDh%DB+wCSNCr66pfBp4W>g($bwX{ei!l6Tlq{Itd*Rk1bEMLA{4v5$^s0=k|nnrVT zb3%Q+&*!6~qeF@+gb+OP$Rmb)W9aUdE?p`uJ|voo#?o0?gS#b5mdFF)a=E0A9a7;M z@q#EQD3AxjstNkJZn1zpfByVg`^ON7+}zx>*JprX#6N~WWM^lmJ$?`WNKu6BLf>3d zgu~&GqX;u*r0!=k;vYjGWEa%tnn}x=WXuVh30-!>G2$OXAf|g`CsjdMy}V|!8iK*# ztOucnK=}QBX%A(F6E#hfS`xo~`?efK+`4s3+Jl(|LT0xV2n6IPLgrihb16n>nugcw zl^3jgdwbI$rum#}*RC0=^v?P}bX}*ryE~;*K`X8iZ#O#K0%=PW(bLl-Erp#cAQVL* z8jW)G>Qy<4fWKzGIy*b(OxGk!5us3s&dyGGAOPCi+ofbqW;jtsjEJdWWMst9{|lqe zX>Dzt6N=DvT?&XuB*M9K=L}ED8dgMicQ-d~+(>6lWAPyr3enQiB6m4W%zpUchdHsa zq17=W)-Cn*^%?euNaW$poH--4j+3eu4u@%IXh`T~orDz8-`{Wf&R=sOef9hOG&eUV zG*6T8VxPLYI!hlk)j@>AVZQ(V`-I0;34^$F=@K0s9hRvg)mMuI0s+4H=9`3PElpYe z_T`sfT9%ola@G_Ih4}jGuT9w_$`lYC9UYuKd)5+Fq%sJv*UQP1Cr#Ob$Fv2ZUwrX} zB{O%a3SxM8m?KAy%xXtXDIf+02B@j2F}+VuMG(PmQO$Z)Dj4mfq=hW+W6|LuQ-1E z`1oGlMh8u147?J7(9+VvhaY}u=?*-W?(HLlptiP_;o)JnY}sO{HJQ<^7*)jR=qOE1 zP3+&l-|~0xEZ<~F2*IgSr||iFY~Q|}?Ck7Wsl(xLB&-S}4dBk5JJi+HQBzZ6S$8C* zYnlw>r=Nb}-FM%mx3@R$Oh{3bgkBSi9Z4{oYiOFr&6_v*+r3A| z2Pukz-|wfPp#i7U$%79*h|Ok;>nNJe&dzbC-fMgjJ5R!9v*BoUL28;&QoWESlMDHg4X$Nkc;eU0q#xy2%_DyD2Ft;koCYLkKbBSRxXMFgQ3!ZEY>}_4TN#Dtihz zd1nl1nue;XY}l}Ys;Vk-b91rV?Nc647Hi=#XUBks!(qbVFhU3%4#)T*QL!&g(`F3z zkw}DKFi1l~1GTla1OfqRdlRM%h`XJUm6gRyFTKQzFTRM=>BMfgkB?mM)wjocuH4xm8YL78(cRrmV`C#tO-&394JD%+N?j0>#|@gMk(--Kd3iY{B_%xm_~SU8&I#Sq z(ew>*QBCaeg4I&OOF*vc-KUGk_ zJB3ZLRzD+%IdOXLWar+GmOfZK4I*u65Gfb}1u&BKL-K>Q06NlsNUj=ys{%Ma_D$N7 zV`_ but can be used independently. + +The code is on `GitHub `_. + +Here is a quick demo: + +|demo| + +Status of this documentation +---------------------------- + +This documentation is a work in progress! + +Content +------- + +.. toctree:: + :maxdepth: 3 + :caption: Usage: + :glob: + + usage + + +.. |demo| image:: img/demo.gif diff --git a/doc/usage.rst b/doc/usage.rst new file mode 100644 index 0000000..60e11f0 --- /dev/null +++ b/doc/usage.rst @@ -0,0 +1,90 @@ +Using Masscanned +================ + +Dedicated addresses +~~~~~~~~~~~~~~~~~~~ + +Masscanned is designed to handle its own IP addresses, which means +that the host should not have those addresses configures, and +Masscanned will answer ARP requests (or ICMPv6 ND neighbor +solicitations). + +The host may have one or more (IPv4 and/or IPv6) addresses configured +on an interface also used by Masscanned, but those addresses must be +different from those configured to be used by Masscanned. + +In that situation (dedicated addresses), just run: + +:: + + # masscanned -i -f + + +Addresses shared with the host +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sometimes it is desirable to have an IP address used by the host +(e.g., for administration tasks) and by Masscanned (to handle all +other incoming packets). + +Since this is not implemented in Masscanned, a tiny hack is needed: we +are going to run Masscanned on a ``veth`` interface. + +For this example, we suppose: + +- The interface is ``eth0``, the address is ``192.168.0.10``. +- We want Masscanned to handle all the traffic except for incoming SSH + connections on TCP/22 port. + +We create a ``veth`` pair of interfaces, on which we are going to use +the 0.255.0.0/31 network (which should not be a problem since +0.0.0.0/8 is reserved as "Current Network"): + +:: + + # ip link add to_masscanned type veth peer masscanned + # ip link set masscanned up + # ip link set to_masscanned up + # ip addr add 0.255.0.0/31 dev to_masscanned + # masscanned -i masscanned + +Masscanned can now be used, but only from the host where it runs: + +:: + + # ping -c 1 0.255.0.1 + PING 0.255.0.1 (0.255.0.1) 56(84) octets de données. + 64 octets de 0.255.0.1 : icmp_seq=1 ttl=64 temps=0.442 ms + + --- statistiques ping 0.255.0.1 --- + 1 paquets transmis, 1 reçus, 0% packet loss, time 0ms + rtt min/avg/max/mdev = 0.442/0.442/0.442/0.000 ms + +Now, we are going to use Netfilter / ``iptables`` to redirect incoming +traffic to Masscanned: + +:: + + # sysctl -w net.ipv4.ip_forward=1 + # iptables -t nat -A PREROUTING -i eth0 -d 192.168.0.10 -p tcp --dport 22 -j ACCEPT + # iptables -t nat -A PREROUTING -i eth0 -d 192.168.0.10/32 -j DNAT --to-destination 0.255.0.1 + +And, from another host on the 192.168.0.0/24 network: + +:: + + # ping -c 1 192.168.0.10 + PING 192.168.0.10 (192.168.0.10) 56(84) octets de données. + 64 octets de 192.168.0.10 : icmp_seq=1 ttl=63 temps=0.366 ms + + --- statistiques ping 192.168.0.10 --- + 1 paquets transmis, 1 reçus, 0% packet loss, time 0ms + rtt min/avg/max/mdev = 0.366/0.366/0.366/0.000 ms + + +The Masscanned output: + +:: + + WARN - ARP-Reply to ea:c0:d6:20:0c:6a for IP 0.255.0.1 + WARN - ICMP-Echo-Reply to ICMP-Echo-Request From dfd35d233d095ad0960cf4efb2c8666d61a26a8f Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 17 Dec 2021 18:21:21 +0100 Subject: [PATCH 021/317] Review of usage.rst --- doc/usage.rst | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/doc/usage.rst b/doc/usage.rst index 60e11f0..91e2c74 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -5,13 +5,13 @@ Dedicated addresses ~~~~~~~~~~~~~~~~~~~ Masscanned is designed to handle its own IP addresses, which means -that the host should not have those addresses configures, and -Masscanned will answer ARP requests (or ICMPv6 ND neighbor -solicitations). +that the host should not have those addresses configured, and +Masscanned will answer ``ARP`` requests (or ``ICMPv6`` ``ND`` neighbor +sollicitations). -The host may have one or more (IPv4 and/or IPv6) addresses configured -on an interface also used by Masscanned, but those addresses must be -different from those configured to be used by Masscanned. +The host may have one or more (``IPv4`` and/or ``IPv6``) addresses configured +on an interface also used by masscanned, but those addresses must be +different from those configured to be used by masscanned. In that situation (dedicated addresses), just run: @@ -19,21 +19,23 @@ In that situation (dedicated addresses), just run: # masscanned -i -f +where ```` is the path of a text file with one address (``IPv4`` +or ``IPv6``) per line. Addresses shared with the host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sometimes it is desirable to have an IP address used by the host -(e.g., for administration tasks) and by Masscanned (to handle all +(*e.g.*, for administration tasks) and by masscanned (to handle all other incoming packets). -Since this is not implemented in Masscanned, a tiny hack is needed: we -are going to run Masscanned on a ``veth`` interface. +Since this is not implemented in masscanned, a tiny hack is needed: we +are going to run it on a ``veth`` interface. For this example, we suppose: - The interface is ``eth0``, the address is ``192.168.0.10``. -- We want Masscanned to handle all the traffic except for incoming SSH +- We want masscanned to handle all the traffic except for incoming SSH connections on TCP/22 port. We create a ``veth`` pair of interfaces, on which we are going to use @@ -61,7 +63,7 @@ Masscanned can now be used, but only from the host where it runs: rtt min/avg/max/mdev = 0.442/0.442/0.442/0.000 ms Now, we are going to use Netfilter / ``iptables`` to redirect incoming -traffic to Masscanned: +traffic to masscanned: :: @@ -82,7 +84,7 @@ And, from another host on the 192.168.0.0/24 network: rtt min/avg/max/mdev = 0.366/0.366/0.366/0.000 ms -The Masscanned output: +The masscanned output: :: From 951b5a0ba095f93abf262de0d84f7b7af0a59c15 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Sun, 19 Dec 2021 18:45:45 +0100 Subject: [PATCH 022/317] Tests: use a veth pair of interfaces rather than a tap This will allow the use of "regular" network tools and scanners (nc / socat, Nmap, Masscan). --- .github/workflows/test.yml | 2 +- test/src/all.py | 167 +++++++++++++++++++------------------ test/test_masscanned.py | 89 ++++++++++++++++---- 3 files changed, 157 insertions(+), 101 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09d6bdf..41f2ffe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,7 +87,7 @@ jobs: run: black -t py36 --check test/test_masscanned.py test/src/ - name: Run flake8 - run: flake8 --ignore=E266,E501,W503 test/test_masscanned.py test/src/all.py + run: flake8 --ignore=E266,E501,W503 test/test_masscanned.py test/src/ - name: Run tests run: sudo python test/test_masscanned.py diff --git a/test/src/all.py b/test/src/all.py index 9dece7c..c4b740e 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -33,6 +33,7 @@ from scapy.layers.inet6 import ( from scapy.layers.l2 import ARP, Ether from scapy.pton_ntop import inet_pton from scapy.packet import Raw +from scapy.sendrecv import srp1 from scapy.volatile import RandInt from .conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR @@ -60,9 +61,9 @@ def test(f): KO = "\033[1m\033[1;%dmKO\033[0m" % 31 fname = f.__name__.ljust(50, ".") - def w(iface): + def w(): try: - f(iface) + f() LOG.info("{}{}".format(fname, OK)) except AssertionError as e: LOG.error("{}{}: {}".format(fname, KO, e)) @@ -107,10 +108,10 @@ def check_ipv6_checksum(pkt): @test -def test_arp_req(iface): +def test_arp_req(): ##### ARP ##### arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst=IPV4_ADDR) - arp_repl = iface.sr1(arp_req, timeout=1) + arp_repl = srp1(arp_req, timeout=1) assert arp_repl is not None, "expecting answer, got nothing" assert ARP in arp_repl, "no ARP layer found" arp_repl = arp_repl[ARP] @@ -129,18 +130,18 @@ def test_arp_req(iface): @test -def test_arp_req_other_ip(iface): +def test_arp_req_other_ip(): ##### ARP ##### arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst="1.2.3.4") - arp_repl = iface.sr1(arp_req, timeout=1) + arp_repl = srp1(arp_req, timeout=1) assert arp_repl is None, "responding to ARP requests for other IP addresses" @test -def test_ipv4_req(iface): +def test_ipv4_req(): ##### IP ##### ip_req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, id=0x1337) / ICMP(type=8, code=0) - ip_repl = iface.sr1(ip_req, timeout=1) + ip_repl = srp1(ip_req, timeout=1) assert ip_repl is not None, "expecting answer, got nothing" check_ip_checksum(ip_repl) assert IP in ip_repl, "no IP layer in response" @@ -149,23 +150,23 @@ def test_ipv4_req(iface): @test -def test_eth_req_other_mac(iface): +def test_eth_req_other_mac(): #### ETH #### ip_req = Ether(dst="00:00:00:11:11:11") / IP(dst=IPV4_ADDR) / ICMP(type=8, code=0) - ip_repl = iface.sr1(ip_req, timeout=1) + ip_repl = srp1(ip_req, timeout=1) assert ip_repl is None, "responding to other MAC addresses" @test -def test_ipv4_req_other_ip(iface): +def test_ipv4_req_other_ip(): ##### IP ##### ip_req = Ether(dst=MAC_ADDR) / IP(dst="1.2.3.4") / ICMP(type=8, code=0) - ip_repl = iface.sr1(ip_req, timeout=1) + ip_repl = srp1(ip_req, timeout=1) assert ip_repl is None, "responding to other IP addresses" @test -def test_icmpv4_echo_req(iface): +def test_icmpv4_echo_req(): ##### ICMPv4 ##### icmp_req = ( Ether(dst=MAC_ADDR) @@ -173,7 +174,7 @@ def test_icmpv4_echo_req(iface): / ICMP(type=8, code=0) / Raw("idrinkwaytoomuchcoffee") ) - icmp_repl = iface.sr1(icmp_req, timeout=1) + icmp_repl = srp1(icmp_req, timeout=1) assert icmp_repl is not None, "expecting answer, got nothing" check_ip_checksum(icmp_repl) assert ICMP in icmp_repl @@ -187,7 +188,7 @@ def test_icmpv4_echo_req(iface): @test -def test_icmpv6_neighbor_solicitation(iface): +def test_icmpv6_neighbor_solicitation(): ##### IPv6 Neighbor Solicitation ##### for mac in [ "ff:ff:ff:ff:ff:ff", @@ -196,7 +197,7 @@ def test_icmpv6_neighbor_solicitation(iface): multicast(IPV6_ADDR), ]: nd_ns = Ether(dst=mac) / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) - nd_na = iface.sr1(nd_ns, timeout=1) + nd_na = srp1(nd_ns, timeout=1) assert nd_na is not None, "expecting answer, got nothing" assert ICMPv6ND_NA in nd_na nd_na = nd_na[ICMPv6ND_NA] @@ -211,31 +212,31 @@ def test_icmpv6_neighbor_solicitation(iface): assert nd_na.getlayer(ICMPv6NDOptDstLLAddr).lladdr == MAC_ADDR for mac in ["00:00:00:00:00:00", "33:33:33:00:00:01"]: nd_ns = Ether(dst="ff:ff:ff:ff:ff:ff") / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) - nd_na = iface.sr1(nd_ns, timeout=1) + nd_na = srp1(nd_ns, timeout=1) assert nd_na is not None, "expecting no answer, got one" @test -def test_icmpv6_neighbor_solicitation_other_ip(iface): +def test_icmpv6_neighbor_solicitation_other_ip(): ##### IPv6 Neighbor Solicitation ##### nd_ns = ( Ether(dst="ff:ff:ff:ff:ff:ff") / IPv6() / ICMPv6ND_NS(tgt="2020:4141:3030:2020::bdbd") ) - nd_na = iface.sr1(nd_ns, timeout=1) + nd_na = srp1(nd_ns, timeout=1) assert nd_na is None, "responding to ND_NS for other IP addresses" @test -def test_icmpv6_echo_req(iface): +def test_icmpv6_echo_req(): ##### IPv6 Ping ##### echo_req = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / ICMPv6EchoRequest(data="waytoomanynapkins") ) - echo_repl = iface.sr1(echo_req, timeout=1) + echo_repl = srp1(echo_req, timeout=1) assert echo_repl is not None, "expecting answer, got nothing" assert ICMPv6EchoReply in echo_repl echo_repl = echo_repl[ICMPv6EchoReply] @@ -245,7 +246,7 @@ def test_icmpv6_echo_req(iface): @test -def test_tcp_syn(iface): +def test_tcp_syn(): ##### SYN-ACK ##### # test a list of ports, randomly generated once ports_to_test = [ @@ -357,7 +358,7 @@ def test_tcp_syn(iface): / IP(dst=IPV4_ADDR) / TCP(flags="S", dport=p, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -370,7 +371,7 @@ def test_tcp_syn(iface): @test -def test_ipv4_tcp_psh_ack(iface): +def test_ipv4_tcp_psh_ack(): ##### PSH-ACK ##### sport = 26695 port = 445 @@ -382,7 +383,7 @@ def test_ipv4_tcp_psh_ack(iface): / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) / Raw("payload") ) - syn_ack = iface.sr1(psh_ack, timeout=1) + syn_ack = srp1(psh_ack, timeout=1) assert syn_ack is None, "no answer expected, got one" # test the anti-injection mechanism seq_init = int(RandInt()) @@ -391,7 +392,7 @@ def test_ipv4_tcp_psh_ack(iface): / IP(dst=IPV4_ADDR) / TCP(flags="S", sport=sport, dport=port, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -408,7 +409,7 @@ def test_ipv4_tcp_psh_ack(iface): / IP(dst=IPV4_ADDR) / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) ) - ack = iface.sr1(psh_ack, timeout=1) + ack = srp1(psh_ack, timeout=1) assert ack is None, "no answer expected, got one" # should get an answer this time psh_ack = ( @@ -418,7 +419,7 @@ def test_ipv4_tcp_psh_ack(iface): flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 ) ) - ack = iface.sr1(psh_ack, timeout=1) + ack = srp1(psh_ack, timeout=1) assert ack is not None, "expecting answer, got nothing" check_ip_checksum(ack) assert TCP in ack, "expecting TCP, got %r" % ack.summary() @@ -427,7 +428,7 @@ def test_ipv4_tcp_psh_ack(iface): @test -def test_ipv6_tcp_psh_ack(iface): +def test_ipv6_tcp_psh_ack(): ##### PSH-ACK ##### sport = 26695 port = 445 @@ -439,7 +440,7 @@ def test_ipv6_tcp_psh_ack(iface): / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) / Raw("payload") ) - syn_ack = iface.sr1(psh_ack, timeout=1) + syn_ack = srp1(psh_ack, timeout=1) assert syn_ack is None, "no answer expected, got one" # test the anti-injection mechanism syn = ( @@ -447,7 +448,7 @@ def test_ipv6_tcp_psh_ack(iface): / IPv6(dst=IPV6_ADDR) / TCP(flags="S", sport=sport, dport=port, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -464,7 +465,7 @@ def test_ipv6_tcp_psh_ack(iface): / IPv6(dst=IPV6_ADDR) / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) ) - ack = iface.sr1(psh_ack, timeout=1) + ack = srp1(psh_ack, timeout=1) assert ack is None, "no answer expected, got one" # should get an answer this time psh_ack = ( @@ -474,7 +475,7 @@ def test_ipv6_tcp_psh_ack(iface): flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 ) ) - ack = iface.sr1(psh_ack, timeout=1) + ack = srp1(psh_ack, timeout=1) assert ack is not None, "expecting answer, got nothing" check_ipv6_checksum(ack) assert TCP in ack, "expecting TCP, got %r" % ack.summary() @@ -483,7 +484,7 @@ def test_ipv6_tcp_psh_ack(iface): @test -def test_ipv4_tcp_http(iface): +def test_ipv4_tcp_http(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -493,7 +494,7 @@ def test_ipv4_tcp_http(iface): / IP(dst=IPV4_ADDR) / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -510,7 +511,7 @@ def test_ipv4_tcp_http(iface): ack=syn_ack.seq + 1, ) ) - _ = iface.sr1(ack, timeout=1) + _ = srp1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) @@ -523,7 +524,7 @@ def test_ipv4_tcp_http(iface): ) / Raw("GET / HTTP/1.1\r\n\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert TCP in resp, "expecting TCP, got %r" % resp.summary() @@ -532,7 +533,7 @@ def test_ipv4_tcp_http(iface): @test -def test_ipv6_tcp_http(iface): +def test_ipv6_tcp_http(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -542,7 +543,7 @@ def test_ipv6_tcp_http(iface): / IPv6(dst=IPV6_ADDR) / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -559,7 +560,7 @@ def test_ipv6_tcp_http(iface): ack=syn_ack.seq + 1, ) ) - _ = iface.sr1(ack, timeout=1) + _ = srp1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) @@ -572,7 +573,7 @@ def test_ipv6_tcp_http(iface): ) / Raw("GET / HTTP/1.1\r\n\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) assert TCP in resp, "expecting TCP, got %r" % resp.summary() @@ -581,7 +582,7 @@ def test_ipv6_tcp_http(iface): @test -def test_ipv4_udp_http(iface): +def test_ipv4_udp_http(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -591,7 +592,7 @@ def test_ipv4_udp_http(iface): / UDP(sport=sport, dport=dport) / Raw("GET / HTTP/1.1\r\n\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert UDP in resp @@ -600,7 +601,7 @@ def test_ipv4_udp_http(iface): @test -def test_ipv6_udp_http(iface): +def test_ipv6_udp_http(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -610,7 +611,7 @@ def test_ipv6_udp_http(iface): / UDP(sport=sport, dport=dport) / Raw("GET / HTTP/1.1\r\n\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) assert UDP in resp @@ -619,7 +620,7 @@ def test_ipv6_udp_http(iface): @test -def test_ipv4_tcp_http_ko(iface): +def test_ipv4_tcp_http_ko(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -629,7 +630,7 @@ def test_ipv4_tcp_http_ko(iface): / IP(dst=IPV4_ADDR) / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -646,7 +647,7 @@ def test_ipv4_tcp_http_ko(iface): ack=syn_ack.seq + 1, ) ) - _ = iface.sr1(ack, timeout=1) + _ = srp1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) @@ -659,7 +660,7 @@ def test_ipv4_tcp_http_ko(iface): ) / Raw(bytes.fromhex("4f5054494f4e53")) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert TCP in resp, "expecting TCP, got %r" % resp.summary() @@ -668,7 +669,7 @@ def test_ipv4_tcp_http_ko(iface): @test -def test_ipv4_udp_http_ko(iface): +def test_ipv4_udp_http_ko(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -678,12 +679,12 @@ def test_ipv4_udp_http_ko(iface): / UDP(sport=sport, dport=dport) / Raw(bytes.fromhex("4f5054494f4e53")) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is None, "expecting no answer, got one" @test -def test_ipv6_tcp_http_ko(iface): +def test_ipv6_tcp_http_ko(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -693,7 +694,7 @@ def test_ipv6_tcp_http_ko(iface): / IPv6(dst=IPV6_ADDR) / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -710,7 +711,7 @@ def test_ipv6_tcp_http_ko(iface): ack=syn_ack.seq + 1, ) ) - _ = iface.sr1(ack, timeout=1) + _ = srp1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) @@ -723,7 +724,7 @@ def test_ipv6_tcp_http_ko(iface): ) / Raw(bytes.fromhex("4f5054494f4e53")) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) assert TCP in resp, "expecting TCP, got %r" % resp.summary() @@ -732,7 +733,7 @@ def test_ipv6_tcp_http_ko(iface): @test -def test_ipv6_udp_http_ko(iface): +def test_ipv6_udp_http_ko(): sport = 24592 dports = [80, 443, 5000, 53228] for dport in dports: @@ -742,12 +743,12 @@ def test_ipv6_udp_http_ko(iface): / UDP(sport=sport, dport=dport) / Raw(bytes.fromhex("4f5054494f4e53")) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is None, "expecting no answer, got one" @test -def test_ipv4_udp_stun(iface): +def test_ipv4_udp_stun(): sports = [12345, 55555, 80, 43273] dports = [80, 800, 8000, 3478] payload = bytes.fromhex("000100002112a442000000000000000000000000") @@ -759,7 +760,7 @@ def test_ipv4_udp_stun(iface): / UDP(sport=sport, dport=dport) / Raw(payload) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert UDP in resp, "no UDP layer found" @@ -787,7 +788,7 @@ def test_ipv4_udp_stun(iface): @test -def test_ipv6_udp_stun(iface): +def test_ipv6_udp_stun(): sports = [12345, 55555, 80, 43273] dports = [80, 800, 8000, 3478] payload = bytes.fromhex("000100002112a442000000000000000000000000") @@ -799,7 +800,7 @@ def test_ipv6_udp_stun(iface): / UDP(sport=sport, dport=dport) / Raw(payload) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) assert UDP in resp @@ -827,7 +828,7 @@ def test_ipv6_udp_stun(iface): @test -def test_ipv4_udp_stun_change_port(iface): +def test_ipv4_udp_stun_change_port(): sports = [12345, 55555, 80, 43273] dports = [80, 800, 8000, 3478, 65535] payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") @@ -839,7 +840,7 @@ def test_ipv4_udp_stun_change_port(iface): / UDP(sport=sport, dport=dport) / Raw(payload) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert UDP in resp, "no UDP layer found" @@ -870,7 +871,7 @@ def test_ipv4_udp_stun_change_port(iface): @test -def test_ipv6_udp_stun_change_port(iface): +def test_ipv6_udp_stun_change_port(): sports = [12345, 55555, 80, 43273] dports = [80, 800, 8000, 3478, 65535] payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") @@ -882,7 +883,7 @@ def test_ipv6_udp_stun_change_port(iface): / UDP(sport=sport, dport=dport) / Raw(payload) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) assert UDP in resp, "expecting UDP layer in answer, got nothing" @@ -915,7 +916,7 @@ def test_ipv6_udp_stun_change_port(iface): @test -def test_ipv4_tcp_ssh(iface): +def test_ipv4_tcp_ssh(): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): @@ -932,7 +933,7 @@ def test_ipv4_tcp_ssh(iface): / IP(dst=IPV4_ADDR) / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -949,7 +950,7 @@ def test_ipv4_tcp_ssh(iface): ack=syn_ack.seq + 1, ) ) - _ = iface.sr1(ack, timeout=1) + _ = srp1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) @@ -962,7 +963,7 @@ def test_ipv4_tcp_ssh(iface): ) / Raw(banner + b"\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert TCP in resp, "expecting TCP, got %r" % resp.summary() @@ -979,7 +980,7 @@ def test_ipv4_tcp_ssh(iface): @test -def test_ipv4_udp_ssh(iface): +def test_ipv4_udp_ssh(): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): @@ -996,7 +997,7 @@ def test_ipv4_udp_ssh(iface): / UDP(sport=sport, dport=dport) / Raw(banner + b"\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert UDP in resp @@ -1011,7 +1012,7 @@ def test_ipv4_udp_ssh(iface): @test -def test_ipv6_tcp_ssh(iface): +def test_ipv6_tcp_ssh(): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): @@ -1028,7 +1029,7 @@ def test_ipv6_tcp_ssh(iface): / IPv6(dst=IPV6_ADDR) / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ipv6_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -1045,7 +1046,7 @@ def test_ipv6_tcp_ssh(iface): ack=syn_ack.seq + 1, ) ) - _ = iface.sr1(ack, timeout=1) + _ = srp1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) @@ -1058,7 +1059,7 @@ def test_ipv6_tcp_ssh(iface): ) / Raw(banner + b"\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) assert TCP in resp, "expecting TCP, got %r" % resp.summary() @@ -1075,7 +1076,7 @@ def test_ipv6_tcp_ssh(iface): @test -def test_ipv6_udp_ssh(iface): +def test_ipv6_udp_ssh(): sport = 37183 dports = [22, 80, 2222, 2022, 23874, 50000] for i, dport in enumerate(dports): @@ -1092,7 +1093,7 @@ def test_ipv6_udp_ssh(iface): / UDP(sport=sport, dport=dport) / Raw(banner + b"\r\n") ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ipv6_checksum(resp) assert UDP in resp @@ -1107,7 +1108,7 @@ def test_ipv6_udp_ssh(iface): @test -def test_ipv4_tcp_ghost(iface): +def test_ipv4_tcp_ghost(): sport = 37184 dports = [22, 23874] for dport in dports: @@ -1118,7 +1119,7 @@ def test_ipv4_tcp_ghost(iface): / IP(dst=IPV4_ADDR) / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) ) - syn_ack = iface.sr1(syn, timeout=1) + syn_ack = srp1(syn, timeout=1) assert syn_ack is not None, "expecting answer, got nothing" check_ip_checksum(syn_ack) assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() @@ -1135,7 +1136,7 @@ def test_ipv4_tcp_ghost(iface): ack=syn_ack.seq + 1, ) ) - _ = iface.sr1(ack, timeout=1) + _ = srp1(ack, timeout=1) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) @@ -1148,7 +1149,7 @@ def test_ipv4_tcp_ghost(iface): ) / Raw(banner) ) - resp = iface.sr1(req, timeout=1) + resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert TCP in resp, "expecting TCP, got %r" % resp.summary() @@ -1165,9 +1166,9 @@ def test_ipv4_tcp_ghost(iface): ) -def test_all(iface): +def test_all(): global TESTS # execute tests for t in TESTS: - t(iface) + t() return len(ERRORS) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index a902cd9..de4548a 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -16,6 +16,8 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . +import atexit +import functools import logging import os import subprocess @@ -31,7 +33,6 @@ else: HAS_IVRE = True from scapy.config import conf from scapy.interfaces import resolve_iface -from scapy.layers.tuntap import TunTapInterface from src.all import test_all from src.conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR, OUTDIR @@ -47,8 +48,65 @@ def setup_logs(): return log +def cleanup_net(iface): + subprocess.check_call(["ip", "link", "delete", iface]) + subprocess.check_call( + [ + "iptables", + "-D", + "INPUT", + "-i", + iface, + "-m", + "state", + "--state", + "ESTABLISHED", + "-j", + "ACCEPT", + ] + ) + subprocess.check_call(["iptables", "-D", "INPUT", "-i", iface, "-j", "DROP"]) + + +def setup_net(iface): + global IPV4_ADDR + # create the interfaces pair + subprocess.check_call( + ["ip", "link", "add", f"{iface}a", "type", "veth", "peer", f"{iface}b"] + ) + atexit.register(functools.partial(cleanup_net, f"{iface}a")) + for sub in "a", "b": + subprocess.check_call(["ip", "link", "set", f"{iface}{sub}", "up"]) + subprocess.check_call(["ip", "addr", "add", "dev", f"{iface}a", "192.0.0.0/31"]) + subprocess.check_call( + ["ip", "addr", "add", "dev", f"{iface}a", "2001:41d0::1234:5678/96"] + ) + subprocess.check_call(["ip", "route", "add", "1.2.3.4/32", "via", IPV4_ADDR]) + # prevent problems between raw scanners (Scapy, Nmap, Masscan) and + # the host IP stack + subprocess.check_call( + [ + "iptables", + "-A", + "INPUT", + "-i", + f"{iface}a", + "-m", + "state", + "--state", + "ESTABLISHED", + "-j", + "ACCEPT", + ] + ) + subprocess.check_call(["iptables", "-A", "INPUT", "-i", f"{iface}a", "-j", "DROP"]) + conf.route.resync() + conf.route6.resync() + + LOG = setup_logs() -IFACE = "tap0" +IFACE = "masscanned" +setup_net(IFACE) TCPDUMP = bool(os.environ.get("USE_TCPDUMP")) if HAS_IVRE: ZEEK_PASSIVERECON = bool(os.environ.get("USE_ZEEK")) @@ -63,21 +121,18 @@ with NamedTemporaryFile(delete=False, mode="w") as ipfile: ipfile.write(f"{IPV6_ADDR}\n") # create test interface -tap = TunTapInterface(IFACE) -conf.iface = resolve_iface(IFACE) - -# set interface -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", "route", "add", "1.2.3.4/32", "via", IPV4_ADDR]) -conf.route.resync() -conf.route6.resync() +conf.iface = resolve_iface(f"{IFACE}a") # start capture if TCPDUMP: tcpdump = subprocess.Popen( - ["tcpdump", "-enli", IFACE, "-w", os.path.join(OUTDIR, "test_capture.pcap")] + [ + "tcpdump", + "-enli", + f"{IFACE}a", + "-w", + os.path.join(OUTDIR, "test_capture.pcap"), + ] ) if ZEEK_PASSIVERECON: zeek = subprocess.Popen( @@ -86,7 +141,7 @@ if ZEEK_PASSIVERECON: "-C", "-b", "-i", - IFACE, + f"{IFACE}a", os.path.join( guess_prefix("zeek"), "ivre", @@ -103,7 +158,7 @@ if ZEEK_PASSIVERECON: ) if P0F: p0f = subprocess.Popen( - ["p0f", "-i", IFACE, "-o", os.path.join(OUTDIR, "p0f_log.txt")], + ["p0f", "-i", f"{IFACE}a", "-o", os.path.join(OUTDIR, "p0f_log.txt")], stdout=open(os.path.join(OUTDIR, "p0f.stdout"), "w"), stderr=open(os.path.join(OUTDIR, "p0f.stderr"), "w"), ) @@ -113,7 +168,7 @@ masscanned = subprocess.Popen( "./target/debug/masscanned", "-vvvvv", "-i", - IFACE, + f"{IFACE}b", "-f", ipfile.name, "-a", @@ -128,7 +183,7 @@ masscanned = subprocess.Popen( sleep(1) try: - result = test_all(tap) + result = test_all() except AssertionError: result = -1 From 37895f952882ccdb2e2697a71c8acb5698382987 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Fri, 17 Dec 2021 23:36:16 +0100 Subject: [PATCH 023/317] Add Unix RPC --- src/proto/mod.rs | 10 + src/proto/rpc.rs | 495 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 505 insertions(+) create mode 100644 src/proto/rpc.rs diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 78b65e1..9000eca 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -36,10 +36,14 @@ use ssh::SSH_PATTERN_CLIENT_PROTOCOL; mod ghost; use ghost::GHOST_PATTERN_SIGNATURE; +mod rpc; +use rpc::RPC_CALL; + const PROTO_HTTP: usize = 1; const PROTO_STUN: usize = 2; const PROTO_SSH: usize = 3; const PROTO_GHOST: usize = 4; +const PROTO_RPC: usize = 5; struct TCPControlBlock { proto_state: usize, @@ -85,6 +89,11 @@ fn proto_init() -> Smack { PROTO_GHOST, SmackFlags::ANCHOR_BEGIN, ); + smack.add_pattern( + RPC_CALL, + PROTO_RPC, + SmackFlags::ANCHOR_BEGIN | SmackFlags::WILDCARDS, + ); smack.compile(); smack } @@ -132,6 +141,7 @@ pub fn repl<'a>( PROTO_STUN => stun::repl(data, masscanned, &mut client_info), PROTO_SSH => ssh::repl(data, masscanned, &mut client_info), PROTO_GHOST => ghost::repl(data, masscanned, &mut client_info), + PROTO_RPC => rpc::repl(data, masscanned, &mut client_info), _ => { debug!("id: {}", id); None diff --git a/src/proto/rpc.rs b/src/proto/rpc.rs new file mode 100644 index 0000000..0619ed7 --- /dev/null +++ b/src/proto/rpc.rs @@ -0,0 +1,495 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use log::warn; +use std::convert::TryInto; +use std::net::IpAddr; + +use crate::client::ClientInfo; +use crate::Masscanned; + +// last fragment (1 bit) + fragment len (31 bits) / length XID (random) / message type: call (0) / RPC version (0-255) / Program: Portmap (99840 - 100095) / Program version (*, random versions used, see below) / / Procedure: ??? (0-255) +pub const RPC_CALL: &[u8; 28] = + b"********\x00\x00\x00\x00\x00\x00\x00*\x00\x01\x86*****\x00\x00\x00*"; + +#[derive(Debug)] +enum RpcState { + Frag, + Xid, + MessageType, + RpcVersion, + Program, + ProgramVersion, + Procedure, + CredsFlavor, + CredsLen, + Creds, + VerifFlavor, + VerifLen, + Verif, + End, +} + +#[derive(Debug)] +struct ProtocolState { + state: RpcState, + last_frag: bool, + frag_len: u32, + xid: u32, + message_type: u32, + rpc_version: u32, + program: u32, + prog_version: u32, + procedure: u32, + creds_flavor: u32, + creds_data: Vec, + verif_flavor: u32, + verif_data: Vec, + payload: Vec, + cur_len: u32, + data_len: u32, +} + +struct Rpcb { + program: u32, + version: u32, + netid: String, + addr: String, + port: u16, + owner: String, +} + +impl ProtocolState { + fn new() -> Self { + ProtocolState { + state: RpcState::Frag, + last_frag: false, + frag_len: 0, + xid: 0, + message_type: 0, + rpc_version: 0, + program: 0, + prog_version: 0, + procedure: 0, + creds_flavor: 0, + creds_data: Vec::::new(), + verif_flavor: 0, + verif_data: Vec::::new(), + payload: Vec::::new(), + cur_len: 0, + data_len: 0, + } + } +} + +fn read_u32(pstate: &mut ProtocolState, byte: u8, value: u32, next_state: RpcState) -> u32 { + pstate.cur_len += 1; + if pstate.cur_len == 4 { + pstate.state = next_state; + pstate.cur_len = 0; + } + value * 256 + byte as u32 +} + +fn read_string(pstate: &mut ProtocolState, next_state: RpcState) { + pstate.data_len -= 1; + if pstate.data_len == 0 { + pstate.state = next_state; + } +} + +fn rpc_parse(pstate: &mut ProtocolState, data: &[u8]) { + for byte in data { + match pstate.state { + RpcState::Frag => { + if pstate.cur_len == 0 { + match byte & 128 { + 0 => pstate.last_frag = false, + _ => pstate.last_frag = true, + }; + pstate.frag_len = (*byte & 127) as u32; + } else { + pstate.frag_len = *byte as u32; + } + pstate.cur_len += 1; + if pstate.cur_len == 4 { + pstate.state = RpcState::Xid; + pstate.cur_len = 0; + } + } + RpcState::Xid => { + pstate.xid = read_u32(pstate, *byte, pstate.xid, RpcState::MessageType) + } + RpcState::MessageType => { + pstate.message_type = + read_u32(pstate, *byte, pstate.message_type, RpcState::RpcVersion) + } + RpcState::RpcVersion => { + pstate.rpc_version = read_u32(pstate, *byte, pstate.rpc_version, RpcState::Program) + } + RpcState::Program => { + pstate.program = read_u32(pstate, *byte, pstate.program, RpcState::ProgramVersion) + } + RpcState::ProgramVersion => { + pstate.prog_version = + read_u32(pstate, *byte, pstate.prog_version, RpcState::Procedure) + } + RpcState::Procedure => { + pstate.procedure = read_u32(pstate, *byte, pstate.procedure, RpcState::CredsFlavor) + } + RpcState::CredsFlavor => { + pstate.creds_flavor = + read_u32(pstate, *byte, pstate.creds_flavor, RpcState::CredsLen) + } + RpcState::CredsLen => { + pstate.data_len = read_u32(pstate, *byte, pstate.data_len, RpcState::Creds); + if matches!(pstate.state, RpcState::Creds) && pstate.data_len == 0 { + pstate.state = RpcState::VerifFlavor + } + } + RpcState::Creds => { + pstate.creds_data.push(*byte); + read_string(pstate, RpcState::VerifFlavor) + } + RpcState::VerifFlavor => { + pstate.verif_flavor = + read_u32(pstate, *byte, pstate.verif_flavor, RpcState::VerifLen) + } + RpcState::VerifLen => { + pstate.data_len = read_u32(pstate, *byte, pstate.data_len, RpcState::Verif); + if matches!(pstate.state, RpcState::Verif) && pstate.cur_len == 0 { + pstate.state = RpcState::End + } + } + RpcState::Verif => { + pstate.verif_data.push(*byte); + read_string(pstate, RpcState::End) + } + RpcState::End => { + pstate.payload.push(*byte); + } + }; + } +} + +fn get_nth_byte(value: u32, nth: u8) -> u8 { + let shift = 8 * (3 - nth); + ((value & (0xff << shift)) >> shift).try_into().unwrap() +} + +fn push_u32(buffer: &mut Vec, data: u32) { + for i in 0..4 { + buffer.push(get_nth_byte(data, i)); + } +} + +fn push_string_pad(buffer: &mut Vec, data: String) { + let len: u32 = data.len().try_into().unwrap(); + push_u32(buffer, len); + buffer.append(&mut data.as_bytes().to_vec()); + if len % 4 != 0 { + for _ in 0..(4 - (len % 4)) { + buffer.append(&mut b"\x00".to_vec()); + } + } +} + +fn build_repl_portmap(pstate: ProtocolState, client_info: &ClientInfo) -> Vec { + let mut resp = Vec::::new(); + match pstate.procedure { + // 0 => {} + 3 => { + // getaddr / getport + // accepted state: 0 (RPC executed successfully) + resp.extend([0, 0, 0, 0]); + let localport = client_info.port.dst.unwrap(); + match pstate.prog_version { + 2 => { + push_u32(&mut resp, localport as u32); + } + 3 | 4 => { + let addr = format!( + "{}.{}.{}", + client_info.ip.dst.unwrap(), + localport >> 8, + localport % 256 + ); + push_string_pad(&mut resp, addr); + } + _ => panic!("Wrong RPC version"), + } + } + 4 => { + // dump + // accepted state: 0 (RPC executed successfully) + resp.extend([0, 0, 0, 0]); + let localaddr = client_info.ip.dst.unwrap(); + let localport = client_info.port.dst.unwrap(); + let netid = match localaddr { + IpAddr::V4(_) => "tcp", + IpAddr::V6(_) => "tcp6", + }; + for rpcb in [ + Rpcb { + program: 100000, + version: 2, + netid: netid.to_string(), + addr: format!("{}", localaddr), + port: localport, + owner: "superuser".to_string(), + }, + Rpcb { + program: 100000, + version: 3, + netid: netid.to_string(), + addr: format!("{}", localaddr), + port: localport, + owner: "superuser".to_string(), + }, + Rpcb { + program: 100000, + version: 4, + netid: netid.to_string(), + addr: format!("{}", localaddr), + port: localport, + owner: "superuser".to_string(), + }, + ] { + resp.append(&mut b"\x00\x00\x00\x01".to_vec()); // value follows: yes + push_u32(&mut resp, rpcb.program); + push_u32(&mut resp, rpcb.version); + match pstate.prog_version { + 2 => { + push_u32( + &mut resp, + match rpcb.netid.as_str() { + "tcp" => 6, + "tcp6" => 6, + "udp" => 17, + "udp6" => 17, + _ => 0, + }, + ); + push_u32(&mut resp, localport as u32); + } + 3 | 4 => { + push_string_pad(&mut resp, rpcb.netid); + push_string_pad( + &mut resp, + format!("{}.{}.{}", rpcb.addr, rpcb.port >> 8, rpcb.port & 0xff), + ); + push_string_pad(&mut resp, rpcb.owner); + } + _ => panic!("Wrong RPC version"), + } + } + resp.append(&mut b"\x00\x00\x00\x00".to_vec()); // value follows: no + } + _ => { + // accepted state: 5 (program can't support procedure) + resp.extend([0, 0, 0, 5]); + } + } + warn!( + "RPC: Portmap version {}, procedure {}", + pstate.prog_version, pstate.procedure + ); + resp +} + +fn build_repl_unknownprog(pstate: ProtocolState, _client_info: &ClientInfo) -> Vec { + warn!( + "Unknown program {}, procedure {}: accepted state 1", + pstate.program, pstate.procedure + ); + // accepted state: 1 (remote hasn't exported program) + vec![0, 0, 0, 1] +} + +fn build_repl(pstate: ProtocolState, client_info: &ClientInfo) -> Vec { + // TODO: test RPC versions, drop non calls? + let mut resp = Vec::::new(); + push_u32(&mut resp, pstate.xid); + // message_type: 1 (reply) + // reply_state: 0 (accepted) + // verifier: 0 (auth null) + // verifier length: 0 + resp.extend([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + if pstate.prog_version < 2 || pstate.prog_version > 4 { + /* + * Scanners (e.g., Nmap script rpc-grind) often use random + * values for program version to find out if a program is + * supported, so for any program, we answer with "remote can't + * support version" accepted state. + */ + // accepted state: 2 (remote can't support version) + // prog_version min: 2 + // prog_version max: 4 + let prog_version = match pstate.prog_version { + 104316 => "104316 (Nmap probe TCP RPCCheck)".to_string(), + x => x.to_string(), + }; + warn!( + "RPC: unsupported version {} for program {}", + prog_version, pstate.program + ); + resp.extend([0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 4]); + } else if pstate.procedure == 0 { + /* + * RPC clients (e.g., Linux kernel NFS client, rpcbind CLI + * tool) would often send a NULL procedure (0) call before any + * real operation . + */ + // accepted state: 0 (RPC executed successfully) + warn!("RPC: NULL procedure call for program {}", pstate.program); + resp.extend([0, 0, 0, 0]); + } else { + let mut specif_resp = match pstate.program { + 100000 => build_repl_portmap(pstate, client_info), + _ => build_repl_unknownprog(pstate, client_info), + }; + resp.append(&mut specif_resp); + } + let length: u32 = resp.len().try_into().unwrap(); + let mut final_resp = Vec::::new(); + for i in 0..4 { + match i { + 0 => final_resp.push(get_nth_byte(length, i) | 0x80), + _ => final_resp.push(get_nth_byte(length, i)), + }; + } + final_resp.append(&mut resp); + final_resp +} + +pub fn repl<'a>( + data: &'a [u8], + _masscanned: &Masscanned, + client_info: &ClientInfo, +) -> Option> { + let mut pstate = ProtocolState::new(); + rpc_parse(&mut pstate, data); + // warn!("RPC {:#?}", pstate); + match pstate.state { + RpcState::End => Some(build_repl(pstate, client_info)), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::client::ClientInfoSrcDst; + use std::net::Ipv4Addr; + + const CLIENT_INFO: ClientInfo = ClientInfo { + mac: ClientInfoSrcDst { + src: None, + dst: None, + }, + ip: ClientInfoSrcDst { + src: Some(IpAddr::V4(Ipv4Addr::new(192, 0, 0, 0))), + dst: Some(IpAddr::V4(Ipv4Addr::new(192, 0, 0, 1))), + }, + transport: None, + port: ClientInfoSrcDst { + src: Some(12345), + dst: Some(111), + }, + cookie: None, + }; + + #[test] + fn test_probe_nmap() { + let mut pstate = ProtocolState::new(); + rpc_parse(&mut pstate, b"\x80\x00\x00\x28\x72\xfe\x1d\x13\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xa0\x00\x01\x97\x7c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); + assert!(matches!(pstate.state, RpcState::End)); + assert!(pstate.xid == 0x72fe1d13); + assert!(pstate.rpc_version == 2); + assert!(pstate.program == 100000); + assert!(pstate.prog_version == 104316); + assert!(pstate.procedure == 0); + assert!(pstate.creds_flavor == 0); + assert!(pstate.creds_data.len() == 0); + assert!(pstate.verif_flavor == 0); + assert!(pstate.verif_data.len() == 0); + let resp = build_repl(pstate, &CLIENT_INFO); + assert!(resp == b"\x80\x00\x00\x20\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); + } + + #[test] + fn test_probe_nmap_split1() { + let mut pstate = ProtocolState::new(); + for byte in b"\x80\x00\x00\x28\x72\xfe\x1d\x13\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xa0\x00\x01\x97\x7c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" { + rpc_parse(&mut pstate, &[*byte]); + } + assert!(matches!(pstate.state, RpcState::End)); + assert!(pstate.xid == 0x72fe1d13); + assert!(pstate.rpc_version == 2); + assert!(pstate.program == 100000); + assert!(pstate.prog_version == 104316); + assert!(pstate.procedure == 0); + assert!(pstate.creds_flavor == 0); + assert!(pstate.creds_data.len() == 0); + assert!(pstate.verif_flavor == 0); + assert!(pstate.verif_data.len() == 0); + let resp = build_repl(pstate, &CLIENT_INFO); + assert!(resp == b"\x80\x00\x00\x20\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); + } + + #[test] + fn test_probe_nmap_split2() { + let mut pstate = ProtocolState::new(); + for data in [ + b"\x80\x00\x00\x28\x72\xfe\x1d", + b"\x13\x00\x00\x00\x00\x00\x00", + b"\x00\x02\x00\x01\x86\xa0\x00", + b"\x01\x97\x7c\x00\x00\x00\x00", + b"\x00\x00\x00\x00\x00\x00\x00", + b"\x00\x00\x00\x00\x00\x00\x00", + ] { + rpc_parse(&mut pstate, data); + } + rpc_parse(&mut pstate, b"\x00\x00"); + assert!(matches!(pstate.state, RpcState::End)); + assert!(pstate.xid == 0x72fe1d13); + assert!(pstate.rpc_version == 2); + assert!(pstate.program == 100000); + assert!(pstate.prog_version == 104316); + assert!(pstate.procedure == 0); + assert!(pstate.creds_flavor == 0); + assert!(pstate.creds_data.len() == 0); + assert!(pstate.verif_flavor == 0); + assert!(pstate.verif_data.len() == 0); + let resp = build_repl(pstate, &CLIENT_INFO); + assert!(resp == b"\x80\x00\x00\x20\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); + } + + #[test] + fn test_probe_portmap_v4_dump() { + let mut pstate = ProtocolState::new(); + rpc_parse(&mut pstate, b"\x80\x00\x00\x28\x01\x1b\x60\xa6\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xa0\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); + assert!(matches!(pstate.state, RpcState::End)); + assert!(pstate.rpc_version == 2); + assert!(pstate.program == 100000); + assert!(pstate.prog_version == 4); + assert!(pstate.procedure == 4); // dump + assert!(pstate.creds_flavor == 0); + assert!(pstate.creds_data.len() == 0); + assert!(pstate.verif_flavor == 0); + assert!(pstate.verif_data.len() == 0); + } +} From 5a52dcace755d06c5a3f8d71801b9ff47058908c Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Sun, 19 Dec 2021 23:25:46 +0100 Subject: [PATCH 024/317] Tests: add Nmap test for RPC --- .github/workflows/test.yml | 3 +++ test/requirements.txt | 1 + test/src/all.py | 43 ++++++++++++++++++++++++++++++++++++++ test/test_masscanned.py | 5 +++++ 4 files changed, 52 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41f2ffe..0fb10e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -83,6 +83,9 @@ jobs: - name: Install linting tools run: sudo pip install -U flake8 black + - name: Install Nmap + run: sudo apt-get -q update && sudo apt-get -qy install nmap + - name: Run black run: black -t py36 --check test/test_masscanned.py test/src/ diff --git a/test/requirements.txt b/test/requirements.txt index ebda39b..fd8f3e8 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -1,2 +1,3 @@ +ivre scapy requests diff --git a/test/src/all.py b/test/src/all.py index c4b740e..f8f140a 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -14,11 +14,16 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . +import json import logging +import os from socket import AF_INET6 +from subprocess import check_call import struct +from tempfile import NamedTemporaryFile import zlib +from ivre.db import DBNmap from scapy.compat import raw from scapy.data import ETHER_BROADCAST from scapy.layers.inet import ICMP, IP, TCP, UDP @@ -1166,6 +1171,44 @@ def test_ipv4_tcp_ghost(): ) +@test +def test_rpc_nmap(): + with NamedTemporaryFile(delete=False) as xml_result: + check_call( + [ + "nmap", + "-n", + "-vv", + "-oX", + "-", + IPV4_ADDR, + "-sSV", + "-p", + "111", + "--script", + "rpcinfo,rpc-grind", + ], + stdout=xml_result, + ) + with NamedTemporaryFile(delete=False, mode="w") as json_result: + DBNmap(output=json_result).store_scan(xml_result.name) + os.unlink(xml_result.name) + with open(json_result.name) as fdesc: + results = [json.loads(line) for line in fdesc] + os.unlink(json_result.name) + assert len(results) == 1, f"Expected 1 result, got {len(results)}" + result = results[0] + assert len(result["ports"]) == 1, f"Expected 1 port, got {len(result['ports'])}" + port = result["ports"][0] + assert port["port"] == 111 and port["protocol"] == "tcp" + assert port["service_name"] in {"rpcbind", "nfs"} + assert port["service_extrainfo"] in {"RPC #100000", "RPC #100003"} + assert len(port["scripts"]) == 1, f"Expected 1 script, got {len(port['scripts'])}" + script = port["scripts"][0] + assert script["id"] == "rpcinfo", "Expected rpcinfo script, not found" + assert len(script["rpcinfo"]) == 1 + + def test_all(): global TESTS # execute tests diff --git a/test/test_masscanned.py b/test/test_masscanned.py index de4548a..54fee57 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -49,6 +49,7 @@ def setup_logs(): def cleanup_net(iface): + global ipfile subprocess.check_call(["ip", "link", "delete", iface]) subprocess.check_call( [ @@ -66,6 +67,10 @@ def cleanup_net(iface): ] ) subprocess.check_call(["iptables", "-D", "INPUT", "-i", iface, "-j", "DROP"]) + try: + os.unlink(ipfile.name) + except NameError: + pass def setup_net(iface): From c70d9b3f1d1d1c7d2c25e2562f098a052d68c9c9 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 20 Dec 2021 23:52:57 +0100 Subject: [PATCH 025/317] Test: add rpcinfo test for RPC --- .github/workflows/test.yml | 4 ++-- test/src/all.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0fb10e8..8cd41fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -83,8 +83,8 @@ jobs: - name: Install linting tools run: sudo pip install -U flake8 black - - name: Install Nmap - run: sudo apt-get -q update && sudo apt-get -qy install nmap + - name: Install packages for tests + run: sudo apt-get -q update && sudo apt-get -qy install nmap rpcbind - name: Run black run: black -t py36 --check test/test_masscanned.py test/src/ diff --git a/test/src/all.py b/test/src/all.py index f8f140a..c73d65b 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -1209,6 +1209,25 @@ def test_rpc_nmap(): assert len(script["rpcinfo"]) == 1 +@test +def test_rpcinfo(): + with NamedTemporaryFile(delete=False) as rpcout: + check_call(["rpcinfo", "-p", IPV4_ADDR], stdout=rpcout) + with open(rpcout.name) as fdesc: + found = [] + for line in fdesc: + line = line.split() + if line[0] == "program": + # header + continue + assert line[0] == "100000", f"Expected program 100000, got {line[0]}" + found.append(int(line[1])) + assert len(found) == 3, f"Expected three versions, got {found}" + for i in range(2, 5): + assert i in found, f"Missing version {i} in {found}" + os.unlink(rpcout.name) + + def test_all(): global TESTS # execute tests From a422f60a9a5feddeb0597bdf7d3e4b6c869cd204 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 11:03:40 +0100 Subject: [PATCH 026/317] Add test to emphasis bug in HTTP FSM --- src/proto/mod.rs | 30 +++++++++++++++++++++++++++++ test/src/all.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 9000eca..291002b 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -285,4 +285,34 @@ mod tests { }; } } + + #[test] + fn test_proto_repl_http() { + /* ensure that HTTP FSM does not answer until completion of request + * (at least headers) */ + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65000); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + }; + /***** TEST COMPLETE REQUEST *****/ + let payload = b"GET / HTTP/1.1\r\n\r\n"; + if let None = repl(&payload.to_vec(), &masscanned, &mut client_info) { + panic!("expected an answer, got nothing"); + } + /***** TEST INCOMPLETE REQUEST *****/ + let payload = b"GET / HTTP/1.1\r\n"; + if let Some(_) = repl(&payload.to_vec(), &masscanned, &mut client_info) { + panic!("expected no answer, got one"); + } + } } diff --git a/test/src/all.py b/test/src/all.py index c73d65b..214a249 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -537,6 +537,56 @@ def test_ipv4_tcp_http(): assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") +@test +def test_ipv4_tcp_http_incomplete(): + sport = 24595 + dports = [80, 443, 5000, 53228] + for dport in dports: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + # purposedly incomplete request (missing additionnal ending \r\n) + / Raw("GET / HTTP/1.1\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting an answer, got none" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert tcp.flags == "A", "expecting TCP flag A, got {}".format(tcp.flags) + + @test def test_ipv6_tcp_http(): sport = 24592 From cffc94feb721cf5deedf4138d07784d6491a3fdc Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 11:06:48 +0100 Subject: [PATCH 027/317] Fix bug in HTTP FSM --- src/proto/http.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/proto/http.rs b/src/proto/http.rs index a31f924..8879c54 100644 --- a/src/proto/http.rs +++ b/src/proto/http.rs @@ -232,6 +232,11 @@ pub fn repl<'a>( debug!("pstate: {}", pstate.state); return None; } + /* if not in CONTENT state, not responding yet (it means the client + * has not finished sending headers yet) */ + if pstate.state != HTTP_STATE_CONTENT { + return None; + } let content = "\ 401 Authorization Required From 6f2f3226a417f7828def4d4344de35045631652d Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 11:19:14 +0100 Subject: [PATCH 028/317] Clean a few commented lines --- Cargo.toml | 1 - src/proto/stun.rs | 158 ---------------------------------------------- 2 files changed, 159 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 211a287..5228bf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ edition = "2018" pcap = "0.7.0" pcap-file = "1.1.1" pnet = "0.26.0" -# pnet = { path = "libpnet" } clap = "2.33.3" log = "0.4.11" stderrlog = "0.5.0" diff --git a/src/proto/stun.rs b/src/proto/stun.rs index a5c7ac4..1ddab10 100644 --- a/src/proto/stun.rs +++ b/src/proto/stun.rs @@ -257,107 +257,6 @@ impl Into> for &StunAttribute { } } -/* -struct StunPacket { - class: u8, - method: u16, - length: u16, - magic: u32, - id: u128, - data: Vec, - attributes: Vec, -} - -impl StunPacket { - fn new(data: &[u8]) -> Result { - if data.len() < 20 { - return Err(io::Error::new( - io::ErrorKind::InvalidInput, - "not enough data", - )); - } - let class: u8 = ((data[0] & 0x01) << 1) | ((data[1] & 0x10) >> 4); - let method: u16 = (((data[0] & 0b00111110) << 7) as u16) | ((data[1] & 0b11101111) as u16); - let length: u16 = BigEndian::read_u16(&data[2..4]); - let magic: u32 = BigEndian::read_u32(&data[4..8]); - let id: u128 = ((BigEndian::read_u64(&data[8..16]) as u128) << 32) - | (BigEndian::read_u32(&data[16..20]) as u128); - if data.len() < 20 + length as usize { - return Err(io::Error::new( - io::ErrorKind::InvalidInput, - "not enough data", - )); - } - let data: Vec = data[20..(20 + length) as usize].to_vec(); - let mut stun = StunPacket { - class, - method, - length, - magic, - id, - data, - attributes: Vec::::new(), - }; - stun.attributes = stun.get_attributes(); - Ok(stun) - } - - fn empty() -> Self { - StunPacket { - class: 0, - method: 0, - length: 0, - magic: 0, - id: 0, - data: Vec::new(), - attributes: Vec::new(), - } - } - - fn get_attributes(&self) -> Vec { - let mut i = 0; - let mut attributes = Vec::::new(); - while i + 4 < self.data.len() { - let attr = StunAttribute::from(self.data[i..].to_vec()); - i += 4 + attr.len() as usize; - attributes.push(attr); - } - attributes - } - - fn set_length(&mut self) { - self.length = 0; - for attr in &self.attributes { - self.length += 4 + attr.len(); - } - } -} - -impl Into> for StunPacket { - fn into(self) -> Vec { - let mut v = Vec::::new(); - // first cocktail with class and method bits - v.push( - TryInto::::try_into((self.method >> 7) & 0b00111110).unwrap() - | TryInto::::try_into((self.class & 0b10) >> 1).unwrap(), - ); - // second cocktail with class and method bits - v.push( - TryInto::::try_into((self.method & 0b01110000) << 1).unwrap() - | TryInto::::try_into((self.class & 0b01) << 4).unwrap() - | TryInto::::try_into(self.method & 0b00001111).unwrap(), - ); - v.append(&mut self.length.to_be_bytes().to_vec()); - v.append(&mut self.magic.to_be_bytes().to_vec()); - v.append(&mut self.id.to_be_bytes()[4..].to_vec()); - for attr in &self.attributes { - v.append(&mut attr.into()); - } - v - } -} -*/ - struct StunPacket { class: u8, method: u16, @@ -451,63 +350,6 @@ impl Into> for StunPacket { } } -/* -pub fn repl<'a>( - data: &'a [u8], - _masscanned: &Masscanned, - client_info: ClientInfo, -) -> Option> { - debug!("receiving STUN data"); - let stun_req: StunPacket = if let Ok(s) = StunPacket::new(&data) { - s - } else { - return None; - }; - if stun_req.class != STUN_CLASS_REQUEST { - info!( - "STUN packet not handled (class unknown: 0b{:b})", - stun_req.class - ); - return None; - } - if stun_req.method != STUN_METHOD_BINDING { - info!( - "STUN packet not handled (method unknown: 0x{:03x})", - stun_req.method - ); - return None; - } - /* - * To be compatible with RFC3489: ignore magic - if stun_req.magic != STUN_MAGIC { - info!( - "STUN packet not handled (magic unknown: 0x{:04x})", - stun_req.magic - ); - return None; - } - */ - if client_info.ip.src == None { - error!("STUN packet not handled (expected client ip address not found)"); - return None; - } - if client_info.port.src == None { - error!("STUN packet not handled (expected client port address not found)"); - return None; - } - let mut stun_resp: StunPacket = StunPacket::empty(); - stun_resp.class = STUN_CLASS_SUCCESS_RESPONSE; - stun_resp.method = STUN_METHOD_BINDING; - stun_resp.id = stun_req.id; - stun_resp.attributes = Vec::::new(); - stun_resp.attributes.push(StunAttribute::MappedAddress( - StunMappedAddressAttribute::new(client_info.ip.src.unwrap(), client_info.port.src.unwrap()), - )); - stun_resp.set_length(); - return Some(stun_resp.into()); -} -*/ - pub fn repl<'a>( data: &'a [u8], _masscanned: &Masscanned, From 166f121d76841f247672494c153b30a35fcf544e Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 22 Dec 2021 18:27:02 +0100 Subject: [PATCH 029/317] Proto/RPC: support RPC over UDP --- src/proto/mod.rs | 17 +++++++--- src/proto/rpc.rs | 75 ++++++++++++++++++++++++++++++++++--------- test/src/all.py | 83 +++++++++++++++++++++++++++++------------------- 3 files changed, 122 insertions(+), 53 deletions(-) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 291002b..db058cf 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -37,13 +37,14 @@ mod ghost; use ghost::GHOST_PATTERN_SIGNATURE; mod rpc; -use rpc::RPC_CALL; +use rpc::{RPC_CALL_TCP, RPC_CALL_UDP}; const PROTO_HTTP: usize = 1; const PROTO_STUN: usize = 2; const PROTO_SSH: usize = 3; const PROTO_GHOST: usize = 4; -const PROTO_RPC: usize = 5; +const PROTO_RPC_TCP: usize = 5; +const PROTO_RPC_UDP: usize = 6; struct TCPControlBlock { proto_state: usize, @@ -90,8 +91,13 @@ fn proto_init() -> Smack { SmackFlags::ANCHOR_BEGIN, ); smack.add_pattern( - RPC_CALL, - PROTO_RPC, + RPC_CALL_TCP, + PROTO_RPC_TCP, + SmackFlags::ANCHOR_BEGIN | SmackFlags::WILDCARDS, + ); + smack.add_pattern( + RPC_CALL_UDP, + PROTO_RPC_UDP, SmackFlags::ANCHOR_BEGIN | SmackFlags::WILDCARDS, ); smack.compile(); @@ -141,7 +147,8 @@ pub fn repl<'a>( PROTO_STUN => stun::repl(data, masscanned, &mut client_info), PROTO_SSH => ssh::repl(data, masscanned, &mut client_info), PROTO_GHOST => ghost::repl(data, masscanned, &mut client_info), - PROTO_RPC => rpc::repl(data, masscanned, &mut client_info), + PROTO_RPC_TCP => rpc::repl_tcp(data, masscanned, &mut client_info), + PROTO_RPC_UDP => rpc::repl_udp(data, masscanned, &mut client_info), _ => { debug!("id: {}", id); None diff --git a/src/proto/rpc.rs b/src/proto/rpc.rs index 0619ed7..7a30b19 100644 --- a/src/proto/rpc.rs +++ b/src/proto/rpc.rs @@ -22,8 +22,11 @@ use crate::client::ClientInfo; use crate::Masscanned; // last fragment (1 bit) + fragment len (31 bits) / length XID (random) / message type: call (0) / RPC version (0-255) / Program: Portmap (99840 - 100095) / Program version (*, random versions used, see below) / / Procedure: ??? (0-255) -pub const RPC_CALL: &[u8; 28] = +pub const RPC_CALL_TCP: &[u8; 28] = b"********\x00\x00\x00\x00\x00\x00\x00*\x00\x01\x86*****\x00\x00\x00*"; +// UDP: last fragment and fragment len are missing +pub const RPC_CALL_UDP: &[u8; 24] = + b"****\x00\x00\x00\x00\x00\x00\x00*\x00\x01\x86*****\x00\x00\x00*"; #[derive(Debug)] enum RpcState { @@ -363,19 +366,10 @@ fn build_repl(pstate: ProtocolState, client_info: &ClientInfo) -> Vec { }; resp.append(&mut specif_resp); } - let length: u32 = resp.len().try_into().unwrap(); - let mut final_resp = Vec::::new(); - for i in 0..4 { - match i { - 0 => final_resp.push(get_nth_byte(length, i) | 0x80), - _ => final_resp.push(get_nth_byte(length, i)), - }; - } - final_resp.append(&mut resp); - final_resp + resp } -pub fn repl<'a>( +pub fn repl_tcp<'a>( data: &'a [u8], _masscanned: &Masscanned, client_info: &ClientInfo, @@ -383,6 +377,38 @@ pub fn repl<'a>( let mut pstate = ProtocolState::new(); rpc_parse(&mut pstate, data); // warn!("RPC {:#?}", pstate); + let resp = match pstate.state { + RpcState::End => Some(build_repl(pstate, client_info)), + _ => None, + }; + match resp { + Some(mut resp) => { + let length: u32 = resp.len().try_into().unwrap(); + let mut final_resp = Vec::::new(); + for i in 0..4 { + match i { + 0 => final_resp.push(get_nth_byte(length, i) | 0x80), + _ => final_resp.push(get_nth_byte(length, i)), + }; + } + final_resp.append(&mut resp); + Some(final_resp) + } + _ => None, + } +} + +pub fn repl_udp<'a>( + data: &'a [u8], + _masscanned: &Masscanned, + client_info: &ClientInfo, +) -> Option> { + let mut pstate = ProtocolState::new(); + pstate.state = RpcState::Xid; + pstate.last_frag = true; + pstate.frag_len = data.len().try_into().unwrap(); + rpc_parse(&mut pstate, data); + // warn!("RPC {:#?}", pstate); match pstate.state { RpcState::End => Some(build_repl(pstate, client_info)), _ => None, @@ -427,7 +453,26 @@ mod tests { assert!(pstate.verif_flavor == 0); assert!(pstate.verif_data.len() == 0); let resp = build_repl(pstate, &CLIENT_INFO); - assert!(resp == b"\x80\x00\x00\x20\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); + assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); + } + + #[test] + fn test_probe_nmap_udp() { + let mut pstate = ProtocolState::new(); + pstate.state = RpcState::Xid; + rpc_parse(&mut pstate, b"\x72\xfe\x1d\x13\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xa0\x00\x01\x97\x7c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); + assert!(matches!(pstate.state, RpcState::End)); + assert!(pstate.xid == 0x72fe1d13); + assert!(pstate.rpc_version == 2); + assert!(pstate.program == 100000); + assert!(pstate.prog_version == 104316); + assert!(pstate.procedure == 0); + assert!(pstate.creds_flavor == 0); + assert!(pstate.creds_data.len() == 0); + assert!(pstate.verif_flavor == 0); + assert!(pstate.verif_data.len() == 0); + let resp = build_repl(pstate, &CLIENT_INFO); + assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); } #[test] @@ -447,7 +492,7 @@ mod tests { assert!(pstate.verif_flavor == 0); assert!(pstate.verif_data.len() == 0); let resp = build_repl(pstate, &CLIENT_INFO); - assert!(resp == b"\x80\x00\x00\x20\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); + assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); } #[test] @@ -475,7 +520,7 @@ mod tests { assert!(pstate.verif_flavor == 0); assert!(pstate.verif_data.len() == 0); let resp = build_repl(pstate, &CLIENT_INFO); - assert!(resp == b"\x80\x00\x00\x20\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); + assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); } #[test] diff --git a/test/src/all.py b/test/src/all.py index 214a249..c2cd5a9 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -17,6 +17,7 @@ import json import logging import os +import re from socket import AF_INET6 from subprocess import check_call import struct @@ -1223,40 +1224,45 @@ def test_ipv4_tcp_ghost(): @test def test_rpc_nmap(): - with NamedTemporaryFile(delete=False) as xml_result: - check_call( - [ - "nmap", - "-n", - "-vv", - "-oX", - "-", - IPV4_ADDR, - "-sSV", - "-p", - "111", - "--script", - "rpcinfo,rpc-grind", - ], - stdout=xml_result, + for scan in "SU": + with NamedTemporaryFile(delete=False) as xml_result: + check_call( + [ + "nmap", + "-n", + "-vv", + "-oX", + "-", + IPV4_ADDR, + f"-s{scan}V", + "-p", + "111", + "--script", + "rpcinfo,rpc-grind", + ], + stdout=xml_result, + ) + with NamedTemporaryFile(delete=False, mode="w") as json_result: + DBNmap(output=json_result).store_scan(xml_result.name) + os.unlink(xml_result.name) + with open(json_result.name) as fdesc: + results = [json.loads(line) for line in fdesc] + os.unlink(json_result.name) + assert len(results) == 1, f"Expected 1 result, got {len(results)}" + result = results[0] + assert len(result["ports"]) == 1, f"Expected 1 port, got {len(result['ports'])}" + port = result["ports"][0] + assert port["port"] == 111 and port["protocol"] == ( + "tcp" if scan == "S" else "udp" ) - with NamedTemporaryFile(delete=False, mode="w") as json_result: - DBNmap(output=json_result).store_scan(xml_result.name) - os.unlink(xml_result.name) - with open(json_result.name) as fdesc: - results = [json.loads(line) for line in fdesc] - os.unlink(json_result.name) - assert len(results) == 1, f"Expected 1 result, got {len(results)}" - result = results[0] - assert len(result["ports"]) == 1, f"Expected 1 port, got {len(result['ports'])}" - port = result["ports"][0] - assert port["port"] == 111 and port["protocol"] == "tcp" - assert port["service_name"] in {"rpcbind", "nfs"} - assert port["service_extrainfo"] in {"RPC #100000", "RPC #100003"} - assert len(port["scripts"]) == 1, f"Expected 1 script, got {len(port['scripts'])}" - script = port["scripts"][0] - assert script["id"] == "rpcinfo", "Expected rpcinfo script, not found" - assert len(script["rpcinfo"]) == 1 + assert port["service_name"] in {"rpcbind", "nfs"} + assert port["service_extrainfo"] in {"RPC #100000", "RPC #100003"} + assert ( + len(port["scripts"]) == 1 + ), f"Expected 1 script, got {len(port['scripts'])}" + script = port["scripts"][0] + assert script["id"] == "rpcinfo", "Expected rpcinfo script, not found" + assert len(script["rpcinfo"]) == 1 @test @@ -1276,6 +1282,17 @@ def test_rpcinfo(): for i in range(2, 5): assert i in found, f"Missing version {i} in {found}" os.unlink(rpcout.name) + with NamedTemporaryFile(delete=False) as rpcout: + check_call(["rpcinfo", "-u", IPV4_ADDR, "100000"], stdout=rpcout) + with open(rpcout.name) as fdesc: + found = [] + expr = re.compile("^program 100000 version ([0-9]) ready and waiting$") + for line in fdesc: + found.append(int(expr.search(line.strip()).group(1))) + assert len(found) == 3, f"Expected three versions, got {found}" + for i in range(2, 5): + assert i in found, f"Missing version {i} in {found}" + os.unlink(rpcout.name) def test_all(): From 0f742f4f2c10d04341e62b6c387c39e419797c5f Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 30 Dec 2021 23:56:54 +0100 Subject: [PATCH 030/317] Add a Dependabot config file --- .github/dependabot.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..149a1e5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,22 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +version: 2 +updates: +- package-ecosystem: cargo + directory: "/" + schedule: + interval: daily From d5c3fddc194dabe3464fd8131fc9a9e10a6a3bb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 Dec 2021 06:24:25 +0000 Subject: [PATCH 031/317] Update itertools requirement from 0.9.0 to 0.10.3 Updates the requirements on [itertools](https://github.com/rust-itertools/itertools) to permit the latest version. - [Release notes](https://github.com/rust-itertools/itertools/releases) - [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-itertools/itertools/compare/v0.9.0...v0.10.3) --- updated-dependencies: - dependency-name: itertools dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5228bf9..cdaabb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ pnet = "0.26.0" clap = "2.33.3" log = "0.4.11" stderrlog = "0.5.0" -itertools = "0.9.0" +itertools = "0.10.3" rand = "0.7.3" dns-parser = "0.8.0" netdevice = "0.1.1" From 797c30ce91b34fe175b21196f5df601d9d626f28 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 11:14:15 +0100 Subject: [PATCH 032/317] Add unit tests for FIN,ACK packets --- src/layer_4/tcp.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index d93585f..1edda4c 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -118,6 +118,56 @@ mod tests { use pnet::util::MacAddr; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; + #[test] + fn test_tcp_fin_ack() { + let masscanned = Masscanned { + mac: MacAddr(0, 0, 0, 0, 0, 0), + ip_addresses: None, + synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], + iface: None, + }; + /* 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 = 1234567; + let ack = 7654321; + 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); + } + #[test] fn test_synack_cookie_ipv4() { let masscanned = Masscanned { From 0749e23eea1689ef9f13415766f88f4284376269 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 11:21:33 +0100 Subject: [PATCH 033/317] Fix TCP FIN,ACK behaviour --- src/layer_4/tcp.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index 1edda4c..de20d53 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -78,10 +78,18 @@ pub fn repl<'a, 'b>( /* answer here when server needs to speak first after handshake */ return None; } - /* Answer to RST and FIN: nothing */ - flags if (flags == TcpFlags::RST || flags == (TcpFlags::FIN | TcpFlags::ACK)) => { + /* Answer to RST: nothing */ + flags if flags == TcpFlags::RST => { return None; } + /* Answer to FIN,ACK with FIN,ACK */ + flags if flags == (TcpFlags::FIN | TcpFlags::ACK) => { + tcp_repl = MutableTcpPacket::owned(vec![0; MutableTcpPacket::minimum_packet_size()]) + .expect("error constructing a TCP packet"); + tcp_repl.set_flags(TcpFlags::FIN | TcpFlags::ACK); + tcp_repl.set_acknowledgement(tcp_req.get_sequence() + 1); + tcp_repl.set_sequence(tcp_req.get_acknowledgement()); + } /* Answer to SYN */ flags if flags & TcpFlags::SYN == TcpFlags::SYN => { tcp_repl = MutableTcpPacket::owned(vec![0; MutableTcpPacket::minimum_packet_size()]) @@ -165,7 +173,7 @@ mod tests { 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); + assert!(tcp_repl.get_acknowledgement() == seq + 1); } #[test] From 81e6100713f269d060d1b0a24bcd632b1b420096 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 12:04:34 +0100 Subject: [PATCH 034/317] Fix terminaison of processes in python test script --- test/test_masscanned.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 54fee57..8c1c08b 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -193,16 +193,20 @@ except AssertionError: result = -1 # terminate masscanned -masscanned.kill() +masscanned.send_signal(2) +masscanned.terminate() masscanned.wait() # terminate capture if TCPDUMP: - tcpdump.kill() + tcpdump.send_signal(2) + tcpdump.terminate() tcpdump.wait() if ZEEK_PASSIVERECON: - zeek.kill() + zeek.send_signal(2) + zeek.terminate() zeek.wait() if P0F: - p0f.kill() + p0f.send_signal(2) + p0f.terminate() p0f.wait() sys.exit(result) From e85f527ca634b81a9dc69ac01ad9eaa9cf0e355c Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:02:14 +0100 Subject: [PATCH 035/317] Use SIGINT and remove unecessary terminate --- test/test_masscanned.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 8c1c08b..044a295 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -20,6 +20,7 @@ import atexit import functools import logging import os +from signal import SIGINT import subprocess import sys from time import sleep @@ -193,20 +194,16 @@ except AssertionError: result = -1 # terminate masscanned -masscanned.send_signal(2) -masscanned.terminate() +masscanned.send_signal(SIGINT) masscanned.wait() # terminate capture if TCPDUMP: - tcpdump.send_signal(2) - tcpdump.terminate() + tcpdump.send_signal(SIGINT) tcpdump.wait() if ZEEK_PASSIVERECON: - zeek.send_signal(2) - zeek.terminate() + zeek.send_signal(SIGINT) zeek.wait() if P0F: - p0f.send_signal(2) - p0f.terminate() + p0f.send_signal(SIGINT) p0f.wait() sys.exit(result) From cb5cba7a4d2a6b7514165906be447fbcf5d799c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jan 2022 22:09:19 +0000 Subject: [PATCH 036/317] Update pnet requirement from 0.26.0 to 0.28.0 Updates the requirements on [pnet](https://github.com/libpnet/libpnet) to permit the latest version. - [Release notes](https://github.com/libpnet/libpnet/releases) - [Commits](https://github.com/libpnet/libpnet/compare/v0.26.0...v0.28.0) --- updated-dependencies: - dependency-name: pnet dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cdaabb1..7b96b6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] pcap = "0.7.0" pcap-file = "1.1.1" -pnet = "0.26.0" +pnet = "0.28.0" clap = "2.33.3" log = "0.4.11" stderrlog = "0.5.0" From 294aa3ba3ee32e1cfb8196c1795ebe70be143238 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jan 2022 22:09:24 +0000 Subject: [PATCH 037/317] Update rand requirement from 0.7.3 to 0.8.4 Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.7.3...0.8.4) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cdaabb1..c5c3a6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ clap = "2.33.3" log = "0.4.11" stderrlog = "0.5.0" itertools = "0.10.3" -rand = "0.7.3" +rand = "0.8.4" dns-parser = "0.8.0" netdevice = "0.1.1" bitflags = "1.2.1" From 310bd1a9fad25572d5410731fc2e2aef7199a0fa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Jan 2022 11:29:54 +0000 Subject: [PATCH 038/317] Update pcap requirement from 0.7.0 to 0.9.1 Updates the requirements on [pcap](https://github.com/ebfull/pcap) to permit the latest version. - [Release notes](https://github.com/ebfull/pcap/releases) - [Changelog](https://github.com/ebfull/pcap/blob/master/CHANGELOG.md) - [Commits](https://github.com/ebfull/pcap/commits/v0.9.1) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 56f6c01..ae514b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -pcap = "0.7.0" +pcap = "0.9.1" pcap-file = "1.1.1" pnet = "0.28.0" clap = "2.33.3" From 7c56fd27a8b58893946f353f84e4d21f122180d1 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Sun, 2 Jan 2022 15:53:02 +0100 Subject: [PATCH 039/317] Install libpcap-dev to build rust package pcap 0.9.1 --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8cd41fa..6ac573d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,6 +37,9 @@ jobs: command: fmt args: -- --check + - name: Install packages for build + run: sudo apt-get -q update && sudo apt-get -qy install libpcap-dev + - name: Run cargo build uses: actions-rs/cargo@v1 with: From 334e9743d2f96a5ef21583c43f68acad425005eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jan 2022 00:48:44 +0000 Subject: [PATCH 040/317] Update clap requirement from 2.33.3 to 3.0.5 Updates the requirements on [clap](https://github.com/clap-rs/clap) to permit the latest version. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_generate-v3.0.0-rc.0...v3.0.5) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ae514b6..7253dce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" pcap = "0.9.1" pcap-file = "1.1.1" pnet = "0.28.0" -clap = "2.33.3" +clap = "3.0.5" log = "0.4.11" stderrlog = "0.5.0" itertools = "0.10.3" From cc399f382897125ad3e7b268a9eca83722f104be Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 3 Jan 2022 10:25:23 +0100 Subject: [PATCH 041/317] clap: switch to new API --- src/masscanned.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index 5794357..ff8f2c8 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -102,8 +102,8 @@ fn main() { .version(VERSION) .about("Network answering machine for various network protocols (L2-L3-L4 + applications)") .arg( - Arg::with_name("interface") - .short("i") + Arg::new("interface") + .short('i') .long("iface") .value_name("iface") .help("the interface to use for receiving/sending packets") @@ -111,23 +111,23 @@ fn main() { .takes_value(true), ) .arg( - Arg::with_name("mac") - .short("a") + Arg::new("mac") + .short('a') .long("mac-addr") .help("MAC address to use in the response packets") .takes_value(true), ) .arg( - Arg::with_name("ip") - .short("f") + Arg::new("ip") + .short('f') .long("ip-addr-file") .help("File with the list of IP addresses to impersonate") .takes_value(true), ) .arg( - Arg::with_name("verbosity") - .short("v") - .multiple(true) + Arg::new("verbosity") + .short('v') + .multiple_occurrences(true) .help("Increase message verbosity"), ) .get_matches(); @@ -143,9 +143,6 @@ fn main() { debug!("debug messages enabled"); trace!("trace messages enabled"); info!("Command line arguments:"); - for arg in &args.args { - info!("....{:?}", arg); - } let iface = if let Some(i) = get_interface( args.value_of("interface") .expect("error parsing iface argument"), From 25a9d431f8037564a5a822e634fceb669c94ba40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 00:31:09 +0000 Subject: [PATCH 042/317] Update pnet requirement from 0.28.0 to 0.29.0 Updates the requirements on [pnet](https://github.com/libpnet/libpnet) to permit the latest version. - [Release notes](https://github.com/libpnet/libpnet/releases) - [Commits](https://github.com/libpnet/libpnet/compare/v0.28.0...v0.29.0) --- updated-dependencies: - dependency-name: pnet dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7253dce..8352e15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] pcap = "0.9.1" pcap-file = "1.1.1" -pnet = "0.28.0" +pnet = "0.29.0" clap = "3.0.5" log = "0.4.11" stderrlog = "0.5.0" From 479ee9a03420492303aac2181fd74b8fb9ac5a1c Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 3 Feb 2022 10:21:22 +0100 Subject: [PATCH 043/317] Tests: fix (black) Python code --- test/src/all.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/src/all.py b/test/src/all.py index c2cd5a9..e11d7d4 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -902,9 +902,9 @@ def test_ipv4_udp_stun_change_port(): assert UDP in resp, "no UDP layer found" udp = resp[UDP] assert ( - udp.sport == (dport + 1) % 2 ** 16 + udp.sport == (dport + 1) % 2**16 ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2 ** 16, udp.sport + (dport + 1) % 2**16, udp.sport ) assert ( udp.dport == sport @@ -945,9 +945,9 @@ def test_ipv6_udp_stun_change_port(): assert UDP in resp, "expecting UDP layer in answer, got nothing" udp = resp[UDP] assert ( - udp.sport == (dport + 1) % 2 ** 16 + udp.sport == (dport + 1) % 2**16 ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2 ** 16, udp.sport + (dport + 1) % 2**16, udp.sport ) assert ( udp.dport == sport From f6870c98b596869ea067edc3c6cdd9b62aa4cdec Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Fri, 11 Feb 2022 18:19:04 +0100 Subject: [PATCH 044/317] Cleanup: use derive instead of impl --- src/client/client_info.rs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/client/client_info.rs b/src/client/client_info.rs index 3005a8e..ca26ac0 100644 --- a/src/client/client_info.rs +++ b/src/client/client_info.rs @@ -35,7 +35,7 @@ pub struct ClientInfoSrcDst { * - source and dest. transport port * - syn cookie **/ -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq)] pub struct ClientInfo { pub mac: ClientInfoSrcDst, pub ip: ClientInfoSrcDst, @@ -65,30 +65,6 @@ impl ClientInfo { } } -impl PartialEq for ClientInfo { - fn eq(&self, other: &Self) -> bool { - if self.mac != other.mac { - return false; - } - if self.ip != other.ip { - return false; - } - if self.transport != other.transport { - return false; - } - if self.port != other.port { - return false; - } - /* this next case should never occur with TCP and UDP, - * but this implementation tries to remain transport-protocol-agnostic - **/ - if self.cookie != other.cookie { - return false; - } - true - } -} - impl Eq for ClientInfo {} impl Display for ClientInfo { From e76ba126119b05291bee9a13838c8bd9f6051ded Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 14:08:20 +0100 Subject: [PATCH 045/317] Add Logger Trait and ConsoleLogger as an example for ARP and Ethernet --- src/layer_2/arp.rs | 16 ++--- src/layer_2/mod.rs | 2 +- src/masscanned.rs | 9 ++- src/utils/loggers.rs | 146 +++++++++++++++++++++++++++++++++++++++++++ src/utils/mod.rs | 2 + 5 files changed, 162 insertions(+), 13 deletions(-) create mode 100644 src/utils/loggers.rs diff --git a/src/layer_2/arp.rs b/src/layer_2/arp.rs index 4798c22..ae4fd52 100644 --- a/src/layer_2/arp.rs +++ b/src/layer_2/arp.rs @@ -29,20 +29,18 @@ pub fn repl<'a, 'b>( arp_req: &'a ArpPacket, masscanned: &Masscanned, ) -> Option> { + masscanned.log.arp_recv(arp_req); let mut arp_repl = MutableArpPacket::owned(arp_req.packet().to_vec()).expect("error parsing ARP packet"); /* Build ARP answer depending of the type of request */ match arp_req.get_operation() { ArpOperations::Request => { + masscanned.log.arp_recv_whohas(arp_req); let ip = IpAddr::V4(arp_req.get_target_proto_addr()); /* Ignore ARP requests for IP addresses not handled by masscanned */ if let Some(ip_addr_list) = masscanned.ip_addresses { if !ip_addr_list.contains(&ip) { - info!( - "Ignoring ARP request from {} for IP {}", - arp_req.get_sender_hw_addr(), - ip - ); + masscanned.log.arp_drop(arp_req); return None; } } @@ -53,14 +51,12 @@ pub fn repl<'a, 'b>( arp_repl.set_target_hw_addr(arp_req.get_sender_hw_addr().to_owned()); arp_repl.set_target_proto_addr(arp_req.get_sender_proto_addr().to_owned()); arp_repl.set_sender_proto_addr(arp_req.get_target_proto_addr().to_owned()); - warn!( - "ARP-Reply to {} for IP {}", - arp_req.get_sender_hw_addr(), - arp_repl.get_sender_proto_addr() - ); + masscanned.log.arp_send_isat(&arp_repl); + masscanned.log.arp_send(&arp_repl); } _ => { info!("ARP Operation not handled: {:?}", arp_repl.get_operation()); + masscanned.log.arp_drop(arp_req); return None; } }; diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 75d4af8..528c224 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -104,7 +104,7 @@ pub fn reply<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { - debug!("receiving Ethernet packet: {:?}", eth_req); + masscanned.log.eth_recv(eth_req, &client_info); let mut eth_repl; /* First, check if the destination MAC address is one of those masscanned * is authorized to answer to (avoid answering to packets addressed to diff --git a/src/masscanned.rs b/src/masscanned.rs index ff8f2c8..250dabe 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -35,7 +35,7 @@ use pnet::{ util::MacAddr, }; -use crate::utils::IpAddrParser; +use crate::utils::{IpAddrParser, ConsoleLogger, MetaLogger}; mod client; mod layer_2; @@ -55,6 +55,8 @@ pub struct Masscanned<'a> { /* iface is an Option to make tests easier */ pub iface: Option<&'a NetworkInterface>, pub ip_addresses: Option<&'a HashSet>, + /* loggers */ + pub log: MetaLogger, } /* Get the L2 network interface from its name */ @@ -184,14 +186,17 @@ fn main() { } else { None }; - let masscanned = Masscanned { + let mut masscanned = Masscanned { synack_key: [0, 0], mac, iface: Some(&iface), ip_addresses, + log: MetaLogger::new(), }; info!("interface......{}", masscanned.iface.unwrap().name); info!("mac address....{}", masscanned.mac); + masscanned.log.add(Box::new(ConsoleLogger::new())); + masscanned.log.init(); let (mut tx, mut rx) = get_channel(masscanned.iface.unwrap()); loop { /* check if network interface is still up */ diff --git a/src/utils/loggers.rs b/src/utils/loggers.rs new file mode 100644 index 0000000..e7f2ce2 --- /dev/null +++ b/src/utils/loggers.rs @@ -0,0 +1,146 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use pnet::packet::{ + arp::{ArpPacket, MutableArpPacket}, + ethernet::{EthernetPacket, MutableEthernetPacket}, +}; + +use crate::client::ClientInfo; + +pub trait Logger { + fn init(&self); + /* list of notifications that a logger might or might not implement */ + /* ARP */ + fn arp_enabled(&self) -> bool { true } + fn arp_recv(&self, _p: &ArpPacket) {} + fn arp_recv_whohas(&self, _p: &ArpPacket) {} + fn arp_drop(&self, _p: &ArpPacket) {} + fn arp_send(&self, _p: &MutableArpPacket) {} + fn arp_send_isat(&self, _p: &MutableArpPacket) {} + /* Ethernet */ + fn eth_enabled(&self) -> bool { true } + fn eth_recv(&self, _p: &EthernetPacket, _c: &ClientInfo) {} + fn eth_drop(&self, _p: &EthernetPacket, _c: &ClientInfo) {} + fn eth_send(&self, _p: &MutableEthernetPacket, _c: &ClientInfo) {} +} + +pub struct ConsoleLogger { + arp: bool, + eth: bool, +} + +impl ConsoleLogger { + pub fn new() -> Self { + ConsoleLogger { + arp: true, + eth: false, + } + } +} + +impl Logger for ConsoleLogger { + fn init(&self) { + println!("arp::init"); + } + fn arp_enabled(&self) -> bool { self.arp } + fn eth_enabled(&self) -> bool { self.arp } + fn arp_recv_whohas(&self, p: &ArpPacket) { + println!("arp::recv\twho-has\t{:}\t{:}\t{:}", p.get_sender_hw_addr(), + p.get_target_hw_addr(), p.get_target_proto_addr()); + } + fn arp_send_isat(&self, p: &MutableArpPacket) { + println!("arp::send\tis-at\t{:}\t{:}\t{:}\t{:}", p.get_sender_hw_addr(), + p.get_sender_proto_addr(), + p.get_target_hw_addr(), p.get_target_proto_addr()); + } +} + +pub struct MetaLogger { + loggers: Vec> +} + +impl MetaLogger { + pub fn new() -> Self { + MetaLogger { + loggers: Vec::new(), + } + } + pub fn add(&mut self, log: Box) { + self.loggers.push(log); + } + pub fn init(&self) { + for l in &self.loggers { + l.init(); + } + } + pub fn arp_recv(&self, p: &ArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_recv(p); + } + } + } + pub fn arp_recv_whohas(&self, p: &ArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_recv_whohas(p); + } + } + } + pub fn arp_drop(&self, p: &ArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_drop(p); + } + } + } + pub fn arp_send(&self, p: &MutableArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_send(p); + } + } + } + pub fn arp_send_isat(&self, p: &MutableArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_send_isat(p); + } + } + } + pub fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.eth_enabled() { + l.eth_recv(p, c); + } + } + } + pub fn eth_drop(&self, p: &EthernetPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.eth_enabled() { + l.eth_drop(p, c); + } + } + } + pub fn eth_send(&self, p: &MutableEthernetPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.eth_enabled() { + l.eth_send(p, c); + } + } + } +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3c788a6..35ae433 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,3 +1,5 @@ mod parsers; +mod loggers; +pub use loggers::{Logger, ConsoleLogger, MetaLogger}; pub use parsers::IpAddrParser; From 7c4e2bac558533b7d72205024b2c1bf588d5e285 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 14:53:25 +0100 Subject: [PATCH 046/317] Cargo fmt --- src/masscanned.rs | 2 +- src/utils/loggers.rs | 36 ++++++++++++++++++++++++++---------- src/utils/mod.rs | 4 ++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index 250dabe..b77d3b4 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -35,7 +35,7 @@ use pnet::{ util::MacAddr, }; -use crate::utils::{IpAddrParser, ConsoleLogger, MetaLogger}; +use crate::utils::{ConsoleLogger, IpAddrParser, MetaLogger}; mod client; mod layer_2; diff --git a/src/utils/loggers.rs b/src/utils/loggers.rs index e7f2ce2..a688395 100644 --- a/src/utils/loggers.rs +++ b/src/utils/loggers.rs @@ -25,14 +25,18 @@ pub trait Logger { fn init(&self); /* list of notifications that a logger might or might not implement */ /* ARP */ - fn arp_enabled(&self) -> bool { true } + fn arp_enabled(&self) -> bool { + true + } fn arp_recv(&self, _p: &ArpPacket) {} fn arp_recv_whohas(&self, _p: &ArpPacket) {} fn arp_drop(&self, _p: &ArpPacket) {} fn arp_send(&self, _p: &MutableArpPacket) {} fn arp_send_isat(&self, _p: &MutableArpPacket) {} /* Ethernet */ - fn eth_enabled(&self) -> bool { true } + fn eth_enabled(&self) -> bool { + true + } fn eth_recv(&self, _p: &EthernetPacket, _c: &ClientInfo) {} fn eth_drop(&self, _p: &EthernetPacket, _c: &ClientInfo) {} fn eth_send(&self, _p: &MutableEthernetPacket, _c: &ClientInfo) {} @@ -56,21 +60,33 @@ impl Logger for ConsoleLogger { fn init(&self) { println!("arp::init"); } - fn arp_enabled(&self) -> bool { self.arp } - fn eth_enabled(&self) -> bool { self.arp } + fn arp_enabled(&self) -> bool { + self.arp + } + fn eth_enabled(&self) -> bool { + self.arp + } fn arp_recv_whohas(&self, p: &ArpPacket) { - println!("arp::recv\twho-has\t{:}\t{:}\t{:}", p.get_sender_hw_addr(), - p.get_target_hw_addr(), p.get_target_proto_addr()); + println!( + "arp::recv\twho-has\t{:}\t{:}\t{:}", + p.get_sender_hw_addr(), + p.get_target_hw_addr(), + p.get_target_proto_addr() + ); } fn arp_send_isat(&self, p: &MutableArpPacket) { - println!("arp::send\tis-at\t{:}\t{:}\t{:}\t{:}", p.get_sender_hw_addr(), - p.get_sender_proto_addr(), - p.get_target_hw_addr(), p.get_target_proto_addr()); + println!( + "arp::send\tis-at\t{:}\t{:}\t{:}\t{:}", + p.get_sender_hw_addr(), + p.get_sender_proto_addr(), + p.get_target_hw_addr(), + p.get_target_proto_addr() + ); } } pub struct MetaLogger { - loggers: Vec> + loggers: Vec>, } impl MetaLogger { diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 35ae433..4fbb706 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,5 +1,5 @@ -mod parsers; mod loggers; +mod parsers; -pub use loggers::{Logger, ConsoleLogger, MetaLogger}; +pub use loggers::{ConsoleLogger, Logger, MetaLogger}; pub use parsers::IpAddrParser; From e9212ae43818a49a9c5ec91438ede37690462899 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 15:09:48 +0100 Subject: [PATCH 047/317] Fix tests and warning --- src/layer_2/arp.rs | 3 +++ src/layer_2/mod.rs | 3 +++ src/layer_3/ipv4.rs | 3 +++ src/layer_3/ipv6.rs | 3 +++ src/layer_4/icmpv4.rs | 3 +++ src/layer_4/icmpv6.rs | 4 ++++ src/layer_4/tcp.rs | 4 ++++ src/proto/mod.rs | 5 +++++ src/proto/stun.rs | 6 ++++++ src/utils/loggers.rs | 4 ++-- 10 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/layer_2/arp.rs b/src/layer_2/arp.rs index ae4fd52..6ef6e1f 100644 --- a/src/layer_2/arp.rs +++ b/src/layer_2/arp.rs @@ -72,6 +72,8 @@ mod tests { use pnet::util::MacAddr; + use crate::utils::MetaLogger; + #[test] fn test_arp_reply() { let mut ips = HashSet::new(); @@ -82,6 +84,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let mut arp_req = MutableArpPacket::owned([0; 28].to_vec()).expect("error constructing ARP request"); diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 528c224..2b3d230 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -193,6 +193,8 @@ mod tests { use std::net::{Ipv4Addr, Ipv6Addr}; use std::str::FromStr; + use crate::utils::MetaLogger; + #[test] fn test_eth_reply() { /* test payload is IP(src="3.2.1.0", dst=".".join(str(b) for b in [0xaa, 0x99, @@ -212,6 +214,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let mut eth_req = MutableEthernetPacket::owned(vec![ 0; diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index 6be97ba..f3604db 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -163,6 +163,8 @@ mod tests { use pnet::util::MacAddr; + use crate::utils::MetaLogger; + #[test] fn test_ipv4_reply() { /* test payload is scapy> ICMP() */ @@ -178,6 +180,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let mut ip_req = MutableIpv4Packet::owned(vec![0; Ipv4Packet::minimum_packet_size() + payload.len()]) diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index edc5390..e7de30a 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -166,6 +166,8 @@ mod tests { use pnet::util::MacAddr; + use crate::utils::MetaLogger; + #[test] fn test_ipv6_reply() { /* test payload is scapy> IPv6(src="7777:6666:5555:4444:3333:2222:1111:0000", @@ -187,6 +189,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let mut ip_req = MutableIpv6Packet::owned(vec![0; Ipv6Packet::minimum_packet_size() + payload.len()]) diff --git a/src/layer_4/icmpv4.rs b/src/layer_4/icmpv4.rs index 95cdf7c..e07ce07 100644 --- a/src/layer_4/icmpv4.rs +++ b/src/layer_4/icmpv4.rs @@ -70,6 +70,8 @@ mod tests { use pnet::util::MacAddr; + use crate::utils::MetaLogger; + #[test] fn test_icmpv4_reply() { /* test payload is scapy> ICMP() */ @@ -81,6 +83,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: None, + log: MetaLogger::new(), }; let mut icmp_req = MutableIcmpPacket::owned(vec![0; IcmpPacket::minimum_packet_size() + payload.len()]) diff --git a/src/layer_4/icmpv6.rs b/src/layer_4/icmpv6.rs index 6db03d2..477699f 100644 --- a/src/layer_4/icmpv6.rs +++ b/src/layer_4/icmpv6.rs @@ -160,6 +160,8 @@ mod tests { use pnet::packet::icmpv6::ndp::{MutableNeighborSolicitPacket, NeighborSolicit}; use pnet::util::MacAddr; + use crate::utils::MetaLogger; + #[test] fn test_nd_na_reply() { let client_info = ClientInfo::new(); @@ -174,6 +176,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; /* Legitimate solicitation */ let ndp_ns = NeighborSolicit { @@ -246,6 +249,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let mut icmpv6_echo_req = MutableIcmpv6Packet::owned(vec![ 0; diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index de20d53..6b64472 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -126,6 +126,8 @@ mod tests { use pnet::util::MacAddr; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; + use crate::utils::MetaLogger; + #[test] fn test_tcp_fin_ack() { let masscanned = Masscanned { @@ -183,6 +185,7 @@ mod tests { ip_addresses: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, + log: MetaLogger::new(), }; /* reference */ let ip_src = IpAddr::V4(Ipv4Addr::new(27, 198, 143, 1)); @@ -232,6 +235,7 @@ mod tests { ip_addresses: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, + log: MetaLogger::new(), }; /* reference */ let ip_src = IpAddr::V6(Ipv6Addr::new(234, 52, 183, 47, 184, 172, 64, 141)); diff --git a/src/proto/mod.rs b/src/proto/mod.rs index db058cf..0e43750 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -165,6 +165,8 @@ mod tests { use pnet::util::MacAddr; + use crate::utils::MetaLogger; + #[test] fn test_proto_dispatch_stun() { let mut client_info = ClientInfo::new(); @@ -180,6 +182,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; /***** TEST STUN - MAGIC *****/ /* test payload is: @@ -239,6 +242,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; /***** TEST SSH *****/ let payloads = [ @@ -278,6 +282,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; /***** TEST GHOST *****/ let payloads = [ diff --git a/src/proto/stun.rs b/src/proto/stun.rs index 1ddab10..5e8d3d4 100644 --- a/src/proto/stun.rs +++ b/src/proto/stun.rs @@ -413,6 +413,8 @@ mod tests { use pnet::util::MacAddr; + use crate::utils::MetaLogger; + #[test] fn test_proto_stun_ipv4() { /* test payload is: @@ -439,6 +441,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { r @@ -498,6 +501,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V6(test_ip_addr)); client_info.ip.dst = Some(IpAddr::V6(masscanned_ip_addr)); @@ -549,6 +553,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); @@ -598,6 +603,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); diff --git a/src/utils/loggers.rs b/src/utils/loggers.rs index a688395..2ae19a5 100644 --- a/src/utils/loggers.rs +++ b/src/utils/loggers.rs @@ -44,14 +44,14 @@ pub trait Logger { pub struct ConsoleLogger { arp: bool, - eth: bool, + _eth: bool, } impl ConsoleLogger { pub fn new() -> Self { ConsoleLogger { arp: true, - eth: false, + _eth: false, } } } From 290f236157c690355d4ee9aba60440cebd31030a Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 20:44:29 +0100 Subject: [PATCH 048/317] Fix test in proto --- src/proto/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 0e43750..b0ebe8f 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -315,6 +315,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; /***** TEST COMPLETE REQUEST *****/ let payload = b"GET / HTTP/1.1\r\n\r\n"; From 908ff3689d6cb5b0efbc2a778ea288febfea1b6b Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 24 Dec 2021 06:26:52 +0100 Subject: [PATCH 049/317] Fix typo in ConsoleLogger --- src/utils/loggers.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/loggers.rs b/src/utils/loggers.rs index 2ae19a5..80b1e55 100644 --- a/src/utils/loggers.rs +++ b/src/utils/loggers.rs @@ -44,14 +44,14 @@ pub trait Logger { pub struct ConsoleLogger { arp: bool, - _eth: bool, + eth: bool, } impl ConsoleLogger { pub fn new() -> Self { ConsoleLogger { arp: true, - _eth: false, + eth: false, } } } @@ -64,7 +64,7 @@ impl Logger for ConsoleLogger { self.arp } fn eth_enabled(&self) -> bool { - self.arp + self.eth } fn arp_recv_whohas(&self, p: &ArpPacket) { println!( From 27f1c4ba651536b751755916017091f8ed2ef7ec Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Sat, 12 Feb 2022 08:32:44 +0100 Subject: [PATCH 050/317] Add Console Logger for Ethernet --- src/layer_2/arp.rs | 2 +- src/layer_2/mod.rs | 13 +++++++------ src/utils/loggers.rs | 27 ++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/layer_2/arp.rs b/src/layer_2/arp.rs index 6ef6e1f..edea343 100644 --- a/src/layer_2/arp.rs +++ b/src/layer_2/arp.rs @@ -52,7 +52,6 @@ pub fn repl<'a, 'b>( arp_repl.set_target_proto_addr(arp_req.get_sender_proto_addr().to_owned()); arp_repl.set_sender_proto_addr(arp_req.get_target_proto_addr().to_owned()); masscanned.log.arp_send_isat(&arp_repl); - masscanned.log.arp_send(&arp_repl); } _ => { info!("ARP Operation not handled: {:?}", arp_repl.get_operation()); @@ -60,6 +59,7 @@ pub fn repl<'a, 'b>( return None; } }; + masscanned.log.arp_send(&arp_repl); Some(arp_repl) } diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 2b3d230..7d688cf 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -113,11 +113,7 @@ pub fn reply<'a, 'b>( if !get_authorized_eth_addr(&masscanned.mac, masscanned.ip_addresses) .contains(ð_req.get_destination()) { - info!( - "Ignoring Ethernet packet from {} to {}", - eth_req.get_source(), - eth_req.get_destination(), - ); + masscanned.log.eth_drop(eth_req, &client_info); return None; } /* Fill client information for this packet with MAC addresses (src and dst) */ @@ -136,6 +132,7 @@ pub fn reply<'a, 'b>( eth_repl.set_ethertype(EtherTypes::Arp); eth_repl.set_payload(arp_repl.packet()); } else { + masscanned.log.eth_drop(eth_req, &client_info); return None; } } @@ -145,6 +142,7 @@ pub fn reply<'a, 'b>( p } else { warn!("error parsing IPv4 packet"); + masscanned.log.eth_drop(eth_req, &client_info); return None; }; if let Some(mut ipv4_repl) = @@ -158,6 +156,7 @@ pub fn reply<'a, 'b>( eth_repl.set_ethertype(EtherTypes::Ipv4); eth_repl.set_payload(ipv4_repl.packet()); } else { + masscanned.log.eth_drop(eth_req, &client_info); return None; } } @@ -172,18 +171,20 @@ pub fn reply<'a, 'b>( eth_repl.set_ethertype(EtherTypes::Ipv6); eth_repl.set_payload(ipv6_repl.packet()); } else { + masscanned.log.eth_drop(eth_req, &client_info); return None; } } /* Log & drop unknown network protocol */ _ => { info!("Ethernet type not handled: {:?}", eth_req.get_ethertype()); + masscanned.log.eth_drop(eth_req, &client_info); return None; } }; eth_repl.set_source(masscanned.mac); eth_repl.set_destination(eth_req.get_source()); - debug!("sending Ethernet packet: {:?}", eth_repl); + masscanned.log.eth_send(ð_repl, &client_info); Some(eth_repl) } diff --git a/src/utils/loggers.rs b/src/utils/loggers.rs index 80b1e55..a194368 100644 --- a/src/utils/loggers.rs +++ b/src/utils/loggers.rs @@ -51,7 +51,7 @@ impl ConsoleLogger { pub fn new() -> Self { ConsoleLogger { arp: true, - eth: false, + eth: true, } } } @@ -59,6 +59,7 @@ impl ConsoleLogger { impl Logger for ConsoleLogger { fn init(&self) { println!("arp::init"); + println!("eth::init"); } fn arp_enabled(&self) -> bool { self.arp @@ -83,6 +84,30 @@ impl Logger for ConsoleLogger { p.get_target_proto_addr() ); } + fn eth_recv(&self, p: &EthernetPacket, _c: &ClientInfo) { + println!( + "eth::recv\t{:}\t{:}\t{:}", + p.get_ethertype(), + p.get_source(), + p.get_destination(), + ); + } + fn eth_drop(&self, p: &EthernetPacket, _c: &ClientInfo) { + println!( + "eth::drop\t{:}\t{:}\t{:}", + p.get_ethertype(), + p.get_source(), + p.get_destination(), + ); + } + fn eth_send(&self, p: &MutableEthernetPacket, _c: &ClientInfo) { + println!( + "eth::send\t{:}\t{:}\t{:}", + p.get_ethertype(), + p.get_destination(), + p.get_source(), + ); + } } pub struct MetaLogger { From 26f74ad6a5d1c335632290e33a102be82391b7ea Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Sat, 12 Feb 2022 09:05:50 +0100 Subject: [PATCH 051/317] Change log format (add timestamp) --- README.md | 25 +++++++++++--- src/layer_2/arp.rs | 4 +-- src/utils/loggers.rs | 79 ++++++++++++++++++++++++++------------------ 3 files changed, 69 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 075e7a0..41574c3 100644 --- a/README.md +++ b/README.md @@ -290,12 +290,27 @@ tcpdump: pcap_loop: The interface disappeared 0 packets dropped by kernel ``` -### Logging Policy +## Logging -* `ERR`: any error - will always be displayed. -* `WARN`, `-v`: responses sent by `masscanned`. -* `INFO`, `-vv`: packets not handled, packets ignored. -* `DEBUG`, `-vvv`: all packets received and sent by `masscanned`. +### Console Logger + +**Verbs**: +* `init` +* `recv` +* `send` +* `drop` + +#### ARP + +``` +$ts arp $verb $operation $client_mac $client_ip $masscanned_mac $masscanned_ip +``` + +#### Ethernet + +``` +$ts eth $verb $ethertype $client_mac $masscanned_mac +``` ## To Do diff --git a/src/layer_2/arp.rs b/src/layer_2/arp.rs index edea343..2df1b10 100644 --- a/src/layer_2/arp.rs +++ b/src/layer_2/arp.rs @@ -35,7 +35,7 @@ pub fn repl<'a, 'b>( /* Build ARP answer depending of the type of request */ match arp_req.get_operation() { ArpOperations::Request => { - masscanned.log.arp_recv_whohas(arp_req); + masscanned.log.arp_recv(arp_req); let ip = IpAddr::V4(arp_req.get_target_proto_addr()); /* Ignore ARP requests for IP addresses not handled by masscanned */ if let Some(ip_addr_list) = masscanned.ip_addresses { @@ -51,7 +51,7 @@ pub fn repl<'a, 'b>( arp_repl.set_target_hw_addr(arp_req.get_sender_hw_addr().to_owned()); arp_repl.set_target_proto_addr(arp_req.get_sender_proto_addr().to_owned()); arp_repl.set_sender_proto_addr(arp_req.get_target_proto_addr().to_owned()); - masscanned.log.arp_send_isat(&arp_repl); + masscanned.log.arp_send(&arp_repl); } _ => { info!("ARP Operation not handled: {:?}", arp_repl.get_operation()); diff --git a/src/utils/loggers.rs b/src/utils/loggers.rs index a194368..e1a03f4 100644 --- a/src/utils/loggers.rs +++ b/src/utils/loggers.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Masscanned. If not, see . +use std::time::SystemTime; + use pnet::packet::{ arp::{ArpPacket, MutableArpPacket}, ethernet::{EthernetPacket, MutableEthernetPacket}, @@ -29,10 +31,8 @@ pub trait Logger { true } fn arp_recv(&self, _p: &ArpPacket) {} - fn arp_recv_whohas(&self, _p: &ArpPacket) {} fn arp_drop(&self, _p: &ArpPacket) {} fn arp_send(&self, _p: &MutableArpPacket) {} - fn arp_send_isat(&self, _p: &MutableArpPacket) {} /* Ethernet */ fn eth_enabled(&self) -> bool { true @@ -54,12 +54,22 @@ impl ConsoleLogger { eth: true, } } + fn prolog(&self, proto: &str, verb: &str, crlf: bool) { + let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); + print!("{}.{}\t{}\t{}{}", + now.as_secs(), + now.subsec_millis(), + proto, + verb, + if crlf { "\n" } else { "\t" }, + ); + } } impl Logger for ConsoleLogger { fn init(&self) { - println!("arp::init"); - println!("eth::init"); + self.prolog("arp", "init", true); + self.prolog("eth", "init", true); } fn arp_enabled(&self) -> bool { self.arp @@ -67,42 +77,61 @@ impl Logger for ConsoleLogger { fn eth_enabled(&self) -> bool { self.eth } - fn arp_recv_whohas(&self, p: &ArpPacket) { + fn arp_recv(&self, p: &ArpPacket) { + self.prolog("arp", "recv", false); println!( - "arp::recv\twho-has\t{:}\t{:}\t{:}", - p.get_sender_hw_addr(), - p.get_target_hw_addr(), - p.get_target_proto_addr() - ); - } - fn arp_send_isat(&self, p: &MutableArpPacket) { - println!( - "arp::send\tis-at\t{:}\t{:}\t{:}\t{:}", + "{:?}\t{:}\t{:}\t{:}\t{:}", + p.get_operation(), p.get_sender_hw_addr(), p.get_sender_proto_addr(), p.get_target_hw_addr(), - p.get_target_proto_addr() + p.get_target_proto_addr(), + ); + } + fn arp_send(&self, p: &MutableArpPacket) { + self.prolog("arp", "send", false); + println!( + "{:?}\t{:}\t{:}\t{:}\t{:}", + p.get_operation(), + p.get_target_hw_addr(), + p.get_target_proto_addr(), + p.get_sender_hw_addr(), + p.get_sender_proto_addr(), + ); + } + fn arp_drop(&self, p: &ArpPacket) { + self.prolog("arp", "drop", false); + println!( + "{:?}\t{:}\t{:}\t{:}\t{:}", + p.get_operation(), + p.get_target_hw_addr(), + p.get_target_proto_addr(), + p.get_sender_hw_addr(), + p.get_sender_proto_addr(), ); } fn eth_recv(&self, p: &EthernetPacket, _c: &ClientInfo) { + self.prolog("eth", "recv", false); println!( - "eth::recv\t{:}\t{:}\t{:}", + "{:}\t{:}\t{:}", p.get_ethertype(), p.get_source(), p.get_destination(), ); } fn eth_drop(&self, p: &EthernetPacket, _c: &ClientInfo) { + self.prolog("eth", "drop", false); println!( - "eth::drop\t{:}\t{:}\t{:}", + "{:}\t{:}\t{:}", p.get_ethertype(), p.get_source(), p.get_destination(), ); } fn eth_send(&self, p: &MutableEthernetPacket, _c: &ClientInfo) { + self.prolog("eth", "send", false); println!( - "eth::send\t{:}\t{:}\t{:}", + "{:}\t{:}\t{:}", p.get_ethertype(), p.get_destination(), p.get_source(), @@ -135,13 +164,6 @@ impl MetaLogger { } } } - pub fn arp_recv_whohas(&self, p: &ArpPacket) { - for l in &self.loggers { - if l.arp_enabled() { - l.arp_recv_whohas(p); - } - } - } pub fn arp_drop(&self, p: &ArpPacket) { for l in &self.loggers { if l.arp_enabled() { @@ -156,13 +178,6 @@ impl MetaLogger { } } } - pub fn arp_send_isat(&self, p: &MutableArpPacket) { - for l in &self.loggers { - if l.arp_enabled() { - l.arp_send_isat(p); - } - } - } pub fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { for l in &self.loggers { if l.eth_enabled() { From 7e5cb39dd3d00df8efe2aadf48d822eb864bbb89 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:14:47 +0100 Subject: [PATCH 052/317] Create crate for logging + add L3-L4 logging functions in Console Logger --- src/logger/console.rs | 307 ++++++++++++++++++++++++++++++++++++++++++ src/logger/meta.rs | 225 +++++++++++++++++++++++++++++++ src/logger/mod.rs | 95 +++++++++++++ src/masscanned.rs | 4 +- src/utils/loggers.rs | 202 --------------------------- src/utils/mod.rs | 2 - 6 files changed, 630 insertions(+), 205 deletions(-) create mode 100644 src/logger/console.rs create mode 100644 src/logger/meta.rs create mode 100644 src/logger/mod.rs delete mode 100644 src/utils/loggers.rs diff --git a/src/logger/console.rs b/src/logger/console.rs new file mode 100644 index 0000000..672b048 --- /dev/null +++ b/src/logger/console.rs @@ -0,0 +1,307 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use std::time::SystemTime; + +use pnet::packet::{ + arp::{ArpPacket, MutableArpPacket}, + ethernet::{EthernetPacket, MutableEthernetPacket}, + ipv4::{Ipv4Packet, MutableIpv4Packet}, + ipv6::{Ipv6Packet, MutableIpv6Packet}, + icmp::{IcmpPacket, MutableIcmpPacket}, + icmpv6::{Icmpv6Packet, MutableIcmpv6Packet}, + tcp::{TcpPacket, MutableTcpPacket}, + udp::{UdpPacket, MutableUdpPacket}, +}; + +use crate::client::ClientInfo; +use crate::logger::Logger; + +pub struct ConsoleLogger { + arp: bool, + eth: bool, + ipv4: bool, + ipv6: bool, + icmpv4: bool, + icmpv6: bool, + tcp: bool, + udp: bool, +} + +impl ConsoleLogger { + pub fn new() -> Self { + ConsoleLogger { + arp: true, + eth: true, + ipv4: true, + ipv6: true, + icmpv4: true, + icmpv6: true, + tcp: true, + udp: true, + } + } + fn prolog(&self, proto: &str, verb: &str, crlf: bool) { + let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); + print!("{}.{}\t{}\t{}{}", + now.as_secs(), + now.subsec_millis(), + proto, + verb, + if crlf { "\n" } else { "\t" }, + ); + } + fn client_info(&self, c: &ClientInfo) { + print!("{}\t{}\t{}\t{}\t{}\t{}\t{}\t", + if let Some(m) = c.mac.src { format!("{}", m) } else { "".to_string() }, + if let Some(m) = c.mac.dst { format!("{}", m) } else { "".to_string() }, + if let Some(i) = c.ip.src { format!("{}", i) } else { "".to_string() }, + if let Some(i) = c.ip.dst { format!("{}", i) } else { "".to_string() }, + if let Some(t) = c.transport { format!("{}", t) } else { "".to_string() }, + if let Some(p) = c.port.src { format!("{}", p) } else { "".to_string() }, + if let Some(p) = c.port.dst { format!("{}", p) } else { "".to_string() }, + ); + } +} + +impl Logger for ConsoleLogger { + fn init(&self) { + self.prolog("arp", "init", true); + self.prolog("eth", "init", true); + self.prolog("ipv4", "init", true); + } + /* ARP */ + fn arp_enabled(&self) -> bool { + self.arp + } + fn arp_recv(&self, p: &ArpPacket) { + self.prolog("arp", "recv", false); + println!( + "{:}\t{:}\t{:}\t{:}\t{:?}", + p.get_sender_hw_addr(), + p.get_target_hw_addr(), + p.get_sender_proto_addr(), + p.get_target_proto_addr(), + p.get_operation(), + ); + } + fn arp_drop(&self, p: &ArpPacket) { + self.prolog("arp", "drop", false); + println!( + "{:}\t{:}\t{:}\t{:}\t{:?}", + p.get_sender_hw_addr(), + p.get_target_hw_addr(), + p.get_sender_proto_addr(), + p.get_target_proto_addr(), + p.get_operation(), + ); + } + fn arp_send(&self, p: &MutableArpPacket) { + self.prolog("arp", "send", false); + println!( + "{:}\t{:}\t{:}\t{:}\t{:?}", + p.get_target_hw_addr(), + p.get_sender_hw_addr(), + p.get_target_proto_addr(), + p.get_sender_proto_addr(), + p.get_operation(), + ); + } + /* Ethernet */ + fn eth_enabled(&self) -> bool { + self.eth + } + fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { + self.prolog("eth", "recv", false); + self.client_info(c); + println!( + "{:}", + p.get_ethertype(), + ); + } + fn eth_drop(&self, p: &EthernetPacket, c: &ClientInfo) { + self.prolog("eth", "drop", false); + self.client_info(c); + println!( + "{:}", + p.get_ethertype(), + ); + } + fn eth_send(&self, p: &MutableEthernetPacket, c: &ClientInfo) { + self.prolog("eth", "send", false); + self.client_info(c); + println!( + "{:}", + p.get_ethertype(), + ); + } + /* IPv4 */ + fn ipv4_enabled(&self) -> bool { + self.ipv4 + } + fn ipv4_recv(&self, p: &Ipv4Packet, c: &ClientInfo) { + self.prolog("ipv4", "recv", false); + self.client_info(c); + println!( + "{:}", + p.get_next_level_protocol(), + ); + } + fn ipv4_drop(&self, p: &Ipv4Packet, c: &ClientInfo) { + self.prolog("ipv4", "drop", false); + self.client_info(c); + println!( + "{:}", + p.get_next_level_protocol(), + ); + } + fn ipv4_send(&self, p: &MutableIpv4Packet, c: &ClientInfo) { + self.prolog("ipv4", "send", false); + self.client_info(c); + println!( + "{:}", + p.get_next_level_protocol(), + ); + } + /* IPv6 */ + fn ipv6_enabled(&self) -> bool { + self.ipv6 + } + fn ipv6_recv(&self, p: &Ipv6Packet, c: &ClientInfo) { + self.prolog("ipv6", "recv", false); + self.client_info(c); + println!( + "{:}", + p.get_next_header(), + ); + } + fn ipv6_drop(&self, p: &Ipv6Packet, c: &ClientInfo) { + self.prolog("ipv6", "drop", false); + self.client_info(c); + println!( + "{:}", + p.get_next_header(), + ); + } + fn ipv6_send(&self, p: &MutableIpv6Packet, c: &ClientInfo) { + self.prolog("ipv6", "send", false); + self.client_info(c); + println!( + "{:}", + p.get_next_header(), + ); + } + /* ICMPv4 */ + fn icmpv4_enabled(&self) -> bool { + self.icmpv4 + } + fn icmpv4_recv(&self, p: &IcmpPacket, c: &ClientInfo) { + self.prolog("icmpv4", "recv", false); + self.client_info(c); + println!( + "{:?}\t{:?}", + p.get_icmp_type(), + p.get_icmp_code(), + ); + } + fn icmpv4_drop(&self, p: &IcmpPacket, c: &ClientInfo) { + self.prolog("icmpv4", "drop", false); + self.client_info(c); + println!( + "{:?}\t{:?}", + p.get_icmp_type(), + p.get_icmp_code(), + ); + } + fn icmpv4_send(&self, p: &MutableIcmpPacket, c: &ClientInfo) { + self.prolog("icmpv4", "send", false); + self.client_info(c); + println!( + "{:?}\t{:?}", + p.get_icmp_type(), + p.get_icmp_code(), + ); + } + /* ICMPv6 */ + fn icmpv6_enabled(&self) -> bool { + self.icmpv6 + } + fn icmpv6_recv(&self, p: &Icmpv6Packet, c: &ClientInfo) { + self.prolog("icmpv6", "recv", false); + self.client_info(c); + println!( + "{:?}\t{:?}", + p.get_icmpv6_type(), + p.get_icmpv6_code(), + ); + } + fn icmpv6_drop(&self, p: &Icmpv6Packet, c: &ClientInfo) { + self.prolog("icmpv6", "drop", false); + self.client_info(c); + println!( + "{:?}\t{:?}", + p.get_icmpv6_type(), + p.get_icmpv6_code(), + ); + } + fn icmpv6_send(&self, p: &MutableIcmpv6Packet, c: &ClientInfo) { + self.prolog("icmpv6", "send", false); + self.client_info(c); + println!( + "{:?}\t{:?}", + p.get_icmpv6_type(), + p.get_icmpv6_code(), + ); + } + /* TCP */ + fn tcp_enabled(&self) -> bool { + self.tcp + } + fn tcp_recv(&self, p: &TcpPacket, c: &ClientInfo) { + self.prolog("tcp", "recv", false); + self.client_info(c); + println!(""); + } + fn tcp_drop(&self, p: &TcpPacket, c: &ClientInfo) { + self.prolog("tcp", "drop", false); + self.client_info(c); + println!(""); + } + fn tcp_send(&self, p: &MutableTcpPacket, c: &ClientInfo) { + self.prolog("tcp", "send", false); + self.client_info(c); + println!(""); + } + /* UDP */ + fn udp_enabled(&self) -> bool { + self.udp + } + fn udp_recv(&self, p: &UdpPacket, c: &ClientInfo) { + self.prolog("udp", "recv", false); + self.client_info(c); + println!(""); + } + fn udp_drop(&self, p: &UdpPacket, c: &ClientInfo) { + self.prolog("udp", "drop", false); + self.client_info(c); + println!(""); + } + fn udp_send(&self, p: &MutableUdpPacket, c: &ClientInfo) { + self.prolog("udp", "send", false); + self.client_info(c); + println!(""); + } +} diff --git a/src/logger/meta.rs b/src/logger/meta.rs new file mode 100644 index 0000000..61b4ccb --- /dev/null +++ b/src/logger/meta.rs @@ -0,0 +1,225 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use pnet::packet::{ + arp::{ArpPacket, MutableArpPacket}, + ethernet::{EthernetPacket, MutableEthernetPacket}, + ipv4::{Ipv4Packet, MutableIpv4Packet}, + ipv6::{Ipv6Packet, MutableIpv6Packet}, + icmp::{IcmpPacket, MutableIcmpPacket}, + icmpv6::{Icmpv6Packet, MutableIcmpv6Packet}, + tcp::{TcpPacket, MutableTcpPacket}, + udp::{UdpPacket, MutableUdpPacket}, +}; + +use crate::client::ClientInfo; +use crate::logger::Logger; + +pub struct MetaLogger { + loggers: Vec>, +} + +impl MetaLogger { + pub fn new() -> Self { + MetaLogger { + loggers: Vec::new(), + } + } + pub fn add(&mut self, log: Box) { + self.loggers.push(log); + } + pub fn init(&self) { + for l in &self.loggers { + l.init(); + } + } + /* ARP */ + pub fn arp_recv(&self, p: &ArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_recv(p); + } + } + } + pub fn arp_drop(&self, p: &ArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_drop(p); + } + } + } + pub fn arp_send(&self, p: &MutableArpPacket) { + for l in &self.loggers { + if l.arp_enabled() { + l.arp_send(p); + } + } + } + /* Ethernet */ + pub fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.eth_enabled() { + l.eth_recv(p, c); + } + } + } + pub fn eth_drop(&self, p: &EthernetPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.eth_enabled() { + l.eth_drop(p, c); + } + } + } + pub fn eth_send(&self, p: &MutableEthernetPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.eth_enabled() { + l.eth_send(p, c); + } + } + } + /* IPv4 */ + pub fn ipv4_recv(&self, p: &Ipv4Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.ipv4_enabled() { + l.ipv4_recv(p, c); + } + } + } + pub fn ipv4_drop(&self, p: &Ipv4Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.ipv4_enabled() { + l.ipv4_drop(p, c); + } + } + } + pub fn ipv4_send(&self, p: &MutableIpv4Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.ipv4_enabled() { + l.ipv4_send(p, c); + } + } + } + /* IPv6 */ + pub fn ipv6_recv(&self, p: &Ipv6Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.ipv6_enabled() { + l.ipv6_recv(p, c); + } + } + } + pub fn ipv6_drop(&self, p: &Ipv6Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.ipv6_enabled() { + l.ipv6_drop(p, c); + } + } + } + pub fn ipv6_send(&self, p: &MutableIpv6Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.ipv6_enabled() { + l.ipv6_send(p, c); + } + } + } + /* ICMPv4 */ + pub fn icmpv4_recv(&self, p: &IcmpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.icmpv4_enabled() { + l.icmpv4_recv(p, c); + } + } + } + pub fn icmpv4_drop(&self, p: &IcmpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.icmpv4_enabled() { + l.icmpv4_drop(p, c); + } + } + } + pub fn icmpv4_send(&self, p: &MutableIcmpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.icmpv4_enabled() { + l.icmpv4_send(p, c); + } + } + } + /* ICMPv6 */ + pub fn icmpv6_recv(&self, p: &Icmpv6Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.icmpv6_enabled() { + l.icmpv6_recv(p, c); + } + } + } + pub fn icmpv6_drop(&self, p: &Icmpv6Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.icmpv6_enabled() { + l.icmpv6_drop(p, c); + } + } + } + pub fn icmpv6_send(&self, p: &MutableIcmpv6Packet, c: &ClientInfo) { + for l in &self.loggers { + if l.icmpv6_enabled() { + l.icmpv6_send(p, c); + } + } + } + /* TCP */ + pub fn tcp_recv(&self, p: &TcpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.tcp_enabled() { + l.tcp_recv(p, c); + } + } + } + pub fn tcp_drop(&self, p: &TcpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.tcp_enabled() { + l.tcp_drop(p, c); + } + } + } + pub fn tcp_send(&self, p: &MutableTcpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.tcp_enabled() { + l.tcp_send(p, c); + } + } + } + /* UDP */ + pub fn udp_recv(&self, p: &UdpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.udp_enabled() { + l.udp_recv(p, c); + } + } + } + pub fn udp_drop(&self, p: &UdpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.udp_enabled() { + l.udp_drop(p, c); + } + } + } + pub fn udp_send(&self, p: &MutableUdpPacket, c: &ClientInfo) { + for l in &self.loggers { + if l.udp_enabled() { + l.udp_send(p, c); + } + } + } +} diff --git a/src/logger/mod.rs b/src/logger/mod.rs new file mode 100644 index 0000000..d3f0d9c --- /dev/null +++ b/src/logger/mod.rs @@ -0,0 +1,95 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use pnet::packet::{ + arp::{ArpPacket, MutableArpPacket}, + ethernet::{EthernetPacket, MutableEthernetPacket}, + ipv4::{Ipv4Packet, MutableIpv4Packet}, + ipv6::{Ipv6Packet, MutableIpv6Packet}, + icmp::{IcmpPacket, MutableIcmpPacket}, + icmpv6::{Icmpv6Packet, MutableIcmpv6Packet}, + tcp::{TcpPacket, MutableTcpPacket}, + udp::{UdpPacket, MutableUdpPacket}, +}; + +use crate::client::ClientInfo; + +mod meta; +mod console; + +pub use meta::MetaLogger; +pub use console::ConsoleLogger; + +pub trait Logger { + fn init(&self); + /* list of notifications that a logger might or might not implement */ + /* ARP */ + fn arp_enabled(&self) -> bool { + true + } + fn arp_recv(&self, _p: &ArpPacket) {} + fn arp_drop(&self, _p: &ArpPacket) {} + fn arp_send(&self, _p: &MutableArpPacket) {} + /* Ethernet */ + fn eth_enabled(&self) -> bool { + true + } + fn eth_recv(&self, _p: &EthernetPacket, _c: &ClientInfo) {} + fn eth_drop(&self, _p: &EthernetPacket, _c: &ClientInfo) {} + fn eth_send(&self, _p: &MutableEthernetPacket, _c: &ClientInfo) {} + /* IPv4 */ + fn ipv4_enabled(&self) -> bool { + true + } + fn ipv4_recv(&self, _p: &Ipv4Packet, _c: &ClientInfo) {} + fn ipv4_drop(&self, _p: &Ipv4Packet, _c: &ClientInfo) {} + fn ipv4_send(&self, _p: &MutableIpv4Packet, _c: &ClientInfo) {} + /* IPv6 */ + fn ipv6_enabled(&self) -> bool { + true + } + fn ipv6_recv(&self, _p: &Ipv6Packet, _c: &ClientInfo) {} + fn ipv6_drop(&self, _p: &Ipv6Packet, _c: &ClientInfo) {} + fn ipv6_send(&self, _p: &MutableIpv6Packet, _c: &ClientInfo) {} + /* ICMPv4 */ + fn icmpv4_enabled(&self) -> bool { + true + } + fn icmpv4_recv(&self, _p: &IcmpPacket, _c: &ClientInfo) {} + fn icmpv4_drop(&self, _p: &IcmpPacket, _c: &ClientInfo) {} + fn icmpv4_send(&self, _p: &MutableIcmpPacket, _c: &ClientInfo) {} + /* ICMPv6 */ + fn icmpv6_enabled(&self) -> bool { + true + } + fn icmpv6_recv(&self, _p: &Icmpv6Packet, _c: &ClientInfo) {} + fn icmpv6_drop(&self, _p: &Icmpv6Packet, _c: &ClientInfo) {} + fn icmpv6_send(&self, _p: &MutableIcmpv6Packet, _c: &ClientInfo) {} + /* TCP */ + fn tcp_enabled(&self) -> bool { + true + } + fn tcp_recv(&self, _p: &TcpPacket, _c: &ClientInfo) {} + fn tcp_drop(&self, _p: &TcpPacket, _c: &ClientInfo) {} + fn tcp_send(&self, _p: &MutableTcpPacket, _c: &ClientInfo) {} + /* UDP */ + fn udp_enabled(&self) -> bool { + true + } + fn udp_recv(&self, _p: &UdpPacket, _c: &ClientInfo) {} + fn udp_drop(&self, _p: &UdpPacket, _c: &ClientInfo) {} + fn udp_send(&self, _p: &MutableUdpPacket, _c: &ClientInfo) {} +} diff --git a/src/masscanned.rs b/src/masscanned.rs index b77d3b4..301cb4a 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -35,12 +35,14 @@ use pnet::{ util::MacAddr, }; -use crate::utils::{ConsoleLogger, IpAddrParser, MetaLogger}; +use crate::utils::IpAddrParser; +use crate::logger::{ConsoleLogger, MetaLogger}; mod client; mod layer_2; mod layer_3; mod layer_4; +mod logger; mod proto; mod smack; mod synackcookie; diff --git a/src/utils/loggers.rs b/src/utils/loggers.rs deleted file mode 100644 index e1a03f4..0000000 --- a/src/utils/loggers.rs +++ /dev/null @@ -1,202 +0,0 @@ -// This file is part of masscanned. -// Copyright 2021 - The IVRE project -// -// Masscanned is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Masscanned is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -// License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Masscanned. If not, see . - -use std::time::SystemTime; - -use pnet::packet::{ - arp::{ArpPacket, MutableArpPacket}, - ethernet::{EthernetPacket, MutableEthernetPacket}, -}; - -use crate::client::ClientInfo; - -pub trait Logger { - fn init(&self); - /* list of notifications that a logger might or might not implement */ - /* ARP */ - fn arp_enabled(&self) -> bool { - true - } - fn arp_recv(&self, _p: &ArpPacket) {} - fn arp_drop(&self, _p: &ArpPacket) {} - fn arp_send(&self, _p: &MutableArpPacket) {} - /* Ethernet */ - fn eth_enabled(&self) -> bool { - true - } - fn eth_recv(&self, _p: &EthernetPacket, _c: &ClientInfo) {} - fn eth_drop(&self, _p: &EthernetPacket, _c: &ClientInfo) {} - fn eth_send(&self, _p: &MutableEthernetPacket, _c: &ClientInfo) {} -} - -pub struct ConsoleLogger { - arp: bool, - eth: bool, -} - -impl ConsoleLogger { - pub fn new() -> Self { - ConsoleLogger { - arp: true, - eth: true, - } - } - fn prolog(&self, proto: &str, verb: &str, crlf: bool) { - let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); - print!("{}.{}\t{}\t{}{}", - now.as_secs(), - now.subsec_millis(), - proto, - verb, - if crlf { "\n" } else { "\t" }, - ); - } -} - -impl Logger for ConsoleLogger { - fn init(&self) { - self.prolog("arp", "init", true); - self.prolog("eth", "init", true); - } - fn arp_enabled(&self) -> bool { - self.arp - } - fn eth_enabled(&self) -> bool { - self.eth - } - fn arp_recv(&self, p: &ArpPacket) { - self.prolog("arp", "recv", false); - println!( - "{:?}\t{:}\t{:}\t{:}\t{:}", - p.get_operation(), - p.get_sender_hw_addr(), - p.get_sender_proto_addr(), - p.get_target_hw_addr(), - p.get_target_proto_addr(), - ); - } - fn arp_send(&self, p: &MutableArpPacket) { - self.prolog("arp", "send", false); - println!( - "{:?}\t{:}\t{:}\t{:}\t{:}", - p.get_operation(), - p.get_target_hw_addr(), - p.get_target_proto_addr(), - p.get_sender_hw_addr(), - p.get_sender_proto_addr(), - ); - } - fn arp_drop(&self, p: &ArpPacket) { - self.prolog("arp", "drop", false); - println!( - "{:?}\t{:}\t{:}\t{:}\t{:}", - p.get_operation(), - p.get_target_hw_addr(), - p.get_target_proto_addr(), - p.get_sender_hw_addr(), - p.get_sender_proto_addr(), - ); - } - fn eth_recv(&self, p: &EthernetPacket, _c: &ClientInfo) { - self.prolog("eth", "recv", false); - println!( - "{:}\t{:}\t{:}", - p.get_ethertype(), - p.get_source(), - p.get_destination(), - ); - } - fn eth_drop(&self, p: &EthernetPacket, _c: &ClientInfo) { - self.prolog("eth", "drop", false); - println!( - "{:}\t{:}\t{:}", - p.get_ethertype(), - p.get_source(), - p.get_destination(), - ); - } - fn eth_send(&self, p: &MutableEthernetPacket, _c: &ClientInfo) { - self.prolog("eth", "send", false); - println!( - "{:}\t{:}\t{:}", - p.get_ethertype(), - p.get_destination(), - p.get_source(), - ); - } -} - -pub struct MetaLogger { - loggers: Vec>, -} - -impl MetaLogger { - pub fn new() -> Self { - MetaLogger { - loggers: Vec::new(), - } - } - pub fn add(&mut self, log: Box) { - self.loggers.push(log); - } - pub fn init(&self) { - for l in &self.loggers { - l.init(); - } - } - pub fn arp_recv(&self, p: &ArpPacket) { - for l in &self.loggers { - if l.arp_enabled() { - l.arp_recv(p); - } - } - } - pub fn arp_drop(&self, p: &ArpPacket) { - for l in &self.loggers { - if l.arp_enabled() { - l.arp_drop(p); - } - } - } - pub fn arp_send(&self, p: &MutableArpPacket) { - for l in &self.loggers { - if l.arp_enabled() { - l.arp_send(p); - } - } - } - pub fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { - for l in &self.loggers { - if l.eth_enabled() { - l.eth_recv(p, c); - } - } - } - pub fn eth_drop(&self, p: &EthernetPacket, c: &ClientInfo) { - for l in &self.loggers { - if l.eth_enabled() { - l.eth_drop(p, c); - } - } - } - pub fn eth_send(&self, p: &MutableEthernetPacket, c: &ClientInfo) { - for l in &self.loggers { - if l.eth_enabled() { - l.eth_send(p, c); - } - } - } -} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 4fbb706..3c788a6 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,5 +1,3 @@ -mod loggers; mod parsers; -pub use loggers::{ConsoleLogger, Logger, MetaLogger}; pub use parsers::IpAddrParser; From 7b431950eb4f17df2c342b15821d33c0f2ff0b05 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:16:37 +0100 Subject: [PATCH 053/317] Add logging function calls for L3 dissectors --- src/layer_2/mod.rs | 6 +++--- src/layer_3/ipv4.rs | 24 ++++++++++-------------- src/layer_3/ipv6.rs | 17 ++++++++++------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 7d688cf..3f42e51 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -104,6 +104,9 @@ pub fn reply<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { + /* Fill client information for this packet with MAC addresses (src and dst) */ + client_info.mac.src = Some(eth_req.get_source()); + client_info.mac.dst = Some(eth_req.get_destination()); masscanned.log.eth_recv(eth_req, &client_info); let mut eth_repl; /* First, check if the destination MAC address is one of those masscanned @@ -116,9 +119,6 @@ pub fn reply<'a, 'b>( masscanned.log.eth_drop(eth_req, &client_info); return None; } - /* Fill client information for this packet with MAC addresses (src and dst) */ - client_info.mac.src = Some(eth_req.get_source()); - client_info.mac.dst = Some(eth_req.get_destination()); /* Build next layer payload for answer depending on the incoming packet */ match eth_req.get_ethertype() { /* Construct answer to ARP request */ diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index f3604db..fd4e133 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -39,24 +39,20 @@ pub fn repl<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { - debug!("receiving IPv4 packet: {:?}", ip_req); + /* Fill client info with source and dest. IP addresses */ + client_info.ip.src = Some(IpAddr::V4(ip_req.get_source())); + client_info.ip.dst = Some(IpAddr::V4(ip_req.get_destination())); + masscanned.log.ipv4_recv(&ip_req, &client_info); /* If masscanned is configured with IP addresses, then * check that the dest. IP address of the packet is one of * those handled by masscanned - otherwise, drop the packet. **/ if let Some(ip_addr_list) = masscanned.ip_addresses { if !ip_addr_list.contains(&IpAddr::V4(ip_req.get_destination())) { - info!( - "Ignoring IP packet from {} for {}", - ip_req.get_source(), - ip_req.get_destination() - ); + masscanned.log.ipv4_drop(&ip_req, &client_info); return None; } } - /* Fill client info with source and dest. IP addresses */ - client_info.ip.src = Some(IpAddr::V4(ip_req.get_source())); - client_info.ip.dst = Some(IpAddr::V4(ip_req.get_destination())); /* Fill client info with transport layer procotol */ client_info.transport = Some(ip_req.get_next_level_protocol()); let mut ip_repl; @@ -77,6 +73,7 @@ pub fn repl<'a, 'b>( ip_repl.set_payload(icmp_repl.packet()); ip_repl.set_next_level_protocol(IpNextHeaderProtocols::Icmp); } else { + masscanned.log.ipv4_drop(&ip_req, &client_info); return None; } } @@ -99,6 +96,7 @@ pub fn repl<'a, 'b>( ip_repl.set_payload(tcp_repl.packet()); ip_repl.set_next_level_protocol(IpNextHeaderProtocols::Tcp); } else { + masscanned.log.ipv4_drop(&ip_req, &client_info); return None; } } @@ -123,15 +121,13 @@ pub fn repl<'a, 'b>( ip_repl.set_payload(udp_repl.packet()); ip_repl.set_next_level_protocol(IpNextHeaderProtocols::Udp); } else { + masscanned.log.ipv4_drop(&ip_req, &client_info); return None; } } /* Next layer protocol not handled (yet) - dropping packet */ _ => { - info!( - "IPv4 upper layer not handled: {:?}", - ip_req.get_next_level_protocol() - ); + masscanned.log.ipv4_drop(&ip_req, &client_info); return None; } }; @@ -150,7 +146,7 @@ pub fn repl<'a, 'b>( /* FIXME when dest. was a multicast IP address */ ip_repl.set_source(ip_req.get_destination()); ip_repl.set_destination(ip_req.get_source()); - debug!("sending IPv4 packet: {:?}", ip_repl); + masscanned.log.ipv4_send(&ip_repl, &client_info); Some(ip_repl) } diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index e7de30a..3fd7a52 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -35,7 +35,10 @@ pub fn repl<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { - debug!("receiving IPv6 packet: {:?}", ip_req); + /* Fill client info with source and dest. IP address */ + client_info.ip.src = Some(IpAddr::V6(ip_req.get_source())); + client_info.ip.dst = Some(IpAddr::V6(ip_req.get_destination())); + masscanned.log.ipv6_recv(ip_req, client_info); let src = ip_req.get_source(); let mut dst = ip_req.get_destination(); /* If masscanned is configured with IP addresses, check that @@ -46,7 +49,7 @@ pub fn repl<'a, 'b>( if !ip_addr_list.contains(&IpAddr::V6(dst)) && ip_req.get_next_header() != IpNextHeaderProtocols::Icmpv6 { - info!("Ignoring IP packet from {} for {}", &src, &dst); + masscanned.log.ipv6_drop(ip_req, client_info); return None; } } @@ -84,6 +87,7 @@ pub fn repl<'a, 'b>( ip_repl.set_hop_limit(255); }; } else { + masscanned.log.ipv6_drop(ip_req, client_info); return None; } } @@ -108,6 +112,7 @@ pub fn repl<'a, 'b>( ip_repl.set_payload_length(tcp_len as u16); ip_repl.set_payload(&tcp_repl.packet()); } else { + masscanned.log.ipv6_drop(ip_req, client_info); return None; } } @@ -132,15 +137,13 @@ pub fn repl<'a, 'b>( ip_repl.set_payload_length(udp_len as u16); ip_repl.set_payload(&udp_repl.packet()); } else { + masscanned.log.ipv6_drop(ip_req, client_info); return None; } } /* Other protocols are not handled (yet) - dropping */ _ => { - info!( - "IPv6 upper layer not handled: {:?}", - ip_req.get_next_header() - ); + masscanned.log.ipv6_drop(ip_req, client_info); return None; } }; @@ -153,7 +156,7 @@ pub fn repl<'a, 'b>( /* Set packet source and dest. */ ip_repl.set_source(dst); ip_repl.set_destination(src); - debug!("sending IPv6 packet: {:?}", ip_repl); + masscanned.log.ipv6_send(&ip_repl, client_info); Some(ip_repl) } From 77ee5e2401a791c618098209c9e748f6eecb9f60 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:24:46 +0100 Subject: [PATCH 054/317] Add logging function calls for L4 dissectors --- src/layer_3/ipv6.rs | 1 - src/layer_4/icmpv4.rs | 14 ++-- src/layer_4/icmpv6.rs | 11 +-- src/layer_4/tcp.rs | 11 +-- src/layer_4/udp.rs | 7 +- src/logger/console.rs | 170 +++++++++++++++++++++--------------------- src/logger/meta.rs | 8 +- src/logger/mod.rs | 12 +-- src/masscanned.rs | 2 +- 9 files changed, 113 insertions(+), 123 deletions(-) diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index 3fd7a52..ab64708 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Masscanned. If not, see . -use log::*; use std::net::IpAddr; use pnet::packet::{ diff --git a/src/layer_4/icmpv4.rs b/src/layer_4/icmpv4.rs index e07ce07..d54c469 100644 --- a/src/layer_4/icmpv4.rs +++ b/src/layer_4/icmpv4.rs @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Masscanned. If not, see . -use log::*; - use pnet::packet::{ icmp::{IcmpCode, IcmpPacket, IcmpTypes, MutableIcmpPacket}, Packet, @@ -26,16 +24,16 @@ use crate::Masscanned; pub fn repl<'a, 'b>( icmp_req: &'a IcmpPacket, - _masscanned: &Masscanned, - mut _client_info: &ClientInfo, + masscanned: &Masscanned, + client_info: &ClientInfo, ) -> Option> { - debug!("receiving ICMPv4 packet: {:?}", icmp_req); + masscanned.log.icmpv4_recv(icmp_req, client_info); let mut icmp_repl; match icmp_req.get_icmp_type() { IcmpTypes::EchoRequest => { /* Check code of ICMP packet */ if icmp_req.get_icmp_code() != IcmpCode(0) { - info!("ICMP code not handled: {:?}", icmp_req.get_icmp_code()); + masscanned.log.icmpv4_drop(icmp_req, client_info); return None; } /* Compute answer length */ @@ -53,13 +51,13 @@ pub fn repl<'a, 'b>( * reply message." **/ icmp_repl.set_payload(icmp_req.payload()); - warn!("ICMP-Echo-Reply to ICMP-Echo-Request"); } _ => { + masscanned.log.icmpv4_drop(icmp_req, client_info); return None; } }; - debug!("sending ICMPv4 packet: {:?}", icmp_repl); + masscanned.log.icmpv4_send(&icmp_repl, client_info); Some(icmp_repl) } diff --git a/src/layer_4/icmpv6.rs b/src/layer_4/icmpv6.rs index 477699f..c295570 100644 --- a/src/layer_4/icmpv6.rs +++ b/src/layer_4/icmpv6.rs @@ -103,7 +103,7 @@ pub fn repl<'a, 'b>( masscanned: &Masscanned, client_info: &ClientInfo, ) -> (Option>, Option) { - debug!("receiving ICMPv6 packet: {:?}", icmp_req); + masscanned.log.icmpv6_recv(icmp_req, client_info); let mut dst_ip = None; if icmp_req.get_icmpv6_code() != Icmpv6Codes::NoCode { return (None, None); @@ -120,6 +120,7 @@ pub fn repl<'a, 'b>( icmp_repl = MutableIcmpv6Packet::owned(nd_na_repl.packet().to_vec()) .expect("error constructing an ICMPv6 packet"); } else { + masscanned.log.icmpv6_drop(icmp_req, client_info); return (None, None); } } @@ -136,17 +137,13 @@ pub fn repl<'a, 'b>( icmp_repl = MutableIcmpv6Packet::owned(vec![0; Icmpv6Packet::packet_size(&echo_repl)]) .expect("error constructing an ICMPv6 packet"); icmp_repl.populate(&echo_repl); - warn!("ICMPv6-Echo-Reply to ICMPv6-Echo-Request"); } _ => { - info!( - "ICMPv6 packet not handled: {:?}", - icmp_req.get_icmpv6_type() - ); + masscanned.log.icmpv6_drop(icmp_req, client_info); return (None, None); } }; - debug!("sending ICMPv6 packet: {:?}", icmp_repl); + masscanned.log.icmpv6_send(&icmp_repl, client_info); (Some(icmp_repl), dst_ip) } diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index 6b64472..28b72a0 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -31,7 +31,7 @@ pub fn repl<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { - debug!("receiving TCP packet: {:?}", tcp_req); + masscanned.log.tcp_recv(tcp_req, client_info); /* Fill client info with source and dest. TCP port */ client_info.port.src = Some(tcp_req.get_source()); client_info.port.dst = Some(tcp_req.get_destination()); @@ -50,7 +50,7 @@ pub fn repl<'a, 'b>( /* Compute syncookie */ if let Ok(cookie) = synackcookie::generate(&client_info, &masscanned.synack_key) { if cookie != ackno { - info!("PSH-ACK ignored: synackcookie not valid"); + masscanned.log.tcp_drop(tcp_req, client_info); return None; } client_info.cookie = Some(cookie); @@ -76,10 +76,12 @@ pub fn repl<'a, 'b>( /* Answer to ACK: nothing */ flags if flags == TcpFlags::ACK => { /* answer here when server needs to speak first after handshake */ + masscanned.log.tcp_drop(tcp_req, client_info); return None; } /* Answer to RST: nothing */ flags if flags == TcpFlags::RST => { + masscanned.log.tcp_drop(tcp_req, client_info); return None; } /* Answer to FIN,ACK with FIN,ACK */ @@ -101,10 +103,9 @@ pub fn repl<'a, 'b>( tcp_repl.set_sequence( synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(), ); - warn!("SYN-ACK to ACK on port {}", tcp_req.get_destination()); } _ => { - info!("TCP flag not handled: {}", tcp_req.get_flags()); + masscanned.log.tcp_drop(tcp_req, client_info); return None; } } @@ -115,7 +116,7 @@ pub fn repl<'a, 'b>( /* Set TCP headers */ tcp_repl.set_data_offset(5); tcp_repl.set_window(65535); - debug!("sending TCP packet: {:?}", tcp_repl); + masscanned.log.tcp_send(&tcp_repl, client_info); Some(tcp_repl) } diff --git a/src/layer_4/udp.rs b/src/layer_4/udp.rs index cdc1d47..75b0b8b 100644 --- a/src/layer_4/udp.rs +++ b/src/layer_4/udp.rs @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Masscanned. If not, see . -use log::*; - use pnet::packet::{ udp::{MutableUdpPacket, UdpPacket}, Packet, @@ -30,7 +28,7 @@ pub fn repl<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { - debug!("receiving UDP packet: {:?}", udp_req); + masscanned.log.udp_recv(udp_req, client_info); /* Fill client info with source and dest. UDP port */ client_info.port.src = Some(udp_req.get_source()); client_info.port.dst = Some(udp_req.get_destination()); @@ -43,12 +41,13 @@ pub fn repl<'a, 'b>( .expect("error constructing a UDP packet"); udp_repl.set_length(udp_repl.packet().len() as u16); } else { + masscanned.log.udp_drop(udp_req, client_info); return None; } /* Set source and dest. port for response packet from client info */ /* Note: client info could have been modified by upper layers (e.g., STUN) */ udp_repl.set_source(client_info.port.dst.unwrap()); udp_repl.set_destination(client_info.port.src.unwrap()); - debug!("sending UDP packet: {:?}", udp_repl); + masscanned.log.udp_send(&udp_repl, client_info); Some(udp_repl) } diff --git a/src/logger/console.rs b/src/logger/console.rs index 672b048..97fef38 100644 --- a/src/logger/console.rs +++ b/src/logger/console.rs @@ -19,12 +19,12 @@ use std::time::SystemTime; use pnet::packet::{ arp::{ArpPacket, MutableArpPacket}, ethernet::{EthernetPacket, MutableEthernetPacket}, - ipv4::{Ipv4Packet, MutableIpv4Packet}, - ipv6::{Ipv6Packet, MutableIpv6Packet}, icmp::{IcmpPacket, MutableIcmpPacket}, icmpv6::{Icmpv6Packet, MutableIcmpv6Packet}, - tcp::{TcpPacket, MutableTcpPacket}, - udp::{UdpPacket, MutableUdpPacket}, + ipv4::{Ipv4Packet, MutableIpv4Packet}, + ipv6::{Ipv6Packet, MutableIpv6Packet}, + tcp::{MutableTcpPacket, TcpPacket}, + udp::{MutableUdpPacket, UdpPacket}, }; use crate::client::ClientInfo; @@ -55,24 +55,56 @@ impl ConsoleLogger { } } fn prolog(&self, proto: &str, verb: &str, crlf: bool) { - let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); - print!("{}.{}\t{}\t{}{}", + let now = SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap(); + print!( + "{}.{}\t{}\t{}{}", now.as_secs(), now.subsec_millis(), proto, verb, if crlf { "\n" } else { "\t" }, - ); + ); } fn client_info(&self, c: &ClientInfo) { - print!("{}\t{}\t{}\t{}\t{}\t{}\t{}\t", - if let Some(m) = c.mac.src { format!("{}", m) } else { "".to_string() }, - if let Some(m) = c.mac.dst { format!("{}", m) } else { "".to_string() }, - if let Some(i) = c.ip.src { format!("{}", i) } else { "".to_string() }, - if let Some(i) = c.ip.dst { format!("{}", i) } else { "".to_string() }, - if let Some(t) = c.transport { format!("{}", t) } else { "".to_string() }, - if let Some(p) = c.port.src { format!("{}", p) } else { "".to_string() }, - if let Some(p) = c.port.dst { format!("{}", p) } else { "".to_string() }, + print!( + "{}\t{}\t{}\t{}\t{}\t{}\t{}\t", + if let Some(m) = c.mac.src { + format!("{}", m) + } else { + "".to_string() + }, + if let Some(m) = c.mac.dst { + format!("{}", m) + } else { + "".to_string() + }, + if let Some(i) = c.ip.src { + format!("{}", i) + } else { + "".to_string() + }, + if let Some(i) = c.ip.dst { + format!("{}", i) + } else { + "".to_string() + }, + if let Some(t) = c.transport { + format!("{}", t) + } else { + "".to_string() + }, + if let Some(p) = c.port.src { + format!("{}", p) + } else { + "".to_string() + }, + if let Some(p) = c.port.dst { + format!("{}", p) + } else { + "".to_string() + }, ); } } @@ -127,26 +159,17 @@ impl Logger for ConsoleLogger { fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { self.prolog("eth", "recv", false); self.client_info(c); - println!( - "{:}", - p.get_ethertype(), - ); + println!("{:}", p.get_ethertype(),); } fn eth_drop(&self, p: &EthernetPacket, c: &ClientInfo) { self.prolog("eth", "drop", false); self.client_info(c); - println!( - "{:}", - p.get_ethertype(), - ); + println!("{:}", p.get_ethertype(),); } fn eth_send(&self, p: &MutableEthernetPacket, c: &ClientInfo) { self.prolog("eth", "send", false); self.client_info(c); - println!( - "{:}", - p.get_ethertype(), - ); + println!("{:}", p.get_ethertype(),); } /* IPv4 */ fn ipv4_enabled(&self) -> bool { @@ -155,26 +178,17 @@ impl Logger for ConsoleLogger { fn ipv4_recv(&self, p: &Ipv4Packet, c: &ClientInfo) { self.prolog("ipv4", "recv", false); self.client_info(c); - println!( - "{:}", - p.get_next_level_protocol(), - ); + println!("{:}", p.get_next_level_protocol(),); } fn ipv4_drop(&self, p: &Ipv4Packet, c: &ClientInfo) { self.prolog("ipv4", "drop", false); self.client_info(c); - println!( - "{:}", - p.get_next_level_protocol(), - ); + println!("{:}", p.get_next_level_protocol(),); } fn ipv4_send(&self, p: &MutableIpv4Packet, c: &ClientInfo) { self.prolog("ipv4", "send", false); self.client_info(c); - println!( - "{:}", - p.get_next_level_protocol(), - ); + println!("{:}", p.get_next_level_protocol(),); } /* IPv6 */ fn ipv6_enabled(&self) -> bool { @@ -183,26 +197,17 @@ impl Logger for ConsoleLogger { fn ipv6_recv(&self, p: &Ipv6Packet, c: &ClientInfo) { self.prolog("ipv6", "recv", false); self.client_info(c); - println!( - "{:}", - p.get_next_header(), - ); + println!("{:}", p.get_next_header(),); } fn ipv6_drop(&self, p: &Ipv6Packet, c: &ClientInfo) { self.prolog("ipv6", "drop", false); self.client_info(c); - println!( - "{:}", - p.get_next_header(), - ); + println!("{:}", p.get_next_header(),); } fn ipv6_send(&self, p: &MutableIpv6Packet, c: &ClientInfo) { self.prolog("ipv6", "send", false); self.client_info(c); - println!( - "{:}", - p.get_next_header(), - ); + println!("{:}", p.get_next_header(),); } /* ICMPv4 */ fn icmpv4_enabled(&self) -> bool { @@ -211,29 +216,17 @@ impl Logger for ConsoleLogger { fn icmpv4_recv(&self, p: &IcmpPacket, c: &ClientInfo) { self.prolog("icmpv4", "recv", false); self.client_info(c); - println!( - "{:?}\t{:?}", - p.get_icmp_type(), - p.get_icmp_code(), - ); + println!("{:?}\t{:?}", p.get_icmp_type(), p.get_icmp_code(),); } fn icmpv4_drop(&self, p: &IcmpPacket, c: &ClientInfo) { self.prolog("icmpv4", "drop", false); self.client_info(c); - println!( - "{:?}\t{:?}", - p.get_icmp_type(), - p.get_icmp_code(), - ); + println!("{:?}\t{:?}", p.get_icmp_type(), p.get_icmp_code(),); } fn icmpv4_send(&self, p: &MutableIcmpPacket, c: &ClientInfo) { self.prolog("icmpv4", "send", false); self.client_info(c); - println!( - "{:?}\t{:?}", - p.get_icmp_type(), - p.get_icmp_code(), - ); + println!("{:?}\t{:?}", p.get_icmp_type(), p.get_icmp_code(),); } /* ICMPv6 */ fn icmpv6_enabled(&self) -> bool { @@ -242,29 +235,17 @@ impl Logger for ConsoleLogger { fn icmpv6_recv(&self, p: &Icmpv6Packet, c: &ClientInfo) { self.prolog("icmpv6", "recv", false); self.client_info(c); - println!( - "{:?}\t{:?}", - p.get_icmpv6_type(), - p.get_icmpv6_code(), - ); + println!("{:?}\t{:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); } fn icmpv6_drop(&self, p: &Icmpv6Packet, c: &ClientInfo) { self.prolog("icmpv6", "drop", false); self.client_info(c); - println!( - "{:?}\t{:?}", - p.get_icmpv6_type(), - p.get_icmpv6_code(), - ); + println!("{:?}\t{:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); } fn icmpv6_send(&self, p: &MutableIcmpv6Packet, c: &ClientInfo) { self.prolog("icmpv6", "send", false); self.client_info(c); - println!( - "{:?}\t{:?}", - p.get_icmpv6_type(), - p.get_icmpv6_code(), - ); + println!("{:?}\t{:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); } /* TCP */ fn tcp_enabled(&self) -> bool { @@ -273,33 +254,48 @@ impl Logger for ConsoleLogger { fn tcp_recv(&self, p: &TcpPacket, c: &ClientInfo) { self.prolog("tcp", "recv", false); self.client_info(c); - println!(""); + println!( + "{:?}\t{:}\t{:}", + p.get_flags(), + p.get_sequence(), + p.get_acknowledgement(), + ); } fn tcp_drop(&self, p: &TcpPacket, c: &ClientInfo) { self.prolog("tcp", "drop", false); self.client_info(c); - println!(""); + println!( + "{:?}\t{:}\t{:}", + p.get_flags(), + p.get_sequence(), + p.get_acknowledgement(), + ); } fn tcp_send(&self, p: &MutableTcpPacket, c: &ClientInfo) { self.prolog("tcp", "send", false); self.client_info(c); - println!(""); + println!( + "{:?}\t{:}\t{:}", + p.get_flags(), + p.get_sequence(), + p.get_acknowledgement(), + ); } /* UDP */ fn udp_enabled(&self) -> bool { self.udp } - fn udp_recv(&self, p: &UdpPacket, c: &ClientInfo) { + fn udp_recv(&self, _p: &UdpPacket, c: &ClientInfo) { self.prolog("udp", "recv", false); self.client_info(c); println!(""); } - fn udp_drop(&self, p: &UdpPacket, c: &ClientInfo) { + fn udp_drop(&self, _p: &UdpPacket, c: &ClientInfo) { self.prolog("udp", "drop", false); self.client_info(c); println!(""); } - fn udp_send(&self, p: &MutableUdpPacket, c: &ClientInfo) { + fn udp_send(&self, _p: &MutableUdpPacket, c: &ClientInfo) { self.prolog("udp", "send", false); self.client_info(c); println!(""); diff --git a/src/logger/meta.rs b/src/logger/meta.rs index 61b4ccb..94c752b 100644 --- a/src/logger/meta.rs +++ b/src/logger/meta.rs @@ -17,12 +17,12 @@ use pnet::packet::{ arp::{ArpPacket, MutableArpPacket}, ethernet::{EthernetPacket, MutableEthernetPacket}, - ipv4::{Ipv4Packet, MutableIpv4Packet}, - ipv6::{Ipv6Packet, MutableIpv6Packet}, icmp::{IcmpPacket, MutableIcmpPacket}, icmpv6::{Icmpv6Packet, MutableIcmpv6Packet}, - tcp::{TcpPacket, MutableTcpPacket}, - udp::{UdpPacket, MutableUdpPacket}, + ipv4::{Ipv4Packet, MutableIpv4Packet}, + ipv6::{Ipv6Packet, MutableIpv6Packet}, + tcp::{MutableTcpPacket, TcpPacket}, + udp::{MutableUdpPacket, UdpPacket}, }; use crate::client::ClientInfo; diff --git a/src/logger/mod.rs b/src/logger/mod.rs index d3f0d9c..bcd6f5e 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -17,21 +17,21 @@ use pnet::packet::{ arp::{ArpPacket, MutableArpPacket}, ethernet::{EthernetPacket, MutableEthernetPacket}, - ipv4::{Ipv4Packet, MutableIpv4Packet}, - ipv6::{Ipv6Packet, MutableIpv6Packet}, icmp::{IcmpPacket, MutableIcmpPacket}, icmpv6::{Icmpv6Packet, MutableIcmpv6Packet}, - tcp::{TcpPacket, MutableTcpPacket}, - udp::{UdpPacket, MutableUdpPacket}, + ipv4::{Ipv4Packet, MutableIpv4Packet}, + ipv6::{Ipv6Packet, MutableIpv6Packet}, + tcp::{MutableTcpPacket, TcpPacket}, + udp::{MutableUdpPacket, UdpPacket}, }; use crate::client::ClientInfo; -mod meta; mod console; +mod meta; -pub use meta::MetaLogger; pub use console::ConsoleLogger; +pub use meta::MetaLogger; pub trait Logger { fn init(&self); diff --git a/src/masscanned.rs b/src/masscanned.rs index 301cb4a..52ed059 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -35,8 +35,8 @@ use pnet::{ util::MacAddr, }; -use crate::utils::IpAddrParser; use crate::logger::{ConsoleLogger, MetaLogger}; +use crate::utils::IpAddrParser; mod client; mod layer_2; From f3d8ff3d128cdb01e4ba10742723d2da8a4fb0f8 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:27:10 +0100 Subject: [PATCH 055/317] Fix import in unit tests --- src/layer_2/arp.rs | 2 +- src/layer_2/mod.rs | 2 +- src/layer_3/ipv4.rs | 2 +- src/layer_3/ipv6.rs | 2 +- src/layer_4/icmpv4.rs | 2 +- src/layer_4/icmpv6.rs | 2 +- src/layer_4/tcp.rs | 2 +- src/proto/mod.rs | 2 +- src/proto/stun.rs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/layer_2/arp.rs b/src/layer_2/arp.rs index 2df1b10..7986028 100644 --- a/src/layer_2/arp.rs +++ b/src/layer_2/arp.rs @@ -72,7 +72,7 @@ mod tests { use pnet::util::MacAddr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_arp_reply() { diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 3f42e51..5e90e96 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -194,7 +194,7 @@ mod tests { use std::net::{Ipv4Addr, Ipv6Addr}; use std::str::FromStr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_eth_reply() { diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index fd4e133..f5d8f25 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -159,7 +159,7 @@ mod tests { use pnet::util::MacAddr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_ipv4_reply() { diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index ab64708..1d4128d 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -168,7 +168,7 @@ mod tests { use pnet::util::MacAddr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_ipv6_reply() { diff --git a/src/layer_4/icmpv4.rs b/src/layer_4/icmpv4.rs index d54c469..096f88a 100644 --- a/src/layer_4/icmpv4.rs +++ b/src/layer_4/icmpv4.rs @@ -68,7 +68,7 @@ mod tests { use pnet::util::MacAddr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_icmpv4_reply() { diff --git a/src/layer_4/icmpv6.rs b/src/layer_4/icmpv6.rs index c295570..59d48fe 100644 --- a/src/layer_4/icmpv6.rs +++ b/src/layer_4/icmpv6.rs @@ -157,7 +157,7 @@ mod tests { use pnet::packet::icmpv6::ndp::{MutableNeighborSolicitPacket, NeighborSolicit}; use pnet::util::MacAddr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_nd_na_reply() { diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index 28b72a0..6e211f2 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -127,7 +127,7 @@ mod tests { use pnet::util::MacAddr; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_tcp_fin_ack() { diff --git a/src/proto/mod.rs b/src/proto/mod.rs index b0ebe8f..7d425bb 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -165,7 +165,7 @@ mod tests { use pnet::util::MacAddr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_proto_dispatch_stun() { diff --git a/src/proto/stun.rs b/src/proto/stun.rs index 5e8d3d4..7dce6bc 100644 --- a/src/proto/stun.rs +++ b/src/proto/stun.rs @@ -413,7 +413,7 @@ mod tests { use pnet::util::MacAddr; - use crate::utils::MetaLogger; + use crate::logger::MetaLogger; #[test] fn test_proto_stun_ipv4() { From 6cace5d64b22eba2311d3bc8175cd26abb169b94 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:33:51 +0100 Subject: [PATCH 056/317] Fix bug --- src/layer_4/tcp.rs | 1 + src/logger/console.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index 6e211f2..e0dec1d 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -136,6 +136,7 @@ mod tests { ip_addresses: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, + log: MetaLogger::new(), }; /* reference */ let ip_src = IpAddr::V4(Ipv4Addr::new(27, 198, 143, 1)); diff --git a/src/logger/console.rs b/src/logger/console.rs index 97fef38..fe7f7ec 100644 --- a/src/logger/console.rs +++ b/src/logger/console.rs @@ -114,6 +114,11 @@ impl Logger for ConsoleLogger { self.prolog("arp", "init", true); self.prolog("eth", "init", true); self.prolog("ipv4", "init", true); + self.prolog("ipv6", "init", true); + self.prolog("icmpv4", "init", true); + self.prolog("icmpv6", "init", true); + self.prolog("tcp", "init", true); + self.prolog("udp", "init", true); } /* ARP */ fn arp_enabled(&self) -> bool { From 5b97b738e90e55a0f59c58fbd414f438daedc6fa Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Mon, 7 Feb 2022 09:20:16 +0100 Subject: [PATCH 057/317] SMB1/SMB2 Negotiate replies --- Cargo.toml | 22 +- src/proto/mod.rs | 21 +- src/proto/smb.rs | 1150 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1180 insertions(+), 13 deletions(-) create mode 100644 src/proto/smb.rs diff --git a/Cargo.toml b/Cargo.toml index 8352e15..9508504 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,22 +21,22 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] +bitflags = "1.2.1" +byteorder = "1.4.3" +chrono = "0.4.19" +clap = "3.0.5" +dns-parser = "0.8.0" +flate2 = "1.0" +itertools = "0.10.3" +lazy_static = "1.4.0" +log = "0.4.11" +netdevice = "0.1.1" pcap = "0.9.1" pcap-file = "1.1.1" pnet = "0.29.0" -clap = "3.0.5" -log = "0.4.11" -stderrlog = "0.5.0" -itertools = "0.10.3" rand = "0.8.4" -dns-parser = "0.8.0" -netdevice = "0.1.1" -bitflags = "1.2.1" -lazy_static = "1.4.0" siphasher = "0.3" -chrono = "0.4.19" -byteorder = "1.4.3" -flate2 = "1.0" +stderrlog = "0.5.0" [[bin]] name = "masscanned" diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 7d425bb..2c780d1 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -39,12 +39,17 @@ use ghost::GHOST_PATTERN_SIGNATURE; mod rpc; use rpc::{RPC_CALL_TCP, RPC_CALL_UDP}; +mod smb; +use smb::{SMB1_PATTERN_MAGIC, SMB2_PATTERN_MAGIC}; + const PROTO_HTTP: usize = 1; const PROTO_STUN: usize = 2; const PROTO_SSH: usize = 3; const PROTO_GHOST: usize = 4; const PROTO_RPC_TCP: usize = 5; const PROTO_RPC_UDP: usize = 6; +const PROTO_SMB1: usize = 7; +const PROTO_SMB2: usize = 8; struct TCPControlBlock { proto_state: usize, @@ -100,6 +105,16 @@ fn proto_init() -> Smack { PROTO_RPC_UDP, SmackFlags::ANCHOR_BEGIN | SmackFlags::WILDCARDS, ); + smack.add_pattern( + SMB1_PATTERN_MAGIC, + PROTO_SMB1, + SmackFlags::ANCHOR_BEGIN | SmackFlags::WILDCARDS, + ); + smack.add_pattern( + SMB2_PATTERN_MAGIC, + PROTO_SMB2, + SmackFlags::ANCHOR_BEGIN | SmackFlags::WILDCARDS, + ); smack.compile(); smack } @@ -129,13 +144,13 @@ pub fn repl<'a>( let mut i = 0; let mut tcb = ct.get_mut(&cookie).unwrap(); let mut state = tcb.proto_state; - id = PROTO_SMACK.search_next(&mut state, &data.to_vec(), &mut i); + id = PROTO_SMACK.search_next(&mut state, data, &mut i); tcb.proto_state = state; } else { /* proto over else (e.g., UDP) */ let mut i = 0; let mut state = BASE_STATE; - id = PROTO_SMACK.search_next(&mut state, &data.to_vec(), &mut i); + id = PROTO_SMACK.search_next(&mut state, data, &mut i); /* because we are not over TCP, we can afford to assume end of pattern */ if id == NO_MATCH { id = PROTO_SMACK.search_next_end(&mut state); @@ -149,6 +164,8 @@ pub fn repl<'a>( PROTO_GHOST => ghost::repl(data, masscanned, &mut client_info), PROTO_RPC_TCP => rpc::repl_tcp(data, masscanned, &mut client_info), PROTO_RPC_UDP => rpc::repl_udp(data, masscanned, &mut client_info), + PROTO_SMB1 => smb::repl_smb1(data, masscanned, &mut client_info), + PROTO_SMB2 => smb::repl_smb2(data, masscanned, &mut client_info), _ => { debug!("id: {}", id); None diff --git a/src/proto/smb.rs b/src/proto/smb.rs new file mode 100644 index 0000000..acfdb8d --- /dev/null +++ b/src/proto/smb.rs @@ -0,0 +1,1150 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use log::*; +use std::collections::HashSet; +use std::convert::TryInto; + +use chrono; + +use crate::client::ClientInfo; +use crate::Masscanned; + +// NBTSession + SMB Header +// netbios type (1 byte) + reserved (1 byte) + length (2 bytes) + SMB MAGIC (4 bytes) +// +pub const SMB1_PATTERN_MAGIC: &[u8; 8] = b"\x00\x00**\xffSMB"; +pub const SMB2_PATTERN_MAGIC: &[u8; 8] = b"\x00\x00**\xfeSMB"; + +// Build/Dissect secblob with Scapy using: GSSAPI_BLOB(b"`\x82.....") +const SECURITY_BLOB: &[u8; 320] = b"`\x82\x01<\x06\x06+\x06\x01\x05\x05\x02\xa0\x82\x0100\x82\x01,\xa0\x1a0\x18\x06\n+\x06\x01\x04\x01\x827\x02\x02\x1e\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2\x82\x01\x0c\x04\x82\x01\x08NEGOEXTS\x01\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00p\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\xf4Rk\x17\x03\x8aK\x91\xc2\t}\x9a\x8f\xe6,\x96\\Q$/\x90MG\xc7\xad\x8f\x87k\"\x02\xbf\xc6\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08NEGOEXTS\x03\x00\x00\x00\x01\x00\x00\x00@\x00\x00\x00\x98\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08@\x00\x00\x00X\x00\x00\x000V\xa0T0R0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key"; + +//////////// +// Common // +//////////// + +pub trait Packet { + type PacketState; + + fn new() -> Self; + fn i(&self) -> usize; + fn set_i(&mut self, i: usize); + fn state(&self) -> Self::PacketState; + fn set_state(&mut self, state: Self::PacketState); + fn repl(&self) -> Option>; + fn parse(&mut self, byte: &u8); + + fn parse_all(&mut self, bytes: &[u8]) { + for byte in bytes { + self.parse(byte); + } + } + + fn next_state(&mut self, state: Self::PacketState) { + self.set_state(state); + self.set_i(0); + } + fn next_state_when_i_reaches(&mut self, state: Self::PacketState, i: usize) { + if self.i() == i { + self.next_state(state); + } + } + fn _read_u( + &mut self, + byte: &u8, + value: usize, + next_state: Self::PacketState, + size: usize, + ) -> usize { + self.set_i(self.i() + 1); + self.next_state_when_i_reaches(next_state, size); + (value << 8) + *byte as usize + } + fn _read_ule( + &mut self, + byte: &u8, + value: usize, + next_state: Self::PacketState, + size: usize, + ) -> usize { + let ret = value + ((*byte as usize) << (8 * self.i())); + self.set_i(self.i() + 1); + self.next_state_when_i_reaches(next_state, size); + ret + } + fn read_u16(&mut self, byte: &u8, value: u16, next_state: Self::PacketState) -> u16 { + self._read_u(byte, value as usize, next_state, 2) as u16 + } + fn read_ule16(&mut self, byte: &u8, value: u16, next_state: Self::PacketState) -> u16 { + self._read_ule(byte, value as usize, next_state, 2) as u16 + } + fn read_ule32(&mut self, byte: &u8, value: u32, next_state: Self::PacketState) -> u32 { + self._read_ule(byte, value as usize, next_state, 4) as u32 + } + fn read_ule64(&mut self, byte: &u8, value: u64, next_state: Self::PacketState) -> u64 { + self._read_ule(byte, value as usize, next_state, 8) as u64 + } +} + +///////////// +// Netbios // +///////////// + +#[derive(Debug, Clone, Copy)] +enum NBTSessionState { + NBType, + Reserved, + Length, + End, +} + +#[derive(Debug, Clone)] +struct NBTSession { + // DISSECTION + state: NBTSessionState, + i: usize, + // STRUCT + nb_type: u8, + length: u16, + payload: Option, +} + +impl Packet for NBTSession { + type PacketState = NBTSessionState; + + fn i(&self) -> usize { + self.i + } + fn set_i(&mut self, i: usize) { + self.i = i; + } + fn state(&self) -> Self::PacketState { + self.state + } + fn set_state(&mut self, state: Self::PacketState) { + self.state = state; + } + + fn new() -> NBTSession { + Self { + state: NBTSessionState::NBType, + i: 0, + nb_type: 0, + length: 0, + payload: None, + } + } + + fn parse(&mut self, byte: &u8) { + match self.state { + NBTSessionState::NBType => { + self.nb_type = *byte; + self.next_state(NBTSessionState::Reserved); + } + NBTSessionState::Reserved => { + self.next_state(NBTSessionState::Length); + } + NBTSessionState::Length => { + self.length = self.read_u16(byte, self.length, NBTSessionState::End) + } + NBTSessionState::End => match self.get_payload() { + Some(pay) => pay.parse(byte), + None => return, + }, + } + } + + fn repl(&self) -> Option> { + let payload_resp = self.payload.as_ref()?.repl()?; + let mut resp: Vec = Vec::new(); + let size = payload_resp.len() & 0x1ffff; // 7 first bits are 0 + resp.push(0x0); + // 7 bits reserved + 17 bits length + resp.push(((size as u32 >> 16) & 0xff).try_into().unwrap()); + resp.extend_from_slice(&((size & 0xffff) as u16).to_be_bytes()); + resp.extend(payload_resp); + Some(resp) + } +} + +impl NBTSession { + fn get_payload(&mut self) -> Option<&mut T> { + if self.payload.is_some() { + return self.payload.as_mut(); + } + self.payload = Some(T::new()); + self.payload.as_mut() + } +} + +////////// +// SMB1 // +////////// + +#[derive(Debug, Clone, Copy)] +enum SMB1HeaderState { + Start, + Command, + Status, + Flags, + Flags2, + PIDHigh, + SecuritySignature, + Reserved, + TID, + PIDLow, + UID, + MID, + End, +} + +#[derive(Debug, Clone)] +struct SMB1Header { + // DISSECTION + state: SMB1HeaderState, + i: usize, + // STRUCT + start: [u8; 4], + command: u8, + status: u32, + flags: u8, + flags2: u16, + pid_high: u16, + security_signature: [u8; 8], + tid: u16, + pid_low: u16, + uid: u16, + mid: u16, + payload: Option, +} + +impl Packet for SMB1Header { + type PacketState = SMB1HeaderState; + + fn i(&self) -> usize { + self.i + } + fn set_i(&mut self, i: usize) { + self.i = i; + } + fn state(&self) -> Self::PacketState { + self.state + } + fn set_state(&mut self, state: Self::PacketState) { + self.state = state; + } + + fn new() -> SMB1Header { + Self { + state: SMB1HeaderState::Start, + i: 0, + start: [0; 4], + command: 0, + status: 0, + flags: 0, + flags2: 0, + pid_high: 0, + security_signature: [0; 8], + tid: 0, + pid_low: 0, + uid: 0, + mid: 0, + payload: None, + } + } + + fn parse(&mut self, byte: &u8) { + match self.state { + SMB1HeaderState::Start => { + self.start[self.i] = *byte; + self.i += 1; + self.next_state_when_i_reaches(SMB1HeaderState::Command, 4); + } + SMB1HeaderState::Command => { + self.command = *byte; + self.next_state(SMB1HeaderState::Status); + } + SMB1HeaderState::Status => { + self.status = self.read_ule32(byte, self.status, SMB1HeaderState::Flags); + } + SMB1HeaderState::Flags => { + self.flags = *byte; + self.next_state(SMB1HeaderState::Flags2); + } + SMB1HeaderState::Flags2 => { + self.flags2 = self.read_ule16(byte, self.flags2, SMB1HeaderState::PIDHigh); + } + SMB1HeaderState::PIDHigh => { + self.pid_high = + self.read_ule16(byte, self.pid_high, SMB1HeaderState::SecuritySignature); + } + SMB1HeaderState::SecuritySignature => { + self.security_signature[self.i] = *byte; + self.i += 1; + self.next_state_when_i_reaches(SMB1HeaderState::Reserved, 8); + } + SMB1HeaderState::Reserved => { + self.i += 1; + self.next_state_when_i_reaches(SMB1HeaderState::TID, 2); + } + SMB1HeaderState::TID => { + self.tid = self.read_ule16(byte, self.tid, SMB1HeaderState::PIDLow); + } + SMB1HeaderState::PIDLow => { + self.pid_low = self.read_ule16(byte, self.pid_low, SMB1HeaderState::UID); + } + SMB1HeaderState::UID => { + self.uid = self.read_ule16(byte, self.uid, SMB1HeaderState::MID); + } + SMB1HeaderState::MID => { + self.mid = self.read_ule16(byte, self.mid, SMB1HeaderState::End); + } + SMB1HeaderState::End => match self.get_payload() { + Some(pay) => pay.parse(byte), + None => return, + }, + } + } + + fn repl(&self) -> Option> { + let payload_resp = self.payload.as_ref()?.repl()?; + let mut resp: Vec = Vec::new(); + resp.extend_from_slice(b"\xffSMB"); // Start + resp.push(self.command); // Command + resp.extend_from_slice(&0_u32.to_le_bytes()); // Status + resp.push(0x98); // Flags = CASE_INSENSITIVE+CANONICALIZED_PATHS+REPLY + resp.extend_from_slice(&0xc807_u16.to_le_bytes()); // Flags2 = LONG_NAMES+EAS+SMB_SECURITY_SIGNATURE+EXTENDED_SECURITY+NT_STATUS+UNICODE + resp.extend_from_slice(&self.pid_high.to_le_bytes()); // PIDHigh + resp.extend_from_slice(&[0; 8]); // SecuritySignature + resp.extend_from_slice(&[0; 2]); // Reserved + resp.extend_from_slice(&self.tid.to_le_bytes()); // TID + resp.extend_from_slice(&self.pid_low.to_le_bytes()); // PIDLOW + resp.extend_from_slice(&self.uid.to_le_bytes()); // UID + resp.extend_from_slice(&self.mid.to_le_bytes()); // MID + resp.extend(payload_resp); + Some(resp) + } +} + +impl SMB1Header { + fn get_payload(&mut self) -> Option<&mut SMB1Payload> { + if self.payload.is_some() { + return self.payload.as_mut(); + } + if self.flags & 0x80 == 0x80 { + // Response + return None; + } + self.payload = Some(match self.command { + 0x72 => { + // Negotiate + SMB1Payload::NegotiateRequest(SMB1NegotiateRequest::new()) + } + // 0x73 => { + // // Setup + // SMB1Payload::SetupRequest(SMB2SetupRequest::new()) + // } + _ => None?, + }); + self.payload.as_mut() + } +} + +#[derive(Debug, Clone, PartialEq)] +struct SMB1Dialect { + buffer_format: u8, + dialect_string: String, +} + +#[derive(Debug, Clone, Copy)] +enum SMB1NegotiateRequestState { + WordCount, + ByteCount, + Dialects, + End, +} + +#[derive(Debug, Clone)] +struct SMB1NegotiateRequest { + // DISSECTION + state: SMB1NegotiateRequestState, + i: usize, + _tmp_dialect: Option, + // STRUCT + word_count: u8, + byte_count: u16, + dialects: Vec, +} + +impl Packet for SMB1NegotiateRequest { + type PacketState = SMB1NegotiateRequestState; + + fn i(&self) -> usize { + self.i + } + fn set_i(&mut self, i: usize) { + self.i = i; + } + fn state(&self) -> Self::PacketState { + self.state + } + fn set_state(&mut self, state: Self::PacketState) { + self.state = state; + } + + fn new() -> SMB1NegotiateRequest { + Self { + state: SMB1NegotiateRequestState::WordCount, + i: 0, + _tmp_dialect: None, + word_count: 0, + byte_count: 0, + dialects: Vec::new(), + } + } + + fn parse(&mut self, byte: &u8) { + match self.state { + SMB1NegotiateRequestState::WordCount => { + self.word_count = *byte; + self.next_state(SMB1NegotiateRequestState::ByteCount); + } + SMB1NegotiateRequestState::ByteCount => { + self.byte_count = + self.read_ule16(byte, self.byte_count, SMB1NegotiateRequestState::Dialects); + } + SMB1NegotiateRequestState::Dialects => { + self.i += 1; + match self._tmp_dialect.as_mut() { + Some(dial) => { + if *byte == 0 { + // Final nul byte: dialect is finished + self.dialects.push(dial.clone()); + self._tmp_dialect = None; + self.next_state_when_i_reaches( + SMB1NegotiateRequestState::End, + self.byte_count as usize, + ); + } else { + dial.dialect_string.push(*byte as char); + } + } + None => { + self._tmp_dialect = Some(SMB1Dialect { + buffer_format: *byte, + dialect_string: String::new(), + }); + } + } + } + SMB1NegotiateRequestState::End => {} + } + } + + // fn new(data: &[u8]) -> Option { + // if data.len() < 15 { + // return None; + // } + // let word_count = data[0]; + // let byte_count = LittleEndian::read_u16(&data[1..3]); + // let mut dialects = Vec::new(); + // let mut i: usize = 3; + // while i < 3 + byte_count as usize { + // if i + 1 > data.len() { + // break; + // }; + // // dialect_string is a string that ends with a \0 char + // let string_term = match data[i + 1..].iter().position(|&x| x == b'\0') { + // Some(x) => x, + // None => break, + // }; + // let dialect_string = match std::str::from_utf8(&data[i + 1..i + 1 + string_term]) { + // Ok(x) => x, + // _ => break, + // }; + // dialects.push(SMB1Dialect { + // buffer_format: data[i], + // dialect_string: String::from(dialect_string), + // }); + // i += 2 + string_term; + // } + // Some(SMB1NegotiateRequest { + // word_count, + // byte_count, + // dialects, + // }) + // } + + fn repl(&self) -> Option> { + if !matches!(self.state, SMB1NegotiateRequestState::End) { + return None; + } + let mut resp: Vec = Vec::new(); + let time: u64 = (EPOCH_1601 + chrono::Utc::now().timestamp() as u64) * (1e7 as u64); + let mut dialect_index: u16 = 0; + let mut dialect_name = "Unknown"; + for dialect in ["NT LM 0.12", "SMB 2.???", "SMB 2.002"] { + dialect_index = match self + .dialects + .iter() + .position(|x| x.dialect_string.eq(dialect)) + { + Some(x) => { + dialect_name = dialect; + x as u16 + } + None => continue, + }; + break; + } + resp.push(17); // WordCount + resp.extend_from_slice(&dialect_index.to_le_bytes()); // DialectIndex + resp.push(3); // SecurityMode + resp.extend_from_slice(&50_u16.to_le_bytes()); // MaxMPXCount + resp.extend_from_slice(&50_u16.to_le_bytes()); // MaxNumberVC + resp.extend_from_slice(&0x10000_u32.to_le_bytes()); // MaxBufferSize + resp.extend_from_slice(&0x10000_u32.to_le_bytes()); // MaxRawSize + resp.extend_from_slice(&0x0_u32.to_le_bytes()); // SessionKey + resp.extend_from_slice(&0x8001e3fc_u32.to_le_bytes()); // ServerCapabilities = UNICODE+LARGE_FILES+NT_SMBS+RPC_REMOTE_APIS+STATUS32+LEVEL_II_OPLOCKS+LOCK_AND_READ+NT_FIND+INFOLEVEL_PASSTHRU+LARGE_READX+LARGE_WRITEX+LWIO+EXTENDED_SECURITY + resp.extend_from_slice(&time.to_le_bytes()); // ServerTime + resp.extend_from_slice(&0x3c_u16.to_le_bytes()); // ServerTimeZone + resp.push(0); // ChallengeLength + resp.extend_from_slice(&((SECURITY_BLOB.len() + 16) as u16).to_le_bytes()); // ByteCount + // Challenge: Empty + resp.extend_from_slice(&[0_u8; 16]); // GUID + resp.extend_from_slice(SECURITY_BLOB); // SecurityBlob + warn!("SMB1 Negotiate-Protocol-Reply ({})", dialect_name); + Some(resp) + } +} + +// #[derive(Debug, Clone)] +// struct SMB1SetupRequest { +// +// } + +// impl SMB1SetupRequest { +// // TODO +// fn new(data: &[u8]) -> Option { +// if data.len() < 38 { +// return None; +// } +// None +// } + +// fn repl(&self) -> Option> { +// None +// } +// } + +#[derive(Debug, Clone)] +enum SMB1Payload { + NegotiateRequest(SMB1NegotiateRequest), + // SetupRequest(SMB1SetupRequest), +} + +impl SMB1Payload { + fn repl(&self) -> Option> { + match self { + SMB1Payload::NegotiateRequest(x) => x.repl(), + // SMB1Payload::SetupRequest(x) => x.repl(), + } + } + fn parse(&mut self, byte: &u8) { + match self { + SMB1Payload::NegotiateRequest(x) => x.parse(byte), + // SMB1Payload::SetupRequest(x) => x.repl(), + } + } +} + +////////// +// SMB2 // +////////// + +#[derive(Debug, Clone, Copy)] +enum SMB2HeaderState { + Start, + StructureSize, + CreditsCharge, + Status, + Command, + CreditsRequested, + Flags, + NextCommand, + MessageId, + AsyncId, + SessionId, + SecuritySignature, + End, +} + +#[derive(Debug, Clone)] +struct SMB2Header { + // DISSECTION + state: SMB2HeaderState, + i: usize, + // STRUCT + start: [u8; 4], + structure_size: u16, + credit_charge: u16, + status: u32, + command: u16, + credits_requested: u16, + flags: u32, + next_command: u32, + message_id: u64, + async_id: u64, + session_id: u64, + security_signature: [u8; 16], + // Payload + payload: Option, +} + +impl Packet for SMB2Header { + type PacketState = SMB2HeaderState; + + fn i(&self) -> usize { + self.i + } + fn set_i(&mut self, i: usize) { + self.i = i; + } + fn state(&self) -> Self::PacketState { + self.state + } + fn set_state(&mut self, state: Self::PacketState) { + self.state = state; + } + + fn new() -> SMB2Header { + SMB2Header { + state: SMB2HeaderState::Start, + i: 0, + start: [0; 4], + structure_size: 0, + credit_charge: 0, + status: 0, + command: 0, + credits_requested: 0, + flags: 0, + next_command: 0, + message_id: 0, + async_id: 0, + session_id: 0, + security_signature: [0; 16], + payload: None, + } + } + + fn parse(&mut self, byte: &u8) { + match self.state { + SMB2HeaderState::Start => { + self.start[self.i] = *byte; + self.i += 1; + self.next_state_when_i_reaches(SMB2HeaderState::StructureSize, 4); + } + SMB2HeaderState::StructureSize => { + self.structure_size = + self.read_ule16(byte, self.structure_size, SMB2HeaderState::CreditsCharge) + } + SMB2HeaderState::CreditsCharge => { + self.credit_charge = + self.read_ule16(byte, self.credit_charge, SMB2HeaderState::Status) + } + SMB2HeaderState::Status => { + self.status = self.read_ule32(byte, self.status, SMB2HeaderState::Command) + } + SMB2HeaderState::Command => { + self.command = + self.read_ule16(byte, self.command, SMB2HeaderState::CreditsRequested) + } + SMB2HeaderState::CreditsRequested => { + self.credits_requested = + self.read_ule16(byte, self.credits_requested, SMB2HeaderState::Flags) + } + SMB2HeaderState::Flags => { + self.flags = self.read_ule32(byte, self.flags, SMB2HeaderState::NextCommand) + } + SMB2HeaderState::NextCommand => { + self.next_command = + self.read_ule32(byte, self.next_command, SMB2HeaderState::MessageId) + } + SMB2HeaderState::MessageId => { + self.message_id = self.read_ule64(byte, self.message_id, SMB2HeaderState::AsyncId) + } + SMB2HeaderState::AsyncId => { + self.async_id = self.read_ule64(byte, self.async_id, SMB2HeaderState::SessionId) + } + SMB2HeaderState::SessionId => { + self.session_id = + self.read_ule64(byte, self.session_id, SMB2HeaderState::SecuritySignature) + } + SMB2HeaderState::SecuritySignature => { + self.security_signature[self.i] = *byte; + self.i += 1; + self.next_state_when_i_reaches(SMB2HeaderState::End, 16); + } + SMB2HeaderState::End => match self.get_payload() { + Some(pay) => pay.parse(byte), + None => return, + }, + } + } + + fn repl(&self) -> Option> { + let payload_resp = self.payload.as_ref()?.repl()?; + let mut resp: Vec = Vec::new(); + resp.extend_from_slice(b"\xfeSMB"); // Start + resp.extend_from_slice(&64_u16.to_le_bytes()); // StructureSize + resp.extend_from_slice(&0_u16.to_le_bytes()); // CreditCharge + resp.extend_from_slice(&0_u32.to_le_bytes()); // Status + resp.extend_from_slice(&self.command.to_le_bytes()); // Command + resp.extend_from_slice(&1_u16.to_le_bytes()); // CreditsRequested + resp.extend_from_slice(&1_u32.to_le_bytes()); // Flags = Response + resp.extend_from_slice(&0_u32.to_le_bytes()); // NextCommand + resp.extend_from_slice(&self.message_id.to_le_bytes()); // MessageId + resp.extend_from_slice(&self.async_id.to_le_bytes()); // AsyncId + resp.extend_from_slice(&self.session_id.to_le_bytes()); // SessionId + resp.extend_from_slice(&[0; 16]); // SecuritySignature + // Payload + resp.extend(payload_resp); + Some(resp) + } +} + +impl SMB2Header { + fn get_payload(&mut self) -> Option<&mut SMB2Payload> { + if let Some(_) = &self.payload { + return self.payload.as_mut(); + } + if self.flags & 1 == 1 { + // Response + return None; + } + self.payload = Some(match self.command { + 0x0000 => { + // Negotiate + SMB2Payload::NegotiateRequest(SMB2NegotiateRequest::new()) + } + // 0x0001 => { + // // Setup + // SMB2Payload::SetupRequest(SMB2SetupRequest::new()) + // } + _ => None?, + }); + self.payload.as_mut() + } +} + +#[derive(Debug, Clone, Copy)] +enum SMB2NegotiateRequestState { + StructureSize, + DialectCount, + SecurityMode, + Reserved, + Capabilities, + ClientGUID, + NegotiateAndReserved2, + Dialects, + End, +} + +#[derive(Debug, Clone)] +struct SMB2NegotiateRequest { + // DISSECTION + state: SMB2NegotiateRequestState, + i: usize, + _tmp_dialect: u16, + // STRUCT + structure_size: u16, + dialect_count: u16, + security_mode: u16, + capabilities: u32, + client_guid: [u8; 16], + dialects: HashSet, +} +const EPOCH_1601: u64 = 11644473600; + +impl Packet for SMB2NegotiateRequest { + type PacketState = SMB2NegotiateRequestState; + + fn i(&self) -> usize { + self.i + } + fn set_i(&mut self, i: usize) { + self.i = i; + } + fn state(&self) -> Self::PacketState { + self.state + } + fn set_state(&mut self, state: Self::PacketState) { + self.state = state; + } + + fn new() -> Self { + SMB2NegotiateRequest { + state: SMB2NegotiateRequestState::StructureSize, + i: 0, + _tmp_dialect: 0, + structure_size: 0, + dialect_count: 0, + security_mode: 0, + capabilities: 0, + client_guid: [0; 16], + dialects: HashSet::new(), + } + } + + fn parse(&mut self, byte: &u8) { + match self.state { + SMB2NegotiateRequestState::StructureSize => { + self.structure_size = self.read_ule16( + byte, + self.structure_size, + SMB2NegotiateRequestState::DialectCount, + ); + } + SMB2NegotiateRequestState::DialectCount => { + self.dialect_count = self.read_ule16( + byte, + self.dialect_count, + SMB2NegotiateRequestState::SecurityMode, + ); + } + SMB2NegotiateRequestState::SecurityMode => { + self.security_mode = self.read_ule16( + byte, + self.security_mode, + SMB2NegotiateRequestState::Reserved, + ); + } + SMB2NegotiateRequestState::Reserved => { + self.i += 1; + self.next_state_when_i_reaches(SMB2NegotiateRequestState::Capabilities, 2); + } + SMB2NegotiateRequestState::Capabilities => { + self.capabilities = self.read_ule32( + byte, + self.capabilities, + SMB2NegotiateRequestState::ClientGUID, + ); + } + SMB2NegotiateRequestState::ClientGUID => { + self.client_guid[self.i] = *byte; + self.i += 1; + self.next_state_when_i_reaches( + SMB2NegotiateRequestState::NegotiateAndReserved2, + 16, + ); + } + SMB2NegotiateRequestState::NegotiateAndReserved2 => { + self.i += 1; + self.next_state_when_i_reaches(SMB2NegotiateRequestState::Dialects, 8); + } + SMB2NegotiateRequestState::Dialects => { + self._tmp_dialect = + self.read_ule16(byte, self._tmp_dialect, SMB2NegotiateRequestState::Dialects); + if self.i == 0 { + // Add to dialects list when finished + self.dialects.insert(self._tmp_dialect); + self._tmp_dialect = 0; + // Check if dialects list is finished + if self.dialects.len() == self.dialect_count as usize { + self.state = SMB2NegotiateRequestState::End; + } + } + } + SMB2NegotiateRequestState::End => { + return; + } + } + } + fn repl(&self) -> Option> { + if !matches!(self.state, SMB2NegotiateRequestState::End) { + return None; + } + let mut resp: Vec = Vec::new(); + let time: u64 = (EPOCH_1601 + chrono::Utc::now().timestamp() as u64) * (1e7 as u64); + // Chose dialect + let smb2_versions = [ + (0x0202, "SMB 2.002"), + (0x0210, "SMB 2.1"), + (0x02ff, "SMB 2.???"), + (0x0300, "SMB 3.0"), + (0x0302, "SMB 2.0.2"), + (0x0310, "SMB 3.1.0"), + (0x0311, "SMB 3.1.1"), + ]; + let mut dialect = None; + let mut dialect_name = "Unknown"; + if let Some(smb_ver) = smb2_versions + .iter() + .find(|(d, _)| self.dialects.contains(d)) + { + dialect = Some(smb_ver.0); + dialect_name = smb_ver.1; + } + resp.extend_from_slice(&0x41_u16.to_le_bytes()); // StructureSize + resp.extend_from_slice(&0x1_u16.to_le_bytes()); // SecurityMode + resp.extend_from_slice(&dialect?.to_le_bytes()); // DialectRevision + resp.extend_from_slice(&0x1_u16.to_le_bytes()); // NegotiateCount + resp.extend_from_slice(&self.client_guid); // GUID + resp.extend_from_slice(&0x1_u32.to_le_bytes()); // Capabilities + resp.extend_from_slice(&0x10000_u32.to_le_bytes()); // MaxTransactionSize + resp.extend_from_slice(&0x10000_u32.to_le_bytes()); // MaxReadSize + resp.extend_from_slice(&0x10000_u32.to_le_bytes()); // MaxWriteSize + resp.extend_from_slice(&time.to_le_bytes()); // ServerTime + resp.extend_from_slice(&time.to_le_bytes()); // ServerStartTime + resp.extend_from_slice(&0x80_u16.to_le_bytes()); // SecurityBloboffset + resp.extend_from_slice(&(SECURITY_BLOB.len() as u16).to_le_bytes()); // SecurityBlobLength + resp.extend_from_slice(&0x0_u32.to_le_bytes()); // NegotiateContextOffset + resp.extend_from_slice(SECURITY_BLOB); // SecurityBlob + warn!("SMB2 Negotiate-Protocol-Reply ({})", dialect_name); + Some(resp) + } +} + +// #[derive(Debug, Clone)] +// struct SMB2SetupRequest {} +// impl SMB2SetupRequest { +// fn new() -> Self { +// SMB2SetupRequest {} +// } + +// fn repl(&self) -> Option> { +// (None, None) +// } +// } + +#[derive(Debug, Clone)] +enum SMB2Payload { + NegotiateRequest(SMB2NegotiateRequest), + // SetupRequest(SMB2SetupRequest), +} + +impl SMB2Payload { + fn repl(&self) -> Option> { + match self { + SMB2Payload::NegotiateRequest(x) => x.repl(), + // SMB2Payload::SetupRequest(x) => x.repl(), + } + } + fn parse(&mut self, byte: &u8) { + match self { + SMB2Payload::NegotiateRequest(x) => x.parse(byte), + // SMB2Payload::SetupRequest(x) => x.repl(), + } + } +} + +////////////// +// Handlers // +////////////// + +pub fn repl_smb1<'a>( + data: &'a [u8], + _masscanned: &Masscanned, + _client_info: &ClientInfo, +) -> Option> { + let mut nbtsession: NBTSession = NBTSession::new(); + for byte in data { + nbtsession.parse(byte); + } + return nbtsession.repl(); +} + +pub fn repl_smb2<'a>( + data: &'a [u8], + _masscanned: &Masscanned, + _client_info: &ClientInfo, +) -> Option> { + let mut nbtsession: NBTSession = NBTSession::new(); + for byte in data { + nbtsession.parse(byte); + } + return nbtsession.repl(); +} + +/////////// +// Tests // +/////////// + +#[cfg(test)] +mod tests { + use super::*; + use itertools::assert_equal; + use pnet::util::MacAddr; + use std::str::FromStr; + + // Sent by `smbclient -U "" -N -L 10.1.1.1 -d10 --option='client min protocol=NT1'` + const SMB1_REQ_PAYLOAD: &[u8] = b"\x00\x00\x00T\xffSMBr\x00\x00\x00\x00\x18C\xc8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\x00\x00\x00\x00\x001\x00\x02NT LANMAN 1.0\x00\x02NT LM 0.12\x00\x02SMB 2.002\x00\x02SMB 2.???\x00"; + // Sent by `smbclient -U "" -N -L 10.1.1.1 -d10` + const SMB2_REQ_PAYLOAD: &[u8] = b"\x00\x00\x00\xd0\xfeSMB@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00$\x00\x08\x00\x01\x00\x00\x00\x7f\x00\x00\x00\rr3\x97\"c\x8fA\x9f\xe0\xbawQ\x87rbx\x00\x00\x00\x03\x00\x00\x00\x02\x02\x10\x02\"\x02$\x02\x00\x03\x02\x03\x10\x03\x11\x03\x00\x00\x00\x00\x01\x00&\x00\x00\x00\x00\x00\x01\x00 \x00\x01\x00\xd5Z\x89\x87>\x80\xcd\x02\xc2\xab\x08\xa3\xf4\x94\xb6A\x05\x11V\xeeE\x19p\x19\xed\x17v\xda\x9b\x08\x99V\x00\x00\x02\x00\x06\x00\x00\x00\x00\x00\x02\x00\x02\x00\x01\x00\x00\x00\x05\x00\x10\x00\x00\x00\x00\x001\x000\x00.\x001\x00.\x001\x00.\x001\x00"; + // You can dissect any of those payloads with Scapy using NBTSession(b"...") + + #[test] + fn test_smb1_protocol_nego_parsing() { + let mut nbtsession: NBTSession = NBTSession::new(); + nbtsession.parse_all(SMB1_REQ_PAYLOAD); + assert_eq!(nbtsession.nb_type, 0); + assert_eq!(nbtsession.length, 0x54); + let smb1 = nbtsession.payload.expect("Error while unpacking SMB"); + assert_eq!(&smb1.start, b"\xffSMB"); + assert_eq!(smb1.command, 0x72); + assert_eq!(smb1.status, 0); + assert_eq!(smb1.flags, 24); + assert_eq!(smb1.flags2, 51267); + assert_eq!(smb1.pid_high, 0); + assert_eq!(smb1.security_signature, [0; 8]); + assert_eq!(smb1.tid, 0); + assert_eq!(smb1.pid_low, 65534); + assert_eq!(smb1.uid, 0); + assert_eq!(smb1.mid, 0); + let neg_request = match smb1.payload.expect("Error while reading payload") { + SMB1Payload::NegotiateRequest(x) => x, + }; + assert_eq!(neg_request.word_count, 0); + assert_eq!(neg_request.byte_count, 49); + assert_equal( + neg_request.dialects, + Vec::from([ + SMB1Dialect { + buffer_format: 2, + dialect_string: "NT LANMAN 1.0".to_string(), + }, + SMB1Dialect { + buffer_format: 2, + dialect_string: "NT LM 0.12".to_string(), + }, + SMB1Dialect { + buffer_format: 2, + dialect_string: "SMB 2.002".to_string(), + }, + SMB1Dialect { + buffer_format: 2, + dialect_string: "SMB 2.???".to_string(), + }, + ]), + ); + } + #[test] + fn test_smb1_protocol_nego_reply() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + }; + let client_info = ClientInfo::new(); + let answer = + repl_smb1(SMB1_REQ_PAYLOAD, &masscanned, &client_info).expect("Error: no answer"); + let expected = [ + 0, 0, 1, 149, 255, 83, 77, 66, 114, 0, 0, 0, 0, 152, 7, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 254, 255, 0, 0, 0, 0, 17, 1, 0, 3, 50, 0, 50, 0, 0, 0, 1, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 252, 227, 1, 128, 0, 250, 218, 34, 238, 28, 216, 1, 60, 0, 0, 80, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 130, 1, 60, 6, 6, 43, 6, 1, 5, 5, 2, 160, + 130, 1, 48, 48, 130, 1, 44, 160, 26, 48, 24, 6, 10, 43, 6, 1, 4, 1, 130, 55, 2, 2, 30, + 6, 10, 43, 6, 1, 4, 1, 130, 55, 2, 2, 10, 162, 130, 1, 12, 4, 130, 1, 8, 78, 69, 71, + 79, 69, 88, 84, 83, 1, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 112, 0, 0, 0, 49, 60, 42, 58, + 199, 43, 60, 169, 109, 172, 56, 116, 167, 221, 29, 91, 244, 82, 107, 23, 3, 138, 75, + 145, 194, 9, 125, 154, 143, 230, 44, 150, 92, 81, 36, 47, 144, 77, 71, 199, 173, 143, + 135, 107, 34, 2, 191, 198, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 92, 51, 83, 13, 234, 249, 13, 77, 178, 236, 74, 227, 120, 110, 195, 8, 78, + 69, 71, 79, 69, 88, 84, 83, 3, 0, 0, 0, 1, 0, 0, 0, 64, 0, 0, 0, 152, 0, 0, 0, 49, 60, + 42, 58, 199, 43, 60, 169, 109, 172, 56, 116, 167, 221, 29, 91, 92, 51, 83, 13, 234, + 249, 13, 77, 178, 236, 74, 227, 120, 110, 195, 8, 64, 0, 0, 0, 88, 0, 0, 0, 48, 86, + 160, 84, 48, 82, 48, 39, 128, 37, 48, 35, 49, 33, 48, 31, 6, 3, 85, 4, 3, 19, 24, 84, + 111, 107, 101, 110, 32, 83, 105, 103, 110, 105, 110, 103, 32, 80, 117, 98, 108, 105, + 99, 32, 75, 101, 121, 48, 39, 128, 37, 48, 35, 49, 33, 48, 31, 6, 3, 85, 4, 3, 19, 24, + 84, 111, 107, 101, 110, 32, 83, 105, 103, 110, 105, 110, 103, 32, 80, 117, 98, 108, + 105, 99, 32, 75, 101, 121, + ]; + assert_eq!(answer[..0x3c], expected[..0x3c]); // Test equality except "ServerTime" field + assert_eq!(answer[0x3c + 8..], expected[0x3c + 8..]); + } + #[test] + fn test_smb2_protocol_nego_parsing() { + let mut nbtsession: NBTSession = NBTSession::new(); + nbtsession.parse_all(SMB2_REQ_PAYLOAD); + assert_eq!(nbtsession.nb_type, 0); + assert_eq!(nbtsession.length, 0xd0); + let smb2 = nbtsession.payload.expect("No SMB2 payload found !"); + assert_eq!(&smb2.start, b"\xfeSMB"); + assert_eq!(smb2.structure_size, 64); + assert_eq!(smb2.credit_charge, 0); + assert_eq!(smb2.status, 0); + assert_eq!(smb2.command, 0); + assert_eq!(smb2.credits_requested, 31); + assert_eq!(smb2.flags, 0); + assert_eq!(smb2.next_command, 0); + assert_eq!(smb2.message_id, 0); + assert_eq!(smb2.async_id, 0); + assert_eq!(smb2.session_id, 0); + assert_eq!(smb2.security_signature, [0; 16]); + let neg_request = match smb2.payload.expect("Error while reading payload") { + SMB2Payload::NegotiateRequest(x) => x, + }; + assert_eq!(neg_request.structure_size, 36); + assert_eq!(neg_request.dialect_count, 8); + assert_eq!(neg_request.security_mode, 1); + assert_eq!(neg_request.capabilities, 127); + assert_eq!( + neg_request.client_guid, + [13, 114, 51, 151, 34, 99, 143, 65, 159, 224, 186, 119, 81, 135, 114, 98] + ); + assert_eq!( + neg_request.dialects, + HashSet::from([514, 528, 546, 548, 768, 770, 784, 785]) + ); + } + #[test] + fn test_smb2_protocol_nego_reply() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + }; + let client_info = ClientInfo::new(); + let answer = + repl_smb2(SMB2_REQ_PAYLOAD, &masscanned, &client_info).expect("Error: no answer"); + let expected = [ + 0, 0, 1, 192, 254, 83, 77, 66, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 1, 0, 2, 2, 1, 0, 13, 114, 51, 151, 34, + 99, 143, 65, 159, 224, 186, 119, 81, 135, 114, 98, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 103, 222, 3, 242, 28, 216, 1, 0, 103, 222, 3, 242, 28, 216, 1, 128, 0, + 64, 1, 0, 0, 0, 0, 96, 130, 1, 60, 6, 6, 43, 6, 1, 5, 5, 2, 160, 130, 1, 48, 48, 130, + 1, 44, 160, 26, 48, 24, 6, 10, 43, 6, 1, 4, 1, 130, 55, 2, 2, 30, 6, 10, 43, 6, 1, 4, + 1, 130, 55, 2, 2, 10, 162, 130, 1, 12, 4, 130, 1, 8, 78, 69, 71, 79, 69, 88, 84, 83, 1, + 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 112, 0, 0, 0, 49, 60, 42, 58, 199, 43, 60, 169, 109, + 172, 56, 116, 167, 221, 29, 91, 244, 82, 107, 23, 3, 138, 75, 145, 194, 9, 125, 154, + 143, 230, 44, 150, 92, 81, 36, 47, 144, 77, 71, 199, 173, 143, 135, 107, 34, 2, 191, + 198, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 51, + 83, 13, 234, 249, 13, 77, 178, 236, 74, 227, 120, 110, 195, 8, 78, 69, 71, 79, 69, 88, + 84, 83, 3, 0, 0, 0, 1, 0, 0, 0, 64, 0, 0, 0, 152, 0, 0, 0, 49, 60, 42, 58, 199, 43, 60, + 169, 109, 172, 56, 116, 167, 221, 29, 91, 92, 51, 83, 13, 234, 249, 13, 77, 178, 236, + 74, 227, 120, 110, 195, 8, 64, 0, 0, 0, 88, 0, 0, 0, 48, 86, 160, 84, 48, 82, 48, 39, + 128, 37, 48, 35, 49, 33, 48, 31, 6, 3, 85, 4, 3, 19, 24, 84, 111, 107, 101, 110, 32, + 83, 105, 103, 110, 105, 110, 103, 32, 80, 117, 98, 108, 105, 99, 32, 75, 101, 121, 48, + 39, 128, 37, 48, 35, 49, 33, 48, 31, 6, 3, 85, 4, 3, 19, 24, 84, 111, 107, 101, 110, + 32, 83, 105, 103, 110, 105, 110, 103, 32, 80, 117, 98, 108, 105, 99, 32, 75, 101, 121, + ]; + assert_eq!(answer[..0x6c], expected[..0x6c]); // Test equality except the 2 "ServerTime" fields + assert_eq!(answer[0x6c + 16..], expected[0x6c + 16..]); + } +} From 99bafe232d4497c422c561481cd1a0acb936bf95 Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Fri, 11 Feb 2022 18:17:40 +0100 Subject: [PATCH 058/317] Cleanup & Abstractify --- src/proto/smb.rs | 511 +++++++++++++++++++++++------------------------ 1 file changed, 252 insertions(+), 259 deletions(-) diff --git a/src/proto/smb.rs b/src/proto/smb.rs index acfdb8d..cd887fc 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -36,14 +36,56 @@ const SECURITY_BLOB: &[u8; 320] = b"`\x82\x01<\x06\x06+\x06\x01\x05\x05\x02\xa0\ // Common // //////////// -pub trait Packet { - type PacketState; +/// ### PacketDissector +/// A util class used to dissecate fields. +#[derive(Debug, Clone)] +struct PacketDissector { + i: usize, + state: T, +} +impl PacketDissector { + fn new(initial_state: T) -> PacketDissector { + return PacketDissector { + i: 0, + state: initial_state, + }; + } + fn next_state(&mut self, state: T) { + self.state = state; + self.i = 0; + } + fn next_state_when_i_reaches(&mut self, state: T, i: usize) { + if self.i == i { + self.next_state(state); + } + } + fn _read_u(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { + self.i += 1; + self.next_state_when_i_reaches(next_state, size); + (value << 8) + *byte as usize + } + fn _read_ule(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { + let ret = value + ((*byte as usize) << (8 * self.i)); + self.i += 1; + self.next_state_when_i_reaches(next_state, size); + ret + } + fn read_u16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { + self._read_u(byte, value as usize, next_state, 2) as u16 + } + fn read_ule16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { + self._read_ule(byte, value as usize, next_state, 2) as u16 + } + fn read_ule32(&mut self, byte: &u8, value: u32, next_state: T) -> u32 { + self._read_ule(byte, value as usize, next_state, 4) as u32 + } + fn read_ule64(&mut self, byte: &u8, value: u64, next_state: T) -> u64 { + self._read_ule(byte, value as usize, next_state, 8) as u64 + } +} +pub trait Packet { fn new() -> Self; - fn i(&self) -> usize; - fn set_i(&mut self, i: usize); - fn state(&self) -> Self::PacketState; - fn set_state(&mut self, state: Self::PacketState); fn repl(&self) -> Option>; fn parse(&mut self, byte: &u8); @@ -52,51 +94,6 @@ pub trait Packet { self.parse(byte); } } - - fn next_state(&mut self, state: Self::PacketState) { - self.set_state(state); - self.set_i(0); - } - fn next_state_when_i_reaches(&mut self, state: Self::PacketState, i: usize) { - if self.i() == i { - self.next_state(state); - } - } - fn _read_u( - &mut self, - byte: &u8, - value: usize, - next_state: Self::PacketState, - size: usize, - ) -> usize { - self.set_i(self.i() + 1); - self.next_state_when_i_reaches(next_state, size); - (value << 8) + *byte as usize - } - fn _read_ule( - &mut self, - byte: &u8, - value: usize, - next_state: Self::PacketState, - size: usize, - ) -> usize { - let ret = value + ((*byte as usize) << (8 * self.i())); - self.set_i(self.i() + 1); - self.next_state_when_i_reaches(next_state, size); - ret - } - fn read_u16(&mut self, byte: &u8, value: u16, next_state: Self::PacketState) -> u16 { - self._read_u(byte, value as usize, next_state, 2) as u16 - } - fn read_ule16(&mut self, byte: &u8, value: u16, next_state: Self::PacketState) -> u16 { - self._read_ule(byte, value as usize, next_state, 2) as u16 - } - fn read_ule32(&mut self, byte: &u8, value: u32, next_state: Self::PacketState) -> u32 { - self._read_ule(byte, value as usize, next_state, 4) as u32 - } - fn read_ule64(&mut self, byte: &u8, value: u64, next_state: Self::PacketState) -> u64 { - self._read_ule(byte, value as usize, next_state, 8) as u64 - } } ///////////// @@ -114,8 +111,7 @@ enum NBTSessionState { #[derive(Debug, Clone)] struct NBTSession { // DISSECTION - state: NBTSessionState, - i: usize, + d: PacketDissector, // STRUCT nb_type: u8, length: u16, @@ -123,25 +119,9 @@ struct NBTSession { } impl Packet for NBTSession { - type PacketState = NBTSessionState; - - fn i(&self) -> usize { - self.i - } - fn set_i(&mut self, i: usize) { - self.i = i; - } - fn state(&self) -> Self::PacketState { - self.state - } - fn set_state(&mut self, state: Self::PacketState) { - self.state = state; - } - fn new() -> NBTSession { Self { - state: NBTSessionState::NBType, - i: 0, + d: PacketDissector::new(NBTSessionState::NBType), nb_type: 0, length: 0, payload: None, @@ -149,16 +129,16 @@ impl Packet for NBTSession { } fn parse(&mut self, byte: &u8) { - match self.state { + match self.d.state { NBTSessionState::NBType => { self.nb_type = *byte; - self.next_state(NBTSessionState::Reserved); + self.d.next_state(NBTSessionState::Reserved); } NBTSessionState::Reserved => { - self.next_state(NBTSessionState::Length); + self.d.next_state(NBTSessionState::Length); } NBTSessionState::Length => { - self.length = self.read_u16(byte, self.length, NBTSessionState::End) + self.length = self.d.read_u16(byte, self.length, NBTSessionState::End) } NBTSessionState::End => match self.get_payload() { Some(pay) => pay.parse(byte), @@ -214,8 +194,7 @@ enum SMB1HeaderState { #[derive(Debug, Clone)] struct SMB1Header { // DISSECTION - state: SMB1HeaderState, - i: usize, + d: PacketDissector, // STRUCT start: [u8; 4], command: u8, @@ -232,25 +211,9 @@ struct SMB1Header { } impl Packet for SMB1Header { - type PacketState = SMB1HeaderState; - - fn i(&self) -> usize { - self.i - } - fn set_i(&mut self, i: usize) { - self.i = i; - } - fn state(&self) -> Self::PacketState { - self.state - } - fn set_state(&mut self, state: Self::PacketState) { - self.state = state; - } - fn new() -> SMB1Header { Self { - state: SMB1HeaderState::Start, - i: 0, + d: PacketDissector::new(SMB1HeaderState::Start), start: [0; 4], command: 0, status: 0, @@ -267,50 +230,55 @@ impl Packet for SMB1Header { } fn parse(&mut self, byte: &u8) { - match self.state { + match self.d.state { SMB1HeaderState::Start => { - self.start[self.i] = *byte; - self.i += 1; - self.next_state_when_i_reaches(SMB1HeaderState::Command, 4); + self.start[self.d.i] = *byte; + self.d.i += 1; + self.d + .next_state_when_i_reaches(SMB1HeaderState::Command, 4); } SMB1HeaderState::Command => { self.command = *byte; - self.next_state(SMB1HeaderState::Status); + self.d.next_state(SMB1HeaderState::Status); } SMB1HeaderState::Status => { - self.status = self.read_ule32(byte, self.status, SMB1HeaderState::Flags); + self.status = self.d.read_ule32(byte, self.status, SMB1HeaderState::Flags); } SMB1HeaderState::Flags => { self.flags = *byte; - self.next_state(SMB1HeaderState::Flags2); + self.d.next_state(SMB1HeaderState::Flags2); } SMB1HeaderState::Flags2 => { - self.flags2 = self.read_ule16(byte, self.flags2, SMB1HeaderState::PIDHigh); + self.flags2 = self + .d + .read_ule16(byte, self.flags2, SMB1HeaderState::PIDHigh); } SMB1HeaderState::PIDHigh => { self.pid_high = - self.read_ule16(byte, self.pid_high, SMB1HeaderState::SecuritySignature); + self.d + .read_ule16(byte, self.pid_high, SMB1HeaderState::SecuritySignature); } SMB1HeaderState::SecuritySignature => { - self.security_signature[self.i] = *byte; - self.i += 1; - self.next_state_when_i_reaches(SMB1HeaderState::Reserved, 8); + self.security_signature[self.d.i] = *byte; + self.d.i += 1; + self.d + .next_state_when_i_reaches(SMB1HeaderState::Reserved, 8); } SMB1HeaderState::Reserved => { - self.i += 1; - self.next_state_when_i_reaches(SMB1HeaderState::TID, 2); + self.d.i += 1; + self.d.next_state_when_i_reaches(SMB1HeaderState::TID, 2); } SMB1HeaderState::TID => { - self.tid = self.read_ule16(byte, self.tid, SMB1HeaderState::PIDLow); + self.tid = self.d.read_ule16(byte, self.tid, SMB1HeaderState::PIDLow); } SMB1HeaderState::PIDLow => { - self.pid_low = self.read_ule16(byte, self.pid_low, SMB1HeaderState::UID); + self.pid_low = self.d.read_ule16(byte, self.pid_low, SMB1HeaderState::UID); } SMB1HeaderState::UID => { - self.uid = self.read_ule16(byte, self.uid, SMB1HeaderState::MID); + self.uid = self.d.read_ule16(byte, self.uid, SMB1HeaderState::MID); } SMB1HeaderState::MID => { - self.mid = self.read_ule16(byte, self.mid, SMB1HeaderState::End); + self.mid = self.d.read_ule16(byte, self.mid, SMB1HeaderState::End); } SMB1HeaderState::End => match self.get_payload() { Some(pay) => pay.parse(byte), @@ -380,8 +348,7 @@ enum SMB1NegotiateRequestState { #[derive(Debug, Clone)] struct SMB1NegotiateRequest { // DISSECTION - state: SMB1NegotiateRequestState, - i: usize, + d: PacketDissector, _tmp_dialect: Option, // STRUCT word_count: u8, @@ -390,25 +357,9 @@ struct SMB1NegotiateRequest { } impl Packet for SMB1NegotiateRequest { - type PacketState = SMB1NegotiateRequestState; - - fn i(&self) -> usize { - self.i - } - fn set_i(&mut self, i: usize) { - self.i = i; - } - fn state(&self) -> Self::PacketState { - self.state - } - fn set_state(&mut self, state: Self::PacketState) { - self.state = state; - } - fn new() -> SMB1NegotiateRequest { Self { - state: SMB1NegotiateRequestState::WordCount, - i: 0, + d: PacketDissector::new(SMB1NegotiateRequestState::WordCount), _tmp_dialect: None, word_count: 0, byte_count: 0, @@ -417,24 +368,25 @@ impl Packet for SMB1NegotiateRequest { } fn parse(&mut self, byte: &u8) { - match self.state { + match self.d.state { SMB1NegotiateRequestState::WordCount => { self.word_count = *byte; - self.next_state(SMB1NegotiateRequestState::ByteCount); + self.d.next_state(SMB1NegotiateRequestState::ByteCount); } SMB1NegotiateRequestState::ByteCount => { self.byte_count = - self.read_ule16(byte, self.byte_count, SMB1NegotiateRequestState::Dialects); + self.d + .read_ule16(byte, self.byte_count, SMB1NegotiateRequestState::Dialects); } SMB1NegotiateRequestState::Dialects => { - self.i += 1; + self.d.i += 1; match self._tmp_dialect.as_mut() { Some(dial) => { if *byte == 0 { // Final nul byte: dialect is finished self.dialects.push(dial.clone()); self._tmp_dialect = None; - self.next_state_when_i_reaches( + self.d.next_state_when_i_reaches( SMB1NegotiateRequestState::End, self.byte_count as usize, ); @@ -454,42 +406,8 @@ impl Packet for SMB1NegotiateRequest { } } - // fn new(data: &[u8]) -> Option { - // if data.len() < 15 { - // return None; - // } - // let word_count = data[0]; - // let byte_count = LittleEndian::read_u16(&data[1..3]); - // let mut dialects = Vec::new(); - // let mut i: usize = 3; - // while i < 3 + byte_count as usize { - // if i + 1 > data.len() { - // break; - // }; - // // dialect_string is a string that ends with a \0 char - // let string_term = match data[i + 1..].iter().position(|&x| x == b'\0') { - // Some(x) => x, - // None => break, - // }; - // let dialect_string = match std::str::from_utf8(&data[i + 1..i + 1 + string_term]) { - // Ok(x) => x, - // _ => break, - // }; - // dialects.push(SMB1Dialect { - // buffer_format: data[i], - // dialect_string: String::from(dialect_string), - // }); - // i += 2 + string_term; - // } - // Some(SMB1NegotiateRequest { - // word_count, - // byte_count, - // dialects, - // }) - // } - fn repl(&self) -> Option> { - if !matches!(self.state, SMB1NegotiateRequestState::End) { + if !matches!(self.d.state, SMB1NegotiateRequestState::End) { return None; } let mut resp: Vec = Vec::new(); @@ -595,8 +513,7 @@ enum SMB2HeaderState { #[derive(Debug, Clone)] struct SMB2Header { // DISSECTION - state: SMB2HeaderState, - i: usize, + d: PacketDissector, // STRUCT start: [u8; 4], structure_size: u16, @@ -615,25 +532,9 @@ struct SMB2Header { } impl Packet for SMB2Header { - type PacketState = SMB2HeaderState; - - fn i(&self) -> usize { - self.i - } - fn set_i(&mut self, i: usize) { - self.i = i; - } - fn state(&self) -> Self::PacketState { - self.state - } - fn set_state(&mut self, state: Self::PacketState) { - self.state = state; - } - fn new() -> SMB2Header { SMB2Header { - state: SMB2HeaderState::Start, - i: 0, + d: PacketDissector::new(SMB2HeaderState::Start), start: [0; 4], structure_size: 0, credit_charge: 0, @@ -651,52 +552,67 @@ impl Packet for SMB2Header { } fn parse(&mut self, byte: &u8) { - match self.state { + match self.d.state { SMB2HeaderState::Start => { - self.start[self.i] = *byte; - self.i += 1; - self.next_state_when_i_reaches(SMB2HeaderState::StructureSize, 4); + self.start[self.d.i] = *byte; + self.d.i += 1; + self.d + .next_state_when_i_reaches(SMB2HeaderState::StructureSize, 4); } SMB2HeaderState::StructureSize => { self.structure_size = - self.read_ule16(byte, self.structure_size, SMB2HeaderState::CreditsCharge) + self.d + .read_ule16(byte, self.structure_size, SMB2HeaderState::CreditsCharge) } SMB2HeaderState::CreditsCharge => { self.credit_charge = - self.read_ule16(byte, self.credit_charge, SMB2HeaderState::Status) + self.d + .read_ule16(byte, self.credit_charge, SMB2HeaderState::Status) } SMB2HeaderState::Status => { - self.status = self.read_ule32(byte, self.status, SMB2HeaderState::Command) + self.status = self + .d + .read_ule32(byte, self.status, SMB2HeaderState::Command) } SMB2HeaderState::Command => { self.command = - self.read_ule16(byte, self.command, SMB2HeaderState::CreditsRequested) + self.d + .read_ule16(byte, self.command, SMB2HeaderState::CreditsRequested) } SMB2HeaderState::CreditsRequested => { self.credits_requested = - self.read_ule16(byte, self.credits_requested, SMB2HeaderState::Flags) + self.d + .read_ule16(byte, self.credits_requested, SMB2HeaderState::Flags) } SMB2HeaderState::Flags => { - self.flags = self.read_ule32(byte, self.flags, SMB2HeaderState::NextCommand) + self.flags = self + .d + .read_ule32(byte, self.flags, SMB2HeaderState::NextCommand) } SMB2HeaderState::NextCommand => { self.next_command = - self.read_ule32(byte, self.next_command, SMB2HeaderState::MessageId) + self.d + .read_ule32(byte, self.next_command, SMB2HeaderState::MessageId) } SMB2HeaderState::MessageId => { - self.message_id = self.read_ule64(byte, self.message_id, SMB2HeaderState::AsyncId) + self.message_id = self + .d + .read_ule64(byte, self.message_id, SMB2HeaderState::AsyncId) } SMB2HeaderState::AsyncId => { - self.async_id = self.read_ule64(byte, self.async_id, SMB2HeaderState::SessionId) + self.async_id = self + .d + .read_ule64(byte, self.async_id, SMB2HeaderState::SessionId) } SMB2HeaderState::SessionId => { self.session_id = - self.read_ule64(byte, self.session_id, SMB2HeaderState::SecuritySignature) + self.d + .read_ule64(byte, self.session_id, SMB2HeaderState::SecuritySignature) } SMB2HeaderState::SecuritySignature => { - self.security_signature[self.i] = *byte; - self.i += 1; - self.next_state_when_i_reaches(SMB2HeaderState::End, 16); + self.security_signature[self.d.i] = *byte; + self.d.i += 1; + self.d.next_state_when_i_reaches(SMB2HeaderState::End, 16); } SMB2HeaderState::End => match self.get_payload() { Some(pay) => pay.parse(byte), @@ -740,10 +656,10 @@ impl SMB2Header { // Negotiate SMB2Payload::NegotiateRequest(SMB2NegotiateRequest::new()) } - // 0x0001 => { - // // Setup - // SMB2Payload::SetupRequest(SMB2SetupRequest::new()) - // } + 0x0001 => { + // Setup + SMB2Payload::SetupRequest(SMB2SetupRequest::new()) + } _ => None?, }); self.payload.as_mut() @@ -766,8 +682,7 @@ enum SMB2NegotiateRequestState { #[derive(Debug, Clone)] struct SMB2NegotiateRequest { // DISSECTION - state: SMB2NegotiateRequestState, - i: usize, + d: PacketDissector, _tmp_dialect: u16, // STRUCT structure_size: u16, @@ -780,25 +695,9 @@ struct SMB2NegotiateRequest { const EPOCH_1601: u64 = 11644473600; impl Packet for SMB2NegotiateRequest { - type PacketState = SMB2NegotiateRequestState; - - fn i(&self) -> usize { - self.i - } - fn set_i(&mut self, i: usize) { - self.i = i; - } - fn state(&self) -> Self::PacketState { - self.state - } - fn set_state(&mut self, state: Self::PacketState) { - self.state = state; - } - fn new() -> Self { SMB2NegotiateRequest { - state: SMB2NegotiateRequestState::StructureSize, - i: 0, + d: PacketDissector::new(SMB2NegotiateRequestState::StructureSize), _tmp_dialect: 0, structure_size: 0, dialect_count: 0, @@ -810,61 +709,64 @@ impl Packet for SMB2NegotiateRequest { } fn parse(&mut self, byte: &u8) { - match self.state { + match self.d.state { SMB2NegotiateRequestState::StructureSize => { - self.structure_size = self.read_ule16( + self.structure_size = self.d.read_ule16( byte, self.structure_size, SMB2NegotiateRequestState::DialectCount, ); } SMB2NegotiateRequestState::DialectCount => { - self.dialect_count = self.read_ule16( + self.dialect_count = self.d.read_ule16( byte, self.dialect_count, SMB2NegotiateRequestState::SecurityMode, ); } SMB2NegotiateRequestState::SecurityMode => { - self.security_mode = self.read_ule16( + self.security_mode = self.d.read_ule16( byte, self.security_mode, SMB2NegotiateRequestState::Reserved, ); } SMB2NegotiateRequestState::Reserved => { - self.i += 1; - self.next_state_when_i_reaches(SMB2NegotiateRequestState::Capabilities, 2); + self.d.i += 1; + self.d + .next_state_when_i_reaches(SMB2NegotiateRequestState::Capabilities, 2); } SMB2NegotiateRequestState::Capabilities => { - self.capabilities = self.read_ule32( + self.capabilities = self.d.read_ule32( byte, self.capabilities, SMB2NegotiateRequestState::ClientGUID, ); } SMB2NegotiateRequestState::ClientGUID => { - self.client_guid[self.i] = *byte; - self.i += 1; - self.next_state_when_i_reaches( + self.client_guid[self.d.i] = *byte; + self.d.i += 1; + self.d.next_state_when_i_reaches( SMB2NegotiateRequestState::NegotiateAndReserved2, 16, ); } SMB2NegotiateRequestState::NegotiateAndReserved2 => { - self.i += 1; - self.next_state_when_i_reaches(SMB2NegotiateRequestState::Dialects, 8); + self.d.i += 1; + self.d + .next_state_when_i_reaches(SMB2NegotiateRequestState::Dialects, 8); } SMB2NegotiateRequestState::Dialects => { self._tmp_dialect = - self.read_ule16(byte, self._tmp_dialect, SMB2NegotiateRequestState::Dialects); - if self.i == 0 { + self.d + .read_ule16(byte, self._tmp_dialect, SMB2NegotiateRequestState::Dialects); + if self.d.i == 0 { // Add to dialects list when finished self.dialects.insert(self._tmp_dialect); self._tmp_dialect = 0; // Check if dialects list is finished if self.dialects.len() == self.dialect_count as usize { - self.state = SMB2NegotiateRequestState::End; + self.d.state = SMB2NegotiateRequestState::End; } } } @@ -874,7 +776,7 @@ impl Packet for SMB2NegotiateRequest { } } fn repl(&self) -> Option> { - if !matches!(self.state, SMB2NegotiateRequestState::End) { + if !matches!(self.d.state, SMB2NegotiateRequestState::End) { return None; } let mut resp: Vec = Vec::new(); @@ -912,41 +814,131 @@ impl Packet for SMB2NegotiateRequest { resp.extend_from_slice(&0x80_u16.to_le_bytes()); // SecurityBloboffset resp.extend_from_slice(&(SECURITY_BLOB.len() as u16).to_le_bytes()); // SecurityBlobLength resp.extend_from_slice(&0x0_u32.to_le_bytes()); // NegotiateContextOffset - resp.extend_from_slice(SECURITY_BLOB); // SecurityBlob + resp.extend_from_slice(SECURITY_BLOB); // SecurityBlobw warn!("SMB2 Negotiate-Protocol-Reply ({})", dialect_name); Some(resp) } } -// #[derive(Debug, Clone)] -// struct SMB2SetupRequest {} -// impl SMB2SetupRequest { -// fn new() -> Self { -// SMB2SetupRequest {} -// } +#[derive(Debug, Clone, Copy)] +enum SMB2SetupRequestState { + StructureSize, + Flags, + SecurityMode, + Capabilities, + Channel, + SecurityBufferOffset, + SecurityLen, + PreviousSessionId, + SecurityBlob, + End, +} -// fn repl(&self) -> Option> { -// (None, None) -// } -// } +#[derive(Debug, Clone)] +struct SMB2SetupRequest { + // DISSECTION + d: PacketDissector, + // STRUCT + structure_size: u16, + flags: u8, + security_mode: u8, + capabilities: u32, + channel: u32, + security_buffer_offset: u16, + security_len: u16, + previous_session_id: u64, +} +impl Packet for SMB2SetupRequest { + fn new() -> Self { + SMB2SetupRequest { + d: PacketDissector::new(SMB2SetupRequestState::StructureSize), + structure_size: 0, + flags: 0, + security_mode: 0, + capabilities: 0, + channel: 0, + security_buffer_offset: 0, + security_len: 0, + previous_session_id: 0, + } + } + + fn parse(&mut self, byte: &u8) { + match self.d.state { + SMB2SetupRequestState::StructureSize => { + self.structure_size = + self.d + .read_ule16(byte, self.structure_size, SMB2SetupRequestState::Flags); + } + SMB2SetupRequestState::Flags => { + self.flags = *byte; + self.d.next_state(SMB2SetupRequestState::SecurityMode); + } + SMB2SetupRequestState::SecurityMode => { + self.security_mode = *byte; + self.d.next_state(SMB2SetupRequestState::Capabilities); + } + SMB2SetupRequestState::Capabilities => { + self.capabilities = + self.d + .read_ule32(byte, self.capabilities, SMB2SetupRequestState::Channel); + } + SMB2SetupRequestState::Channel => { + self.channel = self.d.read_ule32( + byte, + self.channel, + SMB2SetupRequestState::SecurityBufferOffset, + ); + } + SMB2SetupRequestState::SecurityBufferOffset => { + self.security_buffer_offset = self.d.read_ule16( + byte, + self.security_buffer_offset, + SMB2SetupRequestState::SecurityLen, + ); + } + SMB2SetupRequestState::SecurityLen => { + self.security_len = self.d.read_ule16( + byte, + self.security_len, + SMB2SetupRequestState::PreviousSessionId, + ); + } + SMB2SetupRequestState::PreviousSessionId => { + self.previous_session_id = + self.d + .read_ule64(byte, self.previous_session_id, SMB2SetupRequestState::SecurityBlob); + } + SMB2SetupRequestState::SecurityBlob => { + // TODO ? Not super useful TBH, also this is ASN.1 :/// + self.d.next_state(SMB2SetupRequestState::End); + }, + SMB2SetupRequestState::End => {} + } + } + + fn repl(&self) -> Option> { + None + } +} #[derive(Debug, Clone)] enum SMB2Payload { NegotiateRequest(SMB2NegotiateRequest), - // SetupRequest(SMB2SetupRequest), + SetupRequest(SMB2SetupRequest), } impl SMB2Payload { fn repl(&self) -> Option> { match self { SMB2Payload::NegotiateRequest(x) => x.repl(), - // SMB2Payload::SetupRequest(x) => x.repl(), + SMB2Payload::SetupRequest(x) => x.repl(), } } fn parse(&mut self, byte: &u8) { match self { SMB2Payload::NegotiateRequest(x) => x.parse(byte), - // SMB2Payload::SetupRequest(x) => x.repl(), + SMB2Payload::SetupRequest(x) => x.parse(byte), } } } @@ -1097,6 +1089,7 @@ mod tests { assert_eq!(smb2.security_signature, [0; 16]); let neg_request = match smb2.payload.expect("Error while reading payload") { SMB2Payload::NegotiateRequest(x) => x, + _ => panic!("Invalid payload type"), }; assert_eq!(neg_request.structure_size, 36); assert_eq!(neg_request.dialect_count, 8); From cda878bd3cbfb0a6efe2404ae744a619dec54c52 Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Mon, 14 Feb 2022 11:38:36 +0100 Subject: [PATCH 059/317] Fix formatting --- src/proto/smb.rs | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/proto/smb.rs b/src/proto/smb.rs index cd887fc..4d0b44c 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -17,10 +17,10 @@ use log::*; use std::collections::HashSet; use std::convert::TryInto; - -use chrono; +use std::time::SystemTime; use crate::client::ClientInfo; +use crate::logger::MetaLogger; use crate::Masscanned; // NBTSession + SMB Header @@ -37,7 +37,7 @@ const SECURITY_BLOB: &[u8; 320] = b"`\x82\x01<\x06\x06+\x06\x01\x05\x05\x02\xa0\ //////////// /// ### PacketDissector -/// A util class used to dissecate fields. +/// A util class used to dissect fields. #[derive(Debug, Clone)] struct PacketDissector { i: usize, @@ -59,28 +59,28 @@ impl PacketDissector { self.next_state(state); } } - fn _read_u(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { + fn _read_usize(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { self.i += 1; self.next_state_when_i_reaches(next_state, size); (value << 8) + *byte as usize } - fn _read_ule(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { + fn _read_ulesize(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { let ret = value + ((*byte as usize) << (8 * self.i)); self.i += 1; self.next_state_when_i_reaches(next_state, size); ret } fn read_u16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { - self._read_u(byte, value as usize, next_state, 2) as u16 + self._read_usize(byte, value as usize, next_state, 2) as u16 } fn read_ule16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { - self._read_ule(byte, value as usize, next_state, 2) as u16 + self._read_ulesize(byte, value as usize, next_state, 2) as u16 } fn read_ule32(&mut self, byte: &u8, value: u32, next_state: T) -> u32 { - self._read_ule(byte, value as usize, next_state, 4) as u32 + self._read_ulesize(byte, value as usize, next_state, 4) as u32 } fn read_ule64(&mut self, byte: &u8, value: u64, next_state: T) -> u64 { - self._read_ule(byte, value as usize, next_state, 8) as u64 + self._read_ulesize(byte, value as usize, next_state, 8) as u64 } } @@ -411,7 +411,12 @@ impl Packet for SMB1NegotiateRequest { return None; } let mut resp: Vec = Vec::new(); - let time: u64 = (EPOCH_1601 + chrono::Utc::now().timestamp() as u64) * (1e7 as u64); + let time: u64 = (EPOCH_1601 + + SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs()) + * (1e7 as u64); let mut dialect_index: u16 = 0; let mut dialect_name = "Unknown"; for dialect in ["NT LM 0.12", "SMB 2.???", "SMB 2.002"] { @@ -780,7 +785,12 @@ impl Packet for SMB2NegotiateRequest { return None; } let mut resp: Vec = Vec::new(); - let time: u64 = (EPOCH_1601 + chrono::Utc::now().timestamp() as u64) * (1e7 as u64); + let time: u64 = (EPOCH_1601 + + SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs()) + * (1e7 as u64); // Chose dialect let smb2_versions = [ (0x0202, "SMB 2.002"), @@ -905,14 +915,16 @@ impl Packet for SMB2SetupRequest { ); } SMB2SetupRequestState::PreviousSessionId => { - self.previous_session_id = - self.d - .read_ule64(byte, self.previous_session_id, SMB2SetupRequestState::SecurityBlob); + self.previous_session_id = self.d.read_ule64( + byte, + self.previous_session_id, + SMB2SetupRequestState::SecurityBlob, + ); } SMB2SetupRequestState::SecurityBlob => { // TODO ? Not super useful TBH, also this is ASN.1 :/// self.d.next_state(SMB2SetupRequestState::End); - }, + } SMB2SetupRequestState::End => {} } } @@ -956,7 +968,7 @@ pub fn repl_smb1<'a>( for byte in data { nbtsession.parse(byte); } - return nbtsession.repl(); + nbtsession.repl() } pub fn repl_smb2<'a>( @@ -968,7 +980,7 @@ pub fn repl_smb2<'a>( for byte in data { nbtsession.parse(byte); } - return nbtsession.repl(); + nbtsession.repl() } /////////// @@ -1040,6 +1052,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + log: MetaLogger::new(), }; let client_info = ClientInfo::new(); let answer = @@ -1111,6 +1124,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + log: MetaLogger::new(), }; let client_info = ClientInfo::new(); let answer = From cafef21436cf3713d447eb4b21a74d5cd4939e5b Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Mon, 14 Feb 2022 13:40:50 +0100 Subject: [PATCH 060/317] Rename Packet->MPacket --- src/proto/smb.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/proto/smb.rs b/src/proto/smb.rs index 4d0b44c..0e1ad4b 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -84,7 +84,7 @@ impl PacketDissector { } } -pub trait Packet { +pub trait MPacket { fn new() -> Self; fn repl(&self) -> Option>; fn parse(&mut self, byte: &u8); @@ -109,7 +109,7 @@ enum NBTSessionState { } #[derive(Debug, Clone)] -struct NBTSession { +struct NBTSession { // DISSECTION d: PacketDissector, // STRUCT @@ -118,7 +118,7 @@ struct NBTSession { payload: Option, } -impl Packet for NBTSession { +impl MPacket for NBTSession { fn new() -> NBTSession { Self { d: PacketDissector::new(NBTSessionState::NBType), @@ -160,7 +160,7 @@ impl Packet for NBTSession { } } -impl NBTSession { +impl NBTSession { fn get_payload(&mut self) -> Option<&mut T> { if self.payload.is_some() { return self.payload.as_mut(); @@ -210,7 +210,7 @@ struct SMB1Header { payload: Option, } -impl Packet for SMB1Header { +impl MPacket for SMB1Header { fn new() -> SMB1Header { Self { d: PacketDissector::new(SMB1HeaderState::Start), @@ -356,7 +356,7 @@ struct SMB1NegotiateRequest { dialects: Vec, } -impl Packet for SMB1NegotiateRequest { +impl MPacket for SMB1NegotiateRequest { fn new() -> SMB1NegotiateRequest { Self { d: PacketDissector::new(SMB1NegotiateRequestState::WordCount), @@ -536,7 +536,7 @@ struct SMB2Header { payload: Option, } -impl Packet for SMB2Header { +impl MPacket for SMB2Header { fn new() -> SMB2Header { SMB2Header { d: PacketDissector::new(SMB2HeaderState::Start), @@ -699,7 +699,7 @@ struct SMB2NegotiateRequest { } const EPOCH_1601: u64 = 11644473600; -impl Packet for SMB2NegotiateRequest { +impl MPacket for SMB2NegotiateRequest { fn new() -> Self { SMB2NegotiateRequest { d: PacketDissector::new(SMB2NegotiateRequestState::StructureSize), @@ -858,7 +858,7 @@ struct SMB2SetupRequest { security_len: u16, previous_session_id: u64, } -impl Packet for SMB2SetupRequest { +impl MPacket for SMB2SetupRequest { fn new() -> Self { SMB2SetupRequest { d: PacketDissector::new(SMB2SetupRequestState::StructureSize), From beefcc9185638ef02c238c3bff69a339ede83421 Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Tue, 15 Feb 2022 14:55:09 +0100 Subject: [PATCH 061/317] Test suite refactor --- .github/workflows/test.yml | 2 +- README.md | 8 + src/proto/smb.rs | 3 +- test/src/all.py | 1308 +----------------------------------- test/src/core.py | 98 +++ test/src/tests/__init__.py | 15 + test/src/tests/arp.py | 51 ++ test/src/tests/ghost.py | 87 +++ test/src/tests/http.py | 339 ++++++++++ test/src/tests/icmpv4.py | 45 ++ test/src/tests/icmpv6.py | 87 +++ test/src/tests/ip46.py | 291 ++++++++ test/src/tests/rpc.py | 99 +++ test/src/tests/smb.py | 65 ++ test/src/tests/ssh.py | 217 ++++++ test/src/tests/stun.py | 196 ++++++ test/test_masscanned.py | 14 +- 17 files changed, 1625 insertions(+), 1300 deletions(-) create mode 100644 test/src/core.py create mode 100644 test/src/tests/__init__.py create mode 100644 test/src/tests/arp.py create mode 100644 test/src/tests/ghost.py create mode 100644 test/src/tests/http.py create mode 100644 test/src/tests/icmpv4.py create mode 100644 test/src/tests/icmpv6.py create mode 100644 test/src/tests/ip46.py create mode 100644 test/src/tests/rpc.py create mode 100644 test/src/tests/smb.py create mode 100644 test/src/tests/ssh.py create mode 100644 test/src/tests/stun.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ac573d..05c8984 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,7 +87,7 @@ jobs: run: sudo pip install -U flake8 black - name: Install packages for tests - run: sudo apt-get -q update && sudo apt-get -qy install nmap rpcbind + run: sudo apt-get -q update && sudo apt-get -qy install nmap rpcbind smbclient - name: Run black run: black -t py36 --check test/test_masscanned.py test/src/ diff --git a/README.md b/README.md index 41574c3..f3ebf81 100644 --- a/README.md +++ b/README.md @@ -290,6 +290,14 @@ tcpdump: pcap_loop: The interface disappeared 0 packets dropped by kernel ``` +You can also chose what tests to run using the `TESTS` environment variable +``` +TESTS=smb ./test/test_masscanned.py +INFO test_smb1_network_req.............................OK +INFO test_smb2_network_req.............................OK +INFO Ran 2 tests with 1 errors +``` + ## Logging ### Console Logger diff --git a/src/proto/smb.rs b/src/proto/smb.rs index 0e1ad4b..dcd5993 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -20,7 +20,6 @@ use std::convert::TryInto; use std::time::SystemTime; use crate::client::ClientInfo; -use crate::logger::MetaLogger; use crate::Masscanned; // NBTSession + SMB Header @@ -990,6 +989,8 @@ pub fn repl_smb2<'a>( #[cfg(test)] mod tests { use super::*; + use crate::logger::MetaLogger; + use itertools::assert_equal; use pnet::util::MacAddr; use std::str::FromStr; diff --git a/test/src/all.py b/test/src/all.py index e11d7d4..96f9062 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -14,1290 +14,28 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . -import json -import logging +import importlib import os -import re -from socket import AF_INET6 -from subprocess import check_call -import struct -from tempfile import NamedTemporaryFile -import zlib -from ivre.db import DBNmap -from scapy.compat import raw -from scapy.data import ETHER_BROADCAST -from scapy.layers.inet import ICMP, IP, TCP, UDP -from scapy.layers.inet6 import ( - ICMPv6EchoReply, - ICMPv6EchoRequest, - ICMPv6ND_NA, - ICMPv6ND_NS, - ICMPv6NDOptDstLLAddr, - IPv6, -) -from scapy.layers.l2 import ARP, Ether -from scapy.pton_ntop import inet_pton -from scapy.packet import Raw -from scapy.sendrecv import srp1 -from scapy.volatile import RandInt - -from .conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR - - -def setup_logs(): - ch = logging.StreamHandler() - ch.setFormatter(logging.Formatter("%(levelname)s\t%(message)s")) - ch.setLevel(logging.DEBUG) - log = logging.getLogger(__name__) - log.setLevel(logging.DEBUG) - log.addHandler(ch) - return log - - -LOG = setup_logs() -TESTS = [] -ERRORS = [] - - -# decorator to automatically add a function to tests -def test(f): - global ERRORS, TESTS - OK = "\033[1mOK\033[0m" - KO = "\033[1m\033[1;%dmKO\033[0m" % 31 - fname = f.__name__.ljust(50, ".") - - def w(): - try: - f() - LOG.info("{}{}".format(fname, OK)) - except AssertionError as e: - LOG.error("{}{}: {}".format(fname, KO, e)) - ERRORS.append(fname) - - TESTS.append(w) - return w - - -def multicast(ip6): - a, b = ip6.split(":")[-2:] - mac = ["33", "33", "ff"] - if len(a) == 4: - mac.append(a[2:]) - else: - mac.append("00") - if len(b) >= 2: - mac.append(b[:2]) - else: - mac.append("00") - if len(b) >= 4: - mac.append(b[2:]) - else: - mac.append("00") - return ":".join(mac) - - -def check_ip_checksum(pkt): - assert IP in pkt, "no IP layer found" - ip_pkt = pkt[IP] - chksum = ip_pkt.chksum - del ip_pkt.chksum - assert IP(raw(ip_pkt)).chksum == chksum, "bad IPv4 checksum" - - -def check_ipv6_checksum(pkt): - assert IPv6 in pkt, "no IP layer found" - ip_pkt = pkt[IPv6] - chksum = ip_pkt.chksum - del ip_pkt.chksum - assert IPv6(raw(ip_pkt)).chksum == chksum, "bad IPv6 checksum" - - -@test -def test_arp_req(): - ##### ARP ##### - arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst=IPV4_ADDR) - arp_repl = srp1(arp_req, timeout=1) - assert arp_repl is not None, "expecting answer, got nothing" - assert ARP in arp_repl, "no ARP layer found" - arp_repl = arp_repl[ARP] - # check answer - ## op is "is-at" - assert arp_repl.op == 2, "unexpected ARP op: {}".format(arp_repl.op) - ## answer for the requested IP - assert arp_repl.psrc == arp_req.pdst, "unexpected ARP psrc: {}".format( - arp_repl.psrc - ) - assert arp_repl.pdst == arp_req.psrc, "unexpected ARP pdst: {}".format( - arp_repl.pdst - ) - ## answer is expected MAC address - assert arp_repl.hwsrc == MAC_ADDR, "unexpected ARP hwsrc: {}".format(arp_repl.hwsrc) - - -@test -def test_arp_req_other_ip(): - ##### ARP ##### - arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst="1.2.3.4") - arp_repl = srp1(arp_req, timeout=1) - assert arp_repl is None, "responding to ARP requests for other IP addresses" - - -@test -def test_ipv4_req(): - ##### IP ##### - ip_req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, id=0x1337) / ICMP(type=8, code=0) - ip_repl = srp1(ip_req, timeout=1) - assert ip_repl is not None, "expecting answer, got nothing" - check_ip_checksum(ip_repl) - assert IP in ip_repl, "no IP layer in response" - ip_repl = ip_repl[IP] - assert ip_repl.id == 0, "IP identification unexpected" - - -@test -def test_eth_req_other_mac(): - #### ETH #### - ip_req = Ether(dst="00:00:00:11:11:11") / IP(dst=IPV4_ADDR) / ICMP(type=8, code=0) - ip_repl = srp1(ip_req, timeout=1) - assert ip_repl is None, "responding to other MAC addresses" - - -@test -def test_ipv4_req_other_ip(): - ##### IP ##### - ip_req = Ether(dst=MAC_ADDR) / IP(dst="1.2.3.4") / ICMP(type=8, code=0) - ip_repl = srp1(ip_req, timeout=1) - assert ip_repl is None, "responding to other IP addresses" - - -@test -def test_icmpv4_echo_req(): - ##### ICMPv4 ##### - icmp_req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / ICMP(type=8, code=0) - / Raw("idrinkwaytoomuchcoffee") - ) - icmp_repl = srp1(icmp_req, timeout=1) - assert icmp_repl is not None, "expecting answer, got nothing" - check_ip_checksum(icmp_repl) - assert ICMP in icmp_repl - icmp_repl = icmp_repl[ICMP] - # check answer - ## type is "echo-reply" - assert icmp_repl.type == 0 - assert icmp_repl.code == 0 - ## data is the same as sent - assert icmp_repl.load == icmp_req.load - - -@test -def test_icmpv6_neighbor_solicitation(): - ##### IPv6 Neighbor Solicitation ##### - for mac in [ - "ff:ff:ff:ff:ff:ff", - "33:33:00:00:00:01", - MAC_ADDR, - multicast(IPV6_ADDR), - ]: - nd_ns = Ether(dst=mac) / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) - nd_na = srp1(nd_ns, timeout=1) - assert nd_na is not None, "expecting answer, got nothing" - assert ICMPv6ND_NA in nd_na - nd_na = nd_na[ICMPv6ND_NA] - # check answer content - assert nd_na.code == 0 - assert nd_na.R == 0 - assert nd_na.S == 1 - assert nd_na.O == 1 # noqa: E741 - assert nd_na.tgt == IPV6_ADDR - # check ND Option - assert nd_na.haslayer(ICMPv6NDOptDstLLAddr) - assert nd_na.getlayer(ICMPv6NDOptDstLLAddr).lladdr == MAC_ADDR - for mac in ["00:00:00:00:00:00", "33:33:33:00:00:01"]: - nd_ns = Ether(dst="ff:ff:ff:ff:ff:ff") / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) - nd_na = srp1(nd_ns, timeout=1) - assert nd_na is not None, "expecting no answer, got one" - - -@test -def test_icmpv6_neighbor_solicitation_other_ip(): - ##### IPv6 Neighbor Solicitation ##### - nd_ns = ( - Ether(dst="ff:ff:ff:ff:ff:ff") - / IPv6() - / ICMPv6ND_NS(tgt="2020:4141:3030:2020::bdbd") - ) - nd_na = srp1(nd_ns, timeout=1) - assert nd_na is None, "responding to ND_NS for other IP addresses" - - -@test -def test_icmpv6_echo_req(): - ##### IPv6 Ping ##### - echo_req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / ICMPv6EchoRequest(data="waytoomanynapkins") - ) - echo_repl = srp1(echo_req, timeout=1) - assert echo_repl is not None, "expecting answer, got nothing" - assert ICMPv6EchoReply in echo_repl - echo_repl = echo_repl[ICMPv6EchoReply] - # check answer content - assert echo_repl.code == 0 - assert echo_repl.data == echo_req.data - - -@test -def test_tcp_syn(): - ##### SYN-ACK ##### - # test a list of ports, randomly generated once - ports_to_test = [ - 1152, - 2003, - 2193, - 3709, - 4054, - 6605, - 6737, - 6875, - 7320, - 8898, - 9513, - 9738, - 10623, - 10723, - 11253, - 12125, - 12189, - 12873, - 14648, - 14659, - 16242, - 16243, - 17209, - 17492, - 17667, - 17838, - 18081, - 18682, - 18790, - 19124, - 19288, - 19558, - 19628, - 19789, - 20093, - 21014, - 21459, - 21740, - 24070, - 24312, - 24576, - 26939, - 27136, - 27165, - 27361, - 29971, - 31088, - 33011, - 33068, - 34990, - 35093, - 35958, - 36626, - 36789, - 37130, - 37238, - 37256, - 37697, - 37890, - 38958, - 42131, - 43864, - 44420, - 44655, - 44868, - 45157, - 46213, - 46497, - 46955, - 49049, - 49067, - 49452, - 49480, - 50498, - 50945, - 51181, - 52890, - 53301, - 53407, - 53417, - 53980, - 55827, - 56483, - 58552, - 58713, - 58836, - 59362, - 59560, - 60534, - 60555, - 60660, - 61615, - 62402, - 62533, - 62941, - 63240, - 63339, - 63616, - 64380, - 65438, - ] - for p in ports_to_test: - seq_init = int(RandInt()) - syn = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="S", dport=p, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ip_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags - assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( - syn_ack.ack, - seq_init + 1, - ) - - -@test -def test_ipv4_tcp_psh_ack(): - ##### PSH-ACK ##### - sport = 26695 - port = 445 - seq_init = int(RandInt()) - # send PSH-ACK first - psh_ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) - / Raw("payload") - ) - syn_ack = srp1(psh_ack, timeout=1) - assert syn_ack is None, "no answer expected, got one" - # test the anti-injection mechanism - seq_init = int(RandInt()) - syn = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=port, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ip_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags - assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( - syn_ack.ack, - seq_init + 1, - ) - ack = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="A", dport=port) - # should fail because no ack given - psh_ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) - ) - ack = srp1(psh_ack, timeout=1) - assert ack is None, "no answer expected, got one" - # should get an answer this time - psh_ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 - ) - ) - ack = srp1(psh_ack, timeout=1) - assert ack is not None, "expecting answer, got nothing" - check_ip_checksum(ack) - assert TCP in ack, "expecting TCP, got %r" % ack.summary() - ack = ack[TCP] - assert ack.flags == "A", "expecting TCP A, got %r" % syn_ack.flags - - -@test -def test_ipv6_tcp_psh_ack(): - ##### PSH-ACK ##### - sport = 26695 - port = 445 - seq_init = int(RandInt()) - # send PSH-ACK first - psh_ack = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) - / Raw("payload") - ) - syn_ack = srp1(psh_ack, timeout=1) - assert syn_ack is None, "no answer expected, got one" - # test the anti-injection mechanism - syn = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP(flags="S", sport=sport, dport=port, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ipv6_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags - assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( - syn_ack.ack, - seq_init + 1, - ) - ack = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="A", dport=port) - # should fail because no ack given - psh_ack = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) - ) - ack = srp1(psh_ack, timeout=1) - assert ack is None, "no answer expected, got one" - # should get an answer this time - psh_ack = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP( - flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 - ) - ) - ack = srp1(psh_ack, timeout=1) - assert ack is not None, "expecting answer, got nothing" - check_ipv6_checksum(ack) - assert TCP in ack, "expecting TCP, got %r" % ack.summary() - ack = ack[TCP] - assert ack.flags == "A", "expecting TCP A, got %r" % syn_ack.flags - - -@test -def test_ipv4_tcp_http(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - seq_init = int(RandInt()) - syn = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ip_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags - ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - / Raw("GET / HTTP/1.1\r\n\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - tcp = resp[TCP] - assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") - - -@test -def test_ipv4_tcp_http_incomplete(): - sport = 24595 - dports = [80, 443, 5000, 53228] - for dport in dports: - seq_init = int(RandInt()) - syn = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ip_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags - ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - # purposedly incomplete request (missing additionnal ending \r\n) - / Raw("GET / HTTP/1.1\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting an answer, got none" - check_ip_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - tcp = resp[TCP] - assert tcp.flags == "A", "expecting TCP flag A, got {}".format(tcp.flags) - - -@test -def test_ipv6_tcp_http(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - seq_init = int(RandInt()) - syn = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ipv6_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" - ack = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - / Raw("GET / HTTP/1.1\r\n\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - tcp = resp[TCP] - assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") - - -@test -def test_ipv4_udp_http(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / UDP(sport=sport, dport=dport) - / Raw("GET / HTTP/1.1\r\n\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert UDP in resp - udp = resp[UDP] - assert udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") - - -@test -def test_ipv6_udp_http(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / UDP(sport=sport, dport=dport) - / Raw("GET / HTTP/1.1\r\n\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert UDP in resp - udp = resp[UDP] - assert udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") - - -@test -def test_ipv4_tcp_http_ko(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - seq_init = int(RandInt()) - syn = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ip_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" - ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - / Raw(bytes.fromhex("4f5054494f4e53")) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - assert "P" not in resp[TCP].flags - assert len(resp[TCP].payload) == 0 - - -@test -def test_ipv4_udp_http_ko(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(bytes.fromhex("4f5054494f4e53")) - ) - resp = srp1(req, timeout=1) - assert resp is None, "expecting no answer, got one" - - -@test -def test_ipv6_tcp_http_ko(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - seq_init = int(RandInt()) - syn = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ipv6_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" - ack = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - / Raw(bytes.fromhex("4f5054494f4e53")) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - assert "P" not in resp[TCP].flags - assert len(resp[TCP].payload) == 0 - - -@test -def test_ipv6_udp_http_ko(): - sport = 24592 - dports = [80, 443, 5000, 53228] - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(bytes.fromhex("4f5054494f4e53")) - ) - resp = srp1(req, timeout=1) - assert resp is None, "expecting no answer, got one" - - -@test -def test_ipv4_udp_stun(): - sports = [12345, 55555, 80, 43273] - dports = [80, 800, 8000, 3478] - payload = bytes.fromhex("000100002112a442000000000000000000000000") - for sport in sports: - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(payload) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert UDP in resp, "no UDP layer found" - udp = resp[UDP] - assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) - assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) - resp_payload = udp.payload.load - type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) - tid = resp_payload[8:20] - data = resp_payload[20:] - assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) - assert length == 12, "expected length 12, got {}".format(length) - assert ( - magic == 0x2112A442 - ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) - assert ( - tid == b"\x00" * 12 - ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( - ">HBBBB", sport, 192, 0, 0, 0 - ) - assert ( - data == expected_data - ), f"unexpected data {data!r} != {expected_data!r}" - - -@test -def test_ipv6_udp_stun(): - sports = [12345, 55555, 80, 43273] - dports = [80, 800, 8000, 3478] - payload = bytes.fromhex("000100002112a442000000000000000000000000") - for sport in sports: - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(payload) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert UDP in resp - udp = resp[UDP] - assert udp.sport == dport - assert udp.dport == sport - resp_payload = udp.payload.load - type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) - tid = resp_payload[8:20] - data = resp_payload[20:] - assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) - assert length == 24, "expected length 24, got {}".format(length) - assert ( - magic == 0x2112A442 - ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) - assert ( - tid == b"\x00" * 12 - ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - expected_data = ( - bytes.fromhex("000100140002") - + struct.pack(">H", sport) - + inet_pton(AF_INET6, "2001:41d0::1234:5678") - ) - assert data == expected_data, "unexpected data: {}".format(data) - - -@test -def test_ipv4_udp_stun_change_port(): - sports = [12345, 55555, 80, 43273] - dports = [80, 800, 8000, 3478, 65535] - payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") - for sport in sports: - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(payload) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert UDP in resp, "no UDP layer found" - udp = resp[UDP] - assert ( - udp.sport == (dport + 1) % 2**16 - ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2**16, udp.sport - ) - assert ( - udp.dport == sport - ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) - resp_payload = udp.payload.load - type_, length = struct.unpack(">HH", resp_payload[:4]) - tid = resp_payload[4:20] - data = resp_payload[20:] - assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) - assert length == 12, "expected length 12, got {}".format(length) - assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( - "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid - ) - expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( - ">HBBBB", sport, 192, 0, 0, 0 - ) - assert ( - data == expected_data - ), f"unexpected data {data!r} != {expected_data!r}" - - -@test -def test_ipv6_udp_stun_change_port(): - sports = [12345, 55555, 80, 43273] - dports = [80, 800, 8000, 3478, 65535] - payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") - for sport in sports: - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(payload) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert UDP in resp, "expecting UDP layer in answer, got nothing" - udp = resp[UDP] - assert ( - udp.sport == (dport + 1) % 2**16 - ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2**16, udp.sport - ) - assert ( - udp.dport == sport - ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) - resp_payload = udp.payload.load - type_, length = struct.unpack(">HH", resp_payload[:4]) - tid = resp_payload[4:20] - data = resp_payload[20:] - assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) - assert length == 24, "expected length 12, got {}".format(length) - assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( - "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid - ) - expected_data = ( - bytes.fromhex("000100140002") - + 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 -def test_ipv4_tcp_ssh(): - sport = 37183 - dports = [22, 80, 2222, 2022, 23874, 50000] - for i, dport in enumerate(dports): - seq_init = int(RandInt()) - banner = [ - b"SSH-2.0-AsyncSSH_2.1.0", - b"SSH-2.0-PuTTY", - b"SSH-2.0-libssh2_1.4.3", - b"SSH-2.0-Go", - b"SSH-2.0-PUTTY", - ][i % 5] - syn = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ip_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" - ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - / Raw(banner + b"\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - tcp = resp[TCP] - assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags - assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags - assert len(tcp.payload) > 0, "expecting payload, got none" - assert tcp.payload.load.startswith(b"SSH-2.0-"), ( - "unexpected banner: %r" % tcp.payload.load - ) - assert tcp.payload.load.endswith(b"\r\n"), ( - "unexpected banner: %r" % tcp.payload.load - ) - - -@test -def test_ipv4_udp_ssh(): - sport = 37183 - dports = [22, 80, 2222, 2022, 23874, 50000] - for i, dport in enumerate(dports): - banner = [ - b"SSH-2.0-AsyncSSH_2.1.0", - b"SSH-2.0-PuTTY", - b"SSH-2.0-libssh2_1.4.3", - b"SSH-2.0-Go", - b"SSH-2.0-PUTTY", - ][i % 5] - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(banner + b"\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert UDP in resp - udp = resp[UDP] - assert len(udp.payload) > 0, "expecting payload, got none" - assert udp.payload.load.startswith(b"SSH-2.0-"), ( - "unexpected banner: %r" % udp.payload.load - ) - assert udp.payload.load.endswith(b"\r\n"), ( - "unexpected banner: %r" % udp.payload.load - ) - - -@test -def test_ipv6_tcp_ssh(): - sport = 37183 - dports = [22, 80, 2222, 2022, 23874, 50000] - for i, dport in enumerate(dports): - seq_init = int(RandInt()) - banner = [ - b"SSH-2.0-AsyncSSH_2.1.0", - b"SSH-2.0-PuTTY", - b"SSH-2.0-libssh2_1.4.3", - b"SSH-2.0-Go", - b"SSH-2.0-PUTTY", - ][i % 5] - syn = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ipv6_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" - ack = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - / Raw(banner + b"\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - tcp = resp[TCP] - assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags - assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags - assert len(tcp.payload) > 0, "expecting payload, got none" - assert tcp.payload.load.startswith(b"SSH-2.0-"), ( - "unexpected banner: %r" % tcp.payload.load - ) - assert tcp.payload.load.endswith(b"\r\n"), ( - "unexpected banner: %r" % tcp.payload.load - ) - - -@test -def test_ipv6_udp_ssh(): - sport = 37183 - dports = [22, 80, 2222, 2022, 23874, 50000] - for i, dport in enumerate(dports): - banner = [ - b"SSH-2.0-AsyncSSH_2.1.0", - b"SSH-2.0-PuTTY", - b"SSH-2.0-libssh2_1.4.3", - b"SSH-2.0-Go", - b"SSH-2.0-PUTTY", - ][i % 5] - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(banner + b"\r\n") - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert UDP in resp - udp = resp[UDP] - assert len(udp.payload) > 0, "expecting payload, got none" - assert udp.payload.load.startswith(b"SSH-2.0-"), ( - "unexpected banner: %r" % udp.payload.load - ) - assert udp.payload.load.endswith(b"\r\n"), ( - "unexpected banner: %r" % udp.payload.load - ) - - -@test -def test_ipv4_tcp_ghost(): - sport = 37184 - dports = [22, 23874] - for dport in dports: - seq_init = int(RandInt()) - banner = b"Gh0st\xad\x00\x00\x00\xe0\x00\x00\x00x\x9cKS``\x98\xc3\xc0\xc0\xc0\x06\xc4\x8c@\xbcQ\x96\x81\x81\tH\x07\xa7\x16\x95e&\xa7*\x04$&g+\x182\x94\xf6\xb000\xac\xa8rc\x00\x01\x11\xa0\x82\x1f\\`&\x83\xc7K7\x86\x19\xe5n\x0c9\x95n\x0c;\x84\x0f3\xac\xe8sch\xa8^\xcf4'J\x97\xa9\x82\xe30\xc3\x91h]&\x90\xf8\xce\x97S\xcbA4L?2=\xe1\xc4\x92\x86\x0b@\xf5`\x0cT\x1f\xae\xaf]\nr\x0b\x03#\xa3\xdc\x02~\x06\x86\x03+\x18m\xc2=\xfdtC,C\xfdL<<==\\\x9d\x19\x88\x00\xe5 \x02\x00T\xf5+\\" - syn = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) - ) - syn_ack = srp1(syn, timeout=1) - assert syn_ack is not None, "expecting answer, got nothing" - check_ip_checksum(syn_ack) - assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() - syn_ack = syn_ack[TCP] - assert syn_ack.flags == "SA" - ack = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="A", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - ) - _ = srp1(ack, timeout=1) - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR) - / TCP( - flags="PA", - sport=sport, - dport=dport, - seq=seq_init + 1, - ack=syn_ack.seq + 1, - ) - / Raw(banner) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ip_checksum(resp) - assert TCP in resp, "expecting TCP, got %r" % resp.summary() - tcp = resp[TCP] - assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags - assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags - data = raw(tcp.payload) - assert data, "expecting payload, got none" - assert data.startswith(b"Gh0st"), "unexpected banner: %r" % tcp.payload.load - data_len, uncompressed_len = struct.unpack(". + +import logging + +from scapy.compat import raw +from scapy.layers.inet import IP +from scapy.layers.inet6 import IPv6 + + +def setup_logs(): + log = logging.getLogger() + log.setLevel(logging.DEBUG) + if not log.handlers: + ch = logging.StreamHandler() + ch.setFormatter(logging.Formatter("%(levelname)s\t%(message)s")) + ch.setLevel(logging.DEBUG) + log.addHandler(ch) + return log + + +LOG = setup_logs() +TESTS = [] +ERRORS = [] + +# decorator to automatically add a function to tests +def test(f): + global ERRORS, TESTS + OK = "\033[1mOK\033[0m" + KO = "\033[1m\033[1;%dmKO\033[0m" % 31 + fname = f.__name__.ljust(50, ".") + + def w(): + try: + f() + LOG.info("{}{}".format(fname, OK)) + except AssertionError as e: + LOG.error("{}{}: {}".format(fname, KO, e)) + ERRORS.append(fname) + + TESTS.append(w) + return w + + +def test_all(): + global ERRORS, TESTS + # execute tests + for t in TESTS: + t() + LOG.info(f"\033[1mRan {len(TESTS)} tests with {len(ERRORS)} errors\033[0m") + return len(ERRORS) + + +def multicast(ip6): + a, b = ip6.split(":")[-2:] + mac = ["33", "33", "ff"] + if len(a) == 4: + mac.append(a[2:]) + else: + mac.append("00") + if len(b) >= 2: + mac.append(b[:2]) + else: + mac.append("00") + if len(b) >= 4: + mac.append(b[2:]) + else: + mac.append("00") + return ":".join(mac) + + +def check_ip_checksum(pkt): + assert IP in pkt, "no IP layer found" + ip_pkt = pkt[IP] + chksum = ip_pkt.chksum + del ip_pkt.chksum + assert IP(raw(ip_pkt)).chksum == chksum, "bad IPv4 checksum" + + +def check_ipv6_checksum(pkt): + assert IPv6 in pkt, "no IP layer found" + ip_pkt = pkt[IPv6] + chksum = ip_pkt.chksum + del ip_pkt.chksum + assert IPv6(raw(ip_pkt)).chksum == chksum, "bad IPv6 checksum" diff --git a/test/src/tests/__init__.py b/test/src/tests/__init__.py new file mode 100644 index 0000000..831f613 --- /dev/null +++ b/test/src/tests/__init__.py @@ -0,0 +1,15 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . diff --git a/test/src/tests/arp.py b/test/src/tests/arp.py new file mode 100644 index 0000000..4f65cb7 --- /dev/null +++ b/test/src/tests/arp.py @@ -0,0 +1,51 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from scapy.layers.l2 import Ether, ARP, ETHER_BROADCAST +from scapy.sendrecv import srp1 + +from ..conf import IPV4_ADDR, MAC_ADDR +from ..core import test + + +@test +def test_arp_req(): + ##### ARP ##### + arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst=IPV4_ADDR) + arp_repl = srp1(arp_req, timeout=1) + assert arp_repl is not None, "expecting answer, got nothing" + assert ARP in arp_repl, "no ARP layer found" + arp_repl = arp_repl[ARP] + # check answer + ## op is "is-at" + assert arp_repl.op == 2, "unexpected ARP op: {}".format(arp_repl.op) + ## answer for the requested IP + assert arp_repl.psrc == arp_req.pdst, "unexpected ARP psrc: {}".format( + arp_repl.psrc + ) + assert arp_repl.pdst == arp_req.psrc, "unexpected ARP pdst: {}".format( + arp_repl.pdst + ) + ## answer is expected MAC address + assert arp_repl.hwsrc == MAC_ADDR, "unexpected ARP hwsrc: {}".format(arp_repl.hwsrc) + + +@test +def test_arp_req_other_ip(): + ##### ARP ##### + arp_req = Ether(dst=ETHER_BROADCAST) / ARP(pdst="1.2.3.4") + arp_repl = srp1(arp_req, timeout=1) + assert arp_repl is None, "responding to ARP requests for other IP addresses" diff --git a/test/src/tests/ghost.py b/test/src/tests/ghost.py new file mode 100644 index 0000000..303e58e --- /dev/null +++ b/test/src/tests/ghost.py @@ -0,0 +1,87 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +import struct +import zlib + +from scapy.compat import raw +from scapy.layers.inet import IP, TCP +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.sendrecv import srp1 +from scapy.volatile import RandInt + +from ..conf import IPV4_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum + + +@test +def test_ipv4_tcp_ghost(): + sport = 37184 + dports = [22, 23874] + for dport in dports: + seq_init = int(RandInt()) + banner = b"Gh0st\xad\x00\x00\x00\xe0\x00\x00\x00x\x9cKS``\x98\xc3\xc0\xc0\xc0\x06\xc4\x8c@\xbcQ\x96\x81\x81\tH\x07\xa7\x16\x95e&\xa7*\x04$&g+\x182\x94\xf6\xb000\xac\xa8rc\x00\x01\x11\xa0\x82\x1f\\`&\x83\xc7K7\x86\x19\xe5n\x0c9\x95n\x0c;\x84\x0f3\xac\xe8sch\xa8^\xcf4'J\x97\xa9\x82\xe30\xc3\x91h]&\x90\xf8\xce\x97S\xcbA4L?2=\xe1\xc4\x92\x86\x0b@\xf5`\x0cT\x1f\xae\xaf]\nr\x0b\x03#\xa3\xdc\x02~\x06\x86\x03+\x18m\xc2=\xfdtC,C\xfdL<<==\\\x9d\x19\x88\x00\xe5 \x02\x00T\xf5+\\" + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw(banner) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags + assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags + data = raw(tcp.payload) + assert data, "expecting payload, got none" + assert data.startswith(b"Gh0st"), "unexpected banner: %r" % tcp.payload.load + data_len, uncompressed_len = struct.unpack(". + +from scapy.layers.inet import IP, TCP, UDP +from scapy.layers.inet6 import IPv6 +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.sendrecv import srp1 +from scapy.volatile import RandInt + +from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum, check_ipv6_checksum + + +@test +def test_ipv4_tcp_http(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + + +@test +def test_ipv4_tcp_http_incomplete(): + sport = 24595 + dports = [80, 443, 5000, 53228] + for dport in dports: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + # purposedly incomplete request (missing additionnal ending \r\n) + / Raw("GET / HTTP/1.1\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting an answer, got none" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert tcp.flags == "A", "expecting TCP flag A, got {}".format(tcp.flags) + + +@test +def test_ipv6_tcp_http(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ipv6_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + + +@test +def test_ipv4_udp_http(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert UDP in resp + udp = resp[UDP] + assert udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + + +@test +def test_ipv6_udp_http(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw("GET / HTTP/1.1\r\n\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert UDP in resp + udp = resp[UDP] + assert udp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + + +@test +def test_ipv4_tcp_http_ko(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + assert "P" not in resp[TCP].flags + assert len(resp[TCP].payload) == 0 + + +@test +def test_ipv4_udp_http_ko(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) + resp = srp1(req, timeout=1) + assert resp is None, "expecting no answer, got one" + + +@test +def test_ipv6_tcp_http_ko(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ipv6_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + assert "P" not in resp[TCP].flags + assert len(resp[TCP].payload) == 0 + + +@test +def test_ipv6_udp_http_ko(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(bytes.fromhex("4f5054494f4e53")) + ) + resp = srp1(req, timeout=1) + assert resp is None, "expecting no answer, got one" diff --git a/test/src/tests/icmpv4.py b/test/src/tests/icmpv4.py new file mode 100644 index 0000000..7722148 --- /dev/null +++ b/test/src/tests/icmpv4.py @@ -0,0 +1,45 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from scapy.layers.inet import IP, ICMP +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.sendrecv import srp1 + +from ..conf import IPV4_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum + + +@test +def test_icmpv4_echo_req(): + ##### ICMPv4 ##### + icmp_req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / ICMP(type=8, code=0) + / Raw("idrinkwaytoomuchcoffee") + ) + icmp_repl = srp1(icmp_req, timeout=1) + assert icmp_repl is not None, "expecting answer, got nothing" + check_ip_checksum(icmp_repl) + assert ICMP in icmp_repl + icmp_repl = icmp_repl[ICMP] + # check answer + ## type is "echo-reply" + assert icmp_repl.type == 0 + assert icmp_repl.code == 0 + ## data is the same as sent + assert icmp_repl.load == icmp_req.load diff --git a/test/src/tests/icmpv6.py b/test/src/tests/icmpv6.py new file mode 100644 index 0000000..13a8817 --- /dev/null +++ b/test/src/tests/icmpv6.py @@ -0,0 +1,87 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from scapy.layers.inet6 import ( + ICMPv6EchoReply, + ICMPv6EchoRequest, + ICMPv6NDOptDstLLAddr, + ICMPv6ND_NA, + ICMPv6ND_NS, + IPv6, +) +from scapy.layers.l2 import Ether +from scapy.sendrecv import srp1 + +from ..conf import IPV6_ADDR, MAC_ADDR +from ..core import test, multicast + + +@test +def test_icmpv6_neighbor_solicitation(): + ##### IPv6 Neighbor Solicitation ##### + for mac in [ + "ff:ff:ff:ff:ff:ff", + "33:33:00:00:00:01", + MAC_ADDR, + multicast(IPV6_ADDR), + ]: + nd_ns = Ether(dst=mac) / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) + nd_na = srp1(nd_ns, timeout=1) + assert nd_na is not None, "expecting answer, got nothing" + assert ICMPv6ND_NA in nd_na + nd_na = nd_na[ICMPv6ND_NA] + # check answer content + assert nd_na.code == 0 + assert nd_na.R == 0 + assert nd_na.S == 1 + assert nd_na.O == 1 # noqa: E741 + assert nd_na.tgt == IPV6_ADDR + # check ND Option + assert nd_na.haslayer(ICMPv6NDOptDstLLAddr) + assert nd_na.getlayer(ICMPv6NDOptDstLLAddr).lladdr == MAC_ADDR + for mac in ["00:00:00:00:00:00", "33:33:33:00:00:01"]: + nd_ns = Ether(dst="ff:ff:ff:ff:ff:ff") / IPv6() / ICMPv6ND_NS(tgt=IPV6_ADDR) + nd_na = srp1(nd_ns, timeout=1) + assert nd_na is not None, "expecting no answer, got one" + + +@test +def test_icmpv6_neighbor_solicitation_other_ip(): + ##### IPv6 Neighbor Solicitation ##### + nd_ns = ( + Ether(dst="ff:ff:ff:ff:ff:ff") + / IPv6() + / ICMPv6ND_NS(tgt="2020:4141:3030:2020::bdbd") + ) + nd_na = srp1(nd_ns, timeout=1) + assert nd_na is None, "responding to ND_NS for other IP addresses" + + +@test +def test_icmpv6_echo_req(): + ##### IPv6 Ping ##### + echo_req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / ICMPv6EchoRequest(data="waytoomanynapkins") + ) + echo_repl = srp1(echo_req, timeout=1) + assert echo_repl is not None, "expecting answer, got nothing" + assert ICMPv6EchoReply in echo_repl + echo_repl = echo_repl[ICMPv6EchoReply] + # check answer content + assert echo_repl.code == 0 + assert echo_repl.data == echo_req.data diff --git a/test/src/tests/ip46.py b/test/src/tests/ip46.py new file mode 100644 index 0000000..62f3912 --- /dev/null +++ b/test/src/tests/ip46.py @@ -0,0 +1,291 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from scapy.layers.inet import IP, ICMP, TCP +from scapy.layers.inet6 import IPv6 +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.sendrecv import srp1 +from scapy.volatile import RandInt + +from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum, check_ipv6_checksum + + +@test +def test_ipv4_req(): + ##### IP ##### + ip_req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, id=0x1337) / ICMP(type=8, code=0) + ip_repl = srp1(ip_req, timeout=1) + assert ip_repl is not None, "expecting answer, got nothing" + check_ip_checksum(ip_repl) + assert IP in ip_repl, "no IP layer in response" + ip_repl = ip_repl[IP] + assert ip_repl.id == 0, "IP identification unexpected" + + +@test +def test_eth_req_other_mac(): + #### ETH #### + ip_req = Ether(dst="00:00:00:11:11:11") / IP(dst=IPV4_ADDR) / ICMP(type=8, code=0) + ip_repl = srp1(ip_req, timeout=1) + assert ip_repl is None, "responding to other MAC addresses" + + +@test +def test_ipv4_req_other_ip(): + ##### IP ##### + ip_req = Ether(dst=MAC_ADDR) / IP(dst="1.2.3.4") / ICMP(type=8, code=0) + ip_repl = srp1(ip_req, timeout=1) + assert ip_repl is None, "responding to other IP addresses" + + +@test +def test_tcp_syn(): + ##### SYN-ACK ##### + # test a list of ports, randomly generated once + ports_to_test = [ + 1152, + 2003, + 2193, + 3709, + 4054, + 6605, + 6737, + 6875, + 7320, + 8898, + 9513, + 9738, + 10623, + 10723, + 11253, + 12125, + 12189, + 12873, + 14648, + 14659, + 16242, + 16243, + 17209, + 17492, + 17667, + 17838, + 18081, + 18682, + 18790, + 19124, + 19288, + 19558, + 19628, + 19789, + 20093, + 21014, + 21459, + 21740, + 24070, + 24312, + 24576, + 26939, + 27136, + 27165, + 27361, + 29971, + 31088, + 33011, + 33068, + 34990, + 35093, + 35958, + 36626, + 36789, + 37130, + 37238, + 37256, + 37697, + 37890, + 38958, + 42131, + 43864, + 44420, + 44655, + 44868, + 45157, + 46213, + 46497, + 46955, + 49049, + 49067, + 49452, + 49480, + 50498, + 50945, + 51181, + 52890, + 53301, + 53407, + 53417, + 53980, + 55827, + 56483, + 58552, + 58713, + 58836, + 59362, + 59560, + 60534, + 60555, + 60660, + 61615, + 62402, + 62533, + 62941, + 63240, + 63339, + 63616, + 64380, + 65438, + ] + for p in ports_to_test: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", dport=p, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( + syn_ack.ack, + seq_init + 1, + ) + + +@test +def test_ipv4_tcp_psh_ack(): + ##### PSH-ACK ##### + sport = 26695 + port = 445 + seq_init = int(RandInt()) + # send PSH-ACK first + psh_ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) + / Raw("payload") + ) + syn_ack = srp1(psh_ack, timeout=1) + assert syn_ack is None, "no answer expected, got one" + # test the anti-injection mechanism + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=port, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( + syn_ack.ack, + seq_init + 1, + ) + ack = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / TCP(flags="A", dport=port) + # should fail because no ack given + psh_ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) + ) + ack = srp1(psh_ack, timeout=1) + assert ack is None, "no answer expected, got one" + # should get an answer this time + psh_ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 + ) + ) + ack = srp1(psh_ack, timeout=1) + assert ack is not None, "expecting answer, got nothing" + check_ip_checksum(ack) + assert TCP in ack, "expecting TCP, got %r" % ack.summary() + ack = ack[TCP] + assert ack.flags == "A", "expecting TCP A, got %r" % syn_ack.flags + + +@test +def test_ipv6_tcp_psh_ack(): + ##### PSH-ACK ##### + sport = 26695 + port = 445 + seq_init = int(RandInt()) + # send PSH-ACK first + psh_ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", sport=sport, dport=port, seq=seq_init) + / Raw("payload") + ) + syn_ack = srp1(psh_ack, timeout=1) + assert syn_ack is None, "no answer expected, got one" + # test the anti-injection mechanism + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=port, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ipv6_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + assert syn_ack.ack == seq_init + 1, "wrong TCP ack value (%r != %r)" % ( + syn_ack.ack, + seq_init + 1, + ) + ack = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR) / TCP(flags="A", dport=port) + # should fail because no ack given + psh_ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="PA", sport=sport, dport=port, ack=0, seq=seq_init + 1) + ) + ack = srp1(psh_ack, timeout=1) + assert ack is None, "no answer expected, got one" + # should get an answer this time + psh_ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP( + flags="PA", sport=sport, dport=port, ack=syn_ack.seq + 1, seq=seq_init + 1 + ) + ) + ack = srp1(psh_ack, timeout=1) + assert ack is not None, "expecting answer, got nothing" + check_ipv6_checksum(ack) + assert TCP in ack, "expecting TCP, got %r" % ack.summary() + ack = ack[TCP] + assert ack.flags == "A", "expecting TCP A, got %r" % syn_ack.flags diff --git a/test/src/tests/rpc.py b/test/src/tests/rpc.py new file mode 100644 index 0000000..62e42a1 --- /dev/null +++ b/test/src/tests/rpc.py @@ -0,0 +1,99 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from subprocess import check_call +from tempfile import NamedTemporaryFile +import json +import os +import re + +from ivre.db import DBNmap + +from ..conf import IPV4_ADDR +from ..core import test + + +@test +def test_rpc_nmap(): + for scan in "SU": + with NamedTemporaryFile(delete=False) as xml_result: + check_call( + [ + "nmap", + "-n", + "-vv", + "-oX", + "-", + IPV4_ADDR, + f"-s{scan}V", + "-p", + "111", + "--script", + "rpcinfo,rpc-grind", + ], + stdout=xml_result, + ) + with NamedTemporaryFile(delete=False, mode="w") as json_result: + DBNmap(output=json_result).store_scan(xml_result.name) + os.unlink(xml_result.name) + with open(json_result.name) as fdesc: + results = [json.loads(line) for line in fdesc] + os.unlink(json_result.name) + assert len(results) == 1, f"Expected 1 result, got {len(results)}" + result = results[0] + assert len(result["ports"]) == 1, f"Expected 1 port, got {len(result['ports'])}" + port = result["ports"][0] + assert port["port"] == 111 and port["protocol"] == ( + "tcp" if scan == "S" else "udp" + ) + assert port["service_name"] in {"rpcbind", "nfs"} + assert port["service_extrainfo"] in {"RPC #100000", "RPC #100003"} + assert ( + len(port["scripts"]) == 1 + ), f"Expected 1 script, got {len(port['scripts'])}" + script = port["scripts"][0] + assert script["id"] == "rpcinfo", "Expected rpcinfo script, not found" + assert len(script["rpcinfo"]) == 1 + + +@test +def test_rpcinfo(): + with NamedTemporaryFile(delete=False) as rpcout: + check_call(["rpcinfo", "-p", IPV4_ADDR], stdout=rpcout) + with open(rpcout.name) as fdesc: + found = [] + for line in fdesc: + line = line.split() + if line[0] == "program": + # header + continue + assert line[0] == "100000", f"Expected program 100000, got {line[0]}" + found.append(int(line[1])) + assert len(found) == 3, f"Expected three versions, got {found}" + for i in range(2, 5): + assert i in found, f"Missing version {i} in {found}" + os.unlink(rpcout.name) + with NamedTemporaryFile(delete=False) as rpcout: + check_call(["rpcinfo", "-u", IPV4_ADDR, "100000"], stdout=rpcout) + with open(rpcout.name) as fdesc: + found = [] + expr = re.compile("^program 100000 version ([0-9]) ready and waiting$") + for line in fdesc: + found.append(int(expr.search(line.strip()).group(1))) + assert len(found) == 3, f"Expected three versions, got {found}" + for i in range(2, 5): + assert i in found, f"Missing version {i} in {found}" + os.unlink(rpcout.name) diff --git a/test/src/tests/smb.py b/test/src/tests/smb.py new file mode 100644 index 0000000..3ce421d --- /dev/null +++ b/test/src/tests/smb.py @@ -0,0 +1,65 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +import subprocess + +from ..core import test +from ..conf import IPV4_ADDR + + +@test +def test_smb1_network_req(): + proc = subprocess.Popen( + [ + "smbclient", + "-U ''", + "-N", + "-d 6", + "-t 1", + "-L", + IPV4_ADDR, + "--option=client min protocol=NT1", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + out, _ = proc.communicate() + assert f"Connecting to {IPV4_ADDR} at port 445" in out, "\n" + out + assert "session request ok" in out, "\n" + out + assert f"negotiated dialect[NT1] against server[{IPV4_ADDR}]" in out, "\n" + out + + +@test +def test_smb2_network_req(): + proc = subprocess.Popen( + [ + "smbclient", + "-U ''", + "-N", + "-d 5", + "-t 1", + "-L", + IPV4_ADDR, + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + out, _ = proc.communicate() + assert f"Connecting to {IPV4_ADDR} at port 445" in out, "\n" + out + assert "session request ok" in out, "\n" + out + assert f"negotiated dialect[SMB2_02] against server[{IPV4_ADDR}]" in out, "\n" + out diff --git a/test/src/tests/ssh.py b/test/src/tests/ssh.py new file mode 100644 index 0000000..31501e4 --- /dev/null +++ b/test/src/tests/ssh.py @@ -0,0 +1,217 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from scapy.layers.inet import IP, TCP, UDP +from scapy.layers.inet6 import IPv6 +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.sendrecv import srp1 +from scapy.volatile import RandInt + +from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum, check_ipv6_checksum + + +@test +def test_ipv4_tcp_ssh(): + sport = 37183 + dports = [22, 80, 2222, 2022, 23874, 50000] + for i, dport in enumerate(dports): + seq_init = int(RandInt()) + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw(banner + b"\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags + assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags + assert len(tcp.payload) > 0, "expecting payload, got none" + assert tcp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % tcp.payload.load + ) + assert tcp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % tcp.payload.load + ) + + +@test +def test_ipv4_udp_ssh(): + sport = 37183 + dports = [22, 80, 2222, 2022, 23874, 50000] + for i, dport in enumerate(dports): + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(banner + b"\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert UDP in resp + udp = resp[UDP] + assert len(udp.payload) > 0, "expecting payload, got none" + assert udp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % udp.payload.load + ) + assert udp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % udp.payload.load + ) + + +@test +def test_ipv6_tcp_ssh(): + sport = 37183 + dports = [22, 80, 2222, 2022, 23874, 50000] + for i, dport in enumerate(dports): + seq_init = int(RandInt()) + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + syn = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ipv6_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA" + ack = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw(banner + b"\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert "A" in tcp.flags, "expecting ACK flag, not set (%r)" % tcp.flags + assert "P" in tcp.flags, "expecting PSH flag, not set (%r)" % tcp.flags + assert len(tcp.payload) > 0, "expecting payload, got none" + assert tcp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % tcp.payload.load + ) + assert tcp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % tcp.payload.load + ) + + +@test +def test_ipv6_udp_ssh(): + sport = 37183 + dports = [22, 80, 2222, 2022, 23874, 50000] + for i, dport in enumerate(dports): + banner = [ + b"SSH-2.0-AsyncSSH_2.1.0", + b"SSH-2.0-PuTTY", + b"SSH-2.0-libssh2_1.4.3", + b"SSH-2.0-Go", + b"SSH-2.0-PUTTY", + ][i % 5] + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(banner + b"\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert UDP in resp + udp = resp[UDP] + assert len(udp.payload) > 0, "expecting payload, got none" + assert udp.payload.load.startswith(b"SSH-2.0-"), ( + "unexpected banner: %r" % udp.payload.load + ) + assert udp.payload.load.endswith(b"\r\n"), ( + "unexpected banner: %r" % udp.payload.load + ) diff --git a/test/src/tests/stun.py b/test/src/tests/stun.py new file mode 100644 index 0000000..4062ec9 --- /dev/null +++ b/test/src/tests/stun.py @@ -0,0 +1,196 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from socket import AF_INET6 +import struct + +from scapy.layers.inet import IP, UDP +from scapy.layers.inet6 import IPv6 +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.pton_ntop import inet_pton +from scapy.sendrecv import srp1 + +from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum, check_ipv6_checksum + + +@test +def test_ipv4_udp_stun(): + sports = [12345, 55555, 80, 43273] + dports = [80, 800, 8000, 3478] + payload = bytes.fromhex("000100002112a442000000000000000000000000") + for sport in sports: + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert UDP in resp, "no UDP layer found" + udp = resp[UDP] + assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) + assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) + resp_payload = udp.payload.load + type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) + tid = resp_payload[8:20] + data = resp_payload[20:] + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 12, "expected length 12, got {}".format(length) + assert ( + magic == 0x2112A442 + ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) + assert ( + tid == b"\x00" * 12 + ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) + expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( + ">HBBBB", sport, 192, 0, 0, 0 + ) + assert ( + data == expected_data + ), f"unexpected data {data!r} != {expected_data!r}" + + +@test +def test_ipv6_udp_stun(): + sports = [12345, 55555, 80, 43273] + dports = [80, 800, 8000, 3478] + payload = bytes.fromhex("000100002112a442000000000000000000000000") + for sport in sports: + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert UDP in resp + udp = resp[UDP] + assert udp.sport == dport + assert udp.dport == sport + resp_payload = udp.payload.load + type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) + tid = resp_payload[8:20] + data = resp_payload[20:] + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 24, "expected length 24, got {}".format(length) + assert ( + magic == 0x2112A442 + ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) + assert ( + tid == b"\x00" * 12 + ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) + expected_data = ( + bytes.fromhex("000100140002") + + struct.pack(">H", sport) + + inet_pton(AF_INET6, "2001:41d0::1234:5678") + ) + assert data == expected_data, "unexpected data: {}".format(data) + + +@test +def test_ipv4_udp_stun_change_port(): + sports = [12345, 55555, 80, 43273] + dports = [80, 800, 8000, 3478, 65535] + payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") + for sport in sports: + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert UDP in resp, "no UDP layer found" + udp = resp[UDP] + assert ( + udp.sport == (dport + 1) % 2**16 + ), "expected answer from UDP/{}, got it from UDP/{}".format( + (dport + 1) % 2**16, udp.sport + ) + assert ( + udp.dport == sport + ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) + resp_payload = udp.payload.load + type_, length = struct.unpack(">HH", resp_payload[:4]) + tid = resp_payload[4:20] + data = resp_payload[20:] + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 12, "expected length 12, got {}".format(length) + assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( + "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid + ) + expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( + ">HBBBB", sport, 192, 0, 0, 0 + ) + assert ( + data == expected_data + ), f"unexpected data {data!r} != {expected_data!r}" + + +@test +def test_ipv6_udp_stun_change_port(): + sports = [12345, 55555, 80, 43273] + dports = [80, 800, 8000, 3478, 65535] + payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") + for sport in sports: + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert UDP in resp, "expecting UDP layer in answer, got nothing" + udp = resp[UDP] + assert ( + udp.sport == (dport + 1) % 2**16 + ), "expected answer from UDP/{}, got it from UDP/{}".format( + (dport + 1) % 2**16, udp.sport + ) + assert ( + udp.dport == sport + ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) + resp_payload = udp.payload.load + type_, length = struct.unpack(">HH", resp_payload[:4]) + tid = resp_payload[4:20] + data = resp_payload[20:] + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 24, "expected length 12, got {}".format(length) + assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( + "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid + ) + expected_data = ( + bytes.fromhex("000100140002") + + struct.pack(">H", sport) + + inet_pton(AF_INET6, "2001:41d0::1234:5678") + ) + assert ( + data == expected_data + ), f"unexpected data {data!r} != {expected_data!r}" diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 044a295..232e65a 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -18,7 +18,6 @@ import atexit import functools -import logging import os from signal import SIGINT import subprocess @@ -39,16 +38,6 @@ from src.all import test_all from src.conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR, OUTDIR -def setup_logs(): - ch = logging.StreamHandler() - ch.setFormatter(logging.Formatter("%(levelname)s\t%(message)s")) - ch.setLevel(logging.INFO) - log = logging.getLogger(__name__) - log.setLevel(logging.INFO) - log.addHandler(ch) - return log - - def cleanup_net(iface): global ipfile subprocess.check_call(["ip", "link", "delete", iface]) @@ -77,10 +66,10 @@ def cleanup_net(iface): def setup_net(iface): global IPV4_ADDR # create the interfaces pair + atexit.register(functools.partial(cleanup_net, f"{iface}a")) subprocess.check_call( ["ip", "link", "add", f"{iface}a", "type", "veth", "peer", f"{iface}b"] ) - atexit.register(functools.partial(cleanup_net, f"{iface}a")) for sub in "a", "b": subprocess.check_call(["ip", "link", "set", f"{iface}{sub}", "up"]) subprocess.check_call(["ip", "addr", "add", "dev", f"{iface}a", "192.0.0.0/31"]) @@ -110,7 +99,6 @@ def setup_net(iface): conf.route6.resync() -LOG = setup_logs() IFACE = "masscanned" setup_net(IFACE) TCPDUMP = bool(os.environ.get("USE_TCPDUMP")) From 5a2b2927d925be9b78d11d040aecd29b8d2cea58 Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Tue, 15 Feb 2022 15:27:25 +0100 Subject: [PATCH 062/317] Split ip46->ip/tcp --- test/src/all.py | 5 +-- test/src/core.py | 1 + test/src/tests/ip.py | 50 ++++++++++++++++++++++++++++++ test/src/tests/{ip46.py => tcp.py} | 30 +----------------- 4 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 test/src/tests/ip.py rename test/src/tests/{ip46.py => tcp.py} (88%) diff --git a/test/src/all.py b/test/src/all.py index 96f9062..0a6bd61 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -18,7 +18,7 @@ import importlib import os # Export / other tests -from .core import test_all +from .core import test_all # noqa: F401 DEFAULT_TESTS = [ "arp", @@ -26,11 +26,12 @@ DEFAULT_TESTS = [ "http", "icmpv4", "icmpv6", - "ip46", + "ip", "rpc", "smb", "ssh", "stun", + "tcp", ] ENABLED_TESTS = DEFAULT_TESTS diff --git a/test/src/core.py b/test/src/core.py index a08e4d0..87f0844 100644 --- a/test/src/core.py +++ b/test/src/core.py @@ -36,6 +36,7 @@ LOG = setup_logs() TESTS = [] ERRORS = [] + # decorator to automatically add a function to tests def test(f): global ERRORS, TESTS diff --git a/test/src/tests/ip.py b/test/src/tests/ip.py new file mode 100644 index 0000000..f87fb75 --- /dev/null +++ b/test/src/tests/ip.py @@ -0,0 +1,50 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from scapy.layers.inet import IP, ICMP +from scapy.layers.l2 import Ether +from scapy.sendrecv import srp1 + +from ..conf import IPV4_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum + + +@test +def test_ipv4_req(): + ##### IP ##### + ip_req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, id=0x1337) / ICMP(type=8, code=0) + ip_repl = srp1(ip_req, timeout=1) + assert ip_repl is not None, "expecting answer, got nothing" + check_ip_checksum(ip_repl) + assert IP in ip_repl, "no IP layer in response" + ip_repl = ip_repl[IP] + assert ip_repl.id == 0, "IP identification unexpected" + + +@test +def test_eth_req_other_mac(): + #### ETH #### + ip_req = Ether(dst="00:00:00:11:11:11") / IP(dst=IPV4_ADDR) / ICMP(type=8, code=0) + ip_repl = srp1(ip_req, timeout=1) + assert ip_repl is None, "responding to other MAC addresses" + + +@test +def test_ipv4_req_other_ip(): + ##### IP ##### + ip_req = Ether(dst=MAC_ADDR) / IP(dst="1.2.3.4") / ICMP(type=8, code=0) + ip_repl = srp1(ip_req, timeout=1) + assert ip_repl is None, "responding to other IP addresses" diff --git a/test/src/tests/ip46.py b/test/src/tests/tcp.py similarity index 88% rename from test/src/tests/ip46.py rename to test/src/tests/tcp.py index 62f3912..1b0d00e 100644 --- a/test/src/tests/ip46.py +++ b/test/src/tests/tcp.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . -from scapy.layers.inet import IP, ICMP, TCP +from scapy.layers.inet import IP, TCP from scapy.layers.inet6 import IPv6 from scapy.layers.l2 import Ether from scapy.packet import Raw @@ -25,34 +25,6 @@ from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR from ..core import test, check_ip_checksum, check_ipv6_checksum -@test -def test_ipv4_req(): - ##### IP ##### - ip_req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, id=0x1337) / ICMP(type=8, code=0) - ip_repl = srp1(ip_req, timeout=1) - assert ip_repl is not None, "expecting answer, got nothing" - check_ip_checksum(ip_repl) - assert IP in ip_repl, "no IP layer in response" - ip_repl = ip_repl[IP] - assert ip_repl.id == 0, "IP identification unexpected" - - -@test -def test_eth_req_other_mac(): - #### ETH #### - ip_req = Ether(dst="00:00:00:11:11:11") / IP(dst=IPV4_ADDR) / ICMP(type=8, code=0) - ip_repl = srp1(ip_req, timeout=1) - assert ip_repl is None, "responding to other MAC addresses" - - -@test -def test_ipv4_req_other_ip(): - ##### IP ##### - ip_req = Ether(dst=MAC_ADDR) / IP(dst="1.2.3.4") / ICMP(type=8, code=0) - ip_repl = srp1(ip_req, timeout=1) - assert ip_repl is None, "responding to other IP addresses" - - @test def test_tcp_syn(): ##### SYN-ACK ##### From f1368df0dea4626eee33a1809d8d6b1e003470af Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 08:08:54 +0100 Subject: [PATCH 063/317] Add test to highlight bug - protocol parsing state not kept --- test/src/tests/http.py | 74 ++++++++++++++++++++++++++++++++++++++++-- test/src/tests/rpc.py | 19 ++++++++--- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/test/src/tests/http.py b/test/src/tests/http.py index 811d9ff..2e829ff 100644 --- a/test/src/tests/http.py +++ b/test/src/tests/http.py @@ -74,6 +74,74 @@ def test_ipv4_tcp_http(): assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") +@test +def test_ipv4_tcp_http_segmented(): + sport = 24592 + dports = [80, 443, 5000, 53228] + for dport in dports: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags="S", sport=sport, dport=dport, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got nothing" + check_ip_checksum(syn_ack) + assert TCP in syn_ack, "expecting TCP, got %r" % syn_ack.summary() + syn_ack = syn_ack[TCP] + assert syn_ack.flags == "SA", "expecting TCP SA, got %r" % syn_ack.flags + ack = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="A", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + ) + _ = srp1(ack, timeout=1) + # request is not complete yet + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + 1, + ack=syn_ack.seq + 1, + ) + / Raw("GET / HTTP/1.1\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + assert resp[TCP].flags == "A" + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP( + flags="PA", + sport=sport, + dport=dport, + seq=seq_init + len(req) + 1, + ack=syn_ack.seq + 1, + ) + / Raw("\r\n") + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert TCP in resp, "expecting TCP, got %r" % resp.summary() + tcp = resp[TCP] + assert tcp.flags == "PA" + assert tcp.payload.load.startswith(b"HTTP/1.1 401 Unauthorized\n") + + @test def test_ipv4_tcp_http_incomplete(): sport = 24595 @@ -126,7 +194,7 @@ def test_ipv4_tcp_http_incomplete(): @test def test_ipv6_tcp_http(): - sport = 24592 + sport = 24594 dports = [80, 443, 5000, 53228] for dport in dports: seq_init = int(RandInt()) @@ -213,7 +281,7 @@ def test_ipv6_udp_http(): @test def test_ipv4_tcp_http_ko(): - sport = 24592 + sport = 24596 dports = [80, 443, 5000, 53228] for dport in dports: seq_init = int(RandInt()) @@ -277,7 +345,7 @@ def test_ipv4_udp_http_ko(): @test def test_ipv6_tcp_http_ko(): - sport = 24592 + sport = 24597 dports = [80, 443, 5000, 53228] for dport in dports: seq_init = int(RandInt()) diff --git a/test/src/tests/rpc.py b/test/src/tests/rpc.py index 62e42a1..8f2e5ce 100644 --- a/test/src/tests/rpc.py +++ b/test/src/tests/rpc.py @@ -56,17 +56,26 @@ def test_rpc_nmap(): result = results[0] assert len(result["ports"]) == 1, f"Expected 1 port, got {len(result['ports'])}" port = result["ports"][0] - assert port["port"] == 111 and port["protocol"] == ( + assert port["port"] == 111, f"Expected port 111, got {port['port']}" + assert port["protocol"] == ( "tcp" if scan == "S" else "udp" - ) - assert port["service_name"] in {"rpcbind", "nfs"} - assert port["service_extrainfo"] in {"RPC #100000", "RPC #100003"} + ), f"Unexpected proto {port['protocol']} for scan {scan}" + assert port["service_name"] in { + "rpcbind", + "nfs", + }, f"Unexpected service_name: {port['service_name']}" + assert port["service_extrainfo"] in { + "RPC #100000", + "RPC #100003", + }, f"Unexpected service_extrainfo: {port['service_extrainfo']}" assert ( len(port["scripts"]) == 1 ), f"Expected 1 script, got {len(port['scripts'])}" script = port["scripts"][0] assert script["id"] == "rpcinfo", "Expected rpcinfo script, not found" - assert len(script["rpcinfo"]) == 1 + assert ( + len(script["rpcinfo"]) == 1 + ), f"Expected 1 rpcinfo, got {len(script['rpcinfo'])}" @test From fe2fd6ca5b4305c2e517edf1dde1e6e2bbaffb27 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 23 Dec 2021 09:05:40 +0100 Subject: [PATCH 064/317] Add TCB argument to repl functions in protos --- src/proto/ghost.rs | 2 ++ src/proto/http.rs | 4 +++- src/proto/mod.rs | 45 ++++++++++++++++++++++++++++----------------- src/proto/rpc.rs | 5 ++++- src/proto/ssh.rs | 4 +++- src/proto/stun.rs | 10 ++++++---- 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/proto/ghost.rs b/src/proto/ghost.rs index 98ca4dd..73d482e 100644 --- a/src/proto/ghost.rs +++ b/src/proto/ghost.rs @@ -21,6 +21,7 @@ use flate2::write::ZlibEncoder; use flate2::Compression; use crate::client::ClientInfo; +use crate::proto::TCPControlBlock; use crate::Masscanned; pub const GHOST_PATTERN_SIGNATURE: &[u8; 5] = b"Gh0st"; @@ -29,6 +30,7 @@ pub fn repl<'a>( _data: &'a [u8], _masscanned: &Masscanned, _client_info: &mut ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving Gh0st data, sending one null byte payload"); // Packet structure: diff --git a/src/proto/http.rs b/src/proto/http.rs index 8879c54..6fd037e 100644 --- a/src/proto/http.rs +++ b/src/proto/http.rs @@ -25,6 +25,7 @@ use crate::smack::{ Smack, SmackFlags, BASE_STATE, NO_MATCH, SMACK_CASE_INSENSITIVE, UNANCHORED_STATE, }; use crate::Masscanned; +use crate::proto::{TCPControlBlock}; pub const HTTP_VERBS: [&str; 9] = [ "GET", "PUT", "POST", "HEAD", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH", @@ -62,7 +63,7 @@ const HTTP_STATE_CONTENT: usize = 64; const HTTP_STATE_FAIL: usize = 0xFFFF; -struct ProtocolState { +pub struct ProtocolState { state: usize, state_bis: usize, smack_state: usize, @@ -223,6 +224,7 @@ pub fn repl<'a>( data: &'a [u8], _masscanned: &Masscanned, _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving HTTP data"); let mut pstate = ProtocolState::new(); diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 2c780d1..9d5e81d 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -25,7 +25,7 @@ use crate::smack::{Smack, SmackFlags, BASE_STATE, NO_MATCH, SMACK_CASE_SENSITIVE use crate::Masscanned; mod http; -use http::HTTP_VERBS; +use http::{ProtocolState as HTTPProtocolState, HTTP_VERBS}; mod stun; use stun::{STUN_PATTERN_CHANGE_REQUEST, STUN_PATTERN_EMPTY, STUN_PATTERN_MAGIC}; @@ -37,7 +37,7 @@ mod ghost; use ghost::GHOST_PATTERN_SIGNATURE; mod rpc; -use rpc::{RPC_CALL_TCP, RPC_CALL_UDP}; +use rpc::{ProtocolState as RPCProtocolState, RPC_CALL_TCP, RPC_CALL_UDP}; mod smb; use smb::{SMB1_PATTERN_MAGIC, SMB2_PATTERN_MAGIC}; @@ -51,8 +51,16 @@ const PROTO_RPC_UDP: usize = 6; const PROTO_SMB1: usize = 7; const PROTO_SMB2: usize = 8; -struct TCPControlBlock { - proto_state: usize, +enum ProtocolState { + HTTPProtocolState, + RPCProtocolState, +} + +pub struct TCPControlBlock { + /* state used to detect protocols (not specific) */ + smack_state: usize, + /* internal state of protocol parser (e.g., HTTP parsing) */ + proto_state: Option, } lazy_static! { @@ -126,26 +134,29 @@ pub fn repl<'a>( ) -> Option> { debug!("packet payload: {:?}", data); let mut id; + let mut ct = CONTABLE.lock().unwrap(); + let mut tcb = None; if client_info.transport == Some(IpNextHeaderProtocols::Tcp) && client_info.cookie == None { error!("Unexpected empty cookie"); return None; } else if client_info.cookie != None { /* proto over TCP */ let cookie = client_info.cookie.unwrap(); - let mut ct = CONTABLE.lock().unwrap(); if !ct.contains_key(&cookie) { ct.insert( cookie, TCPControlBlock { - proto_state: BASE_STATE, + smack_state: BASE_STATE, + proto_state: None, }, ); } let mut i = 0; - let mut tcb = ct.get_mut(&cookie).unwrap(); - let mut state = tcb.proto_state; + let mut t = ct.get_mut(&cookie).unwrap(); + let mut state = t.smack_state; id = PROTO_SMACK.search_next(&mut state, data, &mut i); - tcb.proto_state = state; + t.smack_state = state; + tcb = Some(t); } else { /* proto over else (e.g., UDP) */ let mut i = 0; @@ -158,14 +169,14 @@ pub fn repl<'a>( } /* proto over else (e.g., UDP) */ match id { - PROTO_HTTP => http::repl(data, masscanned, client_info), - PROTO_STUN => stun::repl(data, masscanned, &mut client_info), - PROTO_SSH => ssh::repl(data, masscanned, &mut client_info), - PROTO_GHOST => ghost::repl(data, masscanned, &mut client_info), - PROTO_RPC_TCP => rpc::repl_tcp(data, masscanned, &mut client_info), - PROTO_RPC_UDP => rpc::repl_udp(data, masscanned, &mut client_info), - PROTO_SMB1 => smb::repl_smb1(data, masscanned, &mut client_info), - PROTO_SMB2 => smb::repl_smb2(data, masscanned, &mut client_info), + PROTO_HTTP => http::repl(data, masscanned, client_info, tcb), + PROTO_STUN => stun::repl(data, masscanned, &mut client_info, tcb), + PROTO_SSH => ssh::repl(data, masscanned, &mut client_info, tcb), + PROTO_GHOST => ghost::repl(data, masscanned, &mut client_info, tcb), + PROTO_RPC_TCP => rpc::repl_tcp(data, masscanned, &mut client_info, tcb), + PROTO_RPC_UDP => rpc::repl_udp(data, masscanned, &mut client_info, tcb), + PROTO_SMB1 => smb::repl_smb1(data, masscanned, &mut client_info, tcb), + PROTO_SMB2 => smb::repl_smb2(data, masscanned, &mut client_info, tcb), _ => { debug!("id: {}", id); None diff --git a/src/proto/rpc.rs b/src/proto/rpc.rs index 7a30b19..b87d18f 100644 --- a/src/proto/rpc.rs +++ b/src/proto/rpc.rs @@ -19,6 +19,7 @@ use std::convert::TryInto; use std::net::IpAddr; use crate::client::ClientInfo; +use crate::proto::TCPControlBlock; use crate::Masscanned; // last fragment (1 bit) + fragment len (31 bits) / length XID (random) / message type: call (0) / RPC version (0-255) / Program: Portmap (99840 - 100095) / Program version (*, random versions used, see below) / / Procedure: ??? (0-255) @@ -47,7 +48,7 @@ enum RpcState { } #[derive(Debug)] -struct ProtocolState { +pub struct ProtocolState { state: RpcState, last_frag: bool, frag_len: u32, @@ -373,6 +374,7 @@ pub fn repl_tcp<'a>( data: &'a [u8], _masscanned: &Masscanned, client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { let mut pstate = ProtocolState::new(); rpc_parse(&mut pstate, data); @@ -402,6 +404,7 @@ pub fn repl_udp<'a>( data: &'a [u8], _masscanned: &Masscanned, client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { let mut pstate = ProtocolState::new(); pstate.state = RpcState::Xid; diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 49e18b5..22b8f42 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -19,14 +19,16 @@ use log::*; use std::str; use crate::client::ClientInfo; +use crate::proto::TCPControlBlock; use crate::Masscanned; pub const SSH_PATTERN_CLIENT_PROTOCOL: &[u8; 7] = b"SSH-2.0"; pub fn repl<'a>( data: &'a [u8], - _masscanned: &Masscanned, + _masscanned: &Masscanned, mut _client_info: &mut ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving SSH data"); let repl_data = b"SSH-2.0-1\r\n".to_vec(); diff --git a/src/proto/stun.rs b/src/proto/stun.rs index 7dce6bc..9edef5c 100644 --- a/src/proto/stun.rs +++ b/src/proto/stun.rs @@ -24,6 +24,7 @@ use byteorder::{BigEndian, ByteOrder}; use std::io; use crate::client::ClientInfo; +use crate::proto::TCPControlBlock; use crate::Masscanned; /* RFC 5389: The magic cookie field MUST contain the fixed value 0x2112A442 in @@ -354,6 +355,7 @@ pub fn repl<'a>( data: &'a [u8], _masscanned: &Masscanned, mut client_info: &mut ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving STUN data"); let stun_req: StunPacket = if let Ok(s) = StunPacket::new(&data) { @@ -443,7 +445,7 @@ mod tests { ip_addresses: Some(&ips), log: MetaLogger::new(), }; - let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { + let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got None"); @@ -507,7 +509,7 @@ mod tests { client_info.ip.dst = Some(IpAddr::V6(masscanned_ip_addr)); client_info.port.src = Some(55000); client_info.port.dst = Some(65000); - let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { + let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got None"); @@ -559,7 +561,7 @@ mod tests { client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); client_info.port.src = Some(55000); client_info.port.dst = Some(65000); - let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { + let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got None"); @@ -609,7 +611,7 @@ mod tests { client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); client_info.port.src = Some(55000); client_info.port.dst = Some(65535); - let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { + let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got None"); From 4152f19fe21945e1eed1268c91e1b56b54991da0 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 07:37:31 +0100 Subject: [PATCH 065/317] Cargo Format --- src/proto/http.rs | 2 +- src/proto/ssh.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto/http.rs b/src/proto/http.rs index 6fd037e..45398fd 100644 --- a/src/proto/http.rs +++ b/src/proto/http.rs @@ -21,11 +21,11 @@ use lazy_static::lazy_static; use std::str; use crate::client::ClientInfo; +use crate::proto::TCPControlBlock; use crate::smack::{ Smack, SmackFlags, BASE_STATE, NO_MATCH, SMACK_CASE_INSENSITIVE, UNANCHORED_STATE, }; use crate::Masscanned; -use crate::proto::{TCPControlBlock}; pub const HTTP_VERBS: [&str; 9] = [ "GET", "PUT", "POST", "HEAD", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH", diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 22b8f42..2944ac0 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -26,7 +26,7 @@ pub const SSH_PATTERN_CLIENT_PROTOCOL: &[u8; 7] = b"SSH-2.0"; pub fn repl<'a>( data: &'a [u8], - _masscanned: &Masscanned, + _masscanned: &Masscanned, mut _client_info: &mut ClientInfo, _tcb: Option<&mut TCPControlBlock>, ) -> Option> { From 997b6ae2b659d0acd63f2bb5f5f991e30341ff36 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 09:36:20 +0100 Subject: [PATCH 066/317] Add protocol id in TCB --- src/proto/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 9d5e81d..c80a3a6 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -42,6 +42,7 @@ use rpc::{ProtocolState as RPCProtocolState, RPC_CALL_TCP, RPC_CALL_UDP}; mod smb; use smb::{SMB1_PATTERN_MAGIC, SMB2_PATTERN_MAGIC}; +const PROTO_NONE: usize = 0; const PROTO_HTTP: usize = 1; const PROTO_STUN: usize = 2; const PROTO_SSH: usize = 3; @@ -52,13 +53,15 @@ const PROTO_SMB1: usize = 7; const PROTO_SMB2: usize = 8; enum ProtocolState { - HTTPProtocolState, - RPCProtocolState, + HTTP(HTTPProtocolState), + RPC(RPCProtocolState), } pub struct TCPControlBlock { /* state used to detect protocols (not specific) */ smack_state: usize, + /* detected protocol */ + proto_id: usize, /* internal state of protocol parser (e.g., HTTP parsing) */ proto_state: Option, } @@ -147,6 +150,7 @@ pub fn repl<'a>( cookie, TCPControlBlock { smack_state: BASE_STATE, + proto_id: PROTO_NONE, proto_state: None, }, ); From 5922dcd3708761c8f48799713085f844f11abfe2 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 09:37:03 +0100 Subject: [PATCH 067/317] Add unit tests for protocol ID and protocol state over TCP packets --- src/proto/mod.rs | 167 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index c80a3a6..d1fea5b 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -198,6 +198,173 @@ mod tests { use pnet::util::MacAddr; use crate::logger::MetaLogger; + use crate::synackcookie; + + #[test] + fn test_proto_tcb_proto_id() { + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65000); + client_info.port.dst = Some(80); + client_info.transport = Some(IpNextHeaderProtocols::Tcp); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + }; + let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); + client_info.cookie = Some(cookie); + { + let ct = CONTABLE.lock().unwrap(); + if ct.contains_key(&cookie) { + panic!("expected no TCB entry, found one"); + } + } + /***** TEST PROTOCOL ID IN TCB *****/ + let payload = b"GET / HTTP/1.1\r\n"; + repl(&payload.to_vec(), &masscanned, &mut client_info); + { + let mut ct = CONTABLE.lock().unwrap(); + if !ct.contains_key(&cookie) { + panic!("expected a TCB entry, not found"); + } + let t = ct.get_mut(&cookie).unwrap(); + assert!(t.proto_id == PROTO_HTTP); + } + /***** SENDING MORE DATA *****/ + let payload = b"garbage data with no specific format (no protocol)\r\n\r\n"; + repl(&payload.to_vec(), &masscanned, &mut client_info); + { + let mut ct = CONTABLE.lock().unwrap(); + if !ct.contains_key(&cookie) { + panic!("expected a TCB entry, not found"); + } + let t = ct.get_mut(&cookie).unwrap(); + assert!(t.proto_id == PROTO_HTTP); + } + } + + #[test] + fn test_proto_tcb_proto_state_http() { + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65001); + client_info.port.dst = Some(80); + client_info.transport = Some(IpNextHeaderProtocols::Tcp); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + }; + let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); + client_info.cookie = Some(cookie); + { + let ct = CONTABLE.lock().unwrap(); + if ct.contains_key(&cookie) { + panic!("expected no TCB entry, found one"); + } + } + /***** TEST PROTOCOL ID IN TCB *****/ + let payload = b"GET / HTTP/1.1\r\n"; + repl(&payload.to_vec(), &masscanned, &mut client_info); + { + let mut ct = CONTABLE.lock().unwrap(); + if !ct.contains_key(&cookie) { + panic!("expected a TCB entry, not found"); + } + let t = ct.get_mut(&cookie).unwrap(); + assert!(t.proto_id == PROTO_HTTP); + if let Some(ProtocolState::HTTP(_)) = t.proto_state { + } else { + panic!("expected a HTTP protocole state, found None"); + } + } + /***** SENDING MORE DATA *****/ + let payload = b"Field: empty\r\n\r\n"; + /* Should have an answer here */ + if let None = repl(&payload.to_vec(), &masscanned, &mut client_info) { + panic!("expected an HTTP response, got nothing"); + } + { + let mut ct = CONTABLE.lock().unwrap(); + if !ct.contains_key(&cookie) { + panic!("expected a TCB entry, not found"); + } + let t = ct.get_mut(&cookie).unwrap(); + assert!(t.proto_id == PROTO_HTTP); + } + } + + #[test] + fn test_proto_tcb_proto_state_rpc() { + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65002); + client_info.port.dst = Some(80); + client_info.transport = Some(IpNextHeaderProtocols::Tcp); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + }; + let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); + client_info.cookie = Some(cookie); + { + let ct = CONTABLE.lock().unwrap(); + if ct.contains_key(&cookie) { + panic!("expected no TCB entry, found one"); + } + } + /***** TEST PROTOCOL ID IN TCB *****/ + let payload = b"\x80\x00\x00\x28\x72\xfe\x1d\x13\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xa0\x00\x01\x97\x7c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + repl(&payload[0..28].to_vec(), &masscanned, &mut client_info); + { + let mut ct = CONTABLE.lock().unwrap(); + if !ct.contains_key(&cookie) { + panic!("expected a TCB entry, not found"); + } + let t = ct.get_mut(&cookie).unwrap(); + assert!(t.proto_id == PROTO_RPC_TCP); + if let Some(ProtocolState::RPC(_)) = t.proto_state { + } else { + panic!("expected a RPC protocole state, found None"); + } + } + /***** SENDING MORE DATA *****/ + /* Should have an answer here */ + if let None = repl(&payload[28..].to_vec(), &masscanned, &mut client_info) { + panic!("expected a RPC response, got nothing"); + } + { + let mut ct = CONTABLE.lock().unwrap(); + if !ct.contains_key(&cookie) { + panic!("expected a TCB entry, not found"); + } + let t = ct.get_mut(&cookie).unwrap(); + assert!(t.proto_id == PROTO_RPC_TCP); + } + } #[test] fn test_proto_dispatch_stun() { From 0008cae1efc1c6e3b31026848f7a46cf61a64dd0 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 31 Dec 2021 09:37:25 +0100 Subject: [PATCH 068/317] Fix protocol ID and state in TCB --- src/proto/http.rs | 24 +++++++++++++++++++++--- src/proto/mod.rs | 12 +++++++++--- src/proto/rpc.rs | 40 +++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/proto/http.rs b/src/proto/http.rs index 45398fd..5f28e8a 100644 --- a/src/proto/http.rs +++ b/src/proto/http.rs @@ -21,7 +21,7 @@ use lazy_static::lazy_static; use std::str; use crate::client::ClientInfo; -use crate::proto::TCPControlBlock; +use crate::proto::{ProtocolState as GenericProtocolState, TCPControlBlock}; use crate::smack::{ Smack, SmackFlags, BASE_STATE, NO_MATCH, SMACK_CASE_INSENSITIVE, UNANCHORED_STATE, }; @@ -224,10 +224,28 @@ pub fn repl<'a>( data: &'a [u8], _masscanned: &Masscanned, _client_info: &ClientInfo, - _tcb: Option<&mut TCPControlBlock>, + tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving HTTP data"); - let mut pstate = ProtocolState::new(); + let mut state = ProtocolState::new(); + let mut pstate = { + if let Some(t) = tcb { + match t.proto_state { + None => t.proto_state = Some(GenericProtocolState::HTTP(ProtocolState::new())), + Some(GenericProtocolState::HTTP(_)) => {} + _ => { + panic!() + } + }; + if let Some(GenericProtocolState::HTTP(p)) = &mut t.proto_state { + p + } else { + panic!(); + } + } else { + &mut state + } + }; http_parse(&mut pstate, data); if pstate.state == HTTP_STATE_FAIL { debug!("data in not correctly formatted - not responding"); diff --git a/src/proto/mod.rs b/src/proto/mod.rs index d1fea5b..922ce47 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -157,9 +157,12 @@ pub fn repl<'a>( } let mut i = 0; let mut t = ct.get_mut(&cookie).unwrap(); - let mut state = t.smack_state; - id = PROTO_SMACK.search_next(&mut state, data, &mut i); - t.smack_state = state; + if t.proto_id == PROTO_NONE { + let mut state = t.smack_state; + t.proto_id = PROTO_SMACK.search_next(&mut state, data, &mut i); + t.smack_state = state; + } + id = t.proto_id; tcb = Some(t); } else { /* proto over else (e.g., UDP) */ @@ -182,6 +185,9 @@ pub fn repl<'a>( PROTO_SMB1 => smb::repl_smb1(data, masscanned, &mut client_info, tcb), PROTO_SMB2 => smb::repl_smb2(data, masscanned, &mut client_info, tcb), _ => { + if let Some(t) = &mut tcb { + t.proto_id = PROTO_NONE; + } debug!("id: {}", id); None } diff --git a/src/proto/rpc.rs b/src/proto/rpc.rs index b87d18f..932b2f5 100644 --- a/src/proto/rpc.rs +++ b/src/proto/rpc.rs @@ -19,7 +19,7 @@ use std::convert::TryInto; use std::net::IpAddr; use crate::client::ClientInfo; -use crate::proto::TCPControlBlock; +use crate::proto::{ProtocolState as GenericProtocolState, TCPControlBlock}; use crate::Masscanned; // last fragment (1 bit) + fragment len (31 bits) / length XID (random) / message type: call (0) / RPC version (0-255) / Program: Portmap (99840 - 100095) / Program version (*, random versions used, see below) / / Procedure: ??? (0-255) @@ -211,7 +211,7 @@ fn push_string_pad(buffer: &mut Vec, data: String) { } } -fn build_repl_portmap(pstate: ProtocolState, client_info: &ClientInfo) -> Vec { +fn build_repl_portmap(pstate: &mut ProtocolState, client_info: &ClientInfo) -> Vec { let mut resp = Vec::::new(); match pstate.procedure { // 0 => {} @@ -314,7 +314,7 @@ fn build_repl_portmap(pstate: ProtocolState, client_info: &ClientInfo) -> Vec Vec { +fn build_repl_unknownprog(pstate: &mut ProtocolState, _client_info: &ClientInfo) -> Vec { warn!( "Unknown program {}, procedure {}: accepted state 1", pstate.program, pstate.procedure @@ -323,7 +323,7 @@ fn build_repl_unknownprog(pstate: ProtocolState, _client_info: &ClientInfo) -> V vec![0, 0, 0, 1] } -fn build_repl(pstate: ProtocolState, client_info: &ClientInfo) -> Vec { +fn build_repl(pstate: &mut ProtocolState, client_info: &ClientInfo) -> Vec { // TODO: test RPC versions, drop non calls? let mut resp = Vec::::new(); push_u32(&mut resp, pstate.xid); @@ -374,9 +374,27 @@ pub fn repl_tcp<'a>( data: &'a [u8], _masscanned: &Masscanned, client_info: &ClientInfo, - _tcb: Option<&mut TCPControlBlock>, + tcb: Option<&mut TCPControlBlock>, ) -> Option> { - let mut pstate = ProtocolState::new(); + let mut state = ProtocolState::new(); + let mut pstate = { + if let Some(t) = tcb { + match t.proto_state { + None => t.proto_state = Some(GenericProtocolState::RPC(ProtocolState::new())), + Some(GenericProtocolState::RPC(_)) => {} + _ => { + panic!() + } + }; + if let Some(GenericProtocolState::RPC(p)) = &mut t.proto_state { + p + } else { + panic!(); + } + } else { + &mut state + } + }; rpc_parse(&mut pstate, data); // warn!("RPC {:#?}", pstate); let resp = match pstate.state { @@ -413,7 +431,7 @@ pub fn repl_udp<'a>( rpc_parse(&mut pstate, data); // warn!("RPC {:#?}", pstate); match pstate.state { - RpcState::End => Some(build_repl(pstate, client_info)), + RpcState::End => Some(build_repl(&mut pstate, client_info)), _ => None, } } @@ -455,7 +473,7 @@ mod tests { assert!(pstate.creds_data.len() == 0); assert!(pstate.verif_flavor == 0); assert!(pstate.verif_data.len() == 0); - let resp = build_repl(pstate, &CLIENT_INFO); + let resp = build_repl(&mut pstate, &CLIENT_INFO); assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); } @@ -474,7 +492,7 @@ mod tests { assert!(pstate.creds_data.len() == 0); assert!(pstate.verif_flavor == 0); assert!(pstate.verif_data.len() == 0); - let resp = build_repl(pstate, &CLIENT_INFO); + let resp = build_repl(&mut pstate, &CLIENT_INFO); assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); } @@ -494,7 +512,7 @@ mod tests { assert!(pstate.creds_data.len() == 0); assert!(pstate.verif_flavor == 0); assert!(pstate.verif_data.len() == 0); - let resp = build_repl(pstate, &CLIENT_INFO); + let resp = build_repl(&mut pstate, &CLIENT_INFO); assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); } @@ -522,7 +540,7 @@ mod tests { assert!(pstate.creds_data.len() == 0); assert!(pstate.verif_flavor == 0); assert!(pstate.verif_data.len() == 0); - let resp = build_repl(pstate, &CLIENT_INFO); + let resp = build_repl(&mut pstate, &CLIENT_INFO); assert!(resp == b"\x72\xfe\x1d\x13\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04"); } From 950d40fbbdc1e487049b162f2961a34589859fd7 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:43:07 +0100 Subject: [PATCH 069/317] Add TCB in SMB repl functions --- src/proto/smb.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/proto/smb.rs b/src/proto/smb.rs index dcd5993..682ecd8 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -20,6 +20,8 @@ use std::convert::TryInto; use std::time::SystemTime; use crate::client::ClientInfo; +use crate::logger::MetaLogger; +use crate::proto::TCPControlBlock; use crate::Masscanned; // NBTSession + SMB Header @@ -962,6 +964,7 @@ pub fn repl_smb1<'a>( data: &'a [u8], _masscanned: &Masscanned, _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { let mut nbtsession: NBTSession = NBTSession::new(); for byte in data { @@ -974,6 +977,7 @@ pub fn repl_smb2<'a>( data: &'a [u8], _masscanned: &Masscanned, _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, ) -> Option> { let mut nbtsession: NBTSession = NBTSession::new(); for byte in data { @@ -1057,7 +1061,7 @@ mod tests { }; let client_info = ClientInfo::new(); let answer = - repl_smb1(SMB1_REQ_PAYLOAD, &masscanned, &client_info).expect("Error: no answer"); + repl_smb1(SMB1_REQ_PAYLOAD, &masscanned, &client_info, None).expect("Error: no answer"); let expected = [ 0, 0, 1, 149, 255, 83, 77, 66, 114, 0, 0, 0, 0, 152, 7, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 255, 0, 0, 0, 0, 17, 1, 0, 3, 50, 0, 50, 0, 0, 0, 1, 0, 0, 0, 1, 0, @@ -1129,7 +1133,7 @@ mod tests { }; let client_info = ClientInfo::new(); let answer = - repl_smb2(SMB2_REQ_PAYLOAD, &masscanned, &client_info).expect("Error: no answer"); + repl_smb2(SMB2_REQ_PAYLOAD, &masscanned, &client_info, None).expect("Error: no answer"); let expected = [ 0, 0, 1, 192, 254, 83, 77, 66, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, From b74d891385c4b22155dd0141610e0a9f0594b631 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:43:24 +0100 Subject: [PATCH 070/317] Add MetaLogger in TCB unit tests --- src/proto/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 922ce47..854cde2 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -224,6 +224,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); client_info.cookie = Some(cookie); @@ -275,6 +276,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); client_info.cookie = Some(cookie); @@ -333,6 +335,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); client_info.cookie = Some(cookie); From c6118e1448c91e7aed648e5ee01388df4ab48570 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 16 Feb 2022 12:07:48 +0100 Subject: [PATCH 071/317] Fix bug in HTTP segmented test + clean --- src/proto/smb.rs | 1 - test/src/tests/http.py | 6 ++++-- test/src/tests/rpc.py | 4 ++-- test/src/tests/stun.py | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/proto/smb.rs b/src/proto/smb.rs index 682ecd8..d453289 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -20,7 +20,6 @@ use std::convert::TryInto; use std::time::SystemTime; use crate::client::ClientInfo; -use crate::logger::MetaLogger; use crate::proto::TCPControlBlock; use crate::Masscanned; diff --git a/test/src/tests/http.py b/test/src/tests/http.py index 2e829ff..0e266b7 100644 --- a/test/src/tests/http.py +++ b/test/src/tests/http.py @@ -76,7 +76,7 @@ def test_ipv4_tcp_http(): @test def test_ipv4_tcp_http_segmented(): - sport = 24592 + sport = 24593 dports = [80, 443, 5000, 53228] for dport in dports: seq_init = int(RandInt()) @@ -120,7 +120,9 @@ def test_ipv4_tcp_http_segmented(): assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) 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 = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) diff --git a/test/src/tests/rpc.py b/test/src/tests/rpc.py index 8f2e5ce..86cd140 100644 --- a/test/src/tests/rpc.py +++ b/test/src/tests/rpc.py @@ -63,11 +63,11 @@ def test_rpc_nmap(): assert port["service_name"] in { "rpcbind", "nfs", - }, f"Unexpected service_name: {port['service_name']}" + }, f"Unexpected service_name: {port['service_name']}" assert port["service_extrainfo"] in { "RPC #100000", "RPC #100003", - }, f"Unexpected service_extrainfo: {port['service_extrainfo']}" + }, f"Unexpected service_extrainfo: {port['service_extrainfo']}" assert ( len(port["scripts"]) == 1 ), f"Expected 1 script, got {len(port['scripts'])}" diff --git a/test/src/tests/stun.py b/test/src/tests/stun.py index 4062ec9..373e7f0 100644 --- a/test/src/tests/stun.py +++ b/test/src/tests/stun.py @@ -127,9 +127,9 @@ def test_ipv4_udp_stun_change_port(): assert UDP in resp, "no UDP layer found" udp = resp[UDP] assert ( - udp.sport == (dport + 1) % 2**16 + udp.sport == (dport + 1) % 2 ** 16 ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2**16, udp.sport + (dport + 1) % 2 ** 16, udp.sport ) assert ( 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" udp = resp[UDP] assert ( - udp.sport == (dport + 1) % 2**16 + udp.sport == (dport + 1) % 2 ** 16 ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2**16, udp.sport + (dport + 1) % 2 ** 16, udp.sport ) assert ( udp.dport == sport From 9d892d90c2f5a8a9d50c8cb6c3143f9e3b657ec3 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 16 Feb 2022 12:13:19 +0100 Subject: [PATCH 072/317] Run latest version of Black --- test/src/tests/stun.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/src/tests/stun.py b/test/src/tests/stun.py index 373e7f0..4062ec9 100644 --- a/test/src/tests/stun.py +++ b/test/src/tests/stun.py @@ -127,9 +127,9 @@ def test_ipv4_udp_stun_change_port(): assert UDP in resp, "no UDP layer found" udp = resp[UDP] assert ( - udp.sport == (dport + 1) % 2 ** 16 + udp.sport == (dport + 1) % 2**16 ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2 ** 16, udp.sport + (dport + 1) % 2**16, udp.sport ) assert ( 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" udp = resp[UDP] assert ( - udp.sport == (dport + 1) % 2 ** 16 + udp.sport == (dport + 1) % 2**16 ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2 ** 16, udp.sport + (dport + 1) % 2**16, udp.sport ) assert ( udp.dport == sport From b24d0df124eaf11b5c56b4b42fa128cd8505d022 Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Thu, 17 Feb 2022 15:35:15 +0100 Subject: [PATCH 073/317] TCB: move to layer 4 --- src/client/client_info.rs | 4 +- src/layer_4/tcp.rs | 18 ++- src/layer_4/udp.rs | 2 +- src/proto/mod.rs | 236 +++------------------------------ src/proto/tcb.rs | 267 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 302 insertions(+), 225 deletions(-) create mode 100644 src/proto/tcb.rs diff --git a/src/client/client_info.rs b/src/client/client_info.rs index ca26ac0..a6d33a0 100644 --- a/src/client/client_info.rs +++ b/src/client/client_info.rs @@ -21,7 +21,7 @@ use std::net::IpAddr; use pnet::packet::ip::IpNextHeaderProtocol; use pnet::util::MacAddr; -#[derive(PartialEq, Hash, Copy, Clone)] +#[derive(PartialEq, Hash, Copy, Clone, Debug)] pub struct ClientInfoSrcDst { pub src: Option, pub dst: Option, @@ -35,7 +35,7 @@ pub struct ClientInfoSrcDst { * - source and dest. transport port * - syn cookie **/ -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct ClientInfo { pub mac: ClientInfoSrcDst, pub ip: ClientInfoSrcDst, diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index e0dec1d..e3ae3d0 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -49,16 +49,24 @@ pub fn repl<'a, 'b>( }; /* Compute syncookie */ if let Ok(cookie) = synackcookie::generate(&client_info, &masscanned.synack_key) { - if cookie != ackno { - masscanned.log.tcp_drop(tcp_req, client_info); - return None; - } client_info.cookie = Some(cookie); + if !proto::is_tcb_set(cookie) { + /* First Ack: check syncookie, create tcb */ + if cookie != ackno { + masscanned.log.tcp_drop(tcp_req, client_info); + return None; + } + proto::add_tcb(cookie); + } } warn!("ACK to PSH-ACK on port {}", tcp_req.get_destination()); let payload = tcp_req.payload(); /* Any answer to upper-layer protocol? */ - if let Some(repl) = proto::repl(&payload, masscanned, &mut client_info) { + let mut payload_repl = None; + proto::get_tcb(client_info.cookie.unwrap(), |tcb| { + payload_repl = proto::repl(&payload, masscanned, &mut client_info, tcb); + }); + if let Some(repl) = payload_repl { tcp_repl = MutableTcpPacket::owned( [vec![0; MutableTcpPacket::minimum_packet_size()], repl].concat(), ) diff --git a/src/layer_4/udp.rs b/src/layer_4/udp.rs index 75b0b8b..064e01b 100644 --- a/src/layer_4/udp.rs +++ b/src/layer_4/udp.rs @@ -34,7 +34,7 @@ pub fn repl<'a, 'b>( client_info.port.dst = Some(udp_req.get_destination()); let payload = udp_req.payload(); let mut udp_repl; - if let Some(repl) = proto::repl(&payload, masscanned, &mut client_info) { + if let Some(repl) = proto::repl(&payload, masscanned, &mut client_info, None) { udp_repl = MutableUdpPacket::owned( [vec![0; MutableUdpPacket::minimum_packet_size()], repl].concat(), ) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 854cde2..9be5c02 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -17,15 +17,13 @@ use lazy_static::lazy_static; use log::*; use pnet::packet::ip::IpNextHeaderProtocols; -use std::collections::HashMap; -use std::sync::Mutex; use crate::client::ClientInfo; use crate::smack::{Smack, SmackFlags, BASE_STATE, NO_MATCH, SMACK_CASE_SENSITIVE}; use crate::Masscanned; mod http; -use http::{ProtocolState as HTTPProtocolState, HTTP_VERBS}; +use http::HTTP_VERBS; mod stun; use stun::{STUN_PATTERN_CHANGE_REQUEST, STUN_PATTERN_EMPTY, STUN_PATTERN_MAGIC}; @@ -37,11 +35,14 @@ mod ghost; use ghost::GHOST_PATTERN_SIGNATURE; mod rpc; -use rpc::{ProtocolState as RPCProtocolState, RPC_CALL_TCP, RPC_CALL_UDP}; +use rpc::{RPC_CALL_TCP, RPC_CALL_UDP}; mod smb; use smb::{SMB1_PATTERN_MAGIC, SMB2_PATTERN_MAGIC}; +mod tcb; +pub use tcb::{add_tcb, get_tcb, is_tcb_set, ProtocolState, TCPControlBlock}; + const PROTO_NONE: usize = 0; const PROTO_HTTP: usize = 1; const PROTO_STUN: usize = 2; @@ -52,23 +53,8 @@ const PROTO_RPC_UDP: usize = 6; const PROTO_SMB1: usize = 7; const PROTO_SMB2: usize = 8; -enum ProtocolState { - HTTP(HTTPProtocolState), - RPC(RPCProtocolState), -} - -pub struct TCPControlBlock { - /* state used to detect protocols (not specific) */ - smack_state: usize, - /* detected protocol */ - proto_id: usize, - /* internal state of protocol parser (e.g., HTTP parsing) */ - proto_state: Option, -} - lazy_static! { static ref PROTO_SMACK: Smack = proto_init(); - static ref CONTABLE: Mutex> = Mutex::new(HashMap::new()); } fn proto_init() -> Smack { @@ -134,36 +120,22 @@ pub fn repl<'a>( data: &'a [u8], masscanned: &Masscanned, mut client_info: &mut ClientInfo, + mut tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("packet payload: {:?}", data); let mut id; - let mut ct = CONTABLE.lock().unwrap(); - let mut tcb = None; if client_info.transport == Some(IpNextHeaderProtocols::Tcp) && client_info.cookie == None { error!("Unexpected empty cookie"); return None; - } else if client_info.cookie != None { + } else if let Some(t) = &mut tcb { /* proto over TCP */ - let cookie = client_info.cookie.unwrap(); - if !ct.contains_key(&cookie) { - ct.insert( - cookie, - TCPControlBlock { - smack_state: BASE_STATE, - proto_id: PROTO_NONE, - proto_state: None, - }, - ); - } let mut i = 0; - let mut t = ct.get_mut(&cookie).unwrap(); if t.proto_id == PROTO_NONE { let mut state = t.smack_state; t.proto_id = PROTO_SMACK.search_next(&mut state, data, &mut i); t.smack_state = state; } id = t.proto_id; - tcb = Some(t); } else { /* proto over else (e.g., UDP) */ let mut i = 0; @@ -204,176 +176,6 @@ mod tests { use pnet::util::MacAddr; use crate::logger::MetaLogger; - use crate::synackcookie; - - #[test] - fn test_proto_tcb_proto_id() { - let mut client_info = ClientInfo::new(); - let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); - client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); - client_info.port.src = Some(65000); - client_info.port.dst = Some(80); - client_info.transport = Some(IpNextHeaderProtocols::Tcp); - let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); - client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); - let mut ips = HashSet::new(); - ips.insert(IpAddr::V4(masscanned_ip_addr)); - /* Construct masscanned context object */ - let masscanned = Masscanned { - synack_key: [0, 0], - mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), - iface: None, - ip_addresses: Some(&ips), - log: MetaLogger::new(), - }; - let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); - client_info.cookie = Some(cookie); - { - let ct = CONTABLE.lock().unwrap(); - if ct.contains_key(&cookie) { - panic!("expected no TCB entry, found one"); - } - } - /***** TEST PROTOCOL ID IN TCB *****/ - let payload = b"GET / HTTP/1.1\r\n"; - repl(&payload.to_vec(), &masscanned, &mut client_info); - { - let mut ct = CONTABLE.lock().unwrap(); - if !ct.contains_key(&cookie) { - panic!("expected a TCB entry, not found"); - } - let t = ct.get_mut(&cookie).unwrap(); - assert!(t.proto_id == PROTO_HTTP); - } - /***** SENDING MORE DATA *****/ - let payload = b"garbage data with no specific format (no protocol)\r\n\r\n"; - repl(&payload.to_vec(), &masscanned, &mut client_info); - { - let mut ct = CONTABLE.lock().unwrap(); - if !ct.contains_key(&cookie) { - panic!("expected a TCB entry, not found"); - } - let t = ct.get_mut(&cookie).unwrap(); - assert!(t.proto_id == PROTO_HTTP); - } - } - - #[test] - fn test_proto_tcb_proto_state_http() { - let mut client_info = ClientInfo::new(); - let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); - client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); - client_info.port.src = Some(65001); - client_info.port.dst = Some(80); - client_info.transport = Some(IpNextHeaderProtocols::Tcp); - let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); - client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); - let mut ips = HashSet::new(); - ips.insert(IpAddr::V4(masscanned_ip_addr)); - /* Construct masscanned context object */ - let masscanned = Masscanned { - synack_key: [0, 0], - mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), - iface: None, - ip_addresses: Some(&ips), - log: MetaLogger::new(), - }; - let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); - client_info.cookie = Some(cookie); - { - let ct = CONTABLE.lock().unwrap(); - if ct.contains_key(&cookie) { - panic!("expected no TCB entry, found one"); - } - } - /***** TEST PROTOCOL ID IN TCB *****/ - let payload = b"GET / HTTP/1.1\r\n"; - repl(&payload.to_vec(), &masscanned, &mut client_info); - { - let mut ct = CONTABLE.lock().unwrap(); - if !ct.contains_key(&cookie) { - panic!("expected a TCB entry, not found"); - } - let t = ct.get_mut(&cookie).unwrap(); - assert!(t.proto_id == PROTO_HTTP); - if let Some(ProtocolState::HTTP(_)) = t.proto_state { - } else { - panic!("expected a HTTP protocole state, found None"); - } - } - /***** SENDING MORE DATA *****/ - let payload = b"Field: empty\r\n\r\n"; - /* Should have an answer here */ - if let None = repl(&payload.to_vec(), &masscanned, &mut client_info) { - panic!("expected an HTTP response, got nothing"); - } - { - let mut ct = CONTABLE.lock().unwrap(); - if !ct.contains_key(&cookie) { - panic!("expected a TCB entry, not found"); - } - let t = ct.get_mut(&cookie).unwrap(); - assert!(t.proto_id == PROTO_HTTP); - } - } - - #[test] - fn test_proto_tcb_proto_state_rpc() { - let mut client_info = ClientInfo::new(); - let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); - client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); - client_info.port.src = Some(65002); - client_info.port.dst = Some(80); - client_info.transport = Some(IpNextHeaderProtocols::Tcp); - let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); - client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); - let mut ips = HashSet::new(); - ips.insert(IpAddr::V4(masscanned_ip_addr)); - /* Construct masscanned context object */ - let masscanned = Masscanned { - synack_key: [0, 0], - mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), - iface: None, - ip_addresses: Some(&ips), - log: MetaLogger::new(), - }; - let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); - client_info.cookie = Some(cookie); - { - let ct = CONTABLE.lock().unwrap(); - if ct.contains_key(&cookie) { - panic!("expected no TCB entry, found one"); - } - } - /***** TEST PROTOCOL ID IN TCB *****/ - let payload = b"\x80\x00\x00\x28\x72\xfe\x1d\x13\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xa0\x00\x01\x97\x7c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; - repl(&payload[0..28].to_vec(), &masscanned, &mut client_info); - { - let mut ct = CONTABLE.lock().unwrap(); - if !ct.contains_key(&cookie) { - panic!("expected a TCB entry, not found"); - } - let t = ct.get_mut(&cookie).unwrap(); - assert!(t.proto_id == PROTO_RPC_TCP); - if let Some(ProtocolState::RPC(_)) = t.proto_state { - } else { - panic!("expected a RPC protocole state, found None"); - } - } - /***** SENDING MORE DATA *****/ - /* Should have an answer here */ - if let None = repl(&payload[28..].to_vec(), &masscanned, &mut client_info) { - panic!("expected a RPC response, got nothing"); - } - { - let mut ct = CONTABLE.lock().unwrap(); - if !ct.contains_key(&cookie) { - panic!("expected a TCB entry, not found"); - } - let t = ct.get_mut(&cookie).unwrap(); - assert!(t.proto_id == PROTO_RPC_TCP); - } - } #[test] fn test_proto_dispatch_stun() { @@ -401,7 +203,7 @@ mod tests { */ let payload = b"\x00\x01\x00\x00\x21\x12\xa4\x42\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; - let _stun_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { + let _stun_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got nothing"); @@ -415,7 +217,7 @@ mod tests { */ let payload = b"\x00\x01\x00\x00\xaa\xbb\xcc\xdd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; - let _stun_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { + let _stun_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got nothing"); @@ -428,7 +230,7 @@ mod tests { */ let payload = b"\x00\x01\x00\x08\x01\xdb\xd4]4\x9f\xe2RQ\x19\x05,\x93\x14f4\x00\x03\x00\x04\x00\x00\x00\x00"; - let _stun_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info) { + let _stun_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got nothing"); @@ -466,12 +268,12 @@ mod tests { "SSH-2.0-OpenSSH_6.7p1 Raspbian-5+deb8u3", ]; for payload in payloads.iter() { - let _ssh_resp = if let Some(r) = repl(payload.as_bytes(), &masscanned, &mut client_info) - { - r - } else { - panic!("expected an answer, got nothing"); - }; + let _ssh_resp = + if let Some(r) = repl(payload.as_bytes(), &masscanned, &mut client_info, None) { + r + } else { + panic!("expected an answer, got nothing"); + }; } } @@ -498,7 +300,7 @@ mod tests { ]; for payload in payloads.iter() { let _ghost_resp = - if let Some(r) = repl(&payload.to_vec(), &masscanned, &mut client_info) { + if let Some(r) = repl(&payload.to_vec(), &masscanned, &mut client_info, None) { r } else { panic!("expected an answer, got nothing"); @@ -527,12 +329,12 @@ mod tests { }; /***** TEST COMPLETE REQUEST *****/ let payload = b"GET / HTTP/1.1\r\n\r\n"; - if let None = repl(&payload.to_vec(), &masscanned, &mut client_info) { + if let None = repl(&payload.to_vec(), &masscanned, &mut client_info, None) { panic!("expected an answer, got nothing"); } /***** TEST INCOMPLETE REQUEST *****/ let payload = b"GET / HTTP/1.1\r\n"; - if let Some(_) = repl(&payload.to_vec(), &masscanned, &mut client_info) { + if let Some(_) = repl(&payload.to_vec(), &masscanned, &mut client_info, None) { panic!("expected no answer, got one"); } } diff --git a/src/proto/tcb.rs b/src/proto/tcb.rs new file mode 100644 index 0000000..f092eb8 --- /dev/null +++ b/src/proto/tcb.rs @@ -0,0 +1,267 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use lazy_static::lazy_static; + +use std::collections::HashMap; +use std::sync::Mutex; + +use super::http::ProtocolState as HTTPProtocolState; +use super::rpc::ProtocolState as RPCProtocolState; +use crate::proto::{BASE_STATE, PROTO_NONE}; + +pub enum ProtocolState { + HTTP(HTTPProtocolState), + RPC(RPCProtocolState), +} + +pub struct TCPControlBlock { + /* state used to detect protocols (not specific) */ + pub smack_state: usize, + /* detected protocol */ + pub proto_id: usize, + /* internal state of protocol parser (e.g., HTTP parsing) */ + pub proto_state: Option, +} + +lazy_static! { + static ref CONTABLE: Mutex> = Mutex::new(HashMap::new()); +} + +pub fn is_tcb_set(cookie: u32) -> bool { + CONTABLE.lock().unwrap().contains_key(&cookie) +} + +pub fn get_tcb(cookie: u32, mut f: F) +where + F: FnMut(Option<&mut TCPControlBlock>), +{ + f(CONTABLE.lock().unwrap().get_mut(&cookie)); +} + +pub fn add_tcb(cookie: u32) { + let mut ct = CONTABLE.lock().unwrap(); + let tcb = TCPControlBlock { + smack_state: BASE_STATE, + proto_id: PROTO_NONE, + proto_state: None, + }; + if !ct.contains_key(&cookie) { + ct.insert(cookie, tcb); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::HashSet; + use std::net::{IpAddr, Ipv4Addr}; + use std::str::FromStr; + + use pnet::{ + packet::{ip::IpNextHeaderProtocols, tcp::TcpPacket}, + util::MacAddr, + }; + + use crate::client::ClientInfo; + use crate::layer_4::tcp; + use crate::logger::MetaLogger; + use crate::proto::{PROTO_HTTP, PROTO_RPC_TCP}; + use crate::synackcookie; + use crate::Masscanned; + + fn get_dummy_tcp(&client_info: &ClientInfo) -> Vec { + /* Craft a TCP ACK+PUSH packet with correct ports and ack */ + let mut pkt = Vec::new(); + pkt.extend_from_slice(&client_info.port.src.unwrap().to_be_bytes()); + pkt.extend_from_slice(&client_info.port.dst.unwrap().to_be_bytes()); + pkt.extend_from_slice(b"\x00\x00\x00\x00"); + pkt.extend_from_slice(&(client_info.cookie.unwrap() + 1).to_be_bytes()); + pkt.extend_from_slice(b"P\x18 \x00\x00\x00\x00\x00"); + pkt + } + + #[test] + fn test_proto_tcb_proto_id() { + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65000); + client_info.port.dst = Some(80); + client_info.transport = Some(IpNextHeaderProtocols::Tcp); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + log: MetaLogger::new(), + }; + let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); + client_info.cookie = Some(cookie); + assert!(!is_tcb_set(cookie), "expected no TCB entry, found one"); + /***** TEST PROTOCOL ID IN TCB *****/ + let payload = [get_dummy_tcp(&client_info), b"GET / HTTP/1.1\r\n".to_vec()].concat(); + tcp::repl( + &TcpPacket::new(&payload).unwrap(), + &masscanned, + &mut client_info, + ); + assert!(is_tcb_set(cookie), "expected a TCB entry, not found"); + get_tcb(cookie, |t| { + let t = t.unwrap(); + assert!(t.proto_id == PROTO_HTTP); + }); + + /***** SENDING MORE DATA *****/ + let payload = [ + get_dummy_tcp(&client_info), + b"garbage data with no specific format (no protocol)\r\n\r\n".to_vec(), + ] + .concat(); + tcp::repl( + &TcpPacket::new(&payload).unwrap(), + &masscanned, + &mut client_info, + ); + assert!(is_tcb_set(cookie), "expected a TCB entry, not found"); + get_tcb(cookie, |t| { + let t = t.unwrap(); + assert!(t.proto_id == PROTO_HTTP); + }); + } + + #[test] + fn test_proto_tcb_proto_state_http() { + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65001); + client_info.port.dst = Some(80); + client_info.transport = Some(IpNextHeaderProtocols::Tcp); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + log: MetaLogger::new(), + }; + let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); + client_info.cookie = Some(cookie); + assert!(!is_tcb_set(cookie), "expected no TCB entry, found one"); + /***** TEST PROTOCOL ID IN TCB *****/ + let payload = [get_dummy_tcp(&client_info), b"GET / HTTP/1.1\r\n".to_vec()].concat(); + tcp::repl( + &TcpPacket::new(&payload).unwrap(), + &masscanned, + &mut client_info, + ); + assert!(is_tcb_set(cookie), "expected a TCB entry, not found"); + get_tcb(cookie, |t| { + let t = t.unwrap(); + assert!(t.proto_id == PROTO_HTTP); + if let Some(ProtocolState::HTTP(_)) = t.proto_state { + } else { + panic!("expected a HTTP protocole state, found None"); + } + }); + /***** SENDING MORE DATA *****/ + let payload = [ + get_dummy_tcp(&client_info), + b"Field: empty\r\n\r\n".to_vec(), + ] + .concat(); + /* Should have an answer here */ + if let None = tcp::repl( + &TcpPacket::new(&payload).unwrap(), + &masscanned, + &mut client_info, + ) { + panic!("expected an HTTP response, got nothing"); + } + assert!(is_tcb_set(cookie), "expected a TCB entry, not found"); + get_tcb(cookie, |t| { + let t = t.unwrap(); + assert!(t.proto_id == PROTO_HTTP); + }) + } + + #[test] + fn test_proto_tcb_proto_state_rpc() { + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); + client_info.port.src = Some(65002); + client_info.port.dst = Some(80); + client_info.transport = Some(IpNextHeaderProtocols::Tcp); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + client_info.ip.dst = Some(IpAddr::V4(masscanned_ip_addr)); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + log: MetaLogger::new(), + }; + let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); + client_info.cookie = Some(cookie); + assert!(!is_tcb_set(cookie), "expected no TCB entry, found one"); + /***** TEST PROTOCOL ID IN TCB *****/ + let full_payload = b"\x80\x00\x00\x28\x72\xfe\x1d\x13\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xa0\x00\x01\x97\x7c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + let payload = [get_dummy_tcp(&client_info), full_payload[0..28].to_vec()].concat(); + tcp::repl( + &TcpPacket::new(&payload).unwrap(), + &masscanned, + &mut client_info, + ); + assert!(is_tcb_set(cookie), "expected a TCB entry, not found"); + get_tcb(cookie, |t| { + let t = t.unwrap(); + assert!(t.proto_id == PROTO_RPC_TCP); + if let Some(ProtocolState::RPC(_)) = t.proto_state { + } else { + panic!("expected a RPC protocole state, found None"); + } + }); + /***** SENDING MORE DATA *****/ + /* Should have an answer here */ + let payload = [get_dummy_tcp(&client_info), full_payload[28..].to_vec()].concat(); + if let None = tcp::repl( + &TcpPacket::new(&payload).unwrap(), + &masscanned, + &mut client_info, + ) { + panic!("expected a RPC response, got nothing"); + } + assert!(is_tcb_set(cookie), "expected a TCB entry, not found"); + get_tcb(cookie, |t| { + let t = t.unwrap(); + assert!(t.proto_id == PROTO_RPC_TCP); + }); + } +} From dfe49d26defb9381dc8196a8cad49b05c0b3ad28 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 27 Apr 2022 17:50:58 +0200 Subject: [PATCH 074/317] Add SSH wrong banner test --- src/proto/ssh.rs | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 2944ac0..453de24 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -27,7 +27,7 @@ pub const SSH_PATTERN_CLIENT_PROTOCOL: &[u8; 7] = b"SSH-2.0"; pub fn repl<'a>( data: &'a [u8], _masscanned: &Masscanned, - mut _client_info: &mut ClientInfo, + mut _client_info: &ClientInfo, _tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving SSH data"); @@ -39,3 +39,47 @@ pub fn repl<'a>( ); return Some(repl_data); } + +#[cfg(test)] +mod tests { + use super::*; + use crate::client::ClientInfoSrcDst; + use crate::MetaLogger; + use pnet::util::MacAddr; + use std::net::IpAddr; + use std::net::Ipv4Addr; + + const CLIENT_INFO: ClientInfo = ClientInfo { + mac: ClientInfoSrcDst { + src: None, + dst: None, + }, + ip: ClientInfoSrcDst { + src: Some(IpAddr::V4(Ipv4Addr::new(192, 0, 0, 0))), + dst: Some(IpAddr::V4(Ipv4Addr::new(192, 0, 0, 1))), + }, + transport: None, + port: ClientInfoSrcDst { + src: Some(12345), + dst: Some(111), + }, + cookie: None, + }; + #[test] + fn test_ssh_wrong_banner() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr(0, 1, 2, 3, 4, 5), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + stderrlog::new() + .module(module_path!()) + .verbosity(1) + .init() + .expect("error while initializing logging module"); + let req = b"\xff"; + repl(req, &masscanned, &CLIENT_INFO, None); + } +} From 48003a383e978c58408ab0b75ce82638b00a87f9 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 27 Apr 2022 13:15:17 +0200 Subject: [PATCH 075/317] SSH: fix output --- src/proto/ssh.rs | 8 ++------ src/utils/display.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++ src/utils/mod.rs | 4 ++++ 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 src/utils/display.rs diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 453de24..77478e4 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -16,10 +16,9 @@ use log::*; -use std::str; - use crate::client::ClientInfo; use crate::proto::TCPControlBlock; +use crate::utils::byte2str; use crate::Masscanned; pub const SSH_PATTERN_CLIENT_PROTOCOL: &[u8; 7] = b"SSH-2.0"; @@ -33,10 +32,7 @@ pub fn repl<'a>( debug!("receiving SSH data"); let repl_data = b"SSH-2.0-1\r\n".to_vec(); debug!("sending SSH answer"); - warn!( - "SSH server banner to {}", - str::from_utf8(&data).unwrap().trim_end() - ); + warn!("SSH server banner to {}", byte2str(data)); return Some(repl_data); } diff --git a/src/utils/display.rs b/src/utils/display.rs new file mode 100644 index 0000000..45e3d8f --- /dev/null +++ b/src/utils/display.rs @@ -0,0 +1,48 @@ +// This file is part of masscanned. +// Copyright 2021 - 2022 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +static CHARS: [&'static str; 256] = [ + "\\x00", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\x07", "\\x08", "\\x09", + "\\x0a", "\\x0b", "\\x0c", "\\x0d", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", + "\\x14", "\\x15", "\\x16", "\\x17", "\\x18", "\\x19", "\\x1a", "\\x1b", "\\x1c", "\\x1d", + "\\x1e", "\\x1f", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", + "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", + "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", + "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "{", "|", "}", "~", "\\x7f", "\\x80", "\\x81", "\\x82", "\\x83", "\\x84", "\\x85", "\\x86", + "\\x87", "\\x88", "\\x89", "\\x8a", "\\x8b", "\\x8c", "\\x8d", "\\x8e", "\\x8f", "\\x90", + "\\x91", "\\x92", "\\x93", "\\x94", "\\x95", "\\x96", "\\x97", "\\x98", "\\x99", "\\x9a", + "\\x9b", "\\x9c", "\\x9d", "\\x9e", "\\x9f", "\\xa0", "\\xa1", "\\xa2", "\\xa3", "\\xa4", + "\\xa5", "\\xa6", "\\xa7", "\\xa8", "\\xa9", "\\xaa", "\\xab", "\\xac", "\\xad", "\\xae", + "\\xaf", "\\xb0", "\\xb1", "\\xb2", "\\xb3", "\\xb4", "\\xb5", "\\xb6", "\\xb7", "\\xb8", + "\\xb9", "\\xba", "\\xbb", "\\xbc", "\\xbd", "\\xbe", "\\xbf", "\\xc0", "\\xc1", "\\xc2", + "\\xc3", "\\xc4", "\\xc5", "\\xc6", "\\xc7", "\\xc8", "\\xc9", "\\xca", "\\xcb", "\\xcc", + "\\xcd", "\\xce", "\\xcf", "\\xd0", "\\xd1", "\\xd2", "\\xd3", "\\xd4", "\\xd5", "\\xd6", + "\\xd7", "\\xd8", "\\xd9", "\\xda", "\\xdb", "\\xdc", "\\xdd", "\\xde", "\\xdf", "\\xe0", + "\\xe1", "\\xe2", "\\xe3", "\\xe4", "\\xe5", "\\xe6", "\\xe7", "\\xe8", "\\xe9", "\\xea", + "\\xeb", "\\xec", "\\xed", "\\xee", "\\xef", "\\xf0", "\\xf1", "\\xf2", "\\xf3", "\\xf4", + "\\xf5", "\\xf6", "\\xf7", "\\xf8", "\\xf9", "\\xfa", "\\xfb", "\\xfc", "\\xfd", "\\xfe", + "\\xff", +]; + +pub fn byte2str(data: &[u8]) -> String { + let mut result = String::new(); + for byte in data { + result.push_str(CHARS[usize::from(*byte)]); + } + return result; +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3c788a6..f25ca3d 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,3 +1,7 @@ mod parsers; pub use parsers::IpAddrParser; + +mod display; + +pub use display::byte2str; From 44d00831faa0a5b69ece6819bb9ed8306f9055aa Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 27 Apr 2022 19:00:21 +0200 Subject: [PATCH 076/317] Update clap, switch to Command (App deprecated) --- Cargo.toml | 2 +- src/masscanned.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9508504..dc4028d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "3.0.5" +clap = "3.1.12" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" diff --git a/src/masscanned.rs b/src/masscanned.rs index 52ed059..443b38c 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -24,7 +24,7 @@ use std::fs::File; use std::net::IpAddr; use std::str::FromStr; -use clap::{App, Arg}; +use clap::{Arg, Command}; use log::*; use pnet::{ datalink::{self, Channel::Ethernet, DataLinkReceiver, DataLinkSender, NetworkInterface}, @@ -102,7 +102,7 @@ fn reply<'a, 'b>(packet: &'a [u8], masscanned: &Masscanned) -> Option Date: Fri, 13 May 2022 00:45:14 +0000 Subject: [PATCH 077/317] Update pnet requirement from 0.29.0 to 0.30.0 Updates the requirements on [pnet](https://github.com/libpnet/libpnet) to permit the latest version. - [Release notes](https://github.com/libpnet/libpnet/releases) - [Commits](https://github.com/libpnet/libpnet/compare/v0.29.0...v0.29.0) --- updated-dependencies: - dependency-name: pnet dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index dc4028d..541555e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ log = "0.4.11" netdevice = "0.1.1" pcap = "0.9.1" pcap-file = "1.1.1" -pnet = "0.29.0" +pnet = "0.30.0" rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.0" From d6b6de7d3fb18008bf1c53f0041b72f826168c0d Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 19 May 2022 15:25:33 +0200 Subject: [PATCH 078/317] Add test for issue GH#50 --- src/layer_4/tcp.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index e3ae3d0..feb6e29 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -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 { From 28a8f9b0335f53278482a0fc25b654748ceba795 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 19 May 2022 15:26:35 +0200 Subject: [PATCH 079/317] TCP: fix int overflow in ack --- src/layer_4/tcp.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index feb6e29..08f519e 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -78,7 +78,11 @@ pub fn repl<'a, 'b>( .expect("error constructing a TCP packet"); tcp_repl.set_flags(TcpFlags::ACK); } - tcp_repl.set_acknowledgement(tcp_req.get_sequence() + (tcp_req.payload().len() as u32)); + tcp_repl.set_acknowledgement( + tcp_req + .get_sequence() + .wrapping_add(tcp_req.payload().len() as u32), + ); tcp_repl.set_sequence(tcp_req.get_acknowledgement()); } /* Answer to ACK: nothing */ @@ -97,7 +101,7 @@ pub fn repl<'a, 'b>( tcp_repl = MutableTcpPacket::owned(vec![0; MutableTcpPacket::minimum_packet_size()]) .expect("error constructing a TCP packet"); tcp_repl.set_flags(TcpFlags::FIN | TcpFlags::ACK); - tcp_repl.set_acknowledgement(tcp_req.get_sequence() + 1); + tcp_repl.set_acknowledgement(tcp_req.get_sequence().wrapping_add(1)); tcp_repl.set_sequence(tcp_req.get_acknowledgement()); } /* Answer to SYN */ @@ -106,7 +110,7 @@ pub fn repl<'a, 'b>( .expect("error constructing a TCP packet"); tcp_repl.set_flags(TcpFlags::ACK); tcp_repl.set_flags(TcpFlags::SYN | TcpFlags::ACK); - tcp_repl.set_acknowledgement(tcp_req.get_sequence() + 1); + tcp_repl.set_acknowledgement(tcp_req.get_sequence().wrapping_add(1)); /* generate a SYNACK-cookie (same as masscan) */ tcp_repl.set_sequence( synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(), @@ -185,7 +189,7 @@ mod tests { 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 + 1); + assert!(tcp_repl.get_acknowledgement() == seq.wrapping_add(1)); } #[test] From c2adf50f59f69ebc76366aee2f5ebad079535b5c Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 12:19:15 +0200 Subject: [PATCH 080/317] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 541555e..dc4028d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ log = "0.4.11" netdevice = "0.1.1" pcap = "0.9.1" pcap-file = "1.1.1" -pnet = "0.30.0" +pnet = "0.29.0" rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.0" From bf1a2c742978ffba5959b219a24940e529223385 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 14:45:23 +0200 Subject: [PATCH 081/317] Add pytohn tests for empty payload (TCP/UDP) --- test/src/all.py | 1 + test/src/tests/tcp.py | 21 +++++++++++++++++++ test/src/tests/udp.py | 48 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 test/src/tests/udp.py diff --git a/test/src/all.py b/test/src/all.py index 0a6bd61..44a82b3 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -32,6 +32,7 @@ DEFAULT_TESTS = [ "ssh", "stun", "tcp", + "udp", ] ENABLED_TESTS = DEFAULT_TESTS diff --git a/test/src/tests/tcp.py b/test/src/tests/tcp.py index 1b0d00e..3c2ca5e 100644 --- a/test/src/tests/tcp.py +++ b/test/src/tests/tcp.py @@ -24,6 +24,27 @@ from scapy.volatile import RandInt from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR from ..core import test, check_ip_checksum, check_ipv6_checksum +@test +def test_ipv4_tcp_empty(): + for p in [0, 80, 443]: + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR, proto=6) # UDP + / Raw() + ) + repl = srp1(req, timeout=1) + assert repl is None, "expecting no answer, got one" + +@test +def test_ipv6_tcp_empty(): + for p in [0, 80, 443]: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR, nh=6) # UDP + / Raw() + ) + repl = srp1(req, timeout=1) + assert repl is None, "expecting no answer, got one" @test def test_tcp_syn(): diff --git a/test/src/tests/udp.py b/test/src/tests/udp.py new file mode 100644 index 0000000..73421a4 --- /dev/null +++ b/test/src/tests/udp.py @@ -0,0 +1,48 @@ +# This file is part of masscanned. +# Copyright 2021 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from scapy.layers.inet import IP, UDP +from scapy.layers.inet6 import IPv6 +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.sendrecv import srp1 +from scapy.volatile import RandInt + +from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum, check_ipv6_checksum + + +@test +def test_ipv4_udp_empty(): + for p in [0, 53, 1000]: + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR, proto=17) # UDP + / Raw() + ) + repl = srp1(req, timeout=1) + assert repl is None, "expecting no answer, got one" + +@test +def test_ipv6_udp_empty(): + for p in [0, 53, 1000]: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR, nh=17) # UDP + / Raw() + ) + repl = srp1(req, timeout=1) + assert repl is None, "expecting no answer, got one" From 843729b96160037af76968aa739b3bacdb72d0d2 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 14:45:49 +0200 Subject: [PATCH 082/317] Add check for masscanned panic in python tests --- test/src/core.py | 11 ++++++++--- test/test_masscanned.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/src/core.py b/test/src/core.py index 87f0844..450743f 100644 --- a/test/src/core.py +++ b/test/src/core.py @@ -44,9 +44,13 @@ def test(f): KO = "\033[1m\033[1;%dmKO\033[0m" % 31 fname = f.__name__.ljust(50, ".") - def w(): + def w(m): try: + # check that masscanned is still running + assert(m.poll() is None), "masscanned not running" f() + # check that masscanned is still running + assert(m.poll() is None), "masscanned terminated unexpectedly" LOG.info("{}{}".format(fname, OK)) except AssertionError as e: LOG.error("{}{}: {}".format(fname, KO, e)) @@ -56,11 +60,12 @@ def test(f): return w -def test_all(): +def test_all(m): global ERRORS, TESTS # execute tests for t in TESTS: - t() + # perform unit test + t(m) LOG.info(f"\033[1mRan {len(TESTS)} tests with {len(ERRORS)} errors\033[0m") return len(ERRORS) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 232e65a..1f1355e 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -177,7 +177,7 @@ masscanned = subprocess.Popen( sleep(1) try: - result = test_all() + result = test_all(masscanned) except AssertionError: result = -1 From d2d916239d84e70c541055a4ef63822c06c2fe2a Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 14:47:02 +0200 Subject: [PATCH 083/317] Add Rust unit tests for empty payload --- src/layer_2/mod.rs | 37 +++++++++++++++++++++++++++++++++++++ src/layer_3/ipv4.rs | 39 +++++++++++++++++++++++++++++++++++++++ src/layer_3/ipv6.rs | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 5e90e96..74415b0 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -196,6 +196,43 @@ mod tests { use crate::logger::MetaLogger; + #[test] + fn test_eth_empty() { + let payload = b""; + let test_mac_addr = + MacAddr::from_str("55:44:33:22:11:00").expect("error parsing MAC address"); + let mac = MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"); + let mut client_info = ClientInfo::new(); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(Ipv4Addr::new(0xaa, 0x99, 0x88, 0x77))); + ips.insert(IpAddr::V6(Ipv6Addr::new( + 0x7777, 0x7777, 0x7777, 0x7777, 0x7777, 0x7777, 0xaabb, 0xccdd, + ))); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: mac, + iface: None, + ip_addresses: Some(&ips), + log: MetaLogger::new(), + }; + for proto in [EtherTypes::Ipv4, EtherTypes::Ipv6, EtherTypes::Arp] { + let mut eth_req = MutableEthernetPacket::owned(vec![ + 0; + EthernetPacket::minimum_packet_size() + + payload.len() + ]) + .expect("error constructing ethernet packet"); + eth_req.set_source(test_mac_addr); + eth_req.set_payload(payload); + eth_req.set_ethertype(proto); + eth_req.set_destination(mac); + if let Some(_) = reply(ð_req.to_immutable(), &masscanned, &mut client_info) { + panic!("expected no Ethernet answer, got one"); + } + } + } + #[test] fn test_eth_reply() { /* test payload is IP(src="3.2.1.0", dst=".".join(str(b) for b in [0xaa, 0x99, diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index f5d8f25..87c18a9 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -161,6 +161,45 @@ mod tests { use crate::logger::MetaLogger; + #[test] + fn test_ipv4_empty() { + let payload = b""; + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); + let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V4(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + log: MetaLogger::new(), + }; + for proto in [IpNextHeaderProtocols::Tcp, IpNextHeaderProtocols::Udp, IpNextHeaderProtocols::Icmp] { + let mut ip_req = + MutableIpv4Packet::owned(vec![0; Ipv4Packet::minimum_packet_size() + payload.len()]) + .expect("error constructing IPv4 packet"); + ip_req.set_version(4); + ip_req.set_ttl(64); + ip_req.set_identification(0); + ip_req.set_flags(Ipv4Flags::DontFragment); + ip_req.set_source(test_ip_addr); + ip_req.set_header_length(5); + /* Set test payload for layer 4 */ + ip_req.set_total_length(ip_req.packet().len() as u16); + ip_req.set_payload(payload); + /* Set next protocol */ + ip_req.set_next_level_protocol(proto); + /* Send to a legitimate IP address */ + ip_req.set_destination(masscanned_ip_addr); + if let Some(_) = repl(&ip_req.to_immutable(), &masscanned, &mut client_info) { + panic!("expected no IP answer, got one"); + } + } + } + #[test] fn test_ipv4_reply() { /* test payload is scapy> ICMP() */ diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index 1d4128d..737c627 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -170,6 +170,45 @@ mod tests { use crate::logger::MetaLogger; + #[test] + fn test_ipv6_empty() { + let payload = b""; + let mut client_info = ClientInfo::new(); + let test_ip_addr = Ipv6Addr::new( + 0x7777, 0x6666, 0x5555, 0x4444, 0x3333, 0x2222, 0x1111, 0x0000, + ); + let masscanned_ip_addr = Ipv6Addr::new( + 0x0000, 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, + ); + let mut ips = HashSet::new(); + ips.insert(IpAddr::V6(masscanned_ip_addr)); + /* Construct masscanned context object */ + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: Some(&ips), + log: MetaLogger::new(), + }; + for proto in [IpNextHeaderProtocols::Tcp, IpNextHeaderProtocols::Udp, IpNextHeaderProtocols::Icmp] { + let mut ip_req = + MutableIpv6Packet::owned(vec![0; Ipv6Packet::minimum_packet_size() + payload.len()]) + .expect("error constructing IPv6 packet"); + ip_req.set_version(6); + ip_req.set_source(test_ip_addr); + /* Set test payload for layer 4 */ + ip_req.set_payload_length(payload.len() as u16); + ip_req.set_payload(payload); + /* Set next protocol */ + ip_req.set_next_header(proto); + /* Send to a legitimate IP address */ + ip_req.set_destination(masscanned_ip_addr); + if let Some(_) = repl(&ip_req.to_immutable(), &masscanned, &mut client_info) { + panic!("expected no IP answer, got one"); + } + } + } + #[test] fn test_ipv6_reply() { /* test payload is scapy> IPv6(src="7777:6666:5555:4444:3333:2222:1111:0000", From e34f3a6bcddfc532a6b2a8a2d4a5e13dbec62d82 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 14:47:30 +0200 Subject: [PATCH 084/317] Fix bug with empty or misformed payload --- src/layer_2/mod.rs | 16 ++++++++++++++-- src/layer_3/ipv4.rs | 24 +++++++++++++++++++++--- src/layer_3/ipv6.rs | 26 ++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 74415b0..25edf4d 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -123,7 +123,13 @@ pub fn reply<'a, 'b>( match eth_req.get_ethertype() { /* Construct answer to ARP request */ EtherTypes::Arp => { - let arp_req = ArpPacket::new(eth_req.payload()).expect("error parsing ARP packet"); + let arp_req = if let Some(p) = ArpPacket::new(eth_req.payload()) { + p + } else { + warn!("error parsing ARP packet"); + masscanned.log.eth_drop(eth_req, &client_info); + return None; + }; if let Some(arp_repl) = arp::repl(&arp_req, masscanned) { let arp_len = arp_repl.packet().len(); let eth_len = EthernetPacket::minimum_packet_size() + arp_len; @@ -162,7 +168,13 @@ pub fn reply<'a, 'b>( } /* Construct answer to IPv6 packet */ EtherTypes::Ipv6 => { - let ipv6_req = Ipv6Packet::new(eth_req.payload()).expect("error parsing IPv6 packet"); + let ipv6_req = if let Some(p) = Ipv6Packet::new(eth_req.payload()) { + p + } else { + warn!("error parsing IPv6 packet"); + masscanned.log.eth_drop(eth_req, &client_info); + return None; + }; if let Some(ipv6_repl) = layer_3::ipv6::repl(&ipv6_req, masscanned, &mut client_info) { let ipv6_len = ipv6_repl.packet().len(); let eth_len = EthernetPacket::minimum_packet_size() + ipv6_len; diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index 87c18a9..bed0369 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -59,7 +59,13 @@ pub fn repl<'a, 'b>( match ip_req.get_next_level_protocol() { /* Answer to an ICMP packet */ IpNextHeaderProtocols::Icmp => { - let icmp_req = IcmpPacket::new(ip_req.payload()).expect("error parsing ICMP packet"); + let icmp_req = if let Some(p) = IcmpPacket::new(ip_req.payload()) { + p + } else { + warn!("error parsing ICMP packet"); + masscanned.log.ipv4_drop(&ip_req, &client_info); + return None; + }; if let Some(mut icmp_repl) = layer_4::icmpv4::repl(&icmp_req, masscanned, &client_info) { icmp_repl.set_checksum(ipv4_checksum_icmp(&icmp_repl.to_immutable())); @@ -79,7 +85,13 @@ pub fn repl<'a, 'b>( } /* Answer to a TCP packet */ IpNextHeaderProtocols::Tcp => { - let tcp_req = TcpPacket::new(ip_req.payload()).expect("error parsing TCP packet"); + let tcp_req = if let Some(p) = TcpPacket::new(ip_req.payload()) { + p + } else { + warn!("error parsing TCP packet"); + masscanned.log.ipv4_drop(&ip_req, &client_info); + return None; + }; if let Some(mut tcp_repl) = layer_4::tcp::repl(&tcp_req, masscanned, &mut client_info) { tcp_repl.set_checksum(ipv4_checksum_tcp( &tcp_repl.to_immutable(), @@ -102,7 +114,13 @@ pub fn repl<'a, 'b>( } /* Answer to an UDP packet */ IpNextHeaderProtocols::Udp => { - let udp_req = UdpPacket::new(ip_req.payload()).expect("error parsing UDP packet"); + let udp_req = if let Some(p) = UdpPacket::new(ip_req.payload()) { + p + } else { + warn!("error parsing UDP packet"); + masscanned.log.ipv4_drop(&ip_req, &client_info); + return None; + }; if let Some(mut udp_repl) = layer_4::udp::repl(&udp_req, masscanned, &mut client_info) { udp_repl.set_checksum(ipv4_checksum_udp( &udp_repl.to_immutable(), diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index 737c627..160bf93 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Masscanned. If not, see . +use log::*; use std::net::IpAddr; use pnet::packet::{ @@ -61,8 +62,13 @@ pub fn repl<'a, 'b>( match ip_req.get_next_header() { /* Answer to ICMPv6 */ IpNextHeaderProtocols::Icmpv6 => { - let icmp_req = - Icmpv6Packet::new(ip_req.payload()).expect("error parsing ICMPv6 packet"); + let icmp_req = if let Some(p) = Icmpv6Packet::new(ip_req.payload()) { + p + } else { + warn!("error parsing ICMPv6 packet"); + masscanned.log.ipv6_drop(&ip_req, &client_info); + return None; + }; if let (Some(mut icmp_repl), dst_addr) = layer_4::icmpv6::repl(&icmp_req, masscanned, &client_info) { @@ -92,7 +98,13 @@ pub fn repl<'a, 'b>( } /* Answer to TCP */ IpNextHeaderProtocols::Tcp => { - let tcp_req = TcpPacket::new(ip_req.payload()).expect("error parsing TCP packet"); + let tcp_req = if let Some(p) = TcpPacket::new(ip_req.payload()) { + p + } else { + warn!("error parsing TCP packet"); + masscanned.log.ipv6_drop(&ip_req, &client_info); + return None; + }; if let Some(mut tcp_repl) = layer_4::tcp::repl(&tcp_req, masscanned, &mut client_info) { /* Compute and set TCP checksum */ tcp_repl.set_checksum(ipv6_checksum_tcp( @@ -117,7 +129,13 @@ pub fn repl<'a, 'b>( } /* Answer to UDP */ IpNextHeaderProtocols::Udp => { - let udp_req = UdpPacket::new(ip_req.payload()).expect("error parsing UDP packet"); + let udp_req = if let Some(p) = UdpPacket::new(ip_req.payload()) { + p + } else { + warn!("error parsing UDP packet"); + masscanned.log.ipv6_drop(&ip_req, &client_info); + return None; + }; if let Some(mut udp_repl) = layer_4::udp::repl(&udp_req, masscanned, &mut client_info) { /* Compute and set UDP checksum */ udp_repl.set_checksum(ipv6_checksum_udp( From 9fdecf5be71e26acd8952a0caee5ac2d9e38f3c6 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 14:48:55 +0200 Subject: [PATCH 085/317] Cargo format --- src/layer_2/mod.rs | 4 ++-- src/layer_3/ipv4.rs | 15 +++++++++++---- src/layer_3/ipv6.rs | 15 +++++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index 25edf4d..c298d91 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -231,8 +231,8 @@ mod tests { for proto in [EtherTypes::Ipv4, EtherTypes::Ipv6, EtherTypes::Arp] { let mut eth_req = MutableEthernetPacket::owned(vec![ 0; - EthernetPacket::minimum_packet_size() - + payload.len() + EthernetPacket::minimum_packet_size( + ) + payload.len() ]) .expect("error constructing ethernet packet"); eth_req.set_source(test_mac_addr); diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index bed0369..3c2d0ca 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -195,10 +195,17 @@ mod tests { ip_addresses: Some(&ips), log: MetaLogger::new(), }; - for proto in [IpNextHeaderProtocols::Tcp, IpNextHeaderProtocols::Udp, IpNextHeaderProtocols::Icmp] { - let mut ip_req = - MutableIpv4Packet::owned(vec![0; Ipv4Packet::minimum_packet_size() + payload.len()]) - .expect("error constructing IPv4 packet"); + for proto in [ + IpNextHeaderProtocols::Tcp, + IpNextHeaderProtocols::Udp, + IpNextHeaderProtocols::Icmp, + ] { + let mut ip_req = MutableIpv4Packet::owned(vec![ + 0; + Ipv4Packet::minimum_packet_size() + + payload.len() + ]) + .expect("error constructing IPv4 packet"); ip_req.set_version(4); ip_req.set_ttl(64); ip_req.set_identification(0); diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index 160bf93..42e6293 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -208,10 +208,17 @@ mod tests { ip_addresses: Some(&ips), log: MetaLogger::new(), }; - for proto in [IpNextHeaderProtocols::Tcp, IpNextHeaderProtocols::Udp, IpNextHeaderProtocols::Icmp] { - let mut ip_req = - MutableIpv6Packet::owned(vec![0; Ipv6Packet::minimum_packet_size() + payload.len()]) - .expect("error constructing IPv6 packet"); + for proto in [ + IpNextHeaderProtocols::Tcp, + IpNextHeaderProtocols::Udp, + IpNextHeaderProtocols::Icmp, + ] { + let mut ip_req = MutableIpv6Packet::owned(vec![ + 0; + Ipv6Packet::minimum_packet_size() + + payload.len() + ]) + .expect("error constructing IPv6 packet"); ip_req.set_version(6); ip_req.set_source(test_ip_addr); /* Set test payload for layer 4 */ From f696afa45dc33c57ef44fc8b1d7bcaf4089eda24 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 15:28:05 +0200 Subject: [PATCH 086/317] Run Black --- test/src/core.py | 4 ++-- test/src/tests/tcp.py | 15 +++++---------- test/src/tests/udp.py | 13 +++---------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/test/src/core.py b/test/src/core.py index 450743f..35681e6 100644 --- a/test/src/core.py +++ b/test/src/core.py @@ -47,10 +47,10 @@ def test(f): def w(m): try: # check that masscanned is still running - assert(m.poll() is None), "masscanned not running" + assert m.poll() is None, "masscanned not running" f() # check that masscanned is still running - assert(m.poll() is None), "masscanned terminated unexpectedly" + assert m.poll() is None, "masscanned terminated unexpectedly" LOG.info("{}{}".format(fname, OK)) except AssertionError as e: LOG.error("{}{}: {}".format(fname, KO, e)) diff --git a/test/src/tests/tcp.py b/test/src/tests/tcp.py index 3c2ca5e..f42e4fa 100644 --- a/test/src/tests/tcp.py +++ b/test/src/tests/tcp.py @@ -24,28 +24,23 @@ from scapy.volatile import RandInt from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR from ..core import test, check_ip_checksum, check_ipv6_checksum + @test def test_ipv4_tcp_empty(): for p in [0, 80, 443]: - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR, proto=6) # UDP - / Raw() - ) + req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, proto=6) / Raw() # UDP repl = srp1(req, timeout=1) assert repl is None, "expecting no answer, got one" + @test def test_ipv6_tcp_empty(): for p in [0, 80, 443]: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR, nh=6) # UDP - / Raw() - ) + req = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR, nh=6) / Raw() # UDP repl = srp1(req, timeout=1) assert repl is None, "expecting no answer, got one" + @test def test_tcp_syn(): ##### SYN-ACK ##### diff --git a/test/src/tests/udp.py b/test/src/tests/udp.py index 73421a4..db840cb 100644 --- a/test/src/tests/udp.py +++ b/test/src/tests/udp.py @@ -28,21 +28,14 @@ from ..core import test, check_ip_checksum, check_ipv6_checksum @test def test_ipv4_udp_empty(): for p in [0, 53, 1000]: - req = ( - Ether(dst=MAC_ADDR) - / IP(dst=IPV4_ADDR, proto=17) # UDP - / Raw() - ) + req = Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR, proto=17) / Raw() # UDP repl = srp1(req, timeout=1) assert repl is None, "expecting no answer, got one" + @test def test_ipv6_udp_empty(): for p in [0, 53, 1000]: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR, nh=17) # UDP - / Raw() - ) + req = Ether(dst=MAC_ADDR) / IPv6(dst=IPV6_ADDR, nh=17) / Raw() # UDP repl = srp1(req, timeout=1) assert repl is None, "expecting no answer, got one" From c59893c2a668327ea389ec4835a898869d8a6b53 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Mon, 30 May 2022 17:27:51 +0200 Subject: [PATCH 087/317] Run Flake8 --- test/src/tests/udp.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/src/tests/udp.py b/test/src/tests/udp.py index db840cb..55522f5 100644 --- a/test/src/tests/udp.py +++ b/test/src/tests/udp.py @@ -14,15 +14,14 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . -from scapy.layers.inet import IP, UDP +from scapy.layers.inet import IP from scapy.layers.inet6 import IPv6 from scapy.layers.l2 import Ether from scapy.packet import Raw from scapy.sendrecv import srp1 -from scapy.volatile import RandInt from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR -from ..core import test, check_ip_checksum, check_ipv6_checksum +from ..core import test @test From 6eecc91ce4d9f51f8352ee52c2de33aff938129c Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Wed, 16 Feb 2022 11:55:38 +0100 Subject: [PATCH 088/317] Reply to SMB2 SessionSetup --- src/proto/smb.rs | 112 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 87 insertions(+), 25 deletions(-) diff --git a/src/proto/smb.rs b/src/proto/smb.rs index d453289..ecb3f5d 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -30,7 +30,8 @@ pub const SMB1_PATTERN_MAGIC: &[u8; 8] = b"\x00\x00**\xffSMB"; pub const SMB2_PATTERN_MAGIC: &[u8; 8] = b"\x00\x00**\xfeSMB"; // Build/Dissect secblob with Scapy using: GSSAPI_BLOB(b"`\x82.....") -const SECURITY_BLOB: &[u8; 320] = b"`\x82\x01<\x06\x06+\x06\x01\x05\x05\x02\xa0\x82\x0100\x82\x01,\xa0\x1a0\x18\x06\n+\x06\x01\x04\x01\x827\x02\x02\x1e\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2\x82\x01\x0c\x04\x82\x01\x08NEGOEXTS\x01\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00p\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\xf4Rk\x17\x03\x8aK\x91\xc2\t}\x9a\x8f\xe6,\x96\\Q$/\x90MG\xc7\xad\x8f\x87k\"\x02\xbf\xc6\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08NEGOEXTS\x03\x00\x00\x00\x01\x00\x00\x00@\x00\x00\x00\x98\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08@\x00\x00\x00X\x00\x00\x000V\xa0T0R0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key"; +const SECURITY_BLOB_NEG_PROTO: &[u8] = b"`\x82\x01<\x06\x06+\x06\x01\x05\x05\x02\xa0\x82\x0100\x82\x01,\xa0\x1a0\x18\x06\n+\x06\x01\x04\x01\x827\x02\x02\x1e\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2\x82\x01\x0c\x04\x82\x01\x08NEGOEXTS\x01\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00p\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\xf4Rk\x17\x03\x8aK\x91\xc2\t}\x9a\x8f\xe6,\x96\\Q$/\x90MG\xc7\xad\x8f\x87k\"\x02\xbf\xc6\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08NEGOEXTS\x03\x00\x00\x00\x01\x00\x00\x00@\x00\x00\x00\x98\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08@\x00\x00\x00X\x00\x00\x000V\xa0T0R0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key"; +const SECURITY_BLOB_CHALLENGE: &[u8] = b"\xa1\x81\x9c0\x81\x99\xa0\x03\n\x01\x01\xa1\x0c\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2\x81\x83\x04\x81\x80NTLMSSP\x00\x02\x00\x00\x00\x08\x00\x08\x008\x00\x00\x00\x15\x82\x8a\xe2$\x91\xa8\xf6\xf3\x89-4\x00\x00\x00\x00\x00\x00\x00\x00@\x00@\x00@\x00\x00\x00\n\x00aJ\x00\x00\x00\x0fW\x00I\x00N\x001\x00\x02\x00\x08\x00W\x00I\x00N\x001\x00\x01\x00\x08\x00W\x00I\x00N\x001\x00\x04\x00\x08\x00W\x00I\x00N\x001\x00\x03\x00\x08\x00W\x00I\x00N\x001\x00\x07\x00\x08\x00\xff&9\xf5B\x1d\xd8\x01\x00\x00\x00\x00"; //////////// // Common // @@ -323,7 +324,7 @@ impl SMB1Header { } // 0x73 => { // // Setup - // SMB1Payload::SetupRequest(SMB2SetupRequest::new()) + // SMB1Payload::SessionSetupRequest(SMB2SessionSetupRequest::new()) // } _ => None?, }); @@ -445,10 +446,10 @@ impl MPacket for SMB1NegotiateRequest { resp.extend_from_slice(&time.to_le_bytes()); // ServerTime resp.extend_from_slice(&0x3c_u16.to_le_bytes()); // ServerTimeZone resp.push(0); // ChallengeLength - resp.extend_from_slice(&((SECURITY_BLOB.len() + 16) as u16).to_le_bytes()); // ByteCount - // Challenge: Empty + resp.extend_from_slice(&((SECURITY_BLOB_NEG_PROTO.len() + 16) as u16).to_le_bytes()); // ByteCount + // Challenge: Empty resp.extend_from_slice(&[0_u8; 16]); // GUID - resp.extend_from_slice(SECURITY_BLOB); // SecurityBlob + resp.extend_from_slice(SECURITY_BLOB_NEG_PROTO); // SecurityBlob warn!("SMB1 Negotiate-Protocol-Reply ({})", dialect_name); Some(resp) } @@ -483,13 +484,13 @@ impl SMB1Payload { fn repl(&self) -> Option> { match self { SMB1Payload::NegotiateRequest(x) => x.repl(), - // SMB1Payload::SetupRequest(x) => x.repl(), + // SMB1Payload::SessionSetupRequest(x) => x.repl(), } } fn parse(&mut self, byte: &u8) { match self { SMB1Payload::NegotiateRequest(x) => x.parse(byte), - // SMB1Payload::SetupRequest(x) => x.repl(), + // SMB1Payload::SessionSetupRequest(x) => x.repl(), } } } @@ -663,7 +664,7 @@ impl SMB2Header { } 0x0001 => { // Setup - SMB2Payload::SetupRequest(SMB2SetupRequest::new()) + SMB2Payload::SessionSetupRequest(SMB2SessionSetupRequest::new()) } _ => None?, }); @@ -822,9 +823,9 @@ impl MPacket for SMB2NegotiateRequest { resp.extend_from_slice(&time.to_le_bytes()); // ServerTime resp.extend_from_slice(&time.to_le_bytes()); // ServerStartTime resp.extend_from_slice(&0x80_u16.to_le_bytes()); // SecurityBloboffset - resp.extend_from_slice(&(SECURITY_BLOB.len() as u16).to_le_bytes()); // SecurityBlobLength + resp.extend_from_slice(&(SECURITY_BLOB_NEG_PROTO.len() as u16).to_le_bytes()); // SecurityBlobLength resp.extend_from_slice(&0x0_u32.to_le_bytes()); // NegotiateContextOffset - resp.extend_from_slice(SECURITY_BLOB); // SecurityBlobw + resp.extend_from_slice(SECURITY_BLOB_NEG_PROTO); // SecurityBlobw warn!("SMB2 Negotiate-Protocol-Reply ({})", dialect_name); Some(resp) } @@ -845,7 +846,7 @@ enum SMB2SetupRequestState { } #[derive(Debug, Clone)] -struct SMB2SetupRequest { +struct SMB2SessionSetupRequest { // DISSECTION d: PacketDissector, // STRUCT @@ -858,9 +859,9 @@ struct SMB2SetupRequest { security_len: u16, previous_session_id: u64, } -impl MPacket for SMB2SetupRequest { +impl MPacket for SMB2SessionSetupRequest { fn new() -> Self { - SMB2SetupRequest { + SMB2SessionSetupRequest { d: PacketDissector::new(SMB2SetupRequestState::StructureSize), structure_size: 0, flags: 0, @@ -930,27 +931,37 @@ impl MPacket for SMB2SetupRequest { } fn repl(&self) -> Option> { - None + if !matches!(self.d.state, SMB2SetupRequestState::End) { + return None; + } + let mut resp: Vec = Vec::new(); + resp.extend_from_slice(&0x9_u16.to_le_bytes()); // StructureSize + resp.extend_from_slice(&0x0_u16.to_le_bytes()); // SessionFlags + resp.extend_from_slice(&0x48_u16.to_le_bytes()); // SecurityBufferOffset + resp.extend_from_slice(&(SECURITY_BLOB_CHALLENGE.len() as u16).to_le_bytes()); // SecurityLen + resp.extend_from_slice(SECURITY_BLOB_CHALLENGE); // SecurityBlob + warn!("SMB2 Setup-Reply"); + Some(resp) } } #[derive(Debug, Clone)] enum SMB2Payload { NegotiateRequest(SMB2NegotiateRequest), - SetupRequest(SMB2SetupRequest), + SessionSetupRequest(SMB2SessionSetupRequest), } impl SMB2Payload { fn repl(&self) -> Option> { match self { SMB2Payload::NegotiateRequest(x) => x.repl(), - SMB2Payload::SetupRequest(x) => x.repl(), + SMB2Payload::SessionSetupRequest(x) => x.repl(), } } fn parse(&mut self, byte: &u8) { match self { SMB2Payload::NegotiateRequest(x) => x.parse(byte), - SMB2Payload::SetupRequest(x) => x.parse(byte), + SMB2Payload::SessionSetupRequest(x) => x.parse(byte), } } } @@ -999,15 +1010,16 @@ mod tests { use std::str::FromStr; // Sent by `smbclient -U "" -N -L 10.1.1.1 -d10 --option='client min protocol=NT1'` - const SMB1_REQ_PAYLOAD: &[u8] = b"\x00\x00\x00T\xffSMBr\x00\x00\x00\x00\x18C\xc8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\x00\x00\x00\x00\x001\x00\x02NT LANMAN 1.0\x00\x02NT LM 0.12\x00\x02SMB 2.002\x00\x02SMB 2.???\x00"; + const SMB1_REQ_NEGOTIATE: &[u8] = b"\x00\x00\x00T\xffSMBr\x00\x00\x00\x00\x18C\xc8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\x00\x00\x00\x00\x001\x00\x02NT LANMAN 1.0\x00\x02NT LM 0.12\x00\x02SMB 2.002\x00\x02SMB 2.???\x00"; // Sent by `smbclient -U "" -N -L 10.1.1.1 -d10` - const SMB2_REQ_PAYLOAD: &[u8] = b"\x00\x00\x00\xd0\xfeSMB@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00$\x00\x08\x00\x01\x00\x00\x00\x7f\x00\x00\x00\rr3\x97\"c\x8fA\x9f\xe0\xbawQ\x87rbx\x00\x00\x00\x03\x00\x00\x00\x02\x02\x10\x02\"\x02$\x02\x00\x03\x02\x03\x10\x03\x11\x03\x00\x00\x00\x00\x01\x00&\x00\x00\x00\x00\x00\x01\x00 \x00\x01\x00\xd5Z\x89\x87>\x80\xcd\x02\xc2\xab\x08\xa3\xf4\x94\xb6A\x05\x11V\xeeE\x19p\x19\xed\x17v\xda\x9b\x08\x99V\x00\x00\x02\x00\x06\x00\x00\x00\x00\x00\x02\x00\x02\x00\x01\x00\x00\x00\x05\x00\x10\x00\x00\x00\x00\x001\x000\x00.\x001\x00.\x001\x00.\x001\x00"; + const SMB2_REQ_NEGOTIATE: &[u8] = b"\x00\x00\x00\xd0\xfeSMB@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00$\x00\x08\x00\x01\x00\x00\x00\x7f\x00\x00\x00\rr3\x97\"c\x8fA\x9f\xe0\xbawQ\x87rbx\x00\x00\x00\x03\x00\x00\x00\x02\x02\x10\x02\"\x02$\x02\x00\x03\x02\x03\x10\x03\x11\x03\x00\x00\x00\x00\x01\x00&\x00\x00\x00\x00\x00\x01\x00 \x00\x01\x00\xd5Z\x89\x87>\x80\xcd\x02\xc2\xab\x08\xa3\xf4\x94\xb6A\x05\x11V\xeeE\x19p\x19\xed\x17v\xda\x9b\x08\x99V\x00\x00\x02\x00\x06\x00\x00\x00\x00\x00\x02\x00\x02\x00\x01\x00\x00\x00\x05\x00\x10\x00\x00\x00\x00\x001\x000\x00.\x001\x00.\x001\x00.\x001\x00"; + const SMB2_REQ_SESSION_SETUP: &[u8] = b"\x00\x00\x00\xa2\xfeSMB@\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00X\x00J\x00\x00\x00\x00\x00\x00\x00\x00\x00`H\x06\x06+\x06\x01\x05\x05\x02\xa0>0<\xa0\x0e0\x0c\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2*\x04(NTLMSSP\x00\x01\x00\x00\x00\x15\x82\x08b\x00\x00\x00\x00(\x00\x00\x00\x00\x00\x00\x00(\x00\x00\x00\x06\x01\x00\x00\x00\x00\x00\x0f"; // You can dissect any of those payloads with Scapy using NBTSession(b"...") #[test] fn test_smb1_protocol_nego_parsing() { let mut nbtsession: NBTSession = NBTSession::new(); - nbtsession.parse_all(SMB1_REQ_PAYLOAD); + nbtsession.parse_all(SMB1_REQ_NEGOTIATE); assert_eq!(nbtsession.nb_type, 0); assert_eq!(nbtsession.length, 0x54); let smb1 = nbtsession.payload.expect("Error while unpacking SMB"); @@ -1059,8 +1071,8 @@ mod tests { log: MetaLogger::new(), }; let client_info = ClientInfo::new(); - let answer = - repl_smb1(SMB1_REQ_PAYLOAD, &masscanned, &client_info, None).expect("Error: no answer"); + let answer = repl_smb1(SMB1_REQ_NEGOTIATE, &masscanned, &client_info, None) + .expect("Error: no answer"); let expected = [ 0, 0, 1, 149, 255, 83, 77, 66, 114, 0, 0, 0, 0, 152, 7, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 255, 0, 0, 0, 0, 17, 1, 0, 3, 50, 0, 50, 0, 0, 0, 1, 0, 0, 0, 1, 0, @@ -1088,7 +1100,7 @@ mod tests { #[test] fn test_smb2_protocol_nego_parsing() { let mut nbtsession: NBTSession = NBTSession::new(); - nbtsession.parse_all(SMB2_REQ_PAYLOAD); + nbtsession.parse_all(SMB2_REQ_NEGOTIATE); assert_eq!(nbtsession.nb_type, 0); assert_eq!(nbtsession.length, 0xd0); let smb2 = nbtsession.payload.expect("No SMB2 payload found !"); @@ -1131,8 +1143,8 @@ mod tests { log: MetaLogger::new(), }; let client_info = ClientInfo::new(); - let answer = - repl_smb2(SMB2_REQ_PAYLOAD, &masscanned, &client_info, None).expect("Error: no answer"); + let answer = repl_smb2(SMB2_REQ_NEGOTIATE, &masscanned, &client_info, None) + .expect("Error: no answer"); let expected = [ 0, 0, 1, 192, 254, 83, 77, 66, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1158,4 +1170,54 @@ mod tests { assert_eq!(answer[..0x6c], expected[..0x6c]); // Test equality except the 2 "ServerTime" fields assert_eq!(answer[0x6c + 16..], expected[0x6c + 16..]); } + #[test] + fn test_smb2_session_setup_request_parse() { + let mut nbtsession: NBTSession = NBTSession::new(); + nbtsession.parse_all(SMB2_REQ_SESSION_SETUP); + assert_eq!(nbtsession.nb_type, 0); + assert_eq!(nbtsession.length, 0xa2); + let smb2 = nbtsession.payload.expect("Error while unpacking SMB"); + assert_eq!(&smb2.start, b"\xfeSMB"); + assert_eq!(smb2.command, 1); + assert_eq!(smb2.status, 0); + assert_eq!(smb2.flags, 0); + let sess_setup_req = match smb2.payload.expect("Error while reading payload") { + SMB2Payload::SessionSetupRequest(x) => x, + _ => panic!("Bad type"), + }; + assert_eq!(sess_setup_req.structure_size, 0x19); + assert_eq!(sess_setup_req.flags, 0); + assert_eq!(sess_setup_req.security_mode, 1); + assert_eq!(sess_setup_req.capabilities, 1); + assert_eq!(sess_setup_req.channel, 0); + assert_eq!(sess_setup_req.security_buffer_offset, 0x58); + assert_eq!(sess_setup_req.security_len, 74); + assert_eq!(sess_setup_req.previous_session_id, 0); + } + #[test] + fn test_smb2_session_setup_request_reply() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let client_info = ClientInfo::new(); + let answer = repl_smb2(SMB2_REQ_SESSION_SETUP, &masscanned, &client_info, None) + .expect("Error: no answer"); + let expected = [ + 0, 0, 0, 231, 254, 83, 77, 66, 64, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 72, 0, 159, 0, 161, 129, 156, 48, + 129, 153, 160, 3, 10, 1, 1, 161, 12, 6, 10, 43, 6, 1, 4, 1, 130, 55, 2, 2, 10, 162, + 129, 131, 4, 129, 128, 78, 84, 76, 77, 83, 83, 80, 0, 2, 0, 0, 0, 8, 0, 8, 0, 56, 0, 0, + 0, 21, 130, 138, 226, 36, 145, 168, 246, 243, 137, 45, 52, 0, 0, 0, 0, 0, 0, 0, 0, 64, + 0, 64, 0, 64, 0, 0, 0, 10, 0, 97, 74, 0, 0, 0, 15, 87, 0, 73, 0, 78, 0, 49, 0, 2, 0, 8, + 0, 87, 0, 73, 0, 78, 0, 49, 0, 1, 0, 8, 0, 87, 0, 73, 0, 78, 0, 49, 0, 4, 0, 8, 0, 87, + 0, 73, 0, 78, 0, 49, 0, 3, 0, 8, 0, 87, 0, 73, 0, 78, 0, 49, 0, 7, 0, 8, 0, 255, 38, + 57, 245, 66, 29, 216, 1, 0, 0, 0, 0, + ]; + assert_eq!(answer, expected); + } } From ea65f23a6c8c6c8a1fbd78e6201e38b7d2cb23bb Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Wed, 16 Feb 2022 13:52:10 +0100 Subject: [PATCH 089/317] Reply to SMB1 SessionSetup --- src/proto/smb.rs | 262 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 235 insertions(+), 27 deletions(-) diff --git a/src/proto/smb.rs b/src/proto/smb.rs index ecb3f5d..1d17a3b 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -322,10 +322,10 @@ impl SMB1Header { // Negotiate SMB1Payload::NegotiateRequest(SMB1NegotiateRequest::new()) } - // 0x73 => { - // // Setup - // SMB1Payload::SessionSetupRequest(SMB2SessionSetupRequest::new()) - // } + 0x73 => { + // Setup + SMB1Payload::SessionSetupRequest(SMB1SessionSetupRequest::new()) + } _ => None?, }); self.payload.as_mut() @@ -455,42 +455,186 @@ impl MPacket for SMB1NegotiateRequest { } } -// #[derive(Debug, Clone)] -// struct SMB1SetupRequest { -// -// } +#[derive(Debug, Clone, Copy)] +enum SMB1SessionSetupRequestState { + WordCount, + AndXCommand, + AndXReserved, + AndXOffset, + MaxBufferSize, + MaxMPXCount, + VcNumber, + SessionKey, + SecurityBlobLength, + Reserved, + ServerCapabilities, + ByteCount, + SecurityBlob, + End, +} -// impl SMB1SetupRequest { -// // TODO -// fn new(data: &[u8]) -> Option { -// if data.len() < 38 { -// return None; -// } -// None -// } +#[derive(Debug, Clone)] +struct SMB1SessionSetupRequest { + // DISSECTION + d: PacketDissector, + // STRUCT + word_count: u8, + and_x_command: u8, + and_x_offset: u16, + max_buffer_size: u16, + max_mpx_count: u16, + vc_number: u16, + session_key: u32, + security_len: u16, + server_capabilities: u32, + byte_count: u16, +} -// fn repl(&self) -> Option> { -// None -// } -// } +impl MPacket for SMB1SessionSetupRequest { + fn new() -> SMB1SessionSetupRequest { + Self { + d: PacketDissector::new(SMB1SessionSetupRequestState::WordCount), + word_count: 0, + and_x_command: 0, + and_x_offset: 0, + max_buffer_size: 0, + max_mpx_count: 0, + vc_number: 0, + session_key: 0, + security_len: 0, + server_capabilities: 0, + byte_count: 0, + } + } + fn parse(&mut self, byte: &u8) { + // We expect extended security because that's what we asked for in the NegotiateRequest + match self.d.state { + SMB1SessionSetupRequestState::WordCount => { + self.word_count = *byte; + self.d.next_state(SMB1SessionSetupRequestState::AndXCommand); + } + SMB1SessionSetupRequestState::AndXCommand => { + self.and_x_command = *byte; + self.d + .next_state(SMB1SessionSetupRequestState::AndXReserved); + } + SMB1SessionSetupRequestState::AndXReserved => { + self.d.next_state(SMB1SessionSetupRequestState::AndXOffset); + } + SMB1SessionSetupRequestState::AndXOffset => { + self.and_x_offset = self.d.read_ule16( + byte, + self.and_x_offset, + SMB1SessionSetupRequestState::MaxBufferSize, + ); + } + SMB1SessionSetupRequestState::MaxBufferSize => { + self.max_buffer_size = self.d.read_ule16( + byte, + self.max_buffer_size, + SMB1SessionSetupRequestState::MaxMPXCount, + ); + } + SMB1SessionSetupRequestState::MaxMPXCount => { + self.max_mpx_count = self.d.read_ule16( + byte, + self.max_mpx_count, + SMB1SessionSetupRequestState::VcNumber, + ); + } + SMB1SessionSetupRequestState::VcNumber => { + self.vc_number = self.d.read_ule16( + byte, + self.vc_number, + SMB1SessionSetupRequestState::SessionKey, + ); + } + SMB1SessionSetupRequestState::SessionKey => { + self.session_key = self.d.read_ule32( + byte, + self.session_key, + SMB1SessionSetupRequestState::SecurityBlobLength, + ); + } + SMB1SessionSetupRequestState::SecurityBlobLength => { + self.security_len = self.d.read_ule16( + byte, + self.security_len, + SMB1SessionSetupRequestState::Reserved, + ); + } + SMB1SessionSetupRequestState::Reserved => { + self.d.i += 1; + self.d + .next_state_when_i_reaches(SMB1SessionSetupRequestState::ServerCapabilities, 4); + } + SMB1SessionSetupRequestState::ServerCapabilities => { + self.server_capabilities = self.d.read_ule32( + byte, + self.server_capabilities, + SMB1SessionSetupRequestState::ByteCount, + ); + } + SMB1SessionSetupRequestState::ByteCount => { + self.byte_count = self.d.read_ule16( + byte, + self.byte_count, + SMB1SessionSetupRequestState::SecurityBlob, + ); + } + SMB1SessionSetupRequestState::SecurityBlob => { + self.d.i += 1; + self.d.next_state_when_i_reaches( + SMB1SessionSetupRequestState::End, + self.security_len as usize, + ); + } + SMB1SessionSetupRequestState::End => {} + } + } + fn repl(&self) -> Option> { + if !matches!(self.d.state, SMB1SessionSetupRequestState::End) { + return None; + } + // "Windows 4.0" in UTF-16 + two null bytes + let native_os = b"W\x00i\x00n\x00d\x00o\x00w\x00s\x00 \x004\x00.\x000\x00\x00\x00"; + let native_man_lan = native_os; + let mut resp: Vec = Vec::new(); + resp.push(0x4); // WordCount + resp.push(0xff); // AndXCommand + resp.push(0x0); // AndXReserved + resp.extend_from_slice(&0x44_u16.to_le_bytes()); // AndXOffset + resp.extend_from_slice(&0x0_u16.to_le_bytes()); // Action + resp.extend_from_slice(&(SECURITY_BLOB_CHALLENGE.len() as u16).to_le_bytes()); // SecurityLen + resp.extend_from_slice( + &((SECURITY_BLOB_CHALLENGE.len() + native_os.len() + native_man_lan.len()) as u16) + .to_le_bytes(), + ); // ByteCount + resp.extend_from_slice(SECURITY_BLOB_CHALLENGE); // SecurityBlob + resp.extend_from_slice(native_os); + resp.extend_from_slice(native_man_lan); + warn!("SMB1 SessionSetup-Reply"); + Some(resp) + } +} #[derive(Debug, Clone)] enum SMB1Payload { NegotiateRequest(SMB1NegotiateRequest), - // SetupRequest(SMB1SetupRequest), + SessionSetupRequest(SMB1SessionSetupRequest), } impl SMB1Payload { fn repl(&self) -> Option> { match self { SMB1Payload::NegotiateRequest(x) => x.repl(), - // SMB1Payload::SessionSetupRequest(x) => x.repl(), + SMB1Payload::SessionSetupRequest(x) => x.repl(), } } fn parse(&mut self, byte: &u8) { match self { SMB1Payload::NegotiateRequest(x) => x.parse(byte), - // SMB1Payload::SessionSetupRequest(x) => x.repl(), + SMB1Payload::SessionSetupRequest(x) => x.parse(byte), } } } @@ -825,7 +969,7 @@ impl MPacket for SMB2NegotiateRequest { resp.extend_from_slice(&0x80_u16.to_le_bytes()); // SecurityBloboffset resp.extend_from_slice(&(SECURITY_BLOB_NEG_PROTO.len() as u16).to_le_bytes()); // SecurityBlobLength resp.extend_from_slice(&0x0_u32.to_le_bytes()); // NegotiateContextOffset - resp.extend_from_slice(SECURITY_BLOB_NEG_PROTO); // SecurityBlobw + resp.extend_from_slice(SECURITY_BLOB_NEG_PROTO); // SecurityBlob warn!("SMB2 Negotiate-Protocol-Reply ({})", dialect_name); Some(resp) } @@ -923,8 +1067,11 @@ impl MPacket for SMB2SessionSetupRequest { ); } SMB2SetupRequestState::SecurityBlob => { - // TODO ? Not super useful TBH, also this is ASN.1 :/// - self.d.next_state(SMB2SetupRequestState::End); + self.d.i += 1; + self.d.next_state_when_i_reaches( + SMB2SetupRequestState::End, + self.security_len as usize, + ); } SMB2SetupRequestState::End => {} } @@ -940,7 +1087,7 @@ impl MPacket for SMB2SessionSetupRequest { resp.extend_from_slice(&0x48_u16.to_le_bytes()); // SecurityBufferOffset resp.extend_from_slice(&(SECURITY_BLOB_CHALLENGE.len() as u16).to_le_bytes()); // SecurityLen resp.extend_from_slice(SECURITY_BLOB_CHALLENGE); // SecurityBlob - warn!("SMB2 Setup-Reply"); + warn!("SMB2 SessionSetup-Reply"); Some(resp) } } @@ -1011,6 +1158,7 @@ mod tests { // Sent by `smbclient -U "" -N -L 10.1.1.1 -d10 --option='client min protocol=NT1'` const SMB1_REQ_NEGOTIATE: &[u8] = b"\x00\x00\x00T\xffSMBr\x00\x00\x00\x00\x18C\xc8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\x00\x00\x00\x00\x001\x00\x02NT LANMAN 1.0\x00\x02NT LM 0.12\x00\x02SMB 2.002\x00\x02SMB 2.???\x00"; + const SMB1_REQ_SESSION_SETUP: &[u8] = b"\x00\x00\x00\x9c\xffSMBs\x00\x00\x00\x00\x18C\xc8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x89T\x00\x00\x01\x00\x0c\xff\x00\x00\x00\xff\xff\x02\x00\x01\x00\x00\x00\x00\x00J\x00\x00\x00\x00\x00T\xc0\x00\x80a\x00`H\x06\x06+\x06\x01\x05\x05\x02\xa0>0<\xa0\x0e0\x0c\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2*\x04(NTLMSSP\x00\x01\x00\x00\x00\x15\x82\x08b\x00\x00\x00\x00(\x00\x00\x00\x00\x00\x00\x00(\x00\x00\x00\x06\x01\x00\x00\x00\x00\x00\x0f\x00U\x00n\x00i\x00x\x00\x00\x00S\x00a\x00m\x00b\x00a\x00\x00\x00"; // Sent by `smbclient -U "" -N -L 10.1.1.1 -d10` const SMB2_REQ_NEGOTIATE: &[u8] = b"\x00\x00\x00\xd0\xfeSMB@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00$\x00\x08\x00\x01\x00\x00\x00\x7f\x00\x00\x00\rr3\x97\"c\x8fA\x9f\xe0\xbawQ\x87rbx\x00\x00\x00\x03\x00\x00\x00\x02\x02\x10\x02\"\x02$\x02\x00\x03\x02\x03\x10\x03\x11\x03\x00\x00\x00\x00\x01\x00&\x00\x00\x00\x00\x00\x01\x00 \x00\x01\x00\xd5Z\x89\x87>\x80\xcd\x02\xc2\xab\x08\xa3\xf4\x94\xb6A\x05\x11V\xeeE\x19p\x19\xed\x17v\xda\x9b\x08\x99V\x00\x00\x02\x00\x06\x00\x00\x00\x00\x00\x02\x00\x02\x00\x01\x00\x00\x00\x05\x00\x10\x00\x00\x00\x00\x001\x000\x00.\x001\x00.\x001\x00.\x001\x00"; const SMB2_REQ_SESSION_SETUP: &[u8] = b"\x00\x00\x00\xa2\xfeSMB@\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00X\x00J\x00\x00\x00\x00\x00\x00\x00\x00\x00`H\x06\x06+\x06\x01\x05\x05\x02\xa0>0<\xa0\x0e0\x0c\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2*\x04(NTLMSSP\x00\x01\x00\x00\x00\x15\x82\x08b\x00\x00\x00\x00(\x00\x00\x00\x00\x00\x00\x00(\x00\x00\x00\x06\x01\x00\x00\x00\x00\x00\x0f"; @@ -1036,6 +1184,7 @@ mod tests { assert_eq!(smb1.mid, 0); let neg_request = match smb1.payload.expect("Error while reading payload") { SMB1Payload::NegotiateRequest(x) => x, + _ => panic!("Bad payload"), }; assert_eq!(neg_request.word_count, 0); assert_eq!(neg_request.byte_count, 49); @@ -1098,6 +1247,65 @@ mod tests { assert_eq!(answer[0x3c + 8..], expected[0x3c + 8..]); } #[test] + fn test_smb1_session_setup_request_parse() { + let mut nbtsession: NBTSession = NBTSession::new(); + nbtsession.parse_all(SMB1_REQ_SESSION_SETUP); + assert_eq!(nbtsession.nb_type, 0); + assert_eq!(nbtsession.length, 0x9c); + let smb1 = nbtsession.payload.expect("Error while unpacking SMB"); + assert_eq!(&smb1.start, b"\xffSMB"); + assert_eq!(smb1.command, 0x73); + assert_eq!(smb1.status, 0); + assert_eq!(smb1.flags, 24); + assert_eq!(smb1.flags2, 0xc843); + assert_eq!(smb1.pid_high, 0); + assert_eq!(smb1.tid, 0); + assert_eq!(smb1.pid_low, 21641); + assert_eq!(smb1.uid, 0); + assert_eq!(smb1.mid, 1); + let sess_setup_req = match smb1.payload.expect("Error while reading payload") { + SMB1Payload::SessionSetupRequest(x) => x, + _ => panic!("Bad type"), + }; + assert_eq!(sess_setup_req.word_count, 12); + assert_eq!(sess_setup_req.and_x_command, 0xff); + assert_eq!(sess_setup_req.and_x_offset, 0); + assert_eq!(sess_setup_req.max_buffer_size, 0xffff); + assert_eq!(sess_setup_req.max_mpx_count, 2); + assert_eq!(sess_setup_req.vc_number, 1); + assert_eq!(sess_setup_req.session_key, 0); + assert_eq!(sess_setup_req.security_len, 74); + assert_eq!(sess_setup_req.server_capabilities, 0x8000c054); + assert_eq!(sess_setup_req.server_capabilities, 0x8000c054); + } + #[test] + fn test_smb1_session_setup_request_reply() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let client_info = ClientInfo::new(); + let answer = repl_smb1(SMB1_REQ_SESSION_SETUP, &masscanned, &client_info, None) + .expect("Error: no answer"); + let expected = [ + 0, 0, 0, 250, 255, 83, 77, 66, 115, 0, 0, 0, 0, 152, 7, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 137, 84, 0, 0, 1, 0, 4, 255, 0, 68, 0, 0, 0, 159, 0, 207, 0, 161, 129, + 156, 48, 129, 153, 160, 3, 10, 1, 1, 161, 12, 6, 10, 43, 6, 1, 4, 1, 130, 55, 2, 2, 10, + 162, 129, 131, 4, 129, 128, 78, 84, 76, 77, 83, 83, 80, 0, 2, 0, 0, 0, 8, 0, 8, 0, 56, + 0, 0, 0, 21, 130, 138, 226, 36, 145, 168, 246, 243, 137, 45, 52, 0, 0, 0, 0, 0, 0, 0, + 0, 64, 0, 64, 0, 64, 0, 0, 0, 10, 0, 97, 74, 0, 0, 0, 15, 87, 0, 73, 0, 78, 0, 49, 0, + 2, 0, 8, 0, 87, 0, 73, 0, 78, 0, 49, 0, 1, 0, 8, 0, 87, 0, 73, 0, 78, 0, 49, 0, 4, 0, + 8, 0, 87, 0, 73, 0, 78, 0, 49, 0, 3, 0, 8, 0, 87, 0, 73, 0, 78, 0, 49, 0, 7, 0, 8, 0, + 255, 38, 57, 245, 66, 29, 216, 1, 0, 0, 0, 0, 87, 0, 105, 0, 110, 0, 100, 0, 111, 0, + 119, 0, 115, 0, 32, 0, 52, 0, 46, 0, 48, 0, 0, 0, 87, 0, 105, 0, 110, 0, 100, 0, 111, + 0, 119, 0, 115, 0, 32, 0, 52, 0, 46, 0, 48, 0, 0, 0, + ]; + assert_eq!(answer, expected); + } + #[test] fn test_smb2_protocol_nego_parsing() { let mut nbtsession: NBTSession = NBTSession::new(); nbtsession.parse_all(SMB2_REQ_NEGOTIATE); From 379f48ed8060f4c8bbf9a20af9cdbde87688438e Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:12:19 +0200 Subject: [PATCH 090/317] Add dependency to iterate over enums (for tests) --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index dc4028d..872d250 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,8 @@ pnet = "0.29.0" rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.0" +strum = "0.24.1" +strum_macros = "0.24.2" [[bin]] name = "masscanned" From 0dd0e1d6458cd2cc9a86cc953c352794c5efb60f Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:13:09 +0200 Subject: [PATCH 091/317] Add DNS implementation - Query and RR for IN/A --- src/proto/dns/cst.rs | 93 ++++++ src/proto/dns/header.rs | 383 ++++++++++++++++++++++ src/proto/dns/mod.rs | 687 ++++++++++++++++++++++++++++++++++++++++ src/proto/dns/query.rs | 335 ++++++++++++++++++++ src/proto/dns/rr.rs | 251 +++++++++++++++ 5 files changed, 1749 insertions(+) create mode 100644 src/proto/dns/cst.rs create mode 100644 src/proto/dns/header.rs create mode 100644 src/proto/dns/mod.rs create mode 100644 src/proto/dns/query.rs create mode 100644 src/proto/dns/rr.rs diff --git a/src/proto/dns/cst.rs b/src/proto/dns/cst.rs new file mode 100644 index 0000000..ff306c4 --- /dev/null +++ b/src/proto/dns/cst.rs @@ -0,0 +1,93 @@ +// This file is part of masscanned. +// Copyright 2022 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use strum_macros::EnumIter; + +#[derive(PartialEq, Debug, Clone, Copy, EnumIter)] +pub enum DNSType { + NONE, + A, + TXT, // value: 16 - text strings +} + +impl From for DNSType { + fn from(item: u16) -> Self { + match item { + 1 => DNSType::A, + 16 => DNSType::TXT, + _ => DNSType::NONE, + } + } +} + +impl From for u16 { + fn from(item: DNSType) -> Self { + match item { + DNSType::A => 1, + DNSType::TXT => 16, + _ => 0, + } + } +} + +#[derive(PartialEq, Debug, Clone, Copy, EnumIter)] +pub enum DNSClass { + NONE, + IN, // value: 1 - the Internet + CH, // value: 3 - the CHAOS class +} + +impl From for DNSClass { + fn from(item: u16) -> Self { + match item { + 1 => DNSClass::IN, + 3 => DNSClass::CH, + _ => DNSClass::NONE, + } + } +} + +impl From for u16 { + fn from(item: DNSClass) -> Self { + match item { + DNSClass::IN => 1, + DNSClass::CH => 3, + _ => 0, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn type_parse() { + /* type TXT */ + assert!(DNSType::from(1) == DNSType::A); + assert!(1 as u16 == DNSType::A.into()); + assert!(DNSType::from(16) == DNSType::TXT); + assert!(16 as u16 == DNSType::TXT.into()); + } + + #[test] + fn class_parse() { + assert!(DNSClass::from(1) == DNSClass::IN); + assert!(1 as u16 == DNSClass::IN.into()); + assert!(DNSClass::from(3) == DNSClass::CH); + assert!(3 as u16 == DNSClass::CH.into()); + } +} diff --git a/src/proto/dns/header.rs b/src/proto/dns/header.rs new file mode 100644 index 0000000..5a53318 --- /dev/null +++ b/src/proto/dns/header.rs @@ -0,0 +1,383 @@ +// This file is part of masscanned. +// Copyright 2022 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use std::convert::TryFrom; + +use crate::proto::dissector::{MPacket, PacketDissector}; +use crate::proto::ClientInfo; +use crate::proto::TCPControlBlock; +use crate::Masscanned; + +#[derive(PartialEq)] +pub enum DNSHeaderState { + Id, + Flags, + QDCount, + ANCount, + NSCount, + ARCount, + End, +} + +pub struct DNSHeader { + pub d: PacketDissector, + pub id: u16, + pub flags: u16, + pub _qr: bool, + pub _opcode: u8, + pub _aa: bool, + pub _tc: bool, + pub _rd: bool, + pub _ra: bool, + pub _z: u8, + pub _rcode: u8, + pub qdcount: u16, + pub ancount: u16, + pub nscount: u16, + pub arcount: u16, +} + +impl TryFrom> for DNSHeader { + type Error = &'static str; + + fn try_from(item: Vec) -> Result { + let mut hdr = DNSHeader::new(); + for b in item { + hdr.parse(&b); + } + if hdr.d.state == DNSHeaderState::End { + Ok(hdr) + } else { + Err("packet is incomplete") + } + } +} + +impl From<&DNSHeader> for Vec { + fn from(item: &DNSHeader) -> Self { + let mut v = Vec::new(); + /* id */ + v.push((item.id >> 8) as u8); + v.push((item.id & 0xFF) as u8); + + /* flags */ + /* QR | OPCODE | AA | TC | RD */ + v.push( + ((item._qr as u8) << 7) + | (item._opcode << 3) + | ((item._aa as u8) << 2) + | ((item._tc as u8) << 1) + | (item._rd as u8), + ); + /* AA | ZZZ | RCODE */ + v.push(0); + + /* qdcount */ + v.push((item.qdcount >> 8) as u8); + v.push((item.qdcount & 0xFF) as u8); + + /* ancount */ + v.push((item.ancount >> 8) as u8); + v.push((item.ancount & 0xFF) as u8); + + /* nscount */ + v.push((item.nscount >> 8) as u8); + v.push((item.nscount & 0xFF) as u8); + + /* arcount */ + v.push((item.arcount >> 8) as u8); + v.push((item.arcount & 0xFF) as u8); + + v + } +} + +impl MPacket for DNSHeader { + fn new() -> Self { + DNSHeader { + d: PacketDissector::new(DNSHeaderState::Id), + id: 0, + flags: 0, + _qr: false, + _opcode: 0, + _aa: false, + _tc: false, + _rd: false, + _ra: false, + _z: 0, + _rcode: 0, + qdcount: 0, + ancount: 0, + nscount: 0, + arcount: 0, + } + } + + fn parse(&mut self, byte: &u8) { + match self.d.state { + DNSHeaderState::Id => { + self.id = self.d.read_u16(byte, self.id, DNSHeaderState::Flags); + } + DNSHeaderState::Flags => { + self.flags = self.d.read_u16(byte, self.flags, DNSHeaderState::QDCount); + } + DNSHeaderState::QDCount => { + self.qdcount = self.d.read_u16(byte, self.qdcount, DNSHeaderState::ANCount); + } + DNSHeaderState::ANCount => { + self.ancount = self.d.read_u16(byte, self.ancount, DNSHeaderState::NSCount); + } + DNSHeaderState::NSCount => { + self.nscount = self.d.read_u16(byte, self.nscount, DNSHeaderState::ARCount); + } + DNSHeaderState::ARCount => { + self.arcount = self.d.read_u16(byte, self.arcount, DNSHeaderState::End); + } + DNSHeaderState::End => {} + } + /* we need this to be executed at the same call + * the state changes to End, hence it is not in the + * match structure + **/ + if self.d.state == DNSHeaderState::End { + self._qr = (self.flags >> 15) == 1; + self._opcode = ((self.flags >> 11) & 0x0F) as u8; + self._aa = (self.flags >> 10) & 0x01 == 1; + self._tc = (self.flags >> 9) & 0x01 == 1; + self._rd = (self.flags >> 8) & 0x01 == 1; + self._ra = (self.flags >> 7) & 0x01 == 1; + self._z = ((self.flags >> 4) & 0x07) as u8; + self._rcode = (self.flags & 0x0F) as u8; + } + } + + fn repl( + &self, + _masscanned: &Masscanned, + _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { + let mut r = DNSHeader::new(); + r.id = self.id; + r._qr = true; + r._opcode = self._opcode; + r._aa = true; + r._tc = false; + /* RFC1035 + * Recursion Desired - this bit may be set in a query and + * is copied into the response. */ + r._rd = self._rd; + r._ra = false; + r.qdcount = self.qdcount; + r.ancount = self.qdcount; + Some(Vec::::from(&r)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + use pnet::util::MacAddr; + use std::str::FromStr; + + use crate::logger::MetaLogger; + + #[test] + fn parse_all() { + let payload = b"\xb3\x07\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00"; + let hdr = match DNSHeader::try_from(payload.to_vec()) { + Ok(_hdr) => _hdr, + Err(e) => panic!("error while parsing DNS header: {}", e), + }; + assert!(hdr.d.state == DNSHeaderState::End); + assert!(hdr.id == 0xb307); + assert!(hdr.flags == 0x0100); + assert!(hdr._qr == false); + assert!(hdr._opcode == 0); + assert!(hdr._aa == false); + assert!(hdr._tc == false); + assert!(hdr._rd == true); + assert!(hdr._ra == false); + assert!(hdr._z == 0); + assert!(hdr._rcode == 0); + assert!(hdr.qdcount == 1); + assert!(hdr.ancount == 0); + assert!(hdr.nscount == 0); + assert!(hdr.arcount == 0); + assert!(Vec::::from(&hdr) == payload.to_vec()); + /* KO */ + let payload = b"\xb3\x07\x01\x00\x00\x01\x00\x00\x00\x00\x00"; + match DNSHeader::try_from(payload.to_vec()) { + Ok(_) => panic!("parsing should have failed"), + Err(_) => {} + }; + } + + #[test] + fn parse_byte_by_byte() { + /* OK */ + let payload = b"\xb3\x07\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00"; + let mut hdr = DNSHeader::new(); + for b in payload { + assert!(hdr.d.state != DNSHeaderState::End); + hdr.parse(b); + } + assert!(hdr.d.state == DNSHeaderState::End); + assert!(hdr.id == 0xb307); + assert!(hdr.flags == 0x0100); + assert!(hdr._qr == false); + assert!(hdr._opcode == 0); + assert!(hdr._aa == false); + assert!(hdr._tc == false); + assert!(hdr._rd == true); + assert!(hdr._ra == false); + assert!(hdr._z == 0); + assert!(hdr._rcode == 0); + assert!(hdr.qdcount == 1); + assert!(hdr.ancount == 0); + assert!(hdr.nscount == 0); + assert!(hdr.arcount == 0); + assert!(Vec::::from(&hdr) == payload.to_vec()); + /* KO */ + let payload = b"\xb3\x07\x01\x00\x00\x01\x00\x00\x00\x00\x00"; + let mut hdr = DNSHeader::new(); + for b in payload { + hdr.parse(b); + } + assert!(hdr.d.state != DNSHeaderState::End); + } + + fn consistency_qd_rr(qd: &DNSHeader, rr: &DNSHeader) { + assert!(rr.id == qd.id); + assert!(rr._qr == true); + assert!(rr._opcode == qd._opcode); + assert!(rr._aa == true); + assert!(rr._tc == false); + assert!(rr._rd == qd._rd); + assert!(rr._ra == false); + assert!(rr._z == 0); + assert!(rr._rcode == 0); + /* check flags */ + assert!(rr.flags >> 15 == rr._qr as u16); + assert!((rr.flags >> 11) & 0xF == rr._opcode as u16); + assert!((rr.flags >> 10) & 0x1 == rr._aa as u16); + assert!((rr.flags >> 9) & 0x1 == rr._tc as u16); + assert!((rr.flags >> 8) & 0x1 == rr._rd as u16); + assert!((rr.flags >> 7) & 0x1 == rr._ra as u16); + assert!((rr.flags >> 4) & 0x7 == rr._z as u16); + assert!(rr.flags & 0xF == rr._rcode as u16); + assert!(rr.qdcount == qd.qdcount); + assert!(rr.ancount == qd.qdcount); + assert!(rr.nscount == 0); + assert!(rr.arcount == 0); + } + + #[test] + fn repl_id() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let client_info = ClientInfo::new(); + let mut hdr = DNSHeader::new(); + hdr._qr = false; + for id in [0x1234, 0x4321, 0xffff, 0x0, 0x1337] { + hdr.id = id; + let hdr_repl = if let Some(r) = hdr.repl(&masscanned, &client_info, None) { + DNSHeader::try_from(r).unwrap() + } else { + panic!("expected DNS header answer, got None"); + }; + consistency_qd_rr(&hdr, &hdr_repl); + } + } + + #[test] + fn repl_opcode() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let client_info = ClientInfo::new(); + let mut hdr = DNSHeader::new(); + hdr._qr = false; + /* opcode */ + for opcode in 0..3 { + hdr._opcode = opcode; + let hdr_repl = if let Some(r) = hdr.repl(&masscanned, &client_info, None) { + DNSHeader::try_from(r).unwrap() + } else { + panic!("expected DNS header answer, got None"); + }; + consistency_qd_rr(&hdr, &hdr_repl); + } + } + + #[test] + fn repl_rd() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let client_info = ClientInfo::new(); + let mut hdr = DNSHeader::new(); + hdr._qr = false; + /* rd */ + for rd in [false, true] { + hdr._rd = rd; + let hdr_repl = if let Some(r) = hdr.repl(&masscanned, &client_info, None) { + DNSHeader::try_from(r).unwrap() + } else { + panic!("expected DNS header answer, got None"); + }; + consistency_qd_rr(&hdr, &hdr_repl); + } + } + + #[test] + fn repl_ancount() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let client_info = ClientInfo::new(); + let mut hdr = DNSHeader::new(); + hdr._qr = false; + /* rd */ + for qdcount in 0..16 { + hdr.qdcount = qdcount; + let hdr_repl = if let Some(r) = hdr.repl(&masscanned, &client_info, None) { + DNSHeader::try_from(r).unwrap() + } else { + panic!("expected DNS header answer, got None"); + }; + consistency_qd_rr(&hdr, &hdr_repl); + } + } +} diff --git a/src/proto/dns/mod.rs b/src/proto/dns/mod.rs new file mode 100644 index 0000000..0c97cd5 --- /dev/null +++ b/src/proto/dns/mod.rs @@ -0,0 +1,687 @@ +// This file is part of masscanned. +// Copyright 2022 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use std::convert::TryFrom; + +mod cst; + +mod header; +use header::{DNSHeader, DNSHeaderState}; + +mod query; +use query::{DNSQuery, DNSQueryState}; + +mod rr; +use rr::{DNSRRState, DNSRR}; + +use crate::proto::dissector::{MPacket, PacketDissector}; +use crate::proto::ClientInfo; +use crate::proto::TCPControlBlock; +use crate::Masscanned; + +#[derive(PartialEq, Debug)] +enum DNSState { + Header, + Query, + Answer, + Authority, + Additional, + End, +} + +pub struct DNSPacket { + d: PacketDissector, + header: DNSHeader, + qd: Vec, + rr: Vec, + ns: Vec, + ar: Vec, +} + +impl TryFrom> for DNSPacket { + type Error = &'static str; + + fn try_from(item: Vec) -> Result { + let mut dns = DNSPacket::new(); + for b in item { + dns.parse(&b); + } + if dns.d.state == DNSState::End { + Ok(dns) + } else { + Err("packet is incomplete") + } + } +} + +impl From<&DNSPacket> for Vec { + fn from(item: &DNSPacket) -> Self { + let mut v = Vec::new(); + v.extend(Vec::::from(&item.header)); + for qd in &item.qd { + v.extend(Vec::::from(qd)); + } + for rr in &item.rr { + v.extend(Vec::::from(rr)); + } + for ns in &item.ns { + v.extend(Vec::::from(ns)); + } + for ar in &item.ar { + v.extend(Vec::::from(ar)); + } + v + } +} + +impl MPacket for DNSPacket { + fn new() -> Self { + DNSPacket { + d: PacketDissector::new(DNSState::Header), + header: DNSHeader::new(), + qd: Vec::new(), + rr: Vec::new(), + ns: Vec::new(), + ar: Vec::new(), + } + } + + fn parse(&mut self, byte: &u8) { + match self.d.state { + DNSState::Header => { + self.header.parse(byte); + if self.header.d.state == DNSHeaderState::End { + if self.header.qdcount > 0 { + self.qd.push(DNSQuery::new()); + self.d.next_state(DNSState::Query); + } else if self.header.ancount > 0 { + self.rr.push(DNSRR::new()); + self.d.next_state(DNSState::Answer); + } else if self.header.nscount > 0 { + self.d.next_state(DNSState::Authority); + } else if self.header.arcount > 0 { + self.d.next_state(DNSState::Additional); + } else { + self.d.next_state(DNSState::End); + } + } + } + DNSState::Query => { + let qdcount = self.qd.len(); + self.qd[qdcount - 1].parse(byte); + if self.qd[qdcount - 1].d.state == DNSQueryState::End { + if self.header.qdcount as usize > self.qd.len() { + self.qd.push(DNSQuery::new()); + } else if self.header.ancount > 0 { + self.rr.push(DNSRR::new()); + self.d.next_state(DNSState::Answer); + } else if self.header.nscount > 0 { + self.d.next_state(DNSState::Authority); + } else if self.header.arcount > 0 { + self.d.next_state(DNSState::Additional); + } else { + self.d.next_state(DNSState::End); + } + } + } + DNSState::Answer => { + let ancount = self.rr.len(); + self.rr[ancount - 1].parse(byte); + if self.rr[ancount - 1].d.state == DNSRRState::End { + if self.header.ancount as usize > self.rr.len() { + self.rr.push(DNSRR::new()); + } else if self.header.nscount > 0 { + self.d.next_state(DNSState::Authority); + } else if self.header.arcount > 0 { + self.d.next_state(DNSState::Additional); + } else { + self.d.next_state(DNSState::End); + } + } + } + _ => {} + } + } + + fn repl( + &self, + masscanned: &Masscanned, + client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { + let mut ans = DNSPacket::new(); + ans.header = if let Some(hdr) = self.header.repl(&masscanned, &client_info, None) { + if let Ok(h) = DNSHeader::try_from(hdr) { + h + } else { + return None; + } + } else { + return None; + }; + /* reply to qd */ + for qd in &self.qd { + if let Ok(q) = DNSQuery::try_from(Vec::::from(qd)) { + ans.qd.push(q); + } else { + return None; + } + if let Some(raw_rr) = qd.repl(&masscanned, &client_info, None) { + if let Ok(rr) = DNSRR::try_from(raw_rr) { + ans.rr.push(rr); + } else { + return None; + } + } else { + return None; + } + } + Some(Vec::::from(&ans)) + } +} + +#[cfg(test)] +mod tests { + use super::cst::{DNSClass, DNSType}; + use super::*; + + use pnet::util::MacAddr; + use std::net::{IpAddr, Ipv4Addr}; + use std::str::FromStr; + + use crate::logger::MetaLogger; + + #[test] + fn parse_qd_all() { + /* OK */ + /* scapy: DNS(id=0x1337, + * qd=DNSQR(qname="www.example1.com")/DNSQR(qname="www.example2.com")/DNSQR(qname="www.example3.com")) + **/ + let payload = b"\x137\x01\x00\x00\x03\x00\x00\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x03www\x08example3\x03com\x00\x00\x01\x00\x01"; + let dns = match DNSPacket::try_from(payload.to_vec()) { + Ok(_dns) => _dns, + Err(e) => panic!("error while parsing DNS packet: {}", e), + }; + assert!(dns.header.id == 0x1337); + assert!(dns.header._qr == false); + assert!(dns.header._opcode == 0); + assert!(dns.header._aa == false); + assert!(dns.header._tc == false); + assert!(dns.header._rd == true); + assert!(dns.header._ra == false); + assert!(dns.header._z == 0); + assert!(dns.header._rcode == 0); + assert!(dns.header.qdcount == 3); + assert!(dns.header.ancount == 0); + assert!(dns.header.nscount == 0); + assert!(dns.header.arcount == 0); + assert!(dns.qd.len() == 3); + assert!( + dns.qd[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[0].type_ == DNSType::A); + assert!(dns.qd[0].class == DNSClass::IN); + assert!( + dns.qd[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[1].type_ == DNSType::A); + assert!(dns.qd[1].class == DNSClass::IN); + assert!( + dns.qd[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[2].type_ == DNSType::A); + assert!(dns.qd[2].class == DNSClass::IN); + /* KO */ + let payload = b"\x137\x01\x00\x00\x03\x00\x00\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x03www\x08example3\x03com\x00\x00\x01\x00"; + match DNSPacket::try_from(payload.to_vec()) { + Ok(_) => panic!("parsing should have failed"), + Err(_) => {} + } + let payload = b"xxx"; + match DNSPacket::try_from(payload.to_vec()) { + Ok(_) => panic!("parsing should have failed"), + Err(_) => {} + } + } + + #[test] + fn parse_qd_byte_by_byte() { + /* scapy: DNS(id=0x1337, + * qd=DNSQR(qname="www.example1.com")/DNSQR(qname="www.example2.com")/DNSQR(qname="www.example3.com")) + **/ + let payload = b"\x137\x01\x00\x00\x03\x00\x00\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x03www\x08example3\x03com\x00\x00\x01\x00\x01"; + let mut dns = DNSPacket::new(); + for b in payload { + assert!(dns.d.state != DNSState::End); + dns.parse(&b); + } + assert!(dns.d.state == DNSState::End); + assert!(dns.header.id == 0x1337); + assert!(dns.header._qr == false); + assert!(dns.header._opcode == 0); + assert!(dns.header._aa == false); + assert!(dns.header._tc == false); + assert!(dns.header._rd == true); + assert!(dns.header._ra == false); + assert!(dns.header._z == 0); + assert!(dns.header._rcode == 0); + assert!(dns.header.qdcount == 3); + assert!(dns.header.ancount == 0); + assert!(dns.header.nscount == 0); + assert!(dns.header.arcount == 0); + assert!(dns.qd.len() == 3); + assert!( + dns.qd[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[0].type_ == DNSType::A); + assert!(dns.qd[0].class == DNSClass::IN); + assert!( + dns.qd[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[1].type_ == DNSType::A); + assert!(dns.qd[1].class == DNSClass::IN); + assert!( + dns.qd[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[2].type_ == DNSType::A); + assert!(dns.qd[2].class == DNSClass::IN); + } + + #[test] + fn parse_rr_all() { + /* OK */ + /* scapy: DNS(id=1234, qr=True, aa=True, qd=None, + * an=DNSRR(rrname="www.example1.com", rdata="127.0.0.1")/DNSRR(rrname="www.example2.com", rdata="127.0.0.2")/DNSRR(rrname="www.example3.com", rdata="127.0.0.3")) + **/ + let payload = b"\x04\xd2\x85\x00\x00\x00\x00\x03\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x02\x03www\x08example3\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x03"; + let dns = match DNSPacket::try_from(payload.to_vec()) { + Ok(_dns) => _dns, + Err(e) => panic!("error while parsing DNS packet: {}", e), + }; + assert!(dns.header.id == 1234); + assert!(dns.header._qr == true); + assert!(dns.header._opcode == 0); + assert!(dns.header._aa == true); + assert!(dns.header._tc == false); + assert!(dns.header._rd == true); + assert!(dns.header._ra == false); + assert!(dns.header._z == 0); + assert!(dns.header._rcode == 0); + assert!(dns.header.qdcount == 0); + assert!(dns.header.ancount == 3); + assert!(dns.header.nscount == 0); + assert!(dns.header.arcount == 0); + assert!(dns.rr.len() == 3); + assert!( + dns.rr[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[0].type_ == DNSType::A); + assert!(dns.rr[0].class == DNSClass::IN); + assert!(dns.rr[0].rdata == [0x7f, 0x00, 0x00, 0x01]); + assert!( + dns.rr[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[1].type_ == DNSType::A); + assert!(dns.rr[1].class == DNSClass::IN); + assert!(dns.rr[1].rdata == [0x7f, 0x00, 0x00, 0x02]); + assert!( + dns.rr[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[2].type_ == DNSType::A); + assert!(dns.rr[2].class == DNSClass::IN); + assert!(dns.rr[2].rdata == [0x7f, 0x00, 0x00, 0x03]); + /* KO */ + let payload = b"\x04\xd2\x85\x00\x00\x00\x00\x04\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x02\x03www\x08example3\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x03"; + match DNSPacket::try_from(payload.to_vec()) { + Ok(_) => panic!("parsing should have failed"), + Err(_) => {} + } + let payload = b"xxx"; + match DNSPacket::try_from(payload.to_vec()) { + Ok(_) => panic!("parsing should have failed"), + Err(_) => {} + } + } + + #[test] + fn parse_rr_byte_by_byte() { + /* scapy: DNS(id=1234, qr=True, aa=True, qd=None, + * an=DNSRR(rrname="www.example1.com", rdata="127.0.0.1")/DNSRR(rrname="www.example2.com", rdata="127.0.0.2")/DNSRR(rrname="www.example3.com", rdata="127.0.0.3")) + **/ + let payload = b"\x04\xd2\x85\x00\x00\x00\x00\x03\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x02\x03www\x08example3\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x03"; + let mut dns = DNSPacket::new(); + for b in payload { + assert!(dns.d.state != DNSState::End); + dns.parse(&b); + } + assert!(dns.d.state == DNSState::End); + assert!(dns.header.id == 1234); + assert!(dns.header._qr == true); + assert!(dns.header._opcode == 0); + assert!(dns.header._aa == true); + assert!(dns.header._tc == false); + assert!(dns.header._rd == true); + assert!(dns.header._ra == false); + assert!(dns.header._z == 0); + assert!(dns.header._rcode == 0); + assert!(dns.header.qdcount == 0); + assert!(dns.header.ancount == 3); + assert!(dns.header.nscount == 0); + assert!(dns.header.arcount == 0); + assert!(dns.rr.len() == 3); + assert!( + dns.rr[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[0].type_ == DNSType::A); + assert!(dns.rr[0].class == DNSClass::IN); + assert!(dns.rr[0].rdata == [0x7f, 0x00, 0x00, 0x01]); + assert!( + dns.rr[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[1].type_ == DNSType::A); + assert!(dns.rr[1].class == DNSClass::IN); + assert!(dns.rr[1].rdata == [0x7f, 0x00, 0x00, 0x02]); + assert!( + dns.rr[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[2].type_ == DNSType::A); + assert!(dns.rr[2].class == DNSClass::IN); + assert!(dns.rr[2].rdata == [0x7f, 0x00, 0x00, 0x03]); + } + + #[test] + fn parse_qd_rr_all() { + /* scapy: DNS(id=1234, qr=True, aa=True, + * qd=DNSQR(qname="www.example1.com")/DNSQR(qname="www.example2.com")/DNSQR(qname="www.example3.com"), + * an=DNSRR(rrname="www.example1.com", rdata="127.0.0.1")/DNSRR(rrname="www.example2.com", rdata="127.0.0.2")/DNSRR(rrname="www.example3.com", rdata="127.0.0.3")) + */ + let payload = b"\x04\xd2\x85\x00\x00\x03\x00\x03\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x03www\x08example3\x03com\x00\x00\x01\x00\x01\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x02\x03www\x08example3\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x03"; + let dns = match DNSPacket::try_from(payload.to_vec()) { + Ok(_dns) => _dns, + Err(e) => panic!("error while parsing DNS packet: {}", e), + }; + assert!(dns.header.id == 1234); + assert!(dns.header._qr == true); + assert!(dns.header._opcode == 0); + assert!(dns.header._aa == true); + assert!(dns.header._tc == false); + assert!(dns.header._rd == true); + assert!(dns.header._ra == false); + assert!(dns.header._z == 0); + assert!(dns.header._rcode == 0); + assert!(dns.header.qdcount == 3); + assert!(dns.header.ancount == 3); + assert!(dns.header.nscount == 0); + assert!(dns.header.arcount == 0); + assert!(dns.qd.len() == 3); + assert!( + dns.qd[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[0].type_ == DNSType::A); + assert!(dns.qd[0].class == DNSClass::IN); + assert!( + dns.qd[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[1].type_ == DNSType::A); + assert!(dns.qd[1].class == DNSClass::IN); + assert!( + dns.qd[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[2].type_ == DNSType::A); + assert!(dns.qd[2].class == DNSClass::IN); + assert!(dns.rr.len() == 3); + assert!( + dns.rr[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[0].type_ == DNSType::A); + assert!(dns.rr[0].class == DNSClass::IN); + assert!(dns.rr[0].rdata == [0x7f, 0x00, 0x00, 0x01]); + assert!( + dns.rr[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[1].type_ == DNSType::A); + assert!(dns.rr[1].class == DNSClass::IN); + assert!(dns.rr[1].rdata == [0x7f, 0x00, 0x00, 0x02]); + assert!( + dns.rr[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[2].type_ == DNSType::A); + assert!(dns.rr[2].class == DNSClass::IN); + assert!(dns.rr[2].rdata == [0x7f, 0x00, 0x00, 0x03]); + } + + #[test] + fn parse_qr_rr_byte_by_byte() { + /* scapy: DNS(id=1234, qr=True, aa=True, + * qd=DNSQR(qname="www.example1.com")/DNSQR(qname="www.example2.com")/DNSQR(qname="www.example3.com"), + * an=DNSRR(rrname="www.example1.com", rdata="127.0.0.1")/DNSRR(rrname="www.example2.com", rdata="127.0.0.2")/DNSRR(rrname="www.example3.com", rdata="127.0.0.3")) + */ + let payload = b"\x04\xd2\x85\x00\x00\x03\x00\x03\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x03www\x08example3\x03com\x00\x00\x01\x00\x01\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x02\x03www\x08example3\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x03"; + let mut dns = DNSPacket::new(); + for b in payload { + assert!(dns.d.state != DNSState::End); + dns.parse(&b); + } + assert!(dns.d.state == DNSState::End); + assert!(dns.header.id == 1234); + assert!(dns.header._qr == true); + assert!(dns.header._opcode == 0); + assert!(dns.header._aa == true); + assert!(dns.header._tc == false); + assert!(dns.header._rd == true); + assert!(dns.header._ra == false); + assert!(dns.header._z == 0); + assert!(dns.header._rcode == 0); + assert!(dns.header.qdcount == 3); + assert!(dns.header.ancount == 3); + assert!(dns.header.nscount == 0); + assert!(dns.header.arcount == 0); + assert!(dns.qd.len() == 3); + assert!( + dns.qd[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[0].type_ == DNSType::A); + assert!(dns.qd[0].class == DNSClass::IN); + assert!( + dns.qd[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[1].type_ == DNSType::A); + assert!(dns.qd[1].class == DNSClass::IN); + assert!( + dns.qd[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.qd[2].type_ == DNSType::A); + assert!(dns.qd[2].class == DNSClass::IN); + assert!(dns.rr.len() == 3); + assert!( + dns.rr[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x31, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[0].type_ == DNSType::A); + assert!(dns.rr[0].class == DNSClass::IN); + assert!(dns.rr[0].rdata == [0x7f, 0x00, 0x00, 0x01]); + assert!( + dns.rr[1].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x32, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[1].type_ == DNSType::A); + assert!(dns.rr[1].class == DNSClass::IN); + assert!(dns.rr[1].rdata == [0x7f, 0x00, 0x00, 0x02]); + assert!( + dns.rr[2].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x33, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(dns.rr[2].type_ == DNSType::A); + assert!(dns.rr[2].class == DNSClass::IN); + assert!(dns.rr[2].rdata == [0x7f, 0x00, 0x00, 0x03]); + } + + #[test] + fn reply_in_a() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let mut client_info = ClientInfo::new(); + /* scapy: DNS(id=0x1337, + * qd=DNSQR(qname="www.example.com")) + **/ + let payload = b"\x137\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www\x07example\x03com\x00\x00\x01\x00\x01"; + let dns = DNSPacket::try_from(payload.to_vec()).unwrap(); + for ip in [ + Ipv4Addr::new(127, 0, 0, 1), + Ipv4Addr::new(0, 0, 0, 0), + Ipv4Addr::new(4, 3, 2, 1), + ] { + client_info.ip.dst = Some(IpAddr::V4(ip)); + let ans = if let Some(a) = dns.repl(&masscanned, &client_info, None) { + DNSPacket::try_from(a).unwrap() + } else { + panic!("expected a reply, got None"); + }; + assert!(ans.header.id == 0x1337); + assert!(ans.header._qr == true); + assert!(ans.header._opcode == 0); + assert!(ans.header._aa == true); + assert!(ans.header._tc == false); + assert!(ans.header._rd == dns.header._rd); + assert!(ans.header._ra == false); + assert!(ans.header._z == 0); + assert!(ans.header._rcode == 0); + assert!(ans.header.qdcount == 1); + assert!(ans.header.ancount == 1); + assert!(ans.header.nscount == 0); + assert!(ans.header.arcount == 0); + assert!(ans.qd.len() == 1); + assert!( + ans.qd[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(ans.qd[0].type_ == DNSType::A); + assert!(ans.qd[0].class == DNSClass::IN); + assert!(ans.rr.len() == 1); + assert!( + ans.rr[0].name + == [ + 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x03, 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(ans.rr[0].type_ == DNSType::A); + assert!(ans.rr[0].class == DNSClass::IN); + assert!(ans.rr[0].rdata == ip.octets()); + } + } +} diff --git a/src/proto/dns/query.rs b/src/proto/dns/query.rs new file mode 100644 index 0000000..b5d92cf --- /dev/null +++ b/src/proto/dns/query.rs @@ -0,0 +1,335 @@ +// This file is part of masscanned. +// Copyright 2022 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use super::cst::{DNSClass, DNSType}; +use super::rr::DNSRR; + +use std::convert::TryFrom; +use std::net::IpAddr; + +use crate::proto::dissector::{MPacket, PacketDissector}; +use crate::proto::ClientInfo; +use crate::proto::TCPControlBlock; +use crate::Masscanned; + +#[derive(PartialEq)] +pub enum DNSQueryState { + Name, + Type, + Class, + End, +} + +pub struct DNSQuery { + pub d: PacketDissector, + /* RFC 1035 - Section 4.1.2 */ + pub name: Vec, + _u_type: u16, + pub type_: DNSType, + _u_class: u16, + pub class: DNSClass, +} + +impl TryFrom> for DNSQuery { + type Error = &'static str; + + fn try_from(item: Vec) -> Result { + let mut query = DNSQuery::new(); + for b in item { + query.parse(&b); + } + if query.d.state == DNSQueryState::End { + Ok(query) + } else { + Err("packet is incomplete") + } + } +} + +impl From<&DNSQuery> for Vec { + fn from(item: &DNSQuery) -> Self { + let mut v = Vec::new(); + /* name */ + v.extend(&item.name); + /* type */ + v.push(((u16::from(item.type_)) >> 8) as u8); + v.push(((u16::from(item.type_)) & 0xFF) as u8); + /* class */ + v.push(((u16::from(item.class)) >> 8) as u8); + v.push(((u16::from(item.class)) & 0xFF) as u8); + /* return */ + v + } +} + +impl MPacket for DNSQuery { + fn new() -> Self { + DNSQuery { + d: PacketDissector::new(DNSQueryState::Name), + name: Vec::new(), + _u_type: 0, + type_: DNSType::NONE, + _u_class: 0, + class: DNSClass::NONE, + } + } + + fn parse(&mut self, byte: &u8) { + match self.d.state { + DNSQueryState::Name => { + self.name.push(*byte); + if *byte == 0 { + self.d.next_state(DNSQueryState::Type); + } + } + DNSQueryState::Type => { + self._u_type = self.d.read_u16(byte, self._u_type, DNSQueryState::Class); + } + DNSQueryState::Class => { + self._u_class = self.d.read_u16(byte, self._u_class, DNSQueryState::End); + } + DNSQueryState::End => {} + } + /* we need this to be executed at the same call + * the state changes to End, hence it is not in the + * match structure + **/ + if self.d.state == DNSQueryState::End { + self.type_ = DNSType::from(self._u_type); + self.class = DNSClass::from(self._u_class); + } + } + + fn repl( + &self, + _masscanned: &Masscanned, + client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { + match self.class { + DNSClass::IN => { + match self.type_ { + DNSType::A => { + let mut rr = DNSRR::new(); + /* copy request */ + for b in &self.name { + rr.name.push(*b); + } + rr.type_ = DNSType::A; + rr.class = DNSClass::IN; + rr.ttl = 43200; + rr.rdata = match client_info.ip.dst { + Some(IpAddr::V4(ip)) => ip.octets().to_vec(), + Some(IpAddr::V6(_)) => Vec::new(), + None => Vec::new(), + }; + rr.rdlen = rr.rdata.len() as u16; + Some(Vec::::from(&rr)) + } + _ => None, + } + } + _ => None, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + use pnet::util::MacAddr; + use std::net::{IpAddr, Ipv4Addr}; + use std::str::FromStr; + use strum::IntoEnumIterator; + + use crate::client::ClientInfoSrcDst; + use crate::logger::MetaLogger; + + #[test] + fn parse_in_a_all() { + /* A */ + let payload = b"\x03www\x07example\x03com\x00\x00\x01\x00\x01"; + let qr = match DNSQuery::try_from(payload.to_vec()) { + Ok(_qr) => _qr, + Err(e) => panic!("error while parsing DNS query: {}", e), + }; + assert!( + qr.name + == [ + 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, + 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(qr.type_ == DNSType::A); + assert!(qr.class == DNSClass::IN); + assert!(Vec::::from(&qr) == payload.to_vec()); + /* TXT */ + let payload = b"\x07version\x04bind\x00\x00\x10\x00\x03"; + let qr = match DNSQuery::try_from(payload.to_vec()) { + Ok(_qr) => _qr, + Err(e) => panic!("error while parsing DNS query: {}", e), + }; + assert!(qr.type_ == DNSType::TXT); + assert!(qr.class == DNSClass::CH); + assert!(Vec::::from(&qr) == payload.to_vec()); + /* KO */ + let payload = b"xxx"; + match DNSQuery::try_from(payload.to_vec()) { + Ok(_) => panic!("parsing should have failed"), + Err(_) => {} + } + } + + #[test] + fn parse_in_a_byte_by_byte() { + /* A */ + let payload = b"\x03www\x07example\x03com\x00\x00\x01\x00\x01"; + let mut qr = DNSQuery::new(); + for b in payload { + qr.parse(b); + } + assert!(qr.d.state == DNSQueryState::End); + assert!( + qr.name + == [ + 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, + 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(qr.type_ == DNSType::A); + assert!(qr.class == DNSClass::IN); + assert!(Vec::::from(&qr) == payload.to_vec()); + /* TXT */ + let payload = b"\x07version\x04bind\x00\x00\x10\x00\x03"; + let mut qr = DNSQuery::new(); + for b in payload { + qr.parse(b); + } + assert!(qr.d.state == DNSQueryState::End); + assert!(qr.type_ == DNSType::TXT); + assert!(qr.class == DNSClass::CH); + assert!(Vec::::from(&qr) == payload.to_vec()); + /* KO */ + let payload = b"xxx"; + let mut qr = DNSQuery::new(); + for b in payload { + qr.parse(b); + } + assert!(qr.d.state != DNSQueryState::End); + } + + #[test] + fn reply_in_a() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let ip_src = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); + let ip_dst = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)); + let client_info = ClientInfo { + mac: ClientInfoSrcDst { + src: None, + dst: None, + }, + ip: ClientInfoSrcDst { + src: Some(ip_src), + dst: Some(ip_dst), + }, + transport: None, + port: ClientInfoSrcDst { + src: None, + dst: None, + }, + cookie: None, + }; + /* TXT */ + let payload = b"\x07version\x04bind\x00\x00\x10\x00\x03"; + let mut qr = DNSQuery::new(); + for b in payload { + qr.parse(b); + } + assert!(qr.type_ == DNSType::TXT); + assert!(qr.class == DNSClass::CH); + /* A */ + let payload = b"\x03www\x07example\x03com\x00\x00\x01\x00\x01"; + let mut qr = DNSQuery::new(); + for b in payload { + qr.parse(b); + } + assert!( + qr.name + == [ + 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, + 0x63, 0x6f, 0x6d, 0x00 + ] + ); + assert!(qr.type_ == DNSType::A); + assert!(qr.class == DNSClass::IN); + let rr_raw = match qr.repl(&masscanned, &client_info, None) { + None => { + panic!() + } + Some(r) => r, + }; + let mut rr = DNSRR::new(); + for b in rr_raw { + rr.parse(&b); + } + assert!(rr.name == qr.name); + assert!(rr.type_ == DNSType::A); + assert!(rr.class == DNSClass::IN); + assert!(rr.ttl == 43200); + assert!(rr.rdata == [127, 0, 0, 2]); + } + + #[test] + fn repl() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let client_info = ClientInfo::new(); + /* exhaustive tests */ + let supported: Vec<(DNSClass, DNSType)> = vec![(DNSClass::IN, DNSType::A)]; + let mut qd = DNSQuery::new(); + qd.name = vec![ + 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, + 0x6f, 0x6d, 0x00, + ]; + for c in DNSClass::iter() { + qd.class = c; + for t in DNSType::iter() { + qd.type_ = t; + if supported.contains(&(c, t)) { + if qd.repl(&masscanned, &client_info, None) == None { + panic!("expected reply, got None"); + } + } else { + if qd.repl(&masscanned, &client_info, None) != None { + panic!("expected no reply, got one for {:?}, {:?}", c, t); + } + } + } + } + } +} diff --git a/src/proto/dns/rr.rs b/src/proto/dns/rr.rs new file mode 100644 index 0000000..db188bb --- /dev/null +++ b/src/proto/dns/rr.rs @@ -0,0 +1,251 @@ +// This file is part of masscanned. +// Copyright 2022 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use super::cst::{DNSClass, DNSType}; + +use std::convert::TryFrom; + +use crate::proto::dissector::{MPacket, PacketDissector}; +use crate::proto::ClientInfo; +use crate::proto::TCPControlBlock; +use crate::Masscanned; + +#[derive(PartialEq, Debug)] +pub enum DNSRRState { + Name, + Type, + Class, + TTL, + RDLength, + RData, + End, +} + +pub struct DNSRR { + pub d: PacketDissector, + /* RFC 1035 - Section 3.2.1 */ + pub name: Vec, + _u_type: u16, + pub type_: DNSType, + _u_class: u16, + pub class: DNSClass, + pub ttl: u32, + pub rdlen: u16, + pub rdata: Vec, +} + +impl From<&DNSRR> for Vec { + fn from(item: &DNSRR) -> Self { + /* CAUTION: for the rdlen field: + * - if item.rdlen is not 0, its value is packed + * - if item.rdlen = 0, then the length of item.rdata is used instead + */ + let mut v = Vec::new(); + /* name */ + for b in &item.name { + v.push(b.clone()); + } + /* type */ + let type_: u16 = item.type_.into(); + v.push((type_ >> 8) as u8); + v.push((type_ & 0xFF) as u8); + /* class */ + let class: u16 = item.class.into(); + v.push((class >> 8) as u8); + v.push((class & 0xFF) as u8); + /* ttl */ + v.push((item.ttl >> 24) as u8); + v.push((item.ttl >> 16) as u8); + v.push((item.ttl >> 8) as u8); + v.push((item.ttl & 0xFF) as u8); + /* rdlen */ + let rdlen = if item.rdlen == 0 { + item.rdata.len() as u16 + } else { + item.rdlen + }; + v.push((rdlen >> 8) as u8); + v.push((rdlen & 0xFF) as u8); + /* rdata */ + for b in &item.rdata { + v.push(b.clone()); + } + v + } +} + +impl TryFrom> for DNSRR { + type Error = &'static str; + + fn try_from(item: Vec) -> Result { + let mut rr = DNSRR::new(); + for b in item { + rr.parse(&b); + } + if rr.d.state == DNSRRState::End { + Ok(rr) + } else { + Err("packet is incomplete") + } + } +} + +impl MPacket for DNSRR { + fn new() -> Self { + DNSRR { + d: PacketDissector::new(DNSRRState::Name), + name: Vec::new(), + _u_type: 0, + type_: DNSType::NONE, + _u_class: 0, + class: DNSClass::NONE, + rdlen: 0, + ttl: 0, + rdata: Vec::new(), + } + } + + fn parse(&mut self, byte: &u8) { + match self.d.state { + DNSRRState::Name => { + self.name.push(*byte); + if *byte == 0 { + self.d.next_state(DNSRRState::Type); + } + } + DNSRRState::Type => { + self._u_type = self.d.read_u16(byte, self._u_type, DNSRRState::Class); + } + DNSRRState::Class => { + self._u_class = self.d.read_u16(byte, self._u_class, DNSRRState::TTL); + } + DNSRRState::TTL => { + self.ttl = self.d.read_u32(byte, self.ttl, DNSRRState::RDLength); + } + DNSRRState::RDLength => { + self.rdlen = self.d.read_u16(byte, self.rdlen, DNSRRState::RData); + /* when read the rdlen, check if len is 0 */ + if self.d.state == DNSRRState::RData && self.rdlen == 0 { + self.d.state = DNSRRState::End; + } + } + DNSRRState::RData => { + self.rdata.push(*byte); + if self.rdata.len() == self.rdlen as usize { + self.d.next_state(DNSRRState::End); + } + } + DNSRRState::End => {} + } + /* we need this to be executed at the same call + * the state changes to End, hence it is not in the + * match structure + **/ + if self.d.state == DNSRRState::End { + self.type_ = DNSType::from(self._u_type); + self.class = DNSClass::from(self._u_class); + } + } + + fn repl( + &self, + _masscanned: &Masscanned, + _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { + None + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn build() { + let mut rr = DNSRR::new(); + rr.name = b"\x03www\x07example\x03com\x00".to_vec(); + rr.class = DNSClass::IN; + rr.type_ = DNSType::A; + rr.ttl = 1234; + rr.rdlen = 4; + rr.rdata = b"\x7f\x00\x00\x01".to_vec(); + assert!(Vec::::from(&rr) == b"\x03www\x07example\x03com\x00\x00\x01\x00\x01\x00\x00\x04\xd2\x00\x04\x7f\x00\x00\x01"); + } + + #[test] + fn parse_all() { + /* + * raw(DNSRR(rrname="www.example.com", rdata="127.0.0.1")) + */ + let payload = b"\x03www\x07example\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x01"; + let rr = match DNSRR::try_from(payload.to_vec()) { + Ok(r) => r, + Err(e) => panic!("error while parsing DNS RR: {}", e), + }; + assert!(rr.name == b"\x03www\x07example\x03com\x00"); + assert!(rr.class == DNSClass::IN); + assert!(rr.type_ == DNSType::A); + assert!(rr.rdata == b"\x7f\x00\x00\x01"); + assert!(Vec::::from(&rr) == payload.to_vec()); + /* + * empty data + */ + let payload = b"\x03www\x07example\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00"; + let rr = match DNSRR::try_from(payload.to_vec()) { + Ok(r) => r, + Err(e) => panic!("error while parsing DNS RR: {}", e), + }; + assert!(rr.name == b"\x03www\x07example\x03com\x00"); + assert!(rr.class == DNSClass::IN); + assert!(rr.type_ == DNSType::A); + assert!(rr.rdata == b""); + assert!(Vec::::from(&rr) == payload.to_vec()); + } + + #[test] + fn parse_byte_by_byte() { + /* + * raw(DNSRR(rrname="www.example.com", rdata="127.0.0.1")) + */ + let payload = b"\x03www\x07example\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x7f\x00\x00\x01"; + let mut rr = DNSRR::new(); + for b in payload { + assert!(rr.d.state != DNSRRState::End); + rr.parse(b); + } + assert!(rr.d.state == DNSRRState::End); + assert!(rr.name == b"\x03www\x07example\x03com\x00"); + assert!(rr.class == DNSClass::IN); + assert!(rr.type_ == DNSType::A); + assert!(rr.rdata == b"\x7f\x00\x00\x01"); + assert!(Vec::::from(&rr) == payload.to_vec()); + /* + * empty data + */ + let payload = b"\x03www\x07example\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00"; + let mut rr = DNSRR::new(); + for b in payload { + assert!(rr.d.state != DNSRRState::End); + rr.parse(b); + } + assert!(rr.name == b"\x03www\x07example\x03com\x00"); + assert!(rr.class == DNSClass::IN); + assert!(rr.type_ == DNSType::A); + assert!(rr.rdata == b""); + assert!(Vec::::from(&rr) == payload.to_vec()); + } +} From c6be16382f02078af1076b96ae9fe190ccf27bcd Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:13:45 +0200 Subject: [PATCH 092/317] Move dissector into a separate file --- src/proto/dissector.rs | 92 ++++++++++++++++++++++++ src/proto/smb.rs | 159 ++++++++++++++++++----------------------- 2 files changed, 163 insertions(+), 88 deletions(-) create mode 100644 src/proto/dissector.rs diff --git a/src/proto/dissector.rs b/src/proto/dissector.rs new file mode 100644 index 0000000..a370e12 --- /dev/null +++ b/src/proto/dissector.rs @@ -0,0 +1,92 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use crate::proto::ClientInfo; +use crate::proto::TCPControlBlock; +use crate::Masscanned; + +//////////// +// Common // +//////////// + +/// ### PacketDissector +/// A util class used to dissect fields. +#[derive(Debug, Clone)] +pub struct PacketDissector { + pub i: usize, + pub state: T, +} + +impl PacketDissector { + pub fn new(initial_state: T) -> PacketDissector { + return PacketDissector { + i: 0, + state: initial_state, + }; + } + pub fn next_state(&mut self, state: T) { + self.state = state; + self.i = 0; + } + pub fn next_state_when_i_reaches(&mut self, state: T, i: usize) { + if self.i == i { + self.next_state(state); + } + } + fn _read_usize(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { + self.i += 1; + self.next_state_when_i_reaches(next_state, size); + (value << 8) + *byte as usize + } + fn _read_ulesize(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { + let ret = value + ((*byte as usize) << (8 * self.i)); + self.i += 1; + self.next_state_when_i_reaches(next_state, size); + ret + } + pub fn read_u16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { + self._read_usize(byte, value as usize, next_state, 2) as u16 + } + pub fn read_ule16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { + self._read_ulesize(byte, value as usize, next_state, 2) as u16 + } + pub fn read_u32(&mut self, byte: &u8, value: u32, next_state: T) -> u32 { + self._read_usize(byte, value as usize, next_state, 4) as u32 + } + pub fn read_ule32(&mut self, byte: &u8, value: u32, next_state: T) -> u32 { + self._read_ulesize(byte, value as usize, next_state, 4) as u32 + } + pub fn read_ule64(&mut self, byte: &u8, value: u64, next_state: T) -> u64 { + self._read_ulesize(byte, value as usize, next_state, 8) as u64 + } +} + +pub trait MPacket { + fn new() -> Self; + fn repl( + &self, + _masscanned: &Masscanned, + _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option>; + fn parse(&mut self, byte: &u8); + + fn parse_all(&mut self, bytes: &[u8]) { + for byte in bytes { + self.parse(byte); + } + } +} diff --git a/src/proto/smb.rs b/src/proto/smb.rs index 1d17a3b..2356eb8 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -23,6 +23,8 @@ use crate::client::ClientInfo; use crate::proto::TCPControlBlock; use crate::Masscanned; +use crate::proto::dissector::{MPacket, PacketDissector}; + // NBTSession + SMB Header // netbios type (1 byte) + reserved (1 byte) + length (2 bytes) + SMB MAGIC (4 bytes) // @@ -33,70 +35,6 @@ pub const SMB2_PATTERN_MAGIC: &[u8; 8] = b"\x00\x00**\xfeSMB"; const SECURITY_BLOB_NEG_PROTO: &[u8] = b"`\x82\x01<\x06\x06+\x06\x01\x05\x05\x02\xa0\x82\x0100\x82\x01,\xa0\x1a0\x18\x06\n+\x06\x01\x04\x01\x827\x02\x02\x1e\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2\x82\x01\x0c\x04\x82\x01\x08NEGOEXTS\x01\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00p\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\xf4Rk\x17\x03\x8aK\x91\xc2\t}\x9a\x8f\xe6,\x96\\Q$/\x90MG\xc7\xad\x8f\x87k\"\x02\xbf\xc6\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08NEGOEXTS\x03\x00\x00\x00\x01\x00\x00\x00@\x00\x00\x00\x98\x00\x00\x001<*:\xc7+<\xa9m\xac8t\xa7\xdd\x1d[\\3S\r\xea\xf9\rM\xb2\xecJ\xe3xn\xc3\x08@\x00\x00\x00X\x00\x00\x000V\xa0T0R0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key0'\x80%0#1!0\x1f\x06\x03U\x04\x03\x13\x18Token Signing Public Key"; const SECURITY_BLOB_CHALLENGE: &[u8] = b"\xa1\x81\x9c0\x81\x99\xa0\x03\n\x01\x01\xa1\x0c\x06\n+\x06\x01\x04\x01\x827\x02\x02\n\xa2\x81\x83\x04\x81\x80NTLMSSP\x00\x02\x00\x00\x00\x08\x00\x08\x008\x00\x00\x00\x15\x82\x8a\xe2$\x91\xa8\xf6\xf3\x89-4\x00\x00\x00\x00\x00\x00\x00\x00@\x00@\x00@\x00\x00\x00\n\x00aJ\x00\x00\x00\x0fW\x00I\x00N\x001\x00\x02\x00\x08\x00W\x00I\x00N\x001\x00\x01\x00\x08\x00W\x00I\x00N\x001\x00\x04\x00\x08\x00W\x00I\x00N\x001\x00\x03\x00\x08\x00W\x00I\x00N\x001\x00\x07\x00\x08\x00\xff&9\xf5B\x1d\xd8\x01\x00\x00\x00\x00"; -//////////// -// Common // -//////////// - -/// ### PacketDissector -/// A util class used to dissect fields. -#[derive(Debug, Clone)] -struct PacketDissector { - i: usize, - state: T, -} -impl PacketDissector { - fn new(initial_state: T) -> PacketDissector { - return PacketDissector { - i: 0, - state: initial_state, - }; - } - fn next_state(&mut self, state: T) { - self.state = state; - self.i = 0; - } - fn next_state_when_i_reaches(&mut self, state: T, i: usize) { - if self.i == i { - self.next_state(state); - } - } - fn _read_usize(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { - self.i += 1; - self.next_state_when_i_reaches(next_state, size); - (value << 8) + *byte as usize - } - fn _read_ulesize(&mut self, byte: &u8, value: usize, next_state: T, size: usize) -> usize { - let ret = value + ((*byte as usize) << (8 * self.i)); - self.i += 1; - self.next_state_when_i_reaches(next_state, size); - ret - } - fn read_u16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { - self._read_usize(byte, value as usize, next_state, 2) as u16 - } - fn read_ule16(&mut self, byte: &u8, value: u16, next_state: T) -> u16 { - self._read_ulesize(byte, value as usize, next_state, 2) as u16 - } - fn read_ule32(&mut self, byte: &u8, value: u32, next_state: T) -> u32 { - self._read_ulesize(byte, value as usize, next_state, 4) as u32 - } - fn read_ule64(&mut self, byte: &u8, value: u64, next_state: T) -> u64 { - self._read_ulesize(byte, value as usize, next_state, 8) as u64 - } -} - -pub trait MPacket { - fn new() -> Self; - fn repl(&self) -> Option>; - fn parse(&mut self, byte: &u8); - - fn parse_all(&mut self, bytes: &[u8]) { - for byte in bytes { - self.parse(byte); - } - } -} - ///////////// // Netbios // ///////////// @@ -148,8 +86,13 @@ impl MPacket for NBTSession { } } - fn repl(&self) -> Option> { - let payload_resp = self.payload.as_ref()?.repl()?; + fn repl( + &self, + masscanned: &Masscanned, + client_info: &ClientInfo, + tcb: Option<&mut TCPControlBlock>, + ) -> Option> { + let payload_resp = self.payload.as_ref()?.repl(masscanned, client_info, tcb)?; let mut resp: Vec = Vec::new(); let size = payload_resp.len() & 0x1ffff; // 7 first bits are 0 resp.push(0x0); @@ -288,8 +231,13 @@ impl MPacket for SMB1Header { } } - fn repl(&self) -> Option> { - let payload_resp = self.payload.as_ref()?.repl()?; + fn repl( + &self, + masscanned: &Masscanned, + client_info: &ClientInfo, + tcb: Option<&mut TCPControlBlock>, + ) -> Option> { + let payload_resp = self.payload.as_ref()?.repl(masscanned, client_info, tcb)?; let mut resp: Vec = Vec::new(); resp.extend_from_slice(b"\xffSMB"); // Start resp.push(self.command); // Command @@ -407,7 +355,12 @@ impl MPacket for SMB1NegotiateRequest { } } - fn repl(&self) -> Option> { + fn repl( + &self, + _masscanned: &Masscanned, + _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { if !matches!(self.d.state, SMB1NegotiateRequestState::End) { return None; } @@ -592,7 +545,12 @@ impl MPacket for SMB1SessionSetupRequest { SMB1SessionSetupRequestState::End => {} } } - fn repl(&self) -> Option> { + fn repl( + &self, + _masscanned: &Masscanned, + _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { if !matches!(self.d.state, SMB1SessionSetupRequestState::End) { return None; } @@ -625,10 +583,15 @@ enum SMB1Payload { } impl SMB1Payload { - fn repl(&self) -> Option> { + fn repl( + &self, + masscanned: &Masscanned, + client_info: &ClientInfo, + tcb: Option<&mut TCPControlBlock>, + ) -> Option> { match self { - SMB1Payload::NegotiateRequest(x) => x.repl(), - SMB1Payload::SessionSetupRequest(x) => x.repl(), + SMB1Payload::NegotiateRequest(x) => x.repl(masscanned, client_info, tcb), + SMB1Payload::SessionSetupRequest(x) => x.repl(masscanned, client_info, tcb), } } fn parse(&mut self, byte: &u8) { @@ -771,8 +734,13 @@ impl MPacket for SMB2Header { } } - fn repl(&self) -> Option> { - let payload_resp = self.payload.as_ref()?.repl()?; + fn repl( + &self, + masscanned: &Masscanned, + client_info: &ClientInfo, + tcb: Option<&mut TCPControlBlock>, + ) -> Option> { + let payload_resp = self.payload.as_ref()?.repl(masscanned, client_info, tcb)?; let mut resp: Vec = Vec::new(); resp.extend_from_slice(b"\xfeSMB"); // Start resp.extend_from_slice(&64_u16.to_le_bytes()); // StructureSize @@ -925,7 +893,12 @@ impl MPacket for SMB2NegotiateRequest { } } } - fn repl(&self) -> Option> { + fn repl( + &self, + _masscanned: &Masscanned, + _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { if !matches!(self.d.state, SMB2NegotiateRequestState::End) { return None; } @@ -1077,7 +1050,12 @@ impl MPacket for SMB2SessionSetupRequest { } } - fn repl(&self) -> Option> { + fn repl( + &self, + _masscanned: &Masscanned, + _client_info: &ClientInfo, + _tcb: Option<&mut TCPControlBlock>, + ) -> Option> { if !matches!(self.d.state, SMB2SetupRequestState::End) { return None; } @@ -1099,10 +1077,15 @@ enum SMB2Payload { } impl SMB2Payload { - fn repl(&self) -> Option> { + fn repl( + &self, + masscanned: &Masscanned, + client_info: &ClientInfo, + tcb: Option<&mut TCPControlBlock>, + ) -> Option> { match self { - SMB2Payload::NegotiateRequest(x) => x.repl(), - SMB2Payload::SessionSetupRequest(x) => x.repl(), + SMB2Payload::NegotiateRequest(x) => x.repl(masscanned, client_info, tcb), + SMB2Payload::SessionSetupRequest(x) => x.repl(masscanned, client_info, tcb), } } fn parse(&mut self, byte: &u8) { @@ -1119,28 +1102,28 @@ impl SMB2Payload { pub fn repl_smb1<'a>( data: &'a [u8], - _masscanned: &Masscanned, - _client_info: &ClientInfo, - _tcb: Option<&mut TCPControlBlock>, + masscanned: &Masscanned, + client_info: &ClientInfo, + tcb: Option<&mut TCPControlBlock>, ) -> Option> { let mut nbtsession: NBTSession = NBTSession::new(); for byte in data { nbtsession.parse(byte); } - nbtsession.repl() + nbtsession.repl(masscanned, client_info, tcb) } pub fn repl_smb2<'a>( data: &'a [u8], - _masscanned: &Masscanned, - _client_info: &ClientInfo, - _tcb: Option<&mut TCPControlBlock>, + masscanned: &Masscanned, + client_info: &ClientInfo, + tcb: Option<&mut TCPControlBlock>, ) -> Option> { let mut nbtsession: NBTSession = NBTSession::new(); for byte in data { nbtsession.parse(byte); } - nbtsession.repl() + nbtsession.repl(masscanned, client_info, tcb) } /////////// From 2e296d7546aee86cd6ef1f7b8d4e42509ba9b252 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:14:31 +0200 Subject: [PATCH 093/317] Add DNS to supported protocols + functionnal tests --- src/proto/mod.rs | 50 ++++++++++- test/src/all.py | 1 + test/src/tests/dns.py | 202 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 test/src/tests/dns.py diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 9be5c02..795c564 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -17,11 +17,15 @@ use lazy_static::lazy_static; use log::*; use pnet::packet::ip::IpNextHeaderProtocols; +use std::convert::TryFrom; use crate::client::ClientInfo; use crate::smack::{Smack, SmackFlags, BASE_STATE, NO_MATCH, SMACK_CASE_SENSITIVE}; use crate::Masscanned; +mod dns; +use dns::DNSPacket; + mod http; use http::HTTP_VERBS; @@ -40,6 +44,12 @@ use rpc::{RPC_CALL_TCP, RPC_CALL_UDP}; mod smb; use smb::{SMB1_PATTERN_MAGIC, SMB2_PATTERN_MAGIC}; +mod dissector; +use dissector::MPacket; + +// mod dissector; +// pub use dissector::PacketDissector; +// mod tcb; pub use tcb::{add_tcb, get_tcb, is_tcb_set, ProtocolState, TCPControlBlock}; @@ -145,6 +155,16 @@ pub fn repl<'a>( if id == NO_MATCH { id = PROTO_SMACK.search_next_end(&mut state); } + /* still no match: let us try to parse packet with protocoles + * that are not matched with a regex */ + if id == NO_MATCH { + /* try to parse data as a DNS packet */ + if let Ok(dns) = DNSPacket::try_from(data.to_vec()) { + if let Some(r) = dns.repl(&masscanned, &client_info, None) { + return Some(r); + } + } + } } /* proto over else (e.g., UDP) */ match id { @@ -160,7 +180,6 @@ pub fn repl<'a>( if let Some(t) = &mut tcb { t.proto_id = PROTO_NONE; } - debug!("id: {}", id); None } } @@ -309,7 +328,7 @@ mod tests { } #[test] - fn test_proto_repl_http() { + fn test_proto_dispatch_http() { /* ensure that HTTP FSM does not answer until completion of request * (at least headers) */ let mut client_info = ClientInfo::new(); @@ -338,4 +357,31 @@ mod tests { panic!("expected no answer, got one"); } } + + #[test] + fn dispatch_dns() { + let masscanned = Masscanned { + synack_key: [0, 0], + mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), + iface: None, + ip_addresses: None, + log: MetaLogger::new(), + }; + let mut client_info = ClientInfo::new(); + client_info.ip.dst = Some(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4))); + let payloads = [ + b"\x04\xd2\x01\x00\x00\x03\x00\x00\x00\x00\x00\x00\x03www\x08example1\x03com\x00\x00\x01\x00\x01\x03www\x08example2\x03com\x00\x00\x01\x00\x01\x03www\x08example3\x03com\x00\x00\x01\x00\x01", + ]; + for payload in payloads.iter() { + let dns_resp = + if let Some(r) = repl(&payload.to_vec(), &masscanned, &mut client_info, None) { + r + } else { + panic!("expected an answer, got nothing"); + }; + if let Err(e) = DNSPacket::try_from(dns_resp) { + panic!("error trying to parse the DNS answer: {}", e); + } + } + } } diff --git a/test/src/all.py b/test/src/all.py index 44a82b3..561993e 100644 --- a/test/src/all.py +++ b/test/src/all.py @@ -22,6 +22,7 @@ from .core import test_all # noqa: F401 DEFAULT_TESTS = [ "arp", + "dns", "ghost", "http", "icmpv4", diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py new file mode 100644 index 0000000..2b265ef --- /dev/null +++ b/test/src/tests/dns.py @@ -0,0 +1,202 @@ +# This file is part of masscanned. +# Copyright 2022 - The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +from socket import AF_INET6 +import struct + +from scapy.layers.dns import DNS, DNSQR +from scapy.layers.inet import IP, UDP +from scapy.layers.inet6 import IPv6 +from scapy.layers.l2 import Ether +from scapy.packet import Raw +from scapy.pton_ntop import inet_pton +from scapy.sendrecv import srp1 + +from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum, check_ipv6_checksum + + +@test +def test_ipv4_udp_dns_a(): + sports = [13274] # [53, 13274, 12198, 888, 0] + dports = [80] # [53, 5353, 80, 161, 24732] + payload = DNS() + for sport in sports: + for dport in dports: + for domain in ['example.com', 'www.example.com', 'masscan.ned']: + qd = DNSQR(qname=domain, qtype="A", qclass="IN") + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / DNS(id=1234, rd=False, opcode=0, qd=qd)) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert UDP in resp, "no UDP layer found" + udp = resp[UDP] + assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) + assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) + if not DNS in udp: + try: + rr = DNS(udp.load) + except Exception: + raise AssertionError("no DNS layer found") + else: + rr = udp[DNS] + assert(rr.id == 1234), f"unexpected id value: {rr.id}" + assert(rr.qr == True), f"unexpected qr value" + assert(rr.opcode == 0), f"unexpected opcode value" + assert(rr.aa == True), f"unexpected aa value" + assert(rr.tc == False), f"unexpected tc value" + assert(rr.rd == False), f"unexpected rd value" + assert(rr.ra == False), f"unexpected ra value" + assert(rr.z == 0), f"unexpected z value" + assert(rr.rcode == 0), f"unexpected rcode value" + assert(rr.qdcount == 1), f"unexpected qdcount value" + assert(rr.ancount == 1), f"unexpected ancount value" + assert(rr.nscount == 0), f"unexpected nscount value" + assert(rr.arcount == 0), f"unexpected arcount value" + +""" + +@test +def test_ipv6_udp_stun(): + sports = [12345, 55555, 80, 43273] + dports = [80, 800, 8000, 3478] + payload = bytes.fromhex("000100002112a442000000000000000000000000") + for sport in sports: + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert UDP in resp + udp = resp[UDP] + assert udp.sport == dport + assert udp.dport == sport + resp_payload = udp.payload.load + type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) + tid = resp_payload[8:20] + data = resp_payload[20:] + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 24, "expected length 24, got {}".format(length) + assert ( + magic == 0x2112A442 + ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) + assert ( + tid == b"\x00" * 12 + ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) + expected_data = ( + bytes.fromhex("000100140002") + + struct.pack(">H", sport) + + inet_pton(AF_INET6, "2001:41d0::1234:5678") + ) + assert data == expected_data, "unexpected data: {}".format(data) + + +@test +def test_ipv4_udp_stun_change_port(): + sports = [12345, 55555, 80, 43273] + dports = [80, 800, 8000, 3478, 65535] + payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") + for sport in sports: + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ip_checksum(resp) + assert UDP in resp, "no UDP layer found" + udp = resp[UDP] + assert ( + udp.sport == (dport + 1) % 2**16 + ), "expected answer from UDP/{}, got it from UDP/{}".format( + (dport + 1) % 2**16, udp.sport + ) + assert ( + udp.dport == sport + ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) + resp_payload = udp.payload.load + type_, length = struct.unpack(">HH", resp_payload[:4]) + tid = resp_payload[4:20] + data = resp_payload[20:] + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 12, "expected length 12, got {}".format(length) + assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( + "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid + ) + expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( + ">HBBBB", sport, 192, 0, 0, 0 + ) + assert ( + data == expected_data + ), f"unexpected data {data!r} != {expected_data!r}" + + +@test +def test_ipv6_udp_stun_change_port(): + sports = [12345, 55555, 80, 43273] + dports = [80, 800, 8000, 3478, 65535] + payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") + for sport in sports: + for dport in dports: + req = ( + Ether(dst=MAC_ADDR) + / IPv6(dst=IPV6_ADDR) + / UDP(sport=sport, dport=dport) + / Raw(payload) + ) + resp = srp1(req, timeout=1) + assert resp is not None, "expecting answer, got nothing" + check_ipv6_checksum(resp) + assert UDP in resp, "expecting UDP layer in answer, got nothing" + udp = resp[UDP] + assert ( + udp.sport == (dport + 1) % 2**16 + ), "expected answer from UDP/{}, got it from UDP/{}".format( + (dport + 1) % 2**16, udp.sport + ) + assert ( + udp.dport == sport + ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) + resp_payload = udp.payload.load + type_, length = struct.unpack(">HH", resp_payload[:4]) + tid = resp_payload[4:20] + data = resp_payload[20:] + assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) + assert length == 24, "expected length 12, got {}".format(length) + assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( + "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid + ) + expected_data = ( + bytes.fromhex("000100140002") + + struct.pack(">H", sport) + + inet_pton(AF_INET6, "2001:41d0::1234:5678") + ) + assert ( + data == expected_data + ), f"unexpected data {data!r} != {expected_data!r}" +""" From 9638e0900cc08b85e70ec6216528ca51238d6637 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:49:18 +0200 Subject: [PATCH 094/317] Add test for multiple queries in one request --- test/src/tests/dns.py | 199 +++++++++++++----------------------------- 1 file changed, 63 insertions(+), 136 deletions(-) diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py index 2b265ef..49113ad 100644 --- a/test/src/tests/dns.py +++ b/test/src/tests/dns.py @@ -17,6 +17,7 @@ from socket import AF_INET6 import struct +from scapy.compat import raw from scapy.layers.dns import DNS, DNSQR from scapy.layers.inet import IP, UDP from scapy.layers.inet6 import IPv6 @@ -30,19 +31,20 @@ from ..core import test, check_ip_checksum, check_ipv6_checksum @test -def test_ipv4_udp_dns_a(): - sports = [13274] # [53, 13274, 12198, 888, 0] - dports = [80] # [53, 5353, 80, 161, 24732] +def test_ipv4_udp_dns_in_a(): + sports = [53, 13274, 0] + dports = [53, 5353, 80, 161, 24732] payload = DNS() for sport in sports: for dport in dports: for domain in ['example.com', 'www.example.com', 'masscan.ned']: qd = DNSQR(qname=domain, qtype="A", qclass="IN") + dns_req = DNS(id=1234, rd=False, opcode=0, qd=qd) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / UDP(sport=sport, dport=dport) - / DNS(id=1234, rd=False, opcode=0, qd=qd)) + / dns_req) resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) @@ -52,151 +54,76 @@ def test_ipv4_udp_dns_a(): assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) if not DNS in udp: try: - rr = DNS(udp.load) + dns_rep = DNS(udp.load) except Exception: raise AssertionError("no DNS layer found") else: - rr = udp[DNS] - assert(rr.id == 1234), f"unexpected id value: {rr.id}" - assert(rr.qr == True), f"unexpected qr value" - assert(rr.opcode == 0), f"unexpected opcode value" - assert(rr.aa == True), f"unexpected aa value" - assert(rr.tc == False), f"unexpected tc value" - assert(rr.rd == False), f"unexpected rd value" - assert(rr.ra == False), f"unexpected ra value" - assert(rr.z == 0), f"unexpected z value" - assert(rr.rcode == 0), f"unexpected rcode value" - assert(rr.qdcount == 1), f"unexpected qdcount value" - assert(rr.ancount == 1), f"unexpected ancount value" - assert(rr.nscount == 0), f"unexpected nscount value" - assert(rr.arcount == 0), f"unexpected arcount value" - -""" + dns_rep = udp[DNS] + assert(dns_rep.id == 1234), f"unexpected id value: {rr.id}" + assert(dns_rep.qr == True), f"unexpected qr value" + assert(dns_rep.opcode == 0), f"unexpected opcode value" + assert(dns_rep.aa == True), f"unexpected aa value" + assert(dns_rep.tc == False), f"unexpected tc value" + assert(dns_rep.rd == False), f"unexpected rd value" + assert(dns_rep.ra == False), f"unexpected ra value" + assert(dns_rep.z == 0), f"unexpected z value" + assert(dns_rep.rcode == 0), f"unexpected rcode value" + assert(dns_rep.qdcount == 1), f"unexpected qdcount value" + assert(dns_rep.ancount == 1), f"unexpected ancount value" + assert(dns_rep.nscount == 0), f"unexpected nscount value" + assert(dns_rep.arcount == 0), f"unexpected arcount value" + assert(raw(dns_rep.qd[0]) == raw(dns_req.qd[0])), f"query in request and response do not match" + assert(raw(dns_rep.qd[0].qname) == raw(dns_req.qd[0].qname + b'.')), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert(dns_rep.an[0].rrname == dns_req.qd[0].qname + b'.'), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert(dns_rep.an[0].rclass == dns_req.qd[0].qclass), f"class in answer does not match query" + assert(dns_rep.an[0].type == dns_req.qd[0].qtype), f"type in answer does not match query" + assert(dns_rep.an[0].rdata == IPV4_ADDR) @test -def test_ipv6_udp_stun(): - sports = [12345, 55555, 80, 43273] - dports = [80, 800, 8000, 3478] - payload = bytes.fromhex("000100002112a442000000000000000000000000") - for sport in sports: - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(payload) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert UDP in resp - udp = resp[UDP] - assert udp.sport == dport - assert udp.dport == sport - resp_payload = udp.payload.load - type_, length, magic = struct.unpack(">HHI", resp_payload[:8]) - tid = resp_payload[8:20] - data = resp_payload[20:] - assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) - assert length == 24, "expected length 24, got {}".format(length) - assert ( - magic == 0x2112A442 - ), "expected magic 0x2112a442, got 0x{:08x}".format(magic) - assert ( - tid == b"\x00" * 12 - ), "expected tid 0x000000000000000000000000, got {:x}".format(tid) - expected_data = ( - bytes.fromhex("000100140002") - + struct.pack(">H", sport) - + inet_pton(AF_INET6, "2001:41d0::1234:5678") - ) - assert data == expected_data, "unexpected data: {}".format(data) - - -@test -def test_ipv4_udp_stun_change_port(): - sports = [12345, 55555, 80, 43273] - dports = [80, 800, 8000, 3478, 65535] - payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") +def test_ipv4_udp_dns_in_a_multiple_queries(): + sports = [53, 13274, 12198, 888, 0] + dports = [53, 5353, 80, 161, 24732] + payload = DNS() for sport in sports: for dport in dports: + qd = DNSQR(qname="www.example1.com", qtype="A", qclass="IN")/DNSQR(qname="www.example2.com", qtype="A", qclass="IN")/DNSQR(qname="www.example3.com", qtype="A", qclass="IN") + dns_req = DNS(id=1234, rd=False, opcode=0, qd=qd) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / UDP(sport=sport, dport=dport) - / Raw(payload) - ) + / dns_req) resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) assert UDP in resp, "no UDP layer found" udp = resp[UDP] - assert ( - udp.sport == (dport + 1) % 2**16 - ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2**16, udp.sport - ) - assert ( - udp.dport == sport - ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) - resp_payload = udp.payload.load - type_, length = struct.unpack(">HH", resp_payload[:4]) - tid = resp_payload[4:20] - data = resp_payload[20:] - assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) - assert length == 12, "expected length 12, got {}".format(length) - assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( - "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid - ) - expected_data = b"\x00\x01\x00\x08\x00\x01" + struct.pack( - ">HBBBB", sport, 192, 0, 0, 0 - ) - assert ( - data == expected_data - ), f"unexpected data {data!r} != {expected_data!r}" - - -@test -def test_ipv6_udp_stun_change_port(): - sports = [12345, 55555, 80, 43273] - dports = [80, 800, 8000, 3478, 65535] - payload = bytes.fromhex("0001000803a3b9464dd8eb75e19481474293845c0003000400000002") - for sport in sports: - for dport in dports: - req = ( - Ether(dst=MAC_ADDR) - / IPv6(dst=IPV6_ADDR) - / UDP(sport=sport, dport=dport) - / Raw(payload) - ) - resp = srp1(req, timeout=1) - assert resp is not None, "expecting answer, got nothing" - check_ipv6_checksum(resp) - assert UDP in resp, "expecting UDP layer in answer, got nothing" - udp = resp[UDP] - assert ( - udp.sport == (dport + 1) % 2**16 - ), "expected answer from UDP/{}, got it from UDP/{}".format( - (dport + 1) % 2**16, udp.sport - ) - assert ( - udp.dport == sport - ), "expected answer to UDP/{}, got it to UDP/{}".format(sport, udp.dport) - resp_payload = udp.payload.load - type_, length = struct.unpack(">HH", resp_payload[:4]) - tid = resp_payload[4:20] - data = resp_payload[20:] - assert type_ == 0x0101, "expected type 0X0101, got 0x{:04x}".format(type_) - assert length == 24, "expected length 12, got {}".format(length) - assert tid == bytes.fromhex("03a3b9464dd8eb75e19481474293845c"), ( - "expected tid 0x03a3b9464dd8eb75e19481474293845c, got %r" % tid - ) - expected_data = ( - bytes.fromhex("000100140002") - + struct.pack(">H", sport) - + inet_pton(AF_INET6, "2001:41d0::1234:5678") - ) - assert ( - data == expected_data - ), f"unexpected data {data!r} != {expected_data!r}" -""" + assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) + assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) + if not DNS in udp: + try: + dns_rep = DNS(udp.load) + except Exception: + raise AssertionError("no DNS layer found") + else: + dns_rep = udp[DNS] + assert(dns_rep.id == 1234), f"unexpected id value: {rr.id}" + assert(dns_rep.qr == True), f"unexpected qr value" + assert(dns_rep.opcode == 0), f"unexpected opcode value" + assert(dns_rep.aa == True), f"unexpected aa value" + assert(dns_rep.tc == False), f"unexpected tc value" + assert(dns_rep.rd == False), f"unexpected rd value" + assert(dns_rep.ra == False), f"unexpected ra value" + assert(dns_rep.z == 0), f"unexpected z value" + assert(dns_rep.rcode == 0), f"unexpected rcode value" + assert(dns_rep.qdcount == 3), f"unexpected qdcount value" + assert(dns_rep.ancount == 3), f"unexpected ancount value" + assert(dns_rep.nscount == 0), f"unexpected nscount value" + assert(dns_rep.arcount == 0), f"unexpected arcount value" + for i, q in enumerate(qd): + assert(raw(dns_rep.qd[i]) == raw(dns_req.qd[i])), f"query in request and response do not match" + assert(raw(dns_rep.qd[i].qname) == raw(dns_req.qd[i].qname + b'.')), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert(dns_rep.an[i].rrname == dns_req.qd[i].qname + b'.'), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert(dns_rep.an[i].rclass == dns_req.qd[i].qclass), f"class in answer does not match query" + assert(dns_rep.an[i].type == dns_req.qd[i].qtype), f"type in answer does not match query" + assert(dns_rep.an[i].rdata == IPV4_ADDR) From aaf2eb5e8ff1281cd79fa024d7415f1d98d4cef9 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:52:37 +0200 Subject: [PATCH 095/317] Run black on python tests --- test/src/tests/dns.py | 111 ++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 42 deletions(-) diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py index 49113ad..317ea78 100644 --- a/test/src/tests/dns.py +++ b/test/src/tests/dns.py @@ -37,14 +37,15 @@ def test_ipv4_udp_dns_in_a(): payload = DNS() for sport in sports: for dport in dports: - for domain in ['example.com', 'www.example.com', 'masscan.ned']: + for domain in ["example.com", "www.example.com", "masscan.ned"]: qd = DNSQR(qname=domain, qtype="A", qclass="IN") dns_req = DNS(id=1234, rd=False, opcode=0, qd=qd) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / UDP(sport=sport, dport=dport) - / dns_req) + / dns_req + ) resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) @@ -59,25 +60,36 @@ def test_ipv4_udp_dns_in_a(): raise AssertionError("no DNS layer found") else: dns_rep = udp[DNS] - assert(dns_rep.id == 1234), f"unexpected id value: {rr.id}" - assert(dns_rep.qr == True), f"unexpected qr value" - assert(dns_rep.opcode == 0), f"unexpected opcode value" - assert(dns_rep.aa == True), f"unexpected aa value" - assert(dns_rep.tc == False), f"unexpected tc value" - assert(dns_rep.rd == False), f"unexpected rd value" - assert(dns_rep.ra == False), f"unexpected ra value" - assert(dns_rep.z == 0), f"unexpected z value" - assert(dns_rep.rcode == 0), f"unexpected rcode value" - assert(dns_rep.qdcount == 1), f"unexpected qdcount value" - assert(dns_rep.ancount == 1), f"unexpected ancount value" - assert(dns_rep.nscount == 0), f"unexpected nscount value" - assert(dns_rep.arcount == 0), f"unexpected arcount value" - assert(raw(dns_rep.qd[0]) == raw(dns_req.qd[0])), f"query in request and response do not match" - assert(raw(dns_rep.qd[0].qname) == raw(dns_req.qd[0].qname + b'.')), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" - assert(dns_rep.an[0].rrname == dns_req.qd[0].qname + b'.'), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" - assert(dns_rep.an[0].rclass == dns_req.qd[0].qclass), f"class in answer does not match query" - assert(dns_rep.an[0].type == dns_req.qd[0].qtype), f"type in answer does not match query" - assert(dns_rep.an[0].rdata == IPV4_ADDR) + assert dns_rep.id == 1234, f"unexpected id value: {rr.id}" + assert dns_rep.qr == True, f"unexpected qr value" + assert dns_rep.opcode == 0, f"unexpected opcode value" + assert dns_rep.aa == True, f"unexpected aa value" + assert dns_rep.tc == False, f"unexpected tc value" + assert dns_rep.rd == False, f"unexpected rd value" + assert dns_rep.ra == False, f"unexpected ra value" + assert dns_rep.z == 0, f"unexpected z value" + assert dns_rep.rcode == 0, f"unexpected rcode value" + assert dns_rep.qdcount == 1, f"unexpected qdcount value" + assert dns_rep.ancount == 1, f"unexpected ancount value" + assert dns_rep.nscount == 0, f"unexpected nscount value" + assert dns_rep.arcount == 0, f"unexpected arcount value" + assert raw(dns_rep.qd[0]) == raw( + dns_req.qd[0] + ), f"query in request and response do not match" + assert raw(dns_rep.qd[0].qname) == raw( + dns_req.qd[0].qname + b"." + ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert ( + dns_rep.an[0].rrname == dns_req.qd[0].qname + b"." + ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert ( + dns_rep.an[0].rclass == dns_req.qd[0].qclass + ), f"class in answer does not match query" + assert ( + dns_rep.an[0].type == dns_req.qd[0].qtype + ), f"type in answer does not match query" + assert dns_rep.an[0].rdata == IPV4_ADDR + @test def test_ipv4_udp_dns_in_a_multiple_queries(): @@ -86,13 +98,18 @@ def test_ipv4_udp_dns_in_a_multiple_queries(): payload = DNS() for sport in sports: for dport in dports: - qd = DNSQR(qname="www.example1.com", qtype="A", qclass="IN")/DNSQR(qname="www.example2.com", qtype="A", qclass="IN")/DNSQR(qname="www.example3.com", qtype="A", qclass="IN") + qd = ( + DNSQR(qname="www.example1.com", qtype="A", qclass="IN") + / DNSQR(qname="www.example2.com", qtype="A", qclass="IN") + / DNSQR(qname="www.example3.com", qtype="A", qclass="IN") + ) dns_req = DNS(id=1234, rd=False, opcode=0, qd=qd) req = ( Ether(dst=MAC_ADDR) / IP(dst=IPV4_ADDR) / UDP(sport=sport, dport=dport) - / dns_req) + / dns_req + ) resp = srp1(req, timeout=1) assert resp is not None, "expecting answer, got nothing" check_ip_checksum(resp) @@ -107,23 +124,33 @@ def test_ipv4_udp_dns_in_a_multiple_queries(): raise AssertionError("no DNS layer found") else: dns_rep = udp[DNS] - assert(dns_rep.id == 1234), f"unexpected id value: {rr.id}" - assert(dns_rep.qr == True), f"unexpected qr value" - assert(dns_rep.opcode == 0), f"unexpected opcode value" - assert(dns_rep.aa == True), f"unexpected aa value" - assert(dns_rep.tc == False), f"unexpected tc value" - assert(dns_rep.rd == False), f"unexpected rd value" - assert(dns_rep.ra == False), f"unexpected ra value" - assert(dns_rep.z == 0), f"unexpected z value" - assert(dns_rep.rcode == 0), f"unexpected rcode value" - assert(dns_rep.qdcount == 3), f"unexpected qdcount value" - assert(dns_rep.ancount == 3), f"unexpected ancount value" - assert(dns_rep.nscount == 0), f"unexpected nscount value" - assert(dns_rep.arcount == 0), f"unexpected arcount value" + assert dns_rep.id == 1234, f"unexpected id value: {rr.id}" + assert dns_rep.qr == True, f"unexpected qr value" + assert dns_rep.opcode == 0, f"unexpected opcode value" + assert dns_rep.aa == True, f"unexpected aa value" + assert dns_rep.tc == False, f"unexpected tc value" + assert dns_rep.rd == False, f"unexpected rd value" + assert dns_rep.ra == False, f"unexpected ra value" + assert dns_rep.z == 0, f"unexpected z value" + assert dns_rep.rcode == 0, f"unexpected rcode value" + assert dns_rep.qdcount == 3, f"unexpected qdcount value" + assert dns_rep.ancount == 3, f"unexpected ancount value" + assert dns_rep.nscount == 0, f"unexpected nscount value" + assert dns_rep.arcount == 0, f"unexpected arcount value" for i, q in enumerate(qd): - assert(raw(dns_rep.qd[i]) == raw(dns_req.qd[i])), f"query in request and response do not match" - assert(raw(dns_rep.qd[i].qname) == raw(dns_req.qd[i].qname + b'.')), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" - assert(dns_rep.an[i].rrname == dns_req.qd[i].qname + b'.'), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" - assert(dns_rep.an[i].rclass == dns_req.qd[i].qclass), f"class in answer does not match query" - assert(dns_rep.an[i].type == dns_req.qd[i].qtype), f"type in answer does not match query" - assert(dns_rep.an[i].rdata == IPV4_ADDR) + assert raw(dns_rep.qd[i]) == raw( + dns_req.qd[i] + ), f"query in request and response do not match" + assert raw(dns_rep.qd[i].qname) == raw( + dns_req.qd[i].qname + b"." + ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert ( + dns_rep.an[i].rrname == dns_req.qd[i].qname + b"." + ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + assert ( + dns_rep.an[i].rclass == dns_req.qd[i].qclass + ), f"class in answer does not match query" + assert ( + dns_rep.an[i].type == dns_req.qd[i].qtype + ), f"type in answer does not match query" + assert dns_rep.an[i].rdata == IPV4_ADDR From 87c95ff2404779cfc0d72b4bb29d86aee1dcbaf1 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 16 Dec 2021 22:13:31 +0100 Subject: [PATCH 096/317] Implement FSM for parsing SSH banner --- src/proto/mod.rs | 20 +-- src/proto/ssh.rs | 361 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 369 insertions(+), 12 deletions(-) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 9be5c02..836965a 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -256,16 +256,16 @@ mod tests { }; /***** TEST SSH *****/ let payloads = [ - "SSH-2.0-PUTTY", - "SSH-2.0-Go", - "SSH-2.0-libssh2_1.4.3", - "SSH-2.0-PuTTY", - "SSH-2.0-AsyncSSH_2.1.0", - "SSH-2.0-libssh2_1.9.0", - "SSH-2.0-libssh2_1.7.0", - "SSH-2.0-8.35 FlowSsh: FlowSshNet_SftpStress54.38.116.473", - "SSH-2.0-libssh_0.9.5", - "SSH-2.0-OpenSSH_6.7p1 Raspbian-5+deb8u3", + "SSH-2.0-PUTTY\r\n", + "SSH-2.0-Go\r\n", + "SSH-2.0-libssh2_1.4.3\r\n", + "SSH-2.0-PuTTY\r\n", + "SSH-2.0-AsyncSSH_2.1.0\r\n", + "SSH-2.0-libssh2_1.9.0\r\n", + "SSH-2.0-libssh2_1.7.0\r\n", + "SSH-2.0-8.35 FlowSsh: FlowSshNet_SftpStress54.38.116.473\r\n", + "SSH-2.0-libssh_0.9.5\r\n", + "SSH-2.0-OpenSSH_6.7p1 Raspbian-5+deb8u3\r\n", ]; for payload in payloads.iter() { let _ssh_resp = diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 77478e4..09272f1 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -23,6 +23,142 @@ use crate::Masscanned; pub const SSH_PATTERN_CLIENT_PROTOCOL: &[u8; 7] = b"SSH-2.0"; +const SSH_STATE_START: usize = 0; +const SSH_STATE_S1: usize = 1; +const SSH_STATE_S2: usize = 2; +const SSH_STATE_H: usize = 3; +const SSH_STATE_DASH: usize = 4; +const SSH_STATE_VERSION: usize = 5; +const SSH_STATE_SOFTWARE: usize = 6; +const SSH_STATE_COMMENT: usize = 7; +const SSH_STATE_EOB: usize = 8; +const SSH_STATE_LF: usize = 9; + +const SSH_STATE_FAIL: usize = 0xFFFF; + +struct ProtocolState { + state: usize, + prev_state: usize, + ssh_version: Vec, + ssh_software: Vec, + ssh_comment: Vec, +} + +impl ProtocolState { + fn new() -> Self { + ProtocolState { + state: SSH_STATE_START, + prev_state: SSH_STATE_START, + ssh_version: Vec::::new(), + ssh_software: Vec::::new(), + ssh_comment: Vec::::new(), + } + } +} + +fn ssh_parse(pstate: &mut ProtocolState, data: &[u8]) { + /* RFC 4253: + * + * 4.2. Protocol Version Exchange + * + * When the connection has been established, both sides MUST send an + * identification string. This identification string MUST be + * + * SSH-protoversion-softwareversion SP comments CR LF + * + * Since the protocol being defined in this set of documents is version + * 2.0, the 'protoversion' MUST be "2.0". The 'comments' string is + * OPTIONAL. If the 'comments' string is included, a 'space' character + * (denoted above as SP, ASCII 32) MUST separate the 'softwareversion' + * and 'comments' strings. The identification MUST be terminated by a + * single Carriage Return (CR) and a single Line Feed (LF) character + * (ASCII 13 and 10, respectively). Implementers who wish to maintain + * compatibility with older, undocumented versions of this protocol may + * want to process the identification string without expecting the + * presence of the carriage return character for reasons described in + * Section 5 of this document. The null character MUST NOT be sent. + * The maximum length of the string is 255 characters, including the + * Carriage Return and Line Feed. + */ + let mut i = 0; + while i < data.len() { + match pstate.state { + SSH_STATE_START => { + pstate.state = SSH_STATE_S1; + continue; + } + /* first bytes should be "SSH-" */ + SSH_STATE_S1 | SSH_STATE_S2 | SSH_STATE_H | SSH_STATE_DASH => { + if data[i] != b"SSH-"[pstate.state - SSH_STATE_S1] { + pstate.state = SSH_STATE_FAIL; + } else { + pstate.state += 1; + } + } + /* expect LF after a CR was read */ + SSH_STATE_LF => { + if data[i] == b'\n' { + pstate.state = SSH_STATE_EOB; + } else { + if pstate.prev_state == SSH_STATE_SOFTWARE { + /* when reading software, \r can be followed by something else than \n */ + pstate.state = pstate.prev_state; + /* cancel the read of this char */ + i -= 1; + /* add the previously read \r to the software string */ + pstate.ssh_software.push(b'\r'); + } else if pstate.prev_state == SSH_STATE_COMMENT { + /* when reading comment, \r can be followed by something else than \n */ + pstate.state = pstate.prev_state; + /* cancel the read of this char */ + i -= 1; + /* add the previously read \r to the software string */ + pstate.ssh_comment.push(b'\r'); + } else { + /* in some other cases, it fails */ + pstate.state = SSH_STATE_FAIL; + } + } + } + SSH_STATE_VERSION => { + if data[i] == b'-' { + pstate.state = SSH_STATE_SOFTWARE; + } else if !data[i].is_ascii_digit() && data[i] != b'.' { + pstate.state = SSH_STATE_FAIL; + } else { + pstate.ssh_version.push(data[i]); + } + } + SSH_STATE_SOFTWARE => { + if data[i] == b'\r' { + /* look for LF in the next char */ + pstate.prev_state = pstate.state; + pstate.state = SSH_STATE_LF; + } else if data[i] == b' ' { + pstate.state = SSH_STATE_COMMENT; + } else { + pstate.ssh_software.push(data[i]); + } + } + SSH_STATE_COMMENT => { + if data[i] == b'\r' { + /* look for LF in the next char */ + pstate.prev_state = pstate.state; + pstate.state = SSH_STATE_LF; + } else { + pstate.ssh_comment.push(data[i]); + } + } + SSH_STATE_FAIL => { + return; + } + SSH_STATE_EOB => { /* so far, do not parse after banner */ } + _ => {} + }; + i += 1; + } +} + pub fn repl<'a>( data: &'a [u8], _masscanned: &Masscanned, @@ -30,10 +166,231 @@ pub fn repl<'a>( _tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving SSH data"); + let mut pstate = ProtocolState::new(); + ssh_parse(&mut pstate, data); + if pstate.state != SSH_STATE_EOB { + debug!("data in not correctly formatted - not responding"); + debug!("pstate: {}", pstate.state); + return None; + } let repl_data = b"SSH-2.0-1\r\n".to_vec(); debug!("sending SSH answer"); - warn!("SSH server banner to {}", byte2str(data)); - return Some(repl_data); + warn!("SSH server banner to {}", str::from_utf8(&pstate.ssh_software).unwrap().trim_end()); + Some(repl_data) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_ssh_banner_parse() { + /* all at once */ + let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + /* byte by byte */ + let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + for i in 0..test_banner.len() { + if i == 0 { + assert!(pstate.state == SSH_STATE_START); + } else if i > 0 && i < 4 { + assert!(pstate.state == SSH_STATE_S1 + i); + } else if i >= 4 && i < 8 { + assert!(pstate.state == SSH_STATE_VERSION); + } else if i >= 8 && i < 17 { + assert!(pstate.state == SSH_STATE_SOFTWARE); + } else if i >= 17 && i < test_banner.len() - 1 { + assert!(pstate.state == SSH_STATE_COMMENT); + } else { + assert!(pstate.state == SSH_STATE_LF); + } + ssh_parse(&mut pstate, &test_banner[i..i + 1]); + } + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + } + + #[test] + fn test_ssh_banner_space() { + /* space in SSH */ + let test_banner = b"S SH-2.0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* space in VERSION */ + let test_banner = b"SSH-2. 0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* space in software */ + let test_banner = b"SSH-2.0-SOFT WARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFT"); + assert!(pstate.ssh_comment == b"WARE COMMENT"); + /* space in comment */ + let test_banner = b"SSH-2.0-SOFTWARE COM MENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM MENT"); + /* double space */ + let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b" COMMENT"); + } + + #[test] + fn test_ssh_banner_cr() { + /* CR in SSH */ + let test_banner = b"S\rSH-2.0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CR in VERSION */ + let test_banner = b"SSH-2.\r0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CR in SOFTWARE */ + let test_banner = b"SSH-2.0-SOFT\rWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFT\rWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + /* CR in COMMENT */ + let test_banner = b"SSH-2.0-SOFTWARE COM\rMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM\rMENT"); + /* CR at the end */ + let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT\r"); + } + + #[test] + fn test_ssh_banner_lf() { + /* LF in SSH */ + let test_banner = b"S\nSH-2.0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* LF in VERSION */ + let test_banner = b"SSH-2.\n0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* LF in SOFTWARE */ + let test_banner = b"SSH-2.0-SOFT\nWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFT\nWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + /* LF in COMMENT */ + let test_banner = b"SSH-2.0-SOFTWARE COM\nMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM\nMENT"); + /* LF at the end */ + let test_banner = b"SSH-2.0-SOFTWARE COMMENT\n\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT\n"); + } + + #[test] + fn test_ssh_banner_crlf() { + /* CRLF in SSH */ + let test_banner = b"S\r\nSH-2.0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CRLF in VERSION */ + let test_banner = b"SSH-2.\r\n0-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CRLF in SOFTWARE */ + let test_banner = b"SSH-2.0-SOFT\r\nWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFT"); + assert!(pstate.ssh_comment == b""); + /* CRLF in COMMENT */ + let test_banner = b"SSH-2.0-SOFTWARE COM\r\nMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM"); + /* CRLF at the end */ + let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\n\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"2.0"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + } +>>>>>>> 29f9e75 (Implement FSM for parsing SSH banner) } #[cfg(test)] From 1b3c0cbd2fe6881eb59d0edf5398d7e2ef33addd Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 16 Dec 2021 22:34:24 +0100 Subject: [PATCH 097/317] Format code --- src/proto/ssh.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 09272f1..51bdd98 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -60,12 +60,12 @@ fn ssh_parse(pstate: &mut ProtocolState, data: &[u8]) { /* RFC 4253: * * 4.2. Protocol Version Exchange - * + * * When the connection has been established, both sides MUST send an * identification string. This identification string MUST be - * + * * SSH-protoversion-softwareversion SP comments CR LF - * + * * Since the protocol being defined in this set of documents is version * 2.0, the 'protoversion' MUST be "2.0". The 'comments' string is * OPTIONAL. If the 'comments' string is included, a 'space' character @@ -131,7 +131,7 @@ fn ssh_parse(pstate: &mut ProtocolState, data: &[u8]) { } SSH_STATE_SOFTWARE => { if data[i] == b'\r' { - /* look for LF in the next char */ + /* look for LF in the next char */ pstate.prev_state = pstate.state; pstate.state = SSH_STATE_LF; } else if data[i] == b' ' { @@ -142,7 +142,7 @@ fn ssh_parse(pstate: &mut ProtocolState, data: &[u8]) { } SSH_STATE_COMMENT => { if data[i] == b'\r' { - /* look for LF in the next char */ + /* look for LF in the next char */ pstate.prev_state = pstate.state; pstate.state = SSH_STATE_LF; } else { @@ -175,7 +175,10 @@ pub fn repl<'a>( } let repl_data = b"SSH-2.0-1\r\n".to_vec(); debug!("sending SSH answer"); - warn!("SSH server banner to {}", str::from_utf8(&pstate.ssh_software).unwrap().trim_end()); + warn!( + "SSH server banner to {}", + str::from_utf8(&pstate.ssh_software).unwrap().trim_end() + ); Some(repl_data) } From 7cf67e01b38811e71bf59e755269b18f3e74e1bc Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 17:17:16 +0200 Subject: [PATCH 098/317] Answer to SSH-1.99 banners too --- src/proto/mod.rs | 10 +- src/proto/ssh.rs | 262 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 221 insertions(+), 51 deletions(-) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 836965a..4a80f35 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -29,7 +29,7 @@ mod stun; use stun::{STUN_PATTERN_CHANGE_REQUEST, STUN_PATTERN_EMPTY, STUN_PATTERN_MAGIC}; mod ssh; -use ssh::SSH_PATTERN_CLIENT_PROTOCOL; +use ssh::{SSH_PATTERN_CLIENT_PROTOCOL_2, SSH_PATTERN_CLIENT_PROTOCOL_1}; mod ghost; use ghost::GHOST_PATTERN_SIGNATURE; @@ -83,7 +83,12 @@ fn proto_init() -> Smack { SmackFlags::ANCHOR_BEGIN | SmackFlags::ANCHOR_END | SmackFlags::WILDCARDS, ); smack.add_pattern( - SSH_PATTERN_CLIENT_PROTOCOL, + SSH_PATTERN_CLIENT_PROTOCOL_2, + PROTO_SSH, + SmackFlags::ANCHOR_BEGIN, + ); + smack.add_pattern( + SSH_PATTERN_CLIENT_PROTOCOL_1, PROTO_SSH, SmackFlags::ANCHOR_BEGIN, ); @@ -266,6 +271,7 @@ mod tests { "SSH-2.0-8.35 FlowSsh: FlowSshNet_SftpStress54.38.116.473\r\n", "SSH-2.0-libssh_0.9.5\r\n", "SSH-2.0-OpenSSH_6.7p1 Raspbian-5+deb8u3\r\n", + "SSH-1.99-Cisco-1.25\r\n", ]; for payload in payloads.iter() { let _ssh_resp = diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 51bdd98..2906ec6 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -21,7 +21,8 @@ use crate::proto::TCPControlBlock; use crate::utils::byte2str; use crate::Masscanned; -pub const SSH_PATTERN_CLIENT_PROTOCOL: &[u8; 7] = b"SSH-2.0"; +pub const SSH_PATTERN_CLIENT_PROTOCOL_2: &[u8; 7] = b"SSH-2.0"; +pub const SSH_PATTERN_CLIENT_PROTOCOL_1: &[u8; 8] = b"SSH-1.99"; const SSH_STATE_START: usize = 0; const SSH_STATE_S1: usize = 1; @@ -177,7 +178,7 @@ pub fn repl<'a>( debug!("sending SSH answer"); warn!( "SSH server banner to {}", - str::from_utf8(&pstate.ssh_software).unwrap().trim_end() + std::str::from_utf8(&pstate.ssh_software).unwrap().trim_end() ); Some(repl_data) } @@ -187,7 +188,7 @@ mod tests { use super::*; #[test] - fn test_ssh_banner_parse() { + fn ssh_2_banner_parse() { /* all at once */ let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -223,7 +224,43 @@ mod tests { } #[test] - fn test_ssh_banner_space() { + fn ssh_1_banner_parse() { + /* all at once */ + let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + /* byte by byte */ + let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + for i in 0..test_banner.len() { + if i == 0 { + assert!(pstate.state == SSH_STATE_START); + } else if i > 0 && i < 4 { + assert!(pstate.state == SSH_STATE_S1 + i); + } else if i >= 4 && i < 9 { + assert!(pstate.state == SSH_STATE_VERSION); + } else if i >= 9 && i < 18 { + assert!(pstate.state == SSH_STATE_SOFTWARE); + } else if i >= 18 && i < test_banner.len() - 1 { + assert!(pstate.state == SSH_STATE_COMMENT); + } else { + assert!(pstate.state == SSH_STATE_LF); + } + ssh_parse(&mut pstate, &test_banner[i..i + 1]); + } + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + } + + #[test] + fn ssh_2_banner_space() { /* space in SSH */ let test_banner = b"S SH-2.0-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -266,7 +303,50 @@ mod tests { } #[test] - fn test_ssh_banner_cr() { + fn ssh_1_banner_space() { + /* space in SSH */ + let test_banner = b"S SH-1.99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* space in VERSION */ + let test_banner = b"SSH-1. 99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* space in software */ + let test_banner = b"SSH-1.99-SOFT WARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFT"); + assert!(pstate.ssh_comment == b"WARE COMMENT"); + /* space in comment */ + let test_banner = b"SSH-1.99-SOFTWARE COM MENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM MENT"); + /* double space */ + let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b" COMMENT"); + } + + #[test] + fn ssh_2_banner_cr() { /* CR in SSH */ let test_banner = b"S\rSH-2.0-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -309,7 +389,50 @@ mod tests { } #[test] - fn test_ssh_banner_lf() { + fn ssh_1_banner_cr() { + /* CR in SSH */ + let test_banner = b"S\rSH-1.99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CR in VERSION */ + let test_banner = b"SSH-1.\r99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CR in SOFTWARE */ + let test_banner = b"SSH-1.99-SOFT\rWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFT\rWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + /* CR in COMMENT */ + let test_banner = b"SSH-1.99-SOFTWARE COM\rMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM\rMENT"); + /* CR at the end */ + let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT\r"); + } + + #[test] + fn ssh_2_banner_lf() { /* LF in SSH */ let test_banner = b"S\nSH-2.0-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -352,7 +475,50 @@ mod tests { } #[test] - fn test_ssh_banner_crlf() { + fn ssh_1_banner_lf() { + /* LF in SSH */ + let test_banner = b"S\nSH-1.99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* LF in VERSION */ + let test_banner = b"SSH-1.\n99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* LF in SOFTWARE */ + let test_banner = b"SSH-1.99-SOFT\nWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFT\nWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); + /* LF in COMMENT */ + let test_banner = b"SSH-1.99-SOFTWARE COM\nMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM\nMENT"); + /* LF at the end */ + let test_banner = b"SSH-1.99-SOFTWARE COMMENT\n\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT\n"); + } + + #[test] + fn ssh_2_banner_crlf() { /* CRLF in SSH */ let test_banner = b"S\r\nSH-2.0-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -393,49 +559,47 @@ mod tests { assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT"); } ->>>>>>> 29f9e75 (Implement FSM for parsing SSH banner) -} -#[cfg(test)] -mod tests { - use super::*; - use crate::client::ClientInfoSrcDst; - use crate::MetaLogger; - use pnet::util::MacAddr; - use std::net::IpAddr; - use std::net::Ipv4Addr; - - const CLIENT_INFO: ClientInfo = ClientInfo { - mac: ClientInfoSrcDst { - src: None, - dst: None, - }, - ip: ClientInfoSrcDst { - src: Some(IpAddr::V4(Ipv4Addr::new(192, 0, 0, 0))), - dst: Some(IpAddr::V4(Ipv4Addr::new(192, 0, 0, 1))), - }, - transport: None, - port: ClientInfoSrcDst { - src: Some(12345), - dst: Some(111), - }, - cookie: None, - }; #[test] - fn test_ssh_wrong_banner() { - let masscanned = Masscanned { - synack_key: [0, 0], - mac: MacAddr(0, 1, 2, 3, 4, 5), - iface: None, - ip_addresses: None, - log: MetaLogger::new(), - }; - stderrlog::new() - .module(module_path!()) - .verbosity(1) - .init() - .expect("error while initializing logging module"); - let req = b"\xff"; - repl(req, &masscanned, &CLIENT_INFO, None); + fn ssh_1_banner_crlf() { + /* CRLF in SSH */ + let test_banner = b"S\r\nSH-1.99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CRLF in VERSION */ + let test_banner = b"SSH-1.\r\n99-SOFTWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_FAIL); + /* CRLF in SOFTWARE */ + let test_banner = b"SSH-1.99-SOFT\r\nWARE COMMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFT"); + assert!(pstate.ssh_comment == b""); + /* CRLF in COMMENT */ + let test_banner = b"SSH-1.99-SOFTWARE COM\r\nMENT\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COM"); + /* CRLF at the end */ + let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\n\r\n"; + let mut pstate = ProtocolState::new(); + assert!(pstate.state == SSH_STATE_START); + ssh_parse(&mut pstate, test_banner); + assert!(pstate.state == SSH_STATE_EOB); + assert!(pstate.ssh_version == b"1.99"); + assert!(pstate.ssh_software == b"SOFTWARE"); + assert!(pstate.ssh_comment == b"COMMENT"); } } From 1030dc7d4305d17645bae5440d3497d005c425a8 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 17:33:30 +0200 Subject: [PATCH 099/317] Fix flake8 --- test/src/tests/dns.py | 88 ++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py index 317ea78..01b24b4 100644 --- a/test/src/tests/dns.py +++ b/test/src/tests/dns.py @@ -14,27 +14,20 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . -from socket import AF_INET6 -import struct - from scapy.compat import raw from scapy.layers.dns import DNS, DNSQR from scapy.layers.inet import IP, UDP -from scapy.layers.inet6 import IPv6 from scapy.layers.l2 import Ether -from scapy.packet import Raw -from scapy.pton_ntop import inet_pton from scapy.sendrecv import srp1 -from ..conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR -from ..core import test, check_ip_checksum, check_ipv6_checksum +from ..conf import IPV4_ADDR, MAC_ADDR +from ..core import test, check_ip_checksum @test def test_ipv4_udp_dns_in_a(): sports = [53, 13274, 0] dports = [53, 5353, 80, 161, 24732] - payload = DNS() for sport in sports: for dport in dports: for domain in ["example.com", "www.example.com", "masscan.ned"]: @@ -53,41 +46,41 @@ def test_ipv4_udp_dns_in_a(): udp = resp[UDP] assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) - if not DNS in udp: + if DNS not in udp: try: dns_rep = DNS(udp.load) except Exception: raise AssertionError("no DNS layer found") else: dns_rep = udp[DNS] - assert dns_rep.id == 1234, f"unexpected id value: {rr.id}" - assert dns_rep.qr == True, f"unexpected qr value" - assert dns_rep.opcode == 0, f"unexpected opcode value" - assert dns_rep.aa == True, f"unexpected aa value" - assert dns_rep.tc == False, f"unexpected tc value" - assert dns_rep.rd == False, f"unexpected rd value" - assert dns_rep.ra == False, f"unexpected ra value" - assert dns_rep.z == 0, f"unexpected z value" - assert dns_rep.rcode == 0, f"unexpected rcode value" - assert dns_rep.qdcount == 1, f"unexpected qdcount value" - assert dns_rep.ancount == 1, f"unexpected ancount value" - assert dns_rep.nscount == 0, f"unexpected nscount value" - assert dns_rep.arcount == 0, f"unexpected arcount value" + assert dns_rep.id == 1234, f"unexpected id value: {dns_rep.id}" + assert dns_rep.qr, "unexpected qr value" + assert dns_rep.opcode == 0, "unexpected opcode value" + assert dns_rep.aa, "unexpected aa value" + assert not dns_rep.tc, "unexpected tc value" + assert not dns_rep.rd, "unexpected rd value" + assert not dns_rep.ra, "unexpected ra value" + assert dns_rep.z == 0, "unexpected z value" + assert dns_rep.rcode == 0, "unexpected rcode value" + assert dns_rep.qdcount == 1, "unexpected qdcount value" + assert dns_rep.ancount == 1, "unexpected ancount value" + assert dns_rep.nscount == 0, "unexpected nscount value" + assert dns_rep.arcount == 0, "unexpected arcount value" assert raw(dns_rep.qd[0]) == raw( dns_req.qd[0] - ), f"query in request and response do not match" + ), "query in request and response do not match" assert raw(dns_rep.qd[0].qname) == raw( dns_req.qd[0].qname + b"." - ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" assert ( dns_rep.an[0].rrname == dns_req.qd[0].qname + b"." - ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" assert ( dns_rep.an[0].rclass == dns_req.qd[0].qclass - ), f"class in answer does not match query" + ), "class in answer does not match query" assert ( dns_rep.an[0].type == dns_req.qd[0].qtype - ), f"type in answer does not match query" + ), "type in answer does not match query" assert dns_rep.an[0].rdata == IPV4_ADDR @@ -95,7 +88,6 @@ def test_ipv4_udp_dns_in_a(): def test_ipv4_udp_dns_in_a_multiple_queries(): sports = [53, 13274, 12198, 888, 0] dports = [53, 5353, 80, 161, 24732] - payload = DNS() for sport in sports: for dport in dports: qd = ( @@ -117,40 +109,40 @@ def test_ipv4_udp_dns_in_a_multiple_queries(): udp = resp[UDP] assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) - if not DNS in udp: + if DNS not in udp: try: dns_rep = DNS(udp.load) except Exception: raise AssertionError("no DNS layer found") else: dns_rep = udp[DNS] - assert dns_rep.id == 1234, f"unexpected id value: {rr.id}" - assert dns_rep.qr == True, f"unexpected qr value" - assert dns_rep.opcode == 0, f"unexpected opcode value" - assert dns_rep.aa == True, f"unexpected aa value" - assert dns_rep.tc == False, f"unexpected tc value" - assert dns_rep.rd == False, f"unexpected rd value" - assert dns_rep.ra == False, f"unexpected ra value" - assert dns_rep.z == 0, f"unexpected z value" - assert dns_rep.rcode == 0, f"unexpected rcode value" - assert dns_rep.qdcount == 3, f"unexpected qdcount value" - assert dns_rep.ancount == 3, f"unexpected ancount value" - assert dns_rep.nscount == 0, f"unexpected nscount value" - assert dns_rep.arcount == 0, f"unexpected arcount value" + assert dns_rep.id == 1234, f"unexpected id value: {dns_rep.id}" + assert dns_rep.qr, "unexpected qr value" + assert dns_rep.opcode == 0, "unexpected opcode value" + assert dns_rep.aa, "unexpected aa value" + assert not dns_rep.tc, "unexpected tc value" + assert not dns_rep.rd, "unexpected rd value" + assert not dns_rep.ra, "unexpected ra value" + assert dns_rep.z == 0, "unexpected z value" + assert dns_rep.rcode == 0, "unexpected rcode value" + assert dns_rep.qdcount == 3, "unexpected qdcount value" + assert dns_rep.ancount == 3, "unexpected ancount value" + assert dns_rep.nscount == 0, "unexpected nscount value" + assert dns_rep.arcount == 0, "unexpected arcount value" for i, q in enumerate(qd): assert raw(dns_rep.qd[i]) == raw( dns_req.qd[i] - ), f"query in request and response do not match" + ), "query in request and response do not match" assert raw(dns_rep.qd[i].qname) == raw( dns_req.qd[i].qname + b"." - ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" assert ( dns_rep.an[i].rrname == dns_req.qd[i].qname + b"." - ), f"if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" assert ( dns_rep.an[i].rclass == dns_req.qd[i].qclass - ), f"class in answer does not match query" + ), "class in answer does not match query" assert ( dns_rep.an[i].type == dns_req.qd[i].qtype - ), f"type in answer does not match query" + ), "type in answer does not match query" assert dns_rep.an[i].rdata == IPV4_ADDR From ed464181bc3d87fcf10d4685feadab18c50a8e59 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 4 Aug 2022 17:57:20 +0200 Subject: [PATCH 100/317] Run cargo fmt --- src/proto/mod.rs | 2 +- src/proto/ssh.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 4a80f35..2b82e5e 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -29,7 +29,7 @@ mod stun; use stun::{STUN_PATTERN_CHANGE_REQUEST, STUN_PATTERN_EMPTY, STUN_PATTERN_MAGIC}; mod ssh; -use ssh::{SSH_PATTERN_CLIENT_PROTOCOL_2, SSH_PATTERN_CLIENT_PROTOCOL_1}; +use ssh::{SSH_PATTERN_CLIENT_PROTOCOL_1, SSH_PATTERN_CLIENT_PROTOCOL_2}; mod ghost; use ghost::GHOST_PATTERN_SIGNATURE; diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 2906ec6..35d3ba8 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -178,7 +178,9 @@ pub fn repl<'a>( debug!("sending SSH answer"); warn!( "SSH server banner to {}", - std::str::from_utf8(&pstate.ssh_software).unwrap().trim_end() + std::str::from_utf8(&pstate.ssh_software) + .unwrap() + .trim_end() ); Some(repl_data) } From 2b2fcd81253d74c38a133a122237adcc519c4409 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Fri, 5 Aug 2022 10:16:15 +0200 Subject: [PATCH 101/317] Update readme --- README.md | 285 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 227 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index f3ebf81..c743de5 100644 --- a/README.md +++ b/README.md @@ -21,17 +21,25 @@ For example, when it receives network packets: ![demo](doc/img/demo.gif) -**Masscanned** currently supports most common protocols at layers 2-3-4, and a few application -protocols: +## Overview -* `Eth::ARP::REQ`, -* `Eth::IPv{4,6}::ICMP::ECHO-REQ`, -* `Eth::IPv{4,6}::TCP::SYN` (all ports), -* `Eth::IPv{4,6}::TCP::PSHACK` (all ports), -* `Eth::IPv6::ICMP::ND_NS`. -* `Eth::IPv{4,6}::{TCP,UDP}::HTTP` (all HTTP verbs), -* `Eth::IPv{4,6}::{TCP,UDP}::STUN`, -* `Eth::IPv{4,6}::{TCP,UDP}::SSH` (Server Protocol only). +**Masscanned** currently supports most common protocols at layers 2-3-4, and a few application +protocols. + +### Network protocols + +* ARP (answers to ARP requests) +* ICMP (answers to ping) +* ICMPv6 (answers to ND NS) +* TCP (answers to SYN and PUSH) + +### Application protocols + +* HTTP (answers to all verbs) +* SSH (answers to the client banner) +* STUN (answers to binding requests) +* SMB +* DNS (answers to IN/A queries) ## Try it locally @@ -75,7 +83,7 @@ The pcaps can then be analyzed using [zeek](https://zeek.org/) and the output fi A documentation on how to deploy an instance of **masscanned** on a VPS is coming (see [Issue #2](https://github.com/ivre/masscanned/issues/2)). -## Protocols +## Supported protocols - details ### Layer 2 @@ -123,7 +131,7 @@ An additionnal requirement is that the next layer protocol is supported - see be #### IPv4 -The following L4 protocols are supported for an `IPv4` packet: +The following L3+/4 protocols are supported for an `IPv4` packet: * `ICMPv4` * `UDP` @@ -133,7 +141,7 @@ If the next layer protocol is not one of them, the packet is dropped. #### IPv6 -The following L4 protocols are supported for an `IPv6` packet: +The following L3+/4 protocols are supported for an `IPv6` packet: * `ICMPv6` * `UDP` @@ -184,12 +192,57 @@ a supported protocol (Layer 5/6/7) has been detected, `masscanned` answers to an `UDP` packet if and only if the upper-layer protocol is handled and provides an answer. -### Protocols +### Application protocols #### HTTP +`masscanned` answers to any `HTTP` request (any **valid** verb) with a `401 Authorization Required`. +Note that `HTTP` requests with an invalid verb will not be answered. + +Example: + +``` +$ curl -X GET 10.11.10.129 + +401 Authorization Required + +

401 Authorization Required

+
nginx/1.14.2
+ + +$ curl -X OPTIONS 10.11.10.129 + +401 Authorization Required + +

401 Authorization Required

+
nginx/1.14.2
+ + +$ curl -X HEAD 10.11.10.129 +Warning: Setting custom HTTP method to HEAD with -X/--request may not work the +Warning: way you want. Consider using -I/--head instead. + +401 Authorization Required + +

401 Authorization Required

+
nginx/1.14.2
+ + +$ curl -X XXX 10.11.10.129 +[timeout] +``` + #### STUN +Example: + +``` +$ stun 10.11.10.129 +STUN client version 0.97 +Primary: Open +Return value is 0x000001 +``` + #### SSH `masscanned` answers to `SSH` `Client: Protocol` messages with the following `Server: Protocol` message: @@ -198,6 +251,57 @@ is handled and provides an answer. SSH-2.0-1\r\n ``` +#### SMB + +`masscanned` answers to `Negotiate Protocol Request` packets in order for the +client to send a `NTLMSSP_NEGOTIATE`, to which `masscanned` answers with a challenge. + +Example: + +``` +##$ smbclient -U user \\\\10.11.10.129\\shared +Enter WORKGROUP\user's password: +``` + +#### DNS + +`masscanned` answers to `DNS` queries of class `IN` and type `A` (for now). +The answer it provides always contains the IP address the query was sent to. + +Example: + +``` +$ host -t A masscan.ned 10.11.10.129 +Using domain server: +Name: 10.11.10.129 +Address: 10.11.10.129#53 +Aliases: + +masscan.ned has address 10.11.10.129 +$ host -t A masscan.ned 10.11.10.130 +Using domain server: +Name: 10.11.10.130 +Address: 10.11.10.130#53 +Aliases: + +masscan.ned has address 10.11.10.130 +$ host -t A masscan.ned 10.11.10.131 +Using domain server: +Name: 10.11.10.131 +Address: 10.11.10.131#53 +Aliases: + +masscan.ned has address 10.11.10.131 +$ host -t A masscan.ned 10.11.10.132 +Using domain server: +Name: 10.11.10.132 +Address: 10.11.10.132#53 +Aliases: + +masscan.ned has address 10.11.10.132 + +``` + ## Internals ### Tests @@ -207,68 +311,118 @@ SSH-2.0-1\r\n ``` $ cargo test Compiling masscanned v0.2.0 (/zdata/workdir/masscanned) - Finished test [unoptimized + debuginfo] target(s) in 2.34s - Running target/debug/deps/masscanned-b86211a090e50323 + Finished test [unoptimized + debuginfo] target(s) in 3.83s + Running unittests (target/debug/deps/masscanned-f9292f8600038978) -running 36 tests +running 92 tests test client::client_info::tests::test_client_info_eq ... ok test layer_2::arp::tests::test_arp_reply ... ok -test layer_3::ipv4::tests::test_ipv4_reply ... ok -test layer_3::ipv6::tests::test_ipv6_reply ... ok -test layer_4::icmpv6::tests::test_icmpv6_reply ... ok +test layer_2::tests::test_eth_empty ... ok test layer_2::tests::test_eth_reply ... ok -test layer_4::icmpv6::tests::test_nd_na_reply ... ok -test layer_4::tcp::tests::test_synack_cookie_ipv4 ... ok +test layer_3::ipv4::tests::test_ipv4_reply ... ok +test layer_3::ipv4::tests::test_ipv4_empty ... ok +test layer_3::ipv6::tests::test_ipv6_empty ... ok +test layer_3::ipv6::tests::test_ipv6_reply ... ok test layer_4::icmpv4::tests::test_icmpv4_reply ... ok +test layer_4::icmpv6::tests::test_icmpv6_reply ... ok +test layer_4::icmpv6::tests::test_nd_na_reply ... ok test layer_4::tcp::tests::test_synack_cookie_ipv6 ... ok -test proto::http::test_http_request_field ... ok -test proto::http::test_http_request_no_field ... ok -test proto::http::test_http_request_line ... ok -test proto::http::test_http_verb ... ok -test proto::stun::tests::test_change_request_port ... ok -test proto::stun::tests::test_proto_stun_ipv6 ... ok -test proto::stun::tests::test_proto_stun_ipv4 ... ok +test layer_4::tcp::tests::test_tcp_fin_ack_wrap ... ok +test proto::dns::cst::tests::class_parse ... ok +test layer_4::tcp::tests::test_tcp_fin_ack ... ok +test layer_4::tcp::tests::test_synack_cookie_ipv4 ... ok +test proto::dns::cst::tests::type_parse ... ok +test proto::dns::header::tests::parse_byte_by_byte ... ok +test proto::dns::header::tests::repl_id ... ok +test proto::dns::header::tests::repl_opcode ... ok +test proto::dns::header::tests::repl_ancount ... ok +test proto::dns::header::tests::repl_rd ... ok +test proto::dns::query::tests::parse_in_a_all ... ok +test proto::dns::header::tests::parse_all ... ok +test proto::dns::query::tests::repl ... ok +test proto::dns::query::tests::reply_in_a ... ok +test proto::dns::rr::tests::parse_all ... ok +test proto::dns::rr::tests::parse_byte_by_byte ... ok +test proto::dns::query::tests::parse_in_a_byte_by_byte ... ok +test proto::dns::tests::parse_qd_all ... ok +test proto::dns::tests::parse_qd_byte_by_byte ... ok +test proto::dns::rr::tests::build ... ok +test proto::dns::tests::parse_qd_rr_all ... ok +test proto::dns::tests::parse_qr_rr_byte_by_byte ... ok +test proto::dns::tests::parse_rr_byte_by_byte ... ok +test proto::dns::tests::parse_rr_all ... ok +test proto::dns::tests::reply_in_a ... ok +test proto::http::tests::test_http_request_line ... ok +test proto::http::tests::test_http_request_no_field ... ok +test proto::http::tests::test_http_request_field ... ok +test proto::http::tests::test_http_verb ... ok +test proto::rpc::tests::test_probe_nmap ... ok +test proto::rpc::tests::test_probe_nmap_split1 ... ok +test proto::rpc::tests::test_probe_portmap_v4_dump ... ok +test proto::rpc::tests::test_probe_nmap_split2 ... ok +test proto::rpc::tests::test_probe_nmap_udp ... ok +test proto::smb::tests::test_smb1_session_setup_request_parse ... ok +test proto::smb::tests::test_smb1_protocol_nego_parsing ... ok +test proto::smb::tests::test_smb1_protocol_nego_reply ... ok +test proto::smb::tests::test_smb1_session_setup_request_reply ... ok +test proto::smb::tests::test_smb2_protocol_nego_parsing ... ok +test proto::smb::tests::test_smb2_protocol_nego_reply ... ok +test proto::smb::tests::test_smb2_session_setup_request_reply ... ok +test proto::smb::tests::test_smb2_session_setup_request_parse ... ok +test proto::ssh::tests::ssh_1_banner_cr ... ok +test proto::ssh::tests::ssh_1_banner_crlf ... ok +test proto::ssh::tests::ssh_1_banner_lf ... ok +test proto::ssh::tests::ssh_1_banner_space ... ok +test proto::ssh::tests::ssh_2_banner_cr ... ok +test proto::ssh::tests::ssh_1_banner_parse ... ok +test proto::ssh::tests::ssh_2_banner_parse ... ok +test proto::ssh::tests::ssh_2_banner_lf ... ok +test proto::ssh::tests::ssh_2_banner_crlf ... ok test proto::stun::tests::test_change_request_port_overflow ... ok -test smack::smack::tests::test_anchor_end ... ok -test smack::smack::tests::test_anchor_begin ... ok -test smack::smack::tests::test_multiple_matches ... ok -test smack::smack::tests::test_http_banner ... ok -test smack::smack::tests::test_multiple_matches_wildcard ... ok -test smack::smack::tests::test_proto ... ok -test smack::smack::tests::test_wildcard ... ok +test proto::stun::tests::test_proto_stun_ipv4 ... ok +test proto::stun::tests::test_change_request_port ... ok +test proto::ssh::tests::ssh_2_banner_space ... ok +test proto::stun::tests::test_proto_stun_ipv6 ... ok +test proto::tcb::tests::test_proto_tcb_proto_state_http ... ok +test proto::tests::dispatch_dns ... ok +test proto::tcb::tests::test_proto_tcb_proto_state_rpc ... ok +test proto::tcb::tests::test_proto_tcb_proto_id ... ok +test proto::tests::test_proto_dispatch_http ... ok test proto::tests::test_proto_dispatch_ssh ... ok +test proto::tests::test_proto_dispatch_ghost ... ok test proto::tests::test_proto_dispatch_stun ... ok +test smack::smack::tests::test_anchor_end ... ok +test smack::smack::tests::test_multiple_matches_wildcard ... ok +test smack::smack::tests::test_multiple_matches ... ok +test smack::smack::tests::test_anchor_begin ... ok +test smack::smack::tests::test_http_banner ... ok test synackcookie::tests::test_clientinfo ... ok +test synackcookie::tests::test_ip4 ... ok test synackcookie::tests::test_ip4_dst ... ok test synackcookie::tests::test_ip4_src ... ok -test synackcookie::tests::test_ip4 ... ok test synackcookie::tests::test_ip6 ... ok test synackcookie::tests::test_key ... ok test synackcookie::tests::test_tcp_dst ... ok test synackcookie::tests::test_tcp_src ... ok +test smack::smack::tests::test_wildcard ... ok +test smack::smack::tests::test_proto ... ok test smack::smack::tests::test_pattern ... ok -test result: ok. 36 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +test result: ok. 92 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.41s ``` #### Functional tests ``` # ./test/test_masscanned.py -tcpdump: listening on tap0, link-type EN10MB (Ethernet), snapshot length 262144 bytes INFO test_arp_req......................................OK INFO test_arp_req_other_ip.............................OK -INFO test_ipv4_req.....................................OK -INFO test_eth_req_other_mac............................OK -INFO test_ipv4_req_other_ip............................OK -INFO test_icmpv4_echo_req..............................OK -INFO test_icmpv6_neighbor_solicitation.................OK -INFO test_icmpv6_neighbor_solicitation_other_ip........OK -INFO test_icmpv6_echo_req..............................OK -INFO test_tcp_syn......................................OK -INFO test_ipv4_tcp_psh_ack.............................OK -INFO test_ipv6_tcp_psh_ack.............................OK +INFO test_ipv4_udp_dns_in_a............................OK +INFO test_ipv4_udp_dns_in_a_multiple_queries...........OK +INFO test_ipv4_tcp_ghost...............................OK INFO test_ipv4_tcp_http................................OK +INFO test_ipv4_tcp_http_segmented......................OK +INFO test_ipv4_tcp_http_incomplete.....................OK INFO test_ipv6_tcp_http................................OK INFO test_ipv4_udp_http................................OK INFO test_ipv6_udp_http................................OK @@ -276,18 +430,33 @@ INFO test_ipv4_tcp_http_ko.............................OK INFO test_ipv4_udp_http_ko.............................OK INFO test_ipv6_tcp_http_ko.............................OK INFO test_ipv6_udp_http_ko.............................OK -INFO test_ipv4_udp_stun................................OK -INFO test_ipv6_udp_stun................................OK -INFO test_ipv4_udp_stun_change_port....................OK -INFO test_ipv6_udp_stun_change_port....................OK +INFO test_icmpv4_echo_req..............................OK +INFO test_icmpv6_neighbor_solicitation.................OK +INFO test_icmpv6_neighbor_solicitation_other_ip........OK +INFO test_icmpv6_echo_req..............................OK +INFO test_ipv4_req.....................................OK +INFO test_eth_req_other_mac............................OK +INFO test_ipv4_req_other_ip............................OK +INFO test_rpc_nmap.....................................OK +INFO test_rpcinfo......................................OK +INFO test_smb1_network_req.............................OK +INFO test_smb2_network_req.............................OK INFO test_ipv4_tcp_ssh.................................OK INFO test_ipv4_udp_ssh.................................OK INFO test_ipv6_tcp_ssh.................................OK INFO test_ipv6_udp_ssh.................................OK -tcpdump: pcap_loop: The interface disappeared -604 packets captured -604 packets received by filter -0 packets dropped by kernel +INFO test_ipv4_udp_stun................................OK +INFO test_ipv6_udp_stun................................OK +INFO test_ipv4_udp_stun_change_port....................OK +INFO test_ipv6_udp_stun_change_port....................OK +INFO test_ipv4_tcp_empty...............................OK +INFO test_ipv6_tcp_empty...............................OK +INFO test_tcp_syn......................................OK +INFO test_ipv4_tcp_psh_ack.............................OK +INFO test_ipv6_tcp_psh_ack.............................OK +INFO test_ipv4_udp_empty...............................OK +INFO test_ipv6_udp_empty...............................OK +INFO Ran 41 tests with 0 errors ``` You can also chose what tests to run using the `TESTS` environment variable @@ -295,7 +464,7 @@ You can also chose what tests to run using the `TESTS` environment variable TESTS=smb ./test/test_masscanned.py INFO test_smb1_network_req.............................OK INFO test_smb2_network_req.............................OK -INFO Ran 2 tests with 1 errors +INFO Ran 2 tests with 0 errors ``` ## Logging From 6a2b7e06661b7193db651b032d6ad9f92eb4dff6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Aug 2022 00:37:20 +0000 Subject: [PATCH 102/317] Update pcap requirement from 0.9.1 to 0.10.0 Updates the requirements on [pcap](https://github.com/rust-pcap/pcap) to permit the latest version. - [Release notes](https://github.com/rust-pcap/pcap/releases) - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/compare/v0.9.1...v0.9.2) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 872d250..6738c5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.10.3" lazy_static = "1.4.0" log = "0.4.11" netdevice = "0.1.1" -pcap = "0.9.1" +pcap = "0.10.0" pcap-file = "1.1.1" pnet = "0.29.0" rand = "0.8.4" From 321b8813aa8150186f2db629c1731c1aacec18f1 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 25 Aug 2022 01:24:18 +0200 Subject: [PATCH 103/317] Display data using safe byte2str() Regression from 87c95ff2404779cfc0d72b4bb29d86aee1dcbaf1 (#13) --- src/proto/ssh.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 35d3ba8..000616b 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -176,12 +176,7 @@ pub fn repl<'a>( } let repl_data = b"SSH-2.0-1\r\n".to_vec(); debug!("sending SSH answer"); - warn!( - "SSH server banner to {}", - std::str::from_utf8(&pstate.ssh_software) - .unwrap() - .trim_end() - ); + warn!("SSH server banner to {}", byte2str(&pstate.ssh_software)); Some(repl_data) } From a4e9db8eadd3b83b7c4bec2c024c8ce7406e3c8e Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 25 Aug 2022 00:37:25 +0200 Subject: [PATCH 104/317] Update pnet requirement from 0.29.0 to 0.31.0 Fixes #55 See --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6738c5a..2311ae6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ log = "0.4.11" netdevice = "0.1.1" pcap = "0.10.0" pcap-file = "1.1.1" -pnet = "0.29.0" +pnet = { version = "0.31.0", features = ["std"] } rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.0" From 726b5d2e87d1a093ee13a76ed3c1cbf8c73c97e4 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 15 Sep 2022 17:46:56 +0200 Subject: [PATCH 105/317] Add option for list of IP to bind in command-line argument --- src/masscanned.rs | 21 +++++++++++++++++---- src/utils/parsers.rs | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index 443b38c..5bdfc90 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -116,18 +116,23 @@ fn main() { ) .arg( Arg::new("mac") - .short('a') + .short('m') .long("mac-addr") .help("MAC address to use in the response packets") .takes_value(true), ) .arg( - Arg::new("ip") - .short('f') + Arg::new("ipfile") .long("ip-addr-file") .help("File with the list of IP addresses to impersonate") .takes_value(true), ) + .arg( + Arg::new("iplist") + .long("ip-addr") + .help("Inline list of IP addresses to impersonate, comma-separated") + .takes_value(true), + ) .arg( Arg::new("verbosity") .short('v') @@ -173,7 +178,7 @@ fn main() { }; /* Parse ip address file specified */ /* FIXME: .and_then(|path| File::open(path).map(|file| )).unwrap_or_default() ? */ - let ip_list = if let Some(ref path) = args.value_of("ip") { + let mut ip_list = if let Some(ref path) = args.value_of("ipfile") { if let Ok(file) = File::open(path) { info!("parsing ip address file: {}", &path); file.extract_ip_addresses_only(None) @@ -183,9 +188,17 @@ fn main() { } else { HashSet::new() }; + if let Some(ip_inline_list) = args.value_of("iplist") { + ip_list.extend(ip_inline_list.extract_ip_addresses_only(None)); + } let ip_addresses = if !ip_list.is_empty() { + for ip in &ip_list { + info!("binding........{}", ip); + } Some(&ip_list) } else { + info!("binding........0.0.0.0"); + info!("binding........::"); None }; let mut masscanned = Masscanned { diff --git a/src/utils/parsers.rs b/src/utils/parsers.rs index a17210d..4d4c9ad 100644 --- a/src/utils/parsers.rs +++ b/src/utils/parsers.rs @@ -134,6 +134,45 @@ impl IpAddrParser for File { } } +/* Parse IP addresses from a comma-separated list in a string */ +impl IpAddrParser for &str { + fn extract_ip_addresses_with_count( + self, + _blacklist: Option>, + ) -> HashMap { + panic!("not implemented"); + } + + fn extract_ip_addresses_only(self, blacklist: Option>) -> HashSet { + let mut ip_addresses = HashSet::new(); + for line in self.split(",") { + /* Should never occur */ + if line.is_empty() { + warn!("cannot parse line: {}", line); + continue; + } + let ip: IpAddr; + if let Ok(val) = line.parse::() { + ip = IpAddr::V4(val); + } else if let Ok(val) = line.parse::() { + ip = IpAddr::V6(val); + } else { + warn!( + "cannot parse IP address from line: {}", line + ); + continue; + } + if let Some(ref b) = blacklist { + if b.contains(&ip) { + info!("[blacklist] ignoring {}", &ip); + continue; + } + } + ip_addresses.insert(ip); + } + ip_addresses + } +} /* Get the IP address of source and dest. from an IP packet. * works with both IPv4 and IPv6 packets/addresses */ fn extract_ip(pkt: Packet) -> Option<(IpAddr, IpAddr)> { From b65ed20c1a733aa53e81902eebf06f2fd4724dd8 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 15 Sep 2022 17:47:06 +0200 Subject: [PATCH 106/317] Update README --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index c743de5..556f127 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,25 @@ The pcaps can then be analyzed using [zeek](https://zeek.org/) and the output fi A documentation on how to deploy an instance of **masscanned** on a VPS is coming (see [Issue #2](https://github.com/ivre/masscanned/issues/2)). +### Supported options + +``` +Network responder - answer them all 0.2.0 +Network answering machine for various network protocols (L2-L3-L4 + applications) + +USAGE: + masscanned [OPTIONS] --iface + +OPTIONS: + -h, --help Print help information + -i, --iface the interface to use for receiving/sending packets + --ip-addr Inline list of IP addresses to impersonate, comma-separated + --ip-addr-file File with the list of IP addresses to impersonate + -m, --mac-addr MAC address to use in the response packets + -v Increase message verbosity + -V, --version Print version information +``` + ## Supported protocols - details ### Layer 2 From 331aca3d21c7108a20e803eed9bf408409a917c4 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 15 Sep 2022 17:48:36 +0200 Subject: [PATCH 107/317] Format code --- src/utils/parsers.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/parsers.rs b/src/utils/parsers.rs index 4d4c9ad..6198c7d 100644 --- a/src/utils/parsers.rs +++ b/src/utils/parsers.rs @@ -157,9 +157,7 @@ impl IpAddrParser for &str { } else if let Ok(val) = line.parse::() { ip = IpAddr::V6(val); } else { - warn!( - "cannot parse IP address from line: {}", line - ); + warn!("cannot parse IP address from line: {}", line); continue; } if let Some(ref b) = blacklist { From 26eeb73db7eda943f5f898428452085bfd5ae681 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 15 Sep 2022 17:55:31 +0200 Subject: [PATCH 108/317] Update test with new CLI options --- test/test_masscanned.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 1f1355e..6b9e5b4 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -163,9 +163,9 @@ masscanned = subprocess.Popen( "-vvvvv", "-i", f"{IFACE}b", - "-f", + "--ip-addr-file", ipfile.name, - "-a", + "-m", MAC_ADDR, ] # if args in CLI, they are passed to masscanned From cc2457db67796faa58d06367b34832a1950b0a76 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Tue, 20 Sep 2022 14:44:23 +0200 Subject: [PATCH 109/317] Add quiet mode --- README.md | 1 + src/masscanned.rs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 556f127..c18c630 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ OPTIONS: --ip-addr Inline list of IP addresses to impersonate, comma-separated --ip-addr-file File with the list of IP addresses to impersonate -m, --mac-addr MAC address to use in the response packets + -q, --quiet Quiet mode: does not output anything on stdout -v Increase message verbosity -V, --version Print version information ``` diff --git a/src/masscanned.rs b/src/masscanned.rs index 5bdfc90..202325e 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -139,6 +139,13 @@ fn main() { .multiple_occurrences(true) .help("Increase message verbosity"), ) + .arg( + Arg::new("quiet") + .long("quiet") + .short('q') + .help("Quiet mode: do not output anything on stdout") + .takes_value(false), + ) .get_matches(); let verbose = args.occurrences_of("verbosity") as usize; /* initialise logger */ @@ -210,8 +217,10 @@ fn main() { }; info!("interface......{}", masscanned.iface.unwrap().name); info!("mac address....{}", masscanned.mac); - masscanned.log.add(Box::new(ConsoleLogger::new())); - masscanned.log.init(); + if !args.contains_id("quiet") { + masscanned.log.add(Box::new(ConsoleLogger::new())); + masscanned.log.init(); + } let (mut tx, mut rx) = get_channel(masscanned.iface.unwrap()); loop { /* check if network interface is still up */ From 8b24ab4f24c7304056e46cf4acc76a2700792b17 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 21 Sep 2022 14:32:23 +0200 Subject: [PATCH 110/317] Fix bug in console logger for TCP/UDP --- src/layer_4/tcp.rs | 2 +- src/layer_4/udp.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index 08f519e..fb0681e 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -31,10 +31,10 @@ pub fn repl<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { - masscanned.log.tcp_recv(tcp_req, client_info); /* Fill client info with source and dest. TCP port */ client_info.port.src = Some(tcp_req.get_source()); client_info.port.dst = Some(tcp_req.get_destination()); + masscanned.log.tcp_recv(tcp_req, client_info); /* Construct response TCP packet */ let mut tcp_repl; match tcp_req.get_flags() { diff --git a/src/layer_4/udp.rs b/src/layer_4/udp.rs index 064e01b..57d147f 100644 --- a/src/layer_4/udp.rs +++ b/src/layer_4/udp.rs @@ -28,10 +28,10 @@ pub fn repl<'a, 'b>( masscanned: &Masscanned, mut client_info: &mut ClientInfo, ) -> Option> { - masscanned.log.udp_recv(udp_req, client_info); /* Fill client info with source and dest. UDP port */ client_info.port.src = Some(udp_req.get_source()); client_info.port.dst = Some(udp_req.get_destination()); + masscanned.log.udp_recv(udp_req, client_info); let payload = udp_req.payload(); let mut udp_repl; if let Some(repl) = proto::repl(&payload, masscanned, &mut client_info, None) { From fdf95c63bb647de16b9a9e7a08fb498b402b4aeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 00:31:34 +0000 Subject: [PATCH 111/317] Update clap requirement from 3.1.12 to 4.0.4 Updates the requirements on [clap](https://github.com/clap-rs/clap) to permit the latest version. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v3.2.0...v4.0.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2311ae6..ab4b5a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "3.1.12" +clap = "4.0.4" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From ce4ac2858d72f010f3690fe0b152fcf7c36ac0c2 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Fri, 30 Sep 2022 13:08:44 +0200 Subject: [PATCH 112/317] Fixes for clap v4 See https://github.com/clap-rs/clap/blob/master/CHANGELOG.md --- src/masscanned.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index 202325e..2ea4014 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -1,5 +1,5 @@ // This file is part of masscanned. -// Copyright 2021 - The IVRE project +// Copyright 2021 - 2022 The IVRE project // // Masscanned is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ use std::fs::File; use std::net::IpAddr; use std::str::FromStr; -use clap::{Arg, Command}; +use clap::{Arg, ArgAction, Command}; use log::*; use pnet::{ datalink::{self, Channel::Ethernet, DataLinkReceiver, DataLinkSender, NetworkInterface}, @@ -112,42 +112,41 @@ fn main() { .value_name("iface") .help("the interface to use for receiving/sending packets") .required(true) - .takes_value(true), + .num_args(1), ) .arg( Arg::new("mac") .short('m') .long("mac-addr") .help("MAC address to use in the response packets") - .takes_value(true), + .num_args(1), ) .arg( Arg::new("ipfile") .long("ip-addr-file") .help("File with the list of IP addresses to impersonate") - .takes_value(true), + .num_args(1), ) .arg( Arg::new("iplist") .long("ip-addr") .help("Inline list of IP addresses to impersonate, comma-separated") - .takes_value(true), + .num_args(1), ) .arg( Arg::new("verbosity") .short('v') - .multiple_occurrences(true) + .action(ArgAction::Count) .help("Increase message verbosity"), ) .arg( Arg::new("quiet") .long("quiet") .short('q') - .help("Quiet mode: do not output anything on stdout") - .takes_value(false), + .help("Quiet mode: do not output anything on stdout"), ) .get_matches(); - let verbose = args.occurrences_of("verbosity") as usize; + let verbose = args.value_source("verbosity").unwrap() as usize; /* initialise logger */ stderrlog::new() .module(module_path!()) @@ -160,14 +159,14 @@ fn main() { trace!("trace messages enabled"); info!("Command line arguments:"); let iface = if let Some(i) = get_interface( - args.value_of("interface") + args.get_one::("interface") .expect("error parsing iface argument"), ) { i } else { error!( "Cannot open interface \"{}\" - are you sure it exists?", - args.value_of("interface") + args.get_one::("interface") .expect("error parsing iface argument") ); return; @@ -176,7 +175,7 @@ fn main() { error!("specified interface is DOWN"); return; } - let mac = if let Some(m) = args.value_of("mac") { + let mac = if let Some(m) = args.get_one::("mac") { MacAddr::from_str(m).expect("error parsing provided MAC address") } else if let Some(m) = iface.mac { m @@ -185,7 +184,7 @@ fn main() { }; /* Parse ip address file specified */ /* FIXME: .and_then(|path| File::open(path).map(|file| )).unwrap_or_default() ? */ - let mut ip_list = if let Some(ref path) = args.value_of("ipfile") { + let mut ip_list = if let Some(ref path) = args.get_one::("ipfile") { if let Ok(file) = File::open(path) { info!("parsing ip address file: {}", &path); file.extract_ip_addresses_only(None) @@ -195,7 +194,7 @@ fn main() { } else { HashSet::new() }; - if let Some(ip_inline_list) = args.value_of("iplist") { + if let Some(ip_inline_list) = args.get_one::("iplist") { ip_list.extend(ip_inline_list.extract_ip_addresses_only(None)); } let ip_addresses = if !ip_list.is_empty() { From 699f7572ef148c8e7de27acbffb0fd8d7ba4fb73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Oct 2022 01:18:14 +0000 Subject: [PATCH 113/317] Update pcap requirement from 0.10.0 to 0.11.0 Updates the requirements on [pcap](https://github.com/rust-pcap/pcap) to permit the latest version. - [Release notes](https://github.com/rust-pcap/pcap/releases) - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ab4b5a0..83303bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.10.3" lazy_static = "1.4.0" log = "0.4.11" netdevice = "0.1.1" -pcap = "0.10.0" +pcap = "0.11.0" pcap-file = "1.1.1" pnet = { version = "0.31.0", features = ["std"] } rand = "0.8.4" From b91ac120b9537747fb933e1cd443825969dda66d Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 5 Oct 2022 06:36:46 +0200 Subject: [PATCH 114/317] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c18c630..9df70ae 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ OPTIONS: #### ARP -`masscanned` anwsers to `ARP` requests, for requests that target an `IPv4` address +`masscanned` answers to `ARP` requests, for requests that target an `IPv4` address that is handled by `masscanned` (*i.e.*, an address that is in the IP address file given with option `-f`). From a9da565785d6b7119d21972be25bef676a5ab067 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 5 Oct 2022 08:33:32 +0200 Subject: [PATCH 115/317] Add Cargo.lock to repo --- .gitignore | 1 - Cargo.lock | 793 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 793 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index 3feaee7..b40b324 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /target/ -Cargo.lock **/*.rs.bk # Vim temporary files diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..5fb7a70 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,793 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi", +] + +[[package]] +name = "cidr" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300bccc729b1ada84523246038aad61fead689ac362bb9d44beea6f6a188c34b" + +[[package]] +name = "clap" +version = "3.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3dbbb6653e7c55cc8595ad3e1f7be8f32aba4eb7ff7f0fd1163d4f3d137c0a9" +dependencies = [ + "atty", + "bitflags 1.3.2", + "clap_lex", + "indexmap", + "strsim", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "derive-into-owned" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576fce04d31d592013a5887ba8d9c3830adff329e5096d7e1eb5e8e61262ca62" +dependencies = [ + "quote 0.3.15", + "syn 0.11.11", +] + +[[package]] +name = "dns-parser" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" +dependencies = [ + "byteorder", + "quick-error", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "flate2" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" +dependencies = [ + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "ipnetwork" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f84f1612606f3753f205a4e9a2efd6fe5b4c573a6269b2cc6c3003d44a0d127" +dependencies = [ + "serde", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "libloading" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "masscanned" +version = "0.2.0" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "chrono", + "cidr", + "clap", + "dns-parser", + "flate2", + "itertools", + "lazy_static", + "log", + "netdevice", + "pcap", + "pcap-file", + "pnet", + "rand", + "siphasher", + "stderrlog", + "strum", + "strum_macros", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "miniz_oxide" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +dependencies = [ + "adler", +] + +[[package]] +name = "netdevice" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2f7ba898cd2fef0e36f91c9cd2bf3b849a2a31510d5f7e1cf515cbf698198" +dependencies = [ + "bitflags 0.7.0", + "libc", +] + +[[package]] +name = "no-std-net" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "os_str_bytes" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" + +[[package]] +name = "pcap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da544c8115cc65b474554569c7654fc94a4f6a167f79192536e148fd654e17a" +dependencies = [ + "bitflags 1.3.2", + "errno", + "libc", + "libloading", + "regex", + "windows-sys", +] + +[[package]] +name = "pcap-file" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ad13fed1a83120159aea81b265074f21d753d157dd16b10cc3790ecba40a341" +dependencies = [ + "byteorder", + "derive-into-owned", + "thiserror", +] + +[[package]] +name = "pnet" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0caaf5b11fd907ff15cf14a4477bfabca4b37ab9e447a4f8dead969a59cdafad" +dependencies = [ + "ipnetwork", + "pnet_base", + "pnet_datalink", + "pnet_packet", + "pnet_sys", + "pnet_transport", +] + +[[package]] +name = "pnet_base" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d3a993d49e5fd5d4d854d6999d4addca1f72d86c65adf224a36757161c02b6" +dependencies = [ + "no-std-net", +] + +[[package]] +name = "pnet_datalink" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e466faf03a98ad27f6e15cd27a2b7cc89e73e640a43527742977bc503c37f8aa" +dependencies = [ + "ipnetwork", + "libc", + "pnet_base", + "pnet_sys", + "winapi", +] + +[[package]] +name = "pnet_macros" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48dd52a5211fac27e7acb14cfc9f30ae16ae0e956b7b779c8214c74559cef4c3" +dependencies = [ + "proc-macro2", + "quote 1.0.18", + "regex", + "syn 1.0.95", +] + +[[package]] +name = "pnet_macros_support" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89de095dc7739349559913aed1ef6a11e73ceade4897dadc77c5e09de6740750" +dependencies = [ + "pnet_base", +] + +[[package]] +name = "pnet_packet" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc3b5111e697c39c8b9795b9fdccbc301ab696699e88b9ea5a4e4628978f495f" +dependencies = [ + "glob", + "pnet_base", + "pnet_macros", + "pnet_macros_support", +] + +[[package]] +name = "pnet_sys" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "328e231f0add6d247d82421bf3790b4b33b39c8930637f428eef24c4c6a90805" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "pnet_transport" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff597185e6f1f5671b3122e4dba892a1c73e17c17e723d7669bd9299cbe7f124" +dependencies = [ + "libc", + "pnet_base", + "pnet_packet", + "pnet_sys", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro2" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" + +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + +[[package]] +name = "serde" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" + +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + +[[package]] +name = "stderrlog" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45a53e2eff3e94a019afa6265e8ee04cb05b9d33fe9f5078b14e4e391d155a38" +dependencies = [ + "atty", + "chrono", + "log", + "termcolor", + "thread_local", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4faebde00e8ff94316c01800f9054fd2ba77d30d9e922541913051d1d978918b" +dependencies = [ + "heck", + "proc-macro2", + "quote 1.0.18", + "rustversion", + "syn 1.0.95", +] + +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +dependencies = [ + "quote 0.3.15", + "synom", + "unicode-xid", +] + +[[package]] +name = "syn" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" +dependencies = [ + "proc-macro2", + "quote 1.0.18", + "unicode-ident", +] + +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote 1.0.18", + "syn 1.0.95", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "unicode-ident" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" + +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" From b5525d1060483e2959890d35635be7202c0968cb Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 5 Oct 2022 10:18:09 +0200 Subject: [PATCH 116/317] Update Cargo.lock; fixes security issue with thread_local --- Cargo.lock | 243 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 161 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fb7a70..cc85020 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,13 +10,22 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "atty" version = "0.2.14" @@ -46,6 +55,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bumpalo" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" + [[package]] name = "byteorder" version = "1.4.3" @@ -66,47 +81,47 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" dependencies = [ - "libc", + "iana-time-zone", + "js-sys", "num-integer", "num-traits", "time", + "wasm-bindgen", "winapi", ] -[[package]] -name = "cidr" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300bccc729b1ada84523246038aad61fead689ac362bb9d44beea6f6a188c34b" - [[package]] name = "clap" -version = "3.2.16" +version = "4.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3dbbb6653e7c55cc8595ad3e1f7be8f32aba4eb7ff7f0fd1163d4f3d137c0a9" +checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0" dependencies = [ "atty", "bitflags 1.3.2", "clap_lex", - "indexmap", "strsim", "termcolor", - "textwrap", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" dependencies = [ "os_str_bytes", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "crc32fast" version = "1.3.2" @@ -138,9 +153,9 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "errno" @@ -165,13 +180,11 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ - "cfg-if", "crc32fast", - "libc", "miniz_oxide", ] @@ -192,12 +205,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "heck" version = "0.4.0" @@ -214,13 +221,16 @@ dependencies = [ ] [[package]] -name = "indexmap" -version = "1.9.1" +name = "iana-time-zone" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0" dependencies = [ - "autocfg", - "hashbrown", + "android_system_properties", + "core-foundation-sys", + "js-sys", + "wasm-bindgen", + "winapi", ] [[package]] @@ -234,13 +244,22 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -249,9 +268,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" [[package]] name = "libloading" @@ -279,7 +298,6 @@ dependencies = [ "bitflags 1.3.2", "byteorder", "chrono", - "cidr", "clap", "dns-parser", "flate2", @@ -305,9 +323,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miniz_oxide" -version = "0.5.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" dependencies = [ "adler", ] @@ -348,21 +366,28 @@ dependencies = [ ] [[package]] -name = "os_str_bytes" -version = "6.2.0" +name = "once_cell" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" + +[[package]] +name = "os_str_bytes" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" [[package]] name = "pcap" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da544c8115cc65b474554569c7654fc94a4f6a167f79192536e148fd654e17a" +checksum = "98d92d4bf65b3e26dbbadaf90b0ea90f7dd631459db276b3b1fc3efc3c68696a" dependencies = [ "bitflags 1.3.2", "errno", "libc", "libloading", + "pkg-config", "regex", "windows-sys", ] @@ -378,6 +403,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + [[package]] name = "pnet" version = "0.31.0" @@ -421,9 +452,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48dd52a5211fac27e7acb14cfc9f30ae16ae0e956b7b779c8214c74559cef4c3" dependencies = [ "proc-macro2", - "quote 1.0.18", + "quote 1.0.21", "regex", - "syn 1.0.95", + "syn 1.0.101", ] [[package]] @@ -477,9 +508,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" dependencies = [ "unicode-ident", ] @@ -498,9 +529,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "1.0.18" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -528,9 +559,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] @@ -560,9 +591,9 @@ checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" [[package]] name = "siphasher" @@ -572,9 +603,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "stderrlog" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a53e2eff3e94a019afa6265e8ee04cb05b9d33fe9f5078b14e4e391d155a38" +checksum = "af95cb8a5f79db5b2af2a46f44da7594b5adbcbb65cbf87b8da0959bfdd82460" dependencies = [ "atty", "chrono", @@ -597,15 +628,15 @@ checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" [[package]] name = "strum_macros" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4faebde00e8ff94316c01800f9054fd2ba77d30d9e922541913051d1d978918b" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", "proc-macro2", - "quote 1.0.18", + "quote 1.0.21", "rustversion", - "syn 1.0.95", + "syn 1.0.101", ] [[package]] @@ -621,12 +652,12 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.95" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" +checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" dependencies = [ "proc-macro2", - "quote 1.0.18", + "quote 1.0.21", "unicode-ident", ] @@ -648,39 +679,33 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" - [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", - "quote 1.0.18", - "syn 1.0.95", + "quote 1.0.21", + "syn 1.0.101", ] [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -696,9 +721,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" [[package]] name = "unicode-xid" @@ -718,6 +743,60 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote 1.0.21", + "syn 1.0.101", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote 1.0.21", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote 1.0.21", + "syn 1.0.101", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + [[package]] name = "winapi" version = "0.3.9" From 1f02849656f80aaaf1b2c4d44c170b91703ab79d Mon Sep 17 00:00:00 2001 From: Unactive Date: Wed, 5 Oct 2022 22:11:33 +0200 Subject: [PATCH 117/317] Format option and Logfmt support --- src/logger/logfmt.rs | 308 +++++++++++++++++++++++++++++++++++++++++++ src/logger/mod.rs | 2 + src/masscanned.rs | 28 +++- 3 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 src/logger/logfmt.rs diff --git a/src/logger/logfmt.rs b/src/logger/logfmt.rs new file mode 100644 index 0000000..ec5a744 --- /dev/null +++ b/src/logger/logfmt.rs @@ -0,0 +1,308 @@ +// This file is part of masscanned. +// Copyright 2021 - The IVRE project +// +// Masscanned is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Masscanned is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Masscanned. If not, see . + +use std::time::SystemTime; + +use pnet::packet::{ + arp::{ArpPacket, MutableArpPacket}, + ethernet::{EthernetPacket, MutableEthernetPacket}, + icmp::{IcmpPacket, MutableIcmpPacket}, + icmpv6::{Icmpv6Packet, MutableIcmpv6Packet}, + ipv4::{Ipv4Packet, MutableIpv4Packet}, + ipv6::{Ipv6Packet, MutableIpv6Packet}, + tcp::{MutableTcpPacket, TcpPacket}, + udp::{MutableUdpPacket, UdpPacket}, +}; + +use crate::client::ClientInfo; +use crate::logger::Logger; + +pub struct LogfmtLogger { + arp: bool, + eth: bool, + ipv4: bool, + ipv6: bool, + icmpv4: bool, + icmpv6: bool, + tcp: bool, + udp: bool, +} + +impl LogfmtLogger { + pub fn new() -> Self { + LogfmtLogger { + arp: true, + eth: true, + ipv4: true, + ipv6: true, + icmpv4: true, + icmpv6: true, + tcp: true, + udp: true, + } + } + fn prolog(&self, proto: &str, verb: &str, crlf: bool) { + let now = SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap(); + print!( + "ts={}.{} proto={} verb={}{}", + now.as_secs(), + now.subsec_millis(), + proto, + verb, + if crlf { "\n" } else { " " }, + ); + } + fn client_info(&self, c: &ClientInfo) { + print!( + "{}{}{}{}{}{}{}", + if let Some(m) = c.mac.src { + format!(" mac_src={}", m) + } else { + "".to_string() + }, + if let Some(m) = c.mac.dst { + format!(" mac_dst={}", m) + } else { + "".to_string() + }, + if let Some(i) = c.ip.src { + format!(" ip_src={}", i) + } else { + "".to_string() + }, + if let Some(i) = c.ip.dst { + format!(" ip_dst={}", i) + } else { + "".to_string() + }, + if let Some(t) = c.transport { + format!(" transport={}", t) + } else { + "".to_string() + }, + if let Some(p) = c.port.src { + format!(" port_src={}", p) + } else { + "".to_string() + }, + if let Some(p) = c.port.dst { + format!(" port_dst={}", p) + } else { + "".to_string() + }, + ); + } +} + +impl Logger for LogfmtLogger { + fn init(&self) { + self.prolog("arp", "init", true); + self.prolog("eth", "init", true); + self.prolog("ipv4", "init", true); + self.prolog("ipv6", "init", true); + self.prolog("icmpv4", "init", true); + self.prolog("icmpv6", "init", true); + self.prolog("tcp", "init", true); + self.prolog("udp", "init", true); + } + /* ARP */ + fn arp_enabled(&self) -> bool { + self.arp + } + fn arp_recv(&self, p: &ArpPacket) { + self.prolog("arp", "recv", false); + println!( + " mac_src={:} mac_dst={:} ip_src={:} ip_dst={:} op={:?}", + p.get_sender_hw_addr(), + p.get_target_hw_addr(), + p.get_sender_proto_addr(), + p.get_target_proto_addr(), + p.get_operation(), + ); + } + fn arp_drop(&self, p: &ArpPacket) { + self.prolog("arp", "drop", false); + println!( + " mac_src={:} mac_dst={:} ip_src={:} ip_dst={:} op={:?}", + p.get_sender_hw_addr(), + p.get_target_hw_addr(), + p.get_sender_proto_addr(), + p.get_target_proto_addr(), + p.get_operation(), + ); + } + fn arp_send(&self, p: &MutableArpPacket) { + self.prolog("arp", "send", false); + println!( + " mac_dst={:} mac_src={:} ip_dst={:} ip_src={:} op={:?}", + p.get_target_hw_addr(), + p.get_sender_hw_addr(), + p.get_target_proto_addr(), + p.get_sender_proto_addr(), + p.get_operation(), + ); + } + /* Ethernet */ + fn eth_enabled(&self) -> bool { + self.eth + } + fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { + self.prolog("eth", "recv", false); + self.client_info(c); + println!(" et={:}", p.get_ethertype(),); + } + fn eth_drop(&self, p: &EthernetPacket, c: &ClientInfo) { + self.prolog("eth", "drop", false); + self.client_info(c); + println!(" et={:}", p.get_ethertype(),); + } + fn eth_send(&self, p: &MutableEthernetPacket, c: &ClientInfo) { + self.prolog("eth", "send", false); + self.client_info(c); + println!(" et={:}", p.get_ethertype(),); + } + /* IPv4 */ + fn ipv4_enabled(&self) -> bool { + self.ipv4 + } + fn ipv4_recv(&self, p: &Ipv4Packet, c: &ClientInfo) { + self.prolog("ipv4", "recv", false); + self.client_info(c); + println!(" next_proto={:}", p.get_next_level_protocol(),); + } + fn ipv4_drop(&self, p: &Ipv4Packet, c: &ClientInfo) { + self.prolog("ipv4", "drop", false); + self.client_info(c); + println!(" next_proto={:}", p.get_next_level_protocol(),); + } + fn ipv4_send(&self, p: &MutableIpv4Packet, c: &ClientInfo) { + self.prolog("ipv4", "send", false); + self.client_info(c); + println!(" next_proto={:}", p.get_next_level_protocol(),); + } + /* IPv6 */ + fn ipv6_enabled(&self) -> bool { + self.ipv6 + } + fn ipv6_recv(&self, p: &Ipv6Packet, c: &ClientInfo) { + self.prolog("ipv6", "recv", false); + self.client_info(c); + println!(" next_proto={:}", p.get_next_header(),); + } + fn ipv6_drop(&self, p: &Ipv6Packet, c: &ClientInfo) { + self.prolog("ipv6", "drop", false); + self.client_info(c); + println!(" next_proto={:}", p.get_next_header(),); + } + fn ipv6_send(&self, p: &MutableIpv6Packet, c: &ClientInfo) { + self.prolog("ipv6", "send", false); + self.client_info(c); + println!(" next_proto={:}", p.get_next_header(),); + } + /* ICMPv4 */ + fn icmpv4_enabled(&self) -> bool { + self.icmpv4 + } + fn icmpv4_recv(&self, p: &IcmpPacket, c: &ClientInfo) { + self.prolog("icmpv4", "recv", false); + self.client_info(c); + println!(" icmp_type={:?} icmp_code={:?}", p.get_icmp_type(), p.get_icmp_code(),); + } + fn icmpv4_drop(&self, p: &IcmpPacket, c: &ClientInfo) { + self.prolog("icmpv4", "drop", false); + self.client_info(c); + println!(" icmp_type={:?} icmp_code={:?}", p.get_icmp_type(), p.get_icmp_code(),); + } + fn icmpv4_send(&self, p: &MutableIcmpPacket, c: &ClientInfo) { + self.prolog("icmpv4", "send", false); + self.client_info(c); + println!(" icmp_type={:?} icmp_code={:?}", p.get_icmp_type(), p.get_icmp_code(),); + } + /* ICMPv6 */ + fn icmpv6_enabled(&self) -> bool { + self.icmpv6 + } + fn icmpv6_recv(&self, p: &Icmpv6Packet, c: &ClientInfo) { + self.prolog("icmpv6", "recv", false); + self.client_info(c); + println!(" icmpv6_type={:?} icmpv6_code={:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); + } + fn icmpv6_drop(&self, p: &Icmpv6Packet, c: &ClientInfo) { + self.prolog("icmpv6", "drop", false); + self.client_info(c); + println!(" icmpv6_type={:?} icmpv6_code={:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); + } + fn icmpv6_send(&self, p: &MutableIcmpv6Packet, c: &ClientInfo) { + self.prolog("icmpv6", "send", false); + self.client_info(c); + println!(" icmpv6_type={:?} icmpv6_code={:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); + } + /* TCP */ + fn tcp_enabled(&self) -> bool { + self.tcp + } + fn tcp_recv(&self, p: &TcpPacket, c: &ClientInfo) { + self.prolog("tcp", "recv", false); + self.client_info(c); + println!( + " flags={:?} seq={:} ack={:}", + p.get_flags(), + p.get_sequence(), + p.get_acknowledgement(), + ); + } + fn tcp_drop(&self, p: &TcpPacket, c: &ClientInfo) { + self.prolog("tcp", "drop", false); + self.client_info(c); + println!( + " flags={:?} seq={:} ack={:}", + p.get_flags(), + p.get_sequence(), + p.get_acknowledgement(), + ); + } + fn tcp_send(&self, p: &MutableTcpPacket, c: &ClientInfo) { + self.prolog("tcp", "send", false); + self.client_info(c); + println!( + " flags={:?} seq={:} ack={:}", + p.get_flags(), + p.get_sequence(), + p.get_acknowledgement(), + ); + } + /* UDP */ + fn udp_enabled(&self) -> bool { + self.udp + } + fn udp_recv(&self, _p: &UdpPacket, c: &ClientInfo) { + self.prolog("udp", "recv", false); + self.client_info(c); + println!(""); + } + fn udp_drop(&self, _p: &UdpPacket, c: &ClientInfo) { + self.prolog("udp", "drop", false); + self.client_info(c); + println!(""); + } + fn udp_send(&self, _p: &MutableUdpPacket, c: &ClientInfo) { + self.prolog("udp", "send", false); + self.client_info(c); + println!(""); + } +} diff --git a/src/logger/mod.rs b/src/logger/mod.rs index bcd6f5e..8a6fb5e 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -28,9 +28,11 @@ use pnet::packet::{ use crate::client::ClientInfo; mod console; +mod logfmt; mod meta; pub use console::ConsoleLogger; +pub use logfmt::LogfmtLogger; pub use meta::MetaLogger; pub trait Logger { diff --git a/src/masscanned.rs b/src/masscanned.rs index 2ea4014..d250159 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -24,7 +24,10 @@ use std::fs::File; use std::net::IpAddr; use std::str::FromStr; -use clap::{Arg, ArgAction, Command}; +use clap::{ + Arg, ArgAction, Command, + builder::PossibleValuesParser, +}; use log::*; use pnet::{ datalink::{self, Channel::Ethernet, DataLinkReceiver, DataLinkSender, NetworkInterface}, @@ -35,7 +38,7 @@ use pnet::{ util::MacAddr, }; -use crate::logger::{ConsoleLogger, MetaLogger}; +use crate::logger::{Logger, ConsoleLogger, LogfmtLogger, MetaLogger}; use crate::utils::IpAddrParser; mod client; @@ -145,6 +148,14 @@ fn main() { .short('q') .help("Quiet mode: do not output anything on stdout"), ) + .arg( + Arg::new("format") + .long("format") + .help("Format in which to output logs") + .default_value("console") + .value_parser(PossibleValuesParser::new(["console", "logfmt"])) + .num_args(1), + ) .get_matches(); let verbose = args.value_source("verbosity").unwrap() as usize; /* initialise logger */ @@ -217,7 +228,18 @@ fn main() { info!("interface......{}", masscanned.iface.unwrap().name); info!("mac address....{}", masscanned.mac); if !args.contains_id("quiet") { - masscanned.log.add(Box::new(ConsoleLogger::new())); + if let Some(format) = args.get_one::("format") { + let chosen_logger: Box = match format.as_str() { + "console" => Box::new(ConsoleLogger::new()), + "logfmt" => Box::new(LogfmtLogger::new()), + + // clap should already ensure we're using a valid format + _ => panic!("illegal format") + }; + masscanned.log.add(chosen_logger); + } else { + masscanned.log.add(Box::new(ConsoleLogger::new())); + } masscanned.log.init(); } let (mut tx, mut rx) = get_channel(masscanned.iface.unwrap()); From 366d891d6e71e68ed2d8e7ecf97d0ae27090c023 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Oct 2022 00:34:49 +0000 Subject: [PATCH 118/317] Bump clap from 4.0.9 to 4.0.10 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.9 to 4.0.10. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.9...v4.0.10) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc85020..f88e385 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.9" +version = "4.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0" +checksum = "3b1a0a4208c6c483b952ad35c6eed505fc13b46f08f631b81e828084a9318d74" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 83303bb..655216e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.4" +clap = "4.0.10" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From e5bbd08d4988c667384b7e15560b2caaac5bbf34 Mon Sep 17 00:00:00 2001 From: Unactive Date: Thu, 6 Oct 2022 10:07:00 +0200 Subject: [PATCH 119/317] et -> eth_type and cargo fmt --- src/logger/logfmt.rs | 42 +++++++++++++++++++++++++++++++++--------- src/masscanned.rs | 11 ++++------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/logger/logfmt.rs b/src/logger/logfmt.rs index ec5a744..5c3e02a 100644 --- a/src/logger/logfmt.rs +++ b/src/logger/logfmt.rs @@ -164,17 +164,17 @@ impl Logger for LogfmtLogger { fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) { self.prolog("eth", "recv", false); self.client_info(c); - println!(" et={:}", p.get_ethertype(),); + println!(" eth_type={:}", p.get_ethertype(),); } fn eth_drop(&self, p: &EthernetPacket, c: &ClientInfo) { self.prolog("eth", "drop", false); self.client_info(c); - println!(" et={:}", p.get_ethertype(),); + println!(" eth_type={:}", p.get_ethertype(),); } fn eth_send(&self, p: &MutableEthernetPacket, c: &ClientInfo) { self.prolog("eth", "send", false); self.client_info(c); - println!(" et={:}", p.get_ethertype(),); + println!(" eth_type={:}", p.get_ethertype(),); } /* IPv4 */ fn ipv4_enabled(&self) -> bool { @@ -221,17 +221,29 @@ impl Logger for LogfmtLogger { fn icmpv4_recv(&self, p: &IcmpPacket, c: &ClientInfo) { self.prolog("icmpv4", "recv", false); self.client_info(c); - println!(" icmp_type={:?} icmp_code={:?}", p.get_icmp_type(), p.get_icmp_code(),); + println!( + " icmp_type={:?} icmp_code={:?}", + p.get_icmp_type(), + p.get_icmp_code(), + ); } fn icmpv4_drop(&self, p: &IcmpPacket, c: &ClientInfo) { self.prolog("icmpv4", "drop", false); self.client_info(c); - println!(" icmp_type={:?} icmp_code={:?}", p.get_icmp_type(), p.get_icmp_code(),); + println!( + " icmp_type={:?} icmp_code={:?}", + p.get_icmp_type(), + p.get_icmp_code(), + ); } fn icmpv4_send(&self, p: &MutableIcmpPacket, c: &ClientInfo) { self.prolog("icmpv4", "send", false); self.client_info(c); - println!(" icmp_type={:?} icmp_code={:?}", p.get_icmp_type(), p.get_icmp_code(),); + println!( + " icmp_type={:?} icmp_code={:?}", + p.get_icmp_type(), + p.get_icmp_code(), + ); } /* ICMPv6 */ fn icmpv6_enabled(&self) -> bool { @@ -240,17 +252,29 @@ impl Logger for LogfmtLogger { fn icmpv6_recv(&self, p: &Icmpv6Packet, c: &ClientInfo) { self.prolog("icmpv6", "recv", false); self.client_info(c); - println!(" icmpv6_type={:?} icmpv6_code={:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); + println!( + " icmpv6_type={:?} icmpv6_code={:?}", + p.get_icmpv6_type(), + p.get_icmpv6_code(), + ); } fn icmpv6_drop(&self, p: &Icmpv6Packet, c: &ClientInfo) { self.prolog("icmpv6", "drop", false); self.client_info(c); - println!(" icmpv6_type={:?} icmpv6_code={:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); + println!( + " icmpv6_type={:?} icmpv6_code={:?}", + p.get_icmpv6_type(), + p.get_icmpv6_code(), + ); } fn icmpv6_send(&self, p: &MutableIcmpv6Packet, c: &ClientInfo) { self.prolog("icmpv6", "send", false); self.client_info(c); - println!(" icmpv6_type={:?} icmpv6_code={:?}", p.get_icmpv6_type(), p.get_icmpv6_code(),); + println!( + " icmpv6_type={:?} icmpv6_code={:?}", + p.get_icmpv6_type(), + p.get_icmpv6_code(), + ); } /* TCP */ fn tcp_enabled(&self) -> bool { diff --git a/src/masscanned.rs b/src/masscanned.rs index d250159..189b756 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -24,10 +24,7 @@ use std::fs::File; use std::net::IpAddr; use std::str::FromStr; -use clap::{ - Arg, ArgAction, Command, - builder::PossibleValuesParser, -}; +use clap::{builder::PossibleValuesParser, Arg, ArgAction, Command}; use log::*; use pnet::{ datalink::{self, Channel::Ethernet, DataLinkReceiver, DataLinkSender, NetworkInterface}, @@ -38,7 +35,7 @@ use pnet::{ util::MacAddr, }; -use crate::logger::{Logger, ConsoleLogger, LogfmtLogger, MetaLogger}; +use crate::logger::{ConsoleLogger, LogfmtLogger, Logger, MetaLogger}; use crate::utils::IpAddrParser; mod client; @@ -229,12 +226,12 @@ fn main() { info!("mac address....{}", masscanned.mac); if !args.contains_id("quiet") { if let Some(format) = args.get_one::("format") { - let chosen_logger: Box = match format.as_str() { + let chosen_logger: Box = match format.as_str() { "console" => Box::new(ConsoleLogger::new()), "logfmt" => Box::new(LogfmtLogger::new()), // clap should already ensure we're using a valid format - _ => panic!("illegal format") + _ => panic!("illegal format"), }; masscanned.log.add(chosen_logger); } else { From 409efd4bc5fedac407409fc7708437dd262ad550 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Oct 2022 01:10:06 +0000 Subject: [PATCH 120/317] Bump clap from 4.0.10 to 4.0.11 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.10 to 4.0.11. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.10...v4.0.11) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f88e385..11703a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.10" +version = "4.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1a0a4208c6c483b952ad35c6eed505fc13b46f08f631b81e828084a9318d74" +checksum = "4ed45cc2c62a3eff523e718d8576ba762c83a3146151093283ac62ae11933a73" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 655216e..98ba68d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.10" +clap = "4.0.11" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 0fc137ac3bf6c049fc3fcbc294c04f33c61a607a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 00:47:27 +0000 Subject: [PATCH 121/317] Bump clap from 4.0.11 to 4.0.12 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.11 to 4.0.12. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.11...v4.0.12) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11703a8..c140cf1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.11" +version = "4.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ed45cc2c62a3eff523e718d8576ba762c83a3146151093283ac62ae11933a73" +checksum = "385007cbbed899260395a4107435fead4cad80684461b3cc78238bdcb0bad58f" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 98ba68d..858d8d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.11" +clap = "4.0.12" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 29400cba61049b437954efcbfaf3f0c189363128 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Oct 2022 00:48:41 +0000 Subject: [PATCH 122/317] Bump clap from 4.0.12 to 4.0.13 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.12 to 4.0.13. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.12...v4.0.13) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c140cf1..109cfef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.12" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385007cbbed899260395a4107435fead4cad80684461b3cc78238bdcb0bad58f" +checksum = "69d64e88428747154bd8bc378d178377ef4dace7a5735ca1f3855be72f2c2cb5" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 858d8d2..873bca2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.12" +clap = "4.0.13" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 87c789953bf88efaaa857a2ca720db981872a5a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 00:22:33 +0000 Subject: [PATCH 123/317] Bump clap from 4.0.13 to 4.0.14 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.13 to 4.0.14. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.13...v4.0.14) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 109cfef..16ad4ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.13" +version = "4.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d64e88428747154bd8bc378d178377ef4dace7a5735ca1f3855be72f2c2cb5" +checksum = "6ea54a38e4bce14ff6931c72e5b3c43da7051df056913d4e7e1fcdb1c03df69d" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 873bca2..3d4bcc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.13" +clap = "4.0.14" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From e86fadf32ee68d75834600ce00f9bf58863efcbd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:34:29 +0000 Subject: [PATCH 124/317] Bump clap from 4.0.14 to 4.0.15 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.14 to 4.0.15. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.14...v4.0.15) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16ad4ef..fd2c043 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.14" +version = "4.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea54a38e4bce14ff6931c72e5b3c43da7051df056913d4e7e1fcdb1c03df69d" +checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 3d4bcc9..61d055e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.14" +clap = "4.0.15" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 4932805271e614f75ee962ee129c35f92e54db85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 00:33:07 +0000 Subject: [PATCH 125/317] Bump clap from 4.0.15 to 4.0.17 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.15 to 4.0.17. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.15...v4.0.17) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd2c043..f687700 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.15" +version = "4.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f" +checksum = "06badb543e734a2d6568e19a40af66ed5364360b9226184926f89d229b4b4267" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 61d055e..82e0295 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.15" +clap = "4.0.17" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 04c9621c7e816cebec195f6c8d99949c1f6e99b9 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 20 Oct 2022 17:49:36 +0200 Subject: [PATCH 126/317] Fix clap default options since last update --- src/masscanned.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index 189b756..59651b0 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -143,7 +143,8 @@ fn main() { Arg::new("quiet") .long("quiet") .short('q') - .help("Quiet mode: do not output anything on stdout"), + .help("Quiet mode: do not output anything on stdout") + .num_args(0), ) .arg( Arg::new("format") From ae175e7b7730b83f120f8bf4a62513ff9a618de5 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 20 Oct 2022 20:03:15 +0200 Subject: [PATCH 127/317] Fix other bug in clap --- src/masscanned.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index 59651b0..4d3db61 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -143,8 +143,9 @@ fn main() { Arg::new("quiet") .long("quiet") .short('q') - .help("Quiet mode: do not output anything on stdout") - .num_args(0), + .action(ArgAction::SetTrue) + .required(false) + .help("Quiet mode: do not output anything on stdout"), ) .arg( Arg::new("format") @@ -225,7 +226,10 @@ fn main() { }; info!("interface......{}", masscanned.iface.unwrap().name); info!("mac address....{}", masscanned.mac); - if !args.contains_id("quiet") { + if !args + .get_one::("quiet") + .expect("unexpected error parsing argument") + { if let Some(format) = args.get_one::("format") { let chosen_logger: Box = match format.as_str() { "console" => Box::new(ConsoleLogger::new()), From 090770a5eeff478e208f89ae8c50b51704d49a67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Oct 2022 01:00:28 +0000 Subject: [PATCH 128/317] Bump clap from 4.0.17 to 4.0.18 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.17 to 4.0.18. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.17...v4.0.18) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f687700..3c30ad0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.17" +version = "4.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06badb543e734a2d6568e19a40af66ed5364360b9226184926f89d229b4b4267" +checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 82e0295..2a4c8ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.17" +clap = "4.0.18" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From b564e9762f3047696683d1862b8d770f1680111b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 00:27:46 +0000 Subject: [PATCH 129/317] Bump stderrlog from 0.5.3 to 0.5.4 Bumps [stderrlog](https://github.com/cardoe/stderrlog-rs) from 0.5.3 to 0.5.4. - [Release notes](https://github.com/cardoe/stderrlog-rs/releases) - [Changelog](https://github.com/cardoe/stderrlog-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/cardoe/stderrlog-rs/compare/v0.5.3...v0.5.4) --- updated-dependencies: - dependency-name: stderrlog dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c30ad0..f9ec1ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -603,9 +603,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "stderrlog" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af95cb8a5f79db5b2af2a46f44da7594b5adbcbb65cbf87b8da0959bfdd82460" +checksum = "69a26bbf6de627d389164afa9783739b56746c6c72c4ed16539f4ff54170327b" dependencies = [ "atty", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 2a4c8ed..d3668ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ pcap-file = "1.1.1" pnet = { version = "0.31.0", features = ["std"] } rand = "0.8.4" siphasher = "0.3" -stderrlog = "0.5.0" +stderrlog = "0.5.4" strum = "0.24.1" strum_macros = "0.24.2" From 375f0e3d0499a0623b39a1b1c4bba2da0c0c97b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 00:27:59 +0000 Subject: [PATCH 130/317] Bump clap from 4.0.18 to 4.0.22 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.18 to 4.0.22. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.18...v4.0.22) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c30ad0..88e40ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.18" +version = "4.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b" +checksum = "91b9970d7505127a162fdaa9b96428d28a479ba78c9ec7550a63a5d9863db682" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 2a4c8ed..8b29741 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.18" +clap = "4.0.22" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From eb1228a7aa2169e21ed03f4b5db7ec5824993893 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Nov 2022 00:09:55 +0000 Subject: [PATCH 131/317] Bump clap from 4.0.22 to 4.0.24 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.22 to 4.0.24. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.22...v4.0.24) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2401ba4..67bd06f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.22" +version = "4.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b9970d7505127a162fdaa9b96428d28a479ba78c9ec7550a63a5d9863db682" +checksum = "60494cedb60cb47462c0ff7be53de32c0e42a6fc2c772184554fa12bd9489c03" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 1de0bf4..e2b0322 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "4.0.22" +clap = "4.0.24" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 046ecfd44326cbc40b467df5e0e1c6088dff2b3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Nov 2022 12:07:45 +0000 Subject: [PATCH 132/317] Bump chrono from 0.4.22 to 0.4.23 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.22 to 0.4.23. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.22...v0.4.23) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67bd06f..ec958e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,9 +81,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ "iana-time-zone", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index e2b0322..5fea6c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "1.2.1" byteorder = "1.4.3" -chrono = "0.4.19" +chrono = "0.4.23" clap = "4.0.24" dns-parser = "0.8.0" flate2 = "1.0" From 1ccd464ba688b690ba969aafdcd343af634a1bc0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Nov 2022 00:22:21 +0000 Subject: [PATCH 133/317] Bump clap from 4.0.24 to 4.0.25 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.24 to 4.0.25. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.24...v4.0.25) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec958e2..5985cd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.24" +version = "4.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60494cedb60cb47462c0ff7be53de32c0e42a6fc2c772184554fa12bd9489c03" +checksum = "389ca505fd2c00136e0d0cd34bcd8b6bd0b59d5779aab396054b716334230c1c" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 5fea6c3..c2c7ef4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.0.24" +clap = "4.0.25" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From fd4f04671ffd0e38d566507a2d274f27b88d7b0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Nov 2022 00:27:26 +0000 Subject: [PATCH 134/317] Bump clap from 4.0.25 to 4.0.26 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.25 to 4.0.26. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.25...v4.0.26) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5985cd6..42b2746 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.25" +version = "4.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca505fd2c00136e0d0cd34bcd8b6bd0b59d5779aab396054b716334230c1c" +checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" dependencies = [ "atty", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index c2c7ef4..6e3f521 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.0.25" +clap = "4.0.26" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 86e8b6a60797786e58470051ad3710b819dad518 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 01:14:22 +0000 Subject: [PATCH 135/317] Bump pcap from 0.11.0 to 1.0.0 Bumps [pcap](https://github.com/rust-pcap/pcap) from 0.11.0 to 1.0.0. - [Release notes](https://github.com/rust-pcap/pcap/releases) - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/compare/v0.11.0...v1.0.0) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42b2746..1919803 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -379,9 +379,9 @@ checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" [[package]] name = "pcap" -version = "0.11.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98d92d4bf65b3e26dbbadaf90b0ea90f7dd631459db276b3b1fc3efc3c68696a" +checksum = "d536b12f51fa925b590a6681765ed2bd9f1beb1d2953fa5fe5a20f7c1087b994" dependencies = [ "bitflags 1.3.2", "errno", diff --git a/Cargo.toml b/Cargo.toml index 6e3f521..4075fd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.10.3" lazy_static = "1.4.0" log = "0.4.11" netdevice = "0.1.1" -pcap = "0.11.0" +pcap = "1.0.0" pcap-file = "1.1.1" pnet = { version = "0.31.0", features = ["std"] } rand = "0.8.4" From 0f8ef335a067fd8df02c3cd25d2995103b337cb7 Mon Sep 17 00:00:00 2001 From: Unactive Date: Thu, 24 Nov 2022 15:00:35 +0100 Subject: [PATCH 136/317] Added option to forbid responding to chosen IP addresses --- src/layer_2/arp.rs | 1 + src/layer_2/mod.rs | 2 ++ src/layer_3/ipv4.rs | 12 ++++++++++++ src/layer_3/ipv6.rs | 18 +++++++++++++++--- src/layer_4/icmpv4.rs | 1 + src/layer_4/icmpv6.rs | 2 ++ src/layer_4/tcp.rs | 4 ++++ src/masscanned.rs | 36 ++++++++++++++++++++++++++++++++++++ src/proto/dns/header.rs | 4 ++++ src/proto/dns/mod.rs | 1 + src/proto/dns/query.rs | 2 ++ src/proto/mod.rs | 5 +++++ src/proto/smb.rs | 4 ++++ src/proto/stun.rs | 4 ++++ src/proto/tcb.rs | 3 +++ 15 files changed, 96 insertions(+), 3 deletions(-) diff --git a/src/layer_2/arp.rs b/src/layer_2/arp.rs index 7986028..5cfc3f2 100644 --- a/src/layer_2/arp.rs +++ b/src/layer_2/arp.rs @@ -84,6 +84,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut arp_req = diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index c298d91..a51266c 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -226,6 +226,7 @@ mod tests { mac: mac, iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; for proto in [EtherTypes::Ipv4, EtherTypes::Ipv6, EtherTypes::Arp] { @@ -264,6 +265,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut eth_req = MutableEthernetPacket::owned(vec![ diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index 3c2d0ca..4109a3d 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -53,6 +53,16 @@ pub fn repl<'a, 'b>( return None; } } + /* If masscanned is configured with ignored IP addresses, then + * check if the src. IP address of the packet is one of + * those ignored by masscanned - if so, drop the packet. + **/ + if let Some(ignored_ip_addr_list) = masscanned.ignored_ip_addresses { + if ignored_ip_addr_list.contains(&IpAddr::V4(ip_req.get_source())) { + masscanned.log.ipv4_drop(&ip_req, &client_info); + return None; + } + } /* Fill client info with transport layer procotol */ client_info.transport = Some(ip_req.get_next_level_protocol()); let mut ip_repl; @@ -193,6 +203,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; for proto in [ @@ -240,6 +251,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut ip_req = diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index 42e6293..4a23b46 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -41,9 +41,9 @@ pub fn repl<'a, 'b>( masscanned.log.ipv6_recv(ip_req, client_info); let src = ip_req.get_source(); let mut dst = ip_req.get_destination(); - /* If masscanned is configured with IP addresses, check that - * the dest. IP address corresponds to one of those - * Otherwise, drop the packet. + /* If masscanned is configured with IP addresses, then + * check that the dest. IP address of the packet is one of + * those handled by masscanned - otherwise, drop the packet. **/ if let Some(ip_addr_list) = masscanned.ip_addresses { if !ip_addr_list.contains(&IpAddr::V6(dst)) @@ -53,6 +53,16 @@ pub fn repl<'a, 'b>( return None; } } + /* If masscanned is configured with ignored IP addresses, then + * check if the src. IP address of the packet is one of + * those ignored by masscanned - if so, drop the packet. + **/ + if let Some(ignored_ip_addr_list) = masscanned.ignored_ip_addresses { + if ignored_ip_addr_list.contains(&IpAddr::V6(src)) { + masscanned.log.ipv6_drop(ip_req, client_info); + return None; + } + } /* Fill client info with source and dest. IP address */ client_info.ip.src = Some(IpAddr::V6(ip_req.get_source())); client_info.ip.dst = Some(IpAddr::V6(ip_req.get_destination())); @@ -206,6 +216,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; for proto in [ @@ -255,6 +266,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut ip_req = diff --git a/src/layer_4/icmpv4.rs b/src/layer_4/icmpv4.rs index 096f88a..7075cf0 100644 --- a/src/layer_4/icmpv4.rs +++ b/src/layer_4/icmpv4.rs @@ -81,6 +81,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut icmp_req = diff --git a/src/layer_4/icmpv6.rs b/src/layer_4/icmpv6.rs index 59d48fe..c4820b8 100644 --- a/src/layer_4/icmpv6.rs +++ b/src/layer_4/icmpv6.rs @@ -173,6 +173,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; /* Legitimate solicitation */ @@ -246,6 +247,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut icmpv6_echo_req = MutableIcmpv6Packet::owned(vec![ diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index fb0681e..ba4ff2f 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -146,6 +146,7 @@ mod tests { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), ip_addresses: None, + ignored_ip_addresses: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), @@ -197,6 +198,7 @@ mod tests { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), ip_addresses: None, + ignored_ip_addresses: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), @@ -248,6 +250,7 @@ mod tests { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), ip_addresses: None, + ignored_ip_addresses: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), @@ -298,6 +301,7 @@ mod tests { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), ip_addresses: None, + ignored_ip_addresses: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), diff --git a/src/masscanned.rs b/src/masscanned.rs index 4d3db61..592fbc2 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -57,6 +57,7 @@ pub struct Masscanned<'a> { /* iface is an Option to make tests easier */ pub iface: Option<&'a NetworkInterface>, pub ip_addresses: Option<&'a HashSet>, + pub ignored_ip_addresses: Option<&'a HashSet>, /* loggers */ pub log: MetaLogger, } @@ -133,6 +134,18 @@ fn main() { .help("Inline list of IP addresses to impersonate, comma-separated") .num_args(1), ) + .arg( + Arg::new("ignoredipfile") + .long("ignored-ip-addr-file") + .help("File with the list of IP addresses to NOT respond to") + .num_args(1), + ) + .arg( + Arg::new("ignorediplist") + .long("ignored-ip-addr") + .help("Inline list of IP addresses to NOT respond to, comma-separated") + .num_args(1), + ) .arg( Arg::new("verbosity") .short('v') @@ -217,11 +230,34 @@ fn main() { info!("binding........::"); None }; + let mut ignored_ip_list = if let Some(ref path) = args.get_one::("ignoredipfile") { + if let Ok(file) = File::open(path) { + info!("parsing ignored ip address file: {}", &path); + file.extract_ip_addresses_only(None) + } else { + HashSet::new() + } + } else { + HashSet::new() + }; + if let Some(ignored_ip_inline_list) = args.get_one::("ignorediplist") { + ignored_ip_list.extend(ignored_ip_inline_list.extract_ip_addresses_only(None)); + } + let ignored_ip_addresses = if !ignored_ip_list.is_empty() { + for ip in &ignored_ip_list { + info!("ignoring.......{}", ip); + } + Some(&ignored_ip_list) + } else { + None + }; + let mut masscanned = Masscanned { synack_key: [0, 0], mac, iface: Some(&iface), ip_addresses, + ignored_ip_addresses, log: MetaLogger::new(), }; info!("interface......{}", masscanned.iface.unwrap().name); diff --git a/src/proto/dns/header.rs b/src/proto/dns/header.rs index 5a53318..d4cd4ce 100644 --- a/src/proto/dns/header.rs +++ b/src/proto/dns/header.rs @@ -293,6 +293,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -316,6 +317,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -340,6 +342,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -364,6 +367,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); diff --git a/src/proto/dns/mod.rs b/src/proto/dns/mod.rs index 0c97cd5..b51e15a 100644 --- a/src/proto/dns/mod.rs +++ b/src/proto/dns/mod.rs @@ -629,6 +629,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut client_info = ClientInfo::new(); diff --git a/src/proto/dns/query.rs b/src/proto/dns/query.rs index b5d92cf..639a21c 100644 --- a/src/proto/dns/query.rs +++ b/src/proto/dns/query.rs @@ -239,6 +239,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let ip_src = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); @@ -306,6 +307,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 819540b..aed6d5a 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -216,6 +216,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; /***** TEST STUN - MAGIC *****/ @@ -276,6 +277,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; /***** TEST SSH *****/ @@ -317,6 +319,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; /***** TEST GHOST *****/ @@ -350,6 +353,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; /***** TEST COMPLETE REQUEST *****/ @@ -371,6 +375,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let mut client_info = ClientInfo::new(); diff --git a/src/proto/smb.rs b/src/proto/smb.rs index 2356eb8..26e49ee 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -1200,6 +1200,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -1268,6 +1269,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -1331,6 +1333,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -1392,6 +1395,7 @@ mod tests { mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, ip_addresses: None, + ignored_ip_addresses: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); diff --git a/src/proto/stun.rs b/src/proto/stun.rs index 9edef5c..80780e6 100644 --- a/src/proto/stun.rs +++ b/src/proto/stun.rs @@ -443,6 +443,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { @@ -503,6 +504,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V6(test_ip_addr)); @@ -555,6 +557,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); @@ -605,6 +608,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); diff --git a/src/proto/tcb.rs b/src/proto/tcb.rs index f092eb8..bf41175 100644 --- a/src/proto/tcb.rs +++ b/src/proto/tcb.rs @@ -112,6 +112,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); @@ -166,6 +167,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); @@ -226,6 +228,7 @@ mod tests { mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), + ignored_ip_addresses: None, log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); From 774af0b78148909f79f5b3490b0fb77b59a99553 Mon Sep 17 00:00:00 2001 From: Unactive Date: Thu, 24 Nov 2022 15:49:56 +0100 Subject: [PATCH 137/317] Document ignore and format options --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9df70ae..ba0abfb 100644 --- a/README.md +++ b/README.md @@ -93,14 +93,17 @@ USAGE: masscanned [OPTIONS] --iface OPTIONS: - -h, --help Print help information - -i, --iface the interface to use for receiving/sending packets - --ip-addr Inline list of IP addresses to impersonate, comma-separated - --ip-addr-file File with the list of IP addresses to impersonate - -m, --mac-addr MAC address to use in the response packets - -q, --quiet Quiet mode: does not output anything on stdout - -v Increase message verbosity - -V, --version Print version information + -h, --help Print help information + -i, --iface the interface to use for receiving/sending packets + --ip-addr Inline list of IP addresses to impersonate, comma-separated + --ip-addr-file File with the list of IP addresses to impersonate + --ip-addr Inline list of IP addresses to impersonate, comma-separated + --ignored-ip-addr-file File with the list of IP addresses to NOT respond to + -m, --mac-addr MAC address to use in the response packets + -q, --quiet Quiet mode: does not output anything on stdout + --format Format in which to output logs [default: console] [others: logfmt] + -v Increase message verbosity + -V, --version Print version information ``` ## Supported protocols - details From ca3b9a75fc2573ebe530169fafca8e3537d726d8 Mon Sep 17 00:00:00 2001 From: Unactive <33038089+Unactived@users.noreply.github.com> Date: Thu, 24 Nov 2022 15:56:33 +0100 Subject: [PATCH 138/317] Fix typo in options --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba0abfb..e81cafc 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ OPTIONS: -i, --iface the interface to use for receiving/sending packets --ip-addr Inline list of IP addresses to impersonate, comma-separated --ip-addr-file File with the list of IP addresses to impersonate - --ip-addr Inline list of IP addresses to impersonate, comma-separated + --ignored-ip-addr Inline list of IP addresses to NOT respond to, comma-separated --ignored-ip-addr-file File with the list of IP addresses to NOT respond to -m, --mac-addr MAC address to use in the response packets -q, --quiet Quiet mode: does not output anything on stdout From b136728f8f734815007591cd58b57d6441392b0e Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 24 Nov 2022 17:08:33 +0100 Subject: [PATCH 139/317] Add unit test for IPv4 blacklist --- src/layer_3/ipv4.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index 4109a3d..fb64bf2 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -243,15 +243,18 @@ mod tests { let mut client_info = ClientInfo::new(); let test_ip_addr = Ipv4Addr::new(3, 2, 1, 0); let masscanned_ip_addr = Ipv4Addr::new(0, 1, 2, 3); + let blacklist_ip_addr = Ipv4Addr::new(3, 3, 3, 3); let mut ips = HashSet::new(); ips.insert(IpAddr::V4(masscanned_ip_addr)); + let mut blacklist_ips = HashSet::new(); + blacklist_ips.insert(IpAddr::V4(blacklist_ip_addr)); /* Construct masscanned context object */ let masscanned = Masscanned { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), - ignored_ip_addresses: None, + ignored_ip_addresses: Some(&blacklist_ips), log: MetaLogger::new(), }; let mut ip_req = @@ -281,5 +284,9 @@ mod tests { /* Send to a non-legitimate IP address */ ip_req.set_destination(Ipv4Addr::new(2, 2, 2, 2)); assert!(repl(&ip_req.to_immutable(), &masscanned, &mut client_info) == None); + /* Send from a non-legitimate IP address */ + ip_req.set_source(blacklist_ip_addr); + ip_req.set_destination(masscanned_ip_addr); + assert!(repl(&ip_req.to_immutable(), &masscanned, &mut client_info) == None); } } From e541d1f5ee8fefa6a5709e5ca24e70aefb67e649 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 24 Nov 2022 17:12:21 +0100 Subject: [PATCH 140/317] Add unit test for IPv6 blacklist --- src/layer_3/ipv6.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index 4a23b46..222d0d5 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -258,15 +258,20 @@ mod tests { let masscanned_ip_addr = Ipv6Addr::new( 0x0000, 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, ); + let blacklist_ip_addr = Ipv6Addr::new( + 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, + ); let mut ips = HashSet::new(); ips.insert(IpAddr::V6(masscanned_ip_addr)); + let mut blacklist_ips = HashSet::new(); + blacklist_ips.insert(IpAddr::V6(blacklist_ip_addr)); /* Construct masscanned context object */ let masscanned = Masscanned { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, ip_addresses: Some(&ips), - ignored_ip_addresses: None, + ignored_ip_addresses: Some(&blacklist_ips), log: MetaLogger::new(), }; let mut ip_req = @@ -294,5 +299,9 @@ mod tests { 0x0000, 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7778, )); assert!(repl(&ip_req.to_immutable(), &masscanned, &mut client_info) == None); + /* Send from a non-legitimate IP address */ + ip_req.set_source(blacklist_ip_addr); + ip_req.set_destination(masscanned_ip_addr); + assert!(repl(&ip_req.to_immutable(), &masscanned, &mut client_info) == None); } } From 1181d6eb93a7156e600d382ffde970c757ffeba4 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 24 Nov 2022 19:24:09 +0100 Subject: [PATCH 141/317] SSH: reply with the client's banner --- src/proto/ssh.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 000616b..34434da 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -57,6 +57,27 @@ impl ProtocolState { } } +/* Reconstruct client's banner from the parsed information */ +fn ssh_banner(pstate: &ProtocolState) -> Vec { + let mut banner = b"SSH-".to_vec(); + for b in &pstate.ssh_version { + banner.push(*b); + } + banner.push(b'-'); + for b in &pstate.ssh_software { + banner.push(*b); + } + if pstate.ssh_comment.len() > 0 { + banner.push(b' '); + for b in &pstate.ssh_comment { + banner.push(*b); + } + } + banner.push(b'\r'); + banner.push(b'\n'); + banner +} + fn ssh_parse(pstate: &mut ProtocolState, data: &[u8]) { /* RFC 4253: * @@ -218,6 +239,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -231,6 +253,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* byte by byte */ let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -254,6 +277,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -279,6 +303,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFT"); assert!(pstate.ssh_comment == b"WARE COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* space in comment */ let test_banner = b"SSH-2.0-SOFTWARE COM MENT\r\n"; let mut pstate = ProtocolState::new(); @@ -288,6 +313,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM MENT"); + assert!(ssh_banner(&pstate) == test_banner); /* double space */ let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -297,6 +323,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b" COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -322,6 +349,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFT"); assert!(pstate.ssh_comment == b"WARE COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* space in comment */ let test_banner = b"SSH-1.99-SOFTWARE COM MENT\r\n"; let mut pstate = ProtocolState::new(); @@ -331,6 +359,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM MENT"); + assert!(ssh_banner(&pstate) == test_banner); /* double space */ let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -340,6 +369,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b" COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -365,6 +395,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFT\rWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* CR in COMMENT */ let test_banner = b"SSH-2.0-SOFTWARE COM\rMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -374,6 +405,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM\rMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* CR at the end */ let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\r\n"; let mut pstate = ProtocolState::new(); @@ -383,6 +415,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT\r"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -408,6 +441,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFT\rWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* CR in COMMENT */ let test_banner = b"SSH-1.99-SOFTWARE COM\rMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -417,6 +451,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM\rMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* CR at the end */ let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\r\n"; let mut pstate = ProtocolState::new(); @@ -426,6 +461,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT\r"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -451,6 +487,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFT\nWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* LF in COMMENT */ let test_banner = b"SSH-2.0-SOFTWARE COM\nMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -460,6 +497,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM\nMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* LF at the end */ let test_banner = b"SSH-2.0-SOFTWARE COMMENT\n\r\n"; let mut pstate = ProtocolState::new(); @@ -469,6 +507,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT\n"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -494,6 +533,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFT\nWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* LF in COMMENT */ let test_banner = b"SSH-1.99-SOFTWARE COM\nMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -503,6 +543,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM\nMENT"); + assert!(ssh_banner(&pstate) == test_banner); /* LF at the end */ let test_banner = b"SSH-1.99-SOFTWARE COMMENT\n\r\n"; let mut pstate = ProtocolState::new(); @@ -512,6 +553,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT\n"); + assert!(ssh_banner(&pstate) == test_banner); } #[test] @@ -537,6 +579,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFT"); assert!(pstate.ssh_comment == b""); + assert!(ssh_banner(&pstate) == b"SSH-2.0-SOFT\r\n"); /* CRLF in COMMENT */ let test_banner = b"SSH-2.0-SOFTWARE COM\r\nMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -546,6 +589,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM"); + assert!(ssh_banner(&pstate) == b"SSH-2.0-SOFTWARE COM\r\n"); /* CRLF at the end */ let test_banner = b"SSH-2.0-SOFTWARE COMMENT\r\n\r\n"; let mut pstate = ProtocolState::new(); @@ -555,6 +599,7 @@ mod tests { assert!(pstate.ssh_version == b"2.0"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == b"SSH-2.0-SOFTWARE COMMENT\r\n"); } #[test] @@ -580,6 +625,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFT"); assert!(pstate.ssh_comment == b""); + assert!(ssh_banner(&pstate) == b"SSH-1.99-SOFT\r\n"); /* CRLF in COMMENT */ let test_banner = b"SSH-1.99-SOFTWARE COM\r\nMENT\r\n"; let mut pstate = ProtocolState::new(); @@ -589,6 +635,7 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COM"); + assert!(ssh_banner(&pstate) == b"SSH-1.99-SOFTWARE COM\r\n"); /* CRLF at the end */ let test_banner = b"SSH-1.99-SOFTWARE COMMENT\r\n\r\n"; let mut pstate = ProtocolState::new(); @@ -598,5 +645,6 @@ mod tests { assert!(pstate.ssh_version == b"1.99"); assert!(pstate.ssh_software == b"SOFTWARE"); assert!(pstate.ssh_comment == b"COMMENT"); + assert!(ssh_banner(&pstate) == b"SSH-1.99-SOFTWARE COMMENT\r\n"); } } From 67a2113fd9f96afefd879c3c28602c9b5ac08b79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Nov 2022 00:24:22 +0000 Subject: [PATCH 142/317] Bump clap from 4.0.26 to 4.0.27 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.26 to 4.0.27. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.26...v4.0.27) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 128 ++++++++++++++++++++++++++++++++++++++++++++++++----- Cargo.toml | 2 +- 2 files changed, 119 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1919803..1f7bda9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,7 +32,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -96,13 +96,13 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.26" +version = "4.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" +checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966" dependencies = [ - "atty", "bitflags 1.3.2", "clap_lex", + "is-terminal", "strsim", "termcolor", ] @@ -220,6 +220,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "iana-time-zone" version = "0.1.50" @@ -233,6 +242,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "io-lifetimes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7d367024b3f3414d8e01f437f704f41a9f64ab36f9067fa73e526ad4c763c87" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + [[package]] name = "ipnetwork" version = "0.19.0" @@ -242,6 +261,18 @@ dependencies = [ "serde", ] +[[package]] +name = "is-terminal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys 0.42.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -282,6 +313,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "linux-raw-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" + [[package]] name = "log" version = "0.4.17" @@ -389,7 +426,7 @@ dependencies = [ "libloading", "pkg-config", "regex", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -583,6 +620,20 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +[[package]] +name = "rustix" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + [[package]] name = "rustversion" version = "1.0.9" @@ -834,39 +885,96 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" diff --git a/Cargo.toml b/Cargo.toml index 4075fd0..05d82e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.0.26" +clap = "4.0.27" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From adbbf2259a5a16bfaedad1804105a71efe0a2538 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Nov 2022 06:00:49 +0000 Subject: [PATCH 143/317] Bump flate2 from 1.0.24 to 1.0.25 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.24 to 1.0.25. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/commits/1.0.25) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f7bda9..0dc921d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ "crc32fast", "miniz_oxide", @@ -360,9 +360,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] From 1d208c769b091eaefa7a22e5a17a8b1310497096 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Nov 2022 00:22:22 +0000 Subject: [PATCH 144/317] Bump clap from 4.0.27 to 4.0.29 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.27 to 4.0.29. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.27...v4.0.29) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0dc921d..57b9660 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.27" +version = "4.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966" +checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" dependencies = [ "bitflags 1.3.2", "clap_lex", @@ -263,9 +263,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d" +checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" dependencies = [ "hermit-abi 0.2.6", "io-lifetimes", @@ -622,9 +622,9 @@ checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "rustix" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" +checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23" dependencies = [ "bitflags 1.3.2", "errno", diff --git a/Cargo.toml b/Cargo.toml index 05d82e7..a296975 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.0.27" +clap = "4.0.29" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From bad2c5e02cb283d2459cefc9c4f8978df7e2b185 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 8 Dec 2022 21:28:03 +0100 Subject: [PATCH 145/317] Rename options for IP (self and remote) for more clarity --- src/layer_2/arp.rs | 6 ++--- src/layer_2/mod.rs | 10 +++---- src/layer_3/ipv4.rs | 16 +++++------ src/layer_3/ipv6.rs | 16 +++++------ src/layer_4/icmpv4.rs | 4 +-- src/layer_4/icmpv6.rs | 10 +++---- src/layer_4/tcp.rs | 16 +++++------ src/masscanned.rs | 59 ++++++++++++++++++++++------------------- src/proto/dns/header.rs | 16 +++++------ src/proto/dns/mod.rs | 4 +-- src/proto/dns/query.rs | 8 +++--- src/proto/mod.rs | 20 +++++++------- src/proto/smb.rs | 16 +++++------ src/proto/stun.rs | 16 +++++------ src/proto/tcb.rs | 12 ++++----- 15 files changed, 116 insertions(+), 113 deletions(-) diff --git a/src/layer_2/arp.rs b/src/layer_2/arp.rs index 5cfc3f2..36ec6fe 100644 --- a/src/layer_2/arp.rs +++ b/src/layer_2/arp.rs @@ -38,7 +38,7 @@ pub fn repl<'a, 'b>( masscanned.log.arp_recv(arp_req); let ip = IpAddr::V4(arp_req.get_target_proto_addr()); /* Ignore ARP requests for IP addresses not handled by masscanned */ - if let Some(ip_addr_list) = masscanned.ip_addresses { + if let Some(ip_addr_list) = masscanned.self_ip_list { if !ip_addr_list.contains(&ip) { masscanned.log.arp_drop(arp_req); return None; @@ -83,8 +83,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; let mut arp_req = diff --git a/src/layer_2/mod.rs b/src/layer_2/mod.rs index a51266c..82f2acb 100644 --- a/src/layer_2/mod.rs +++ b/src/layer_2/mod.rs @@ -113,7 +113,7 @@ pub fn reply<'a, 'b>( * is authorized to answer to (avoid answering to packets addressed to * other machines) **/ - if !get_authorized_eth_addr(&masscanned.mac, masscanned.ip_addresses) + if !get_authorized_eth_addr(&masscanned.mac, masscanned.self_ip_list) .contains(ð_req.get_destination()) { masscanned.log.eth_drop(eth_req, &client_info); @@ -225,8 +225,8 @@ mod tests { synack_key: [0, 0], mac: mac, iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; for proto in [EtherTypes::Ipv4, EtherTypes::Ipv6, EtherTypes::Arp] { @@ -264,8 +264,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; let mut eth_req = MutableEthernetPacket::owned(vec![ diff --git a/src/layer_3/ipv4.rs b/src/layer_3/ipv4.rs index fb64bf2..5bff7a9 100644 --- a/src/layer_3/ipv4.rs +++ b/src/layer_3/ipv4.rs @@ -47,18 +47,18 @@ pub fn repl<'a, 'b>( * check that the dest. IP address of the packet is one of * those handled by masscanned - otherwise, drop the packet. **/ - if let Some(ip_addr_list) = masscanned.ip_addresses { + if let Some(ip_addr_list) = masscanned.self_ip_list { if !ip_addr_list.contains(&IpAddr::V4(ip_req.get_destination())) { masscanned.log.ipv4_drop(&ip_req, &client_info); return None; } } - /* If masscanned is configured with ignored IP addresses, then + /* If masscanned is configured with a remote ip deny list, then * check if the src. IP address of the packet is one of * those ignored by masscanned - if so, drop the packet. **/ - if let Some(ignored_ip_addr_list) = masscanned.ignored_ip_addresses { - if ignored_ip_addr_list.contains(&IpAddr::V4(ip_req.get_source())) { + if let Some(remote_ip_deny_list) = masscanned.remote_ip_deny_list { + if remote_ip_deny_list.contains(&IpAddr::V4(ip_req.get_source())) { masscanned.log.ipv4_drop(&ip_req, &client_info); return None; } @@ -202,8 +202,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; for proto in [ @@ -253,8 +253,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: Some(&blacklist_ips), + self_ip_list: Some(&ips), + remote_ip_deny_list: Some(&blacklist_ips), log: MetaLogger::new(), }; let mut ip_req = diff --git a/src/layer_3/ipv6.rs b/src/layer_3/ipv6.rs index 222d0d5..f482475 100644 --- a/src/layer_3/ipv6.rs +++ b/src/layer_3/ipv6.rs @@ -45,7 +45,7 @@ pub fn repl<'a, 'b>( * check that the dest. IP address of the packet is one of * those handled by masscanned - otherwise, drop the packet. **/ - if let Some(ip_addr_list) = masscanned.ip_addresses { + if let Some(ip_addr_list) = masscanned.self_ip_list { if !ip_addr_list.contains(&IpAddr::V6(dst)) && ip_req.get_next_header() != IpNextHeaderProtocols::Icmpv6 { @@ -53,12 +53,12 @@ pub fn repl<'a, 'b>( return None; } } - /* If masscanned is configured with ignored IP addresses, then + /* If masscanned is configured with a remote ip deny list, then * check if the src. IP address of the packet is one of * those ignored by masscanned - if so, drop the packet. **/ - if let Some(ignored_ip_addr_list) = masscanned.ignored_ip_addresses { - if ignored_ip_addr_list.contains(&IpAddr::V6(src)) { + if let Some(remote_ip_deny_list) = masscanned.remote_ip_deny_list { + if remote_ip_deny_list.contains(&IpAddr::V6(src)) { masscanned.log.ipv6_drop(ip_req, client_info); return None; } @@ -215,8 +215,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; for proto in [ @@ -270,8 +270,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: Some(&blacklist_ips), + self_ip_list: Some(&ips), + remote_ip_deny_list: Some(&blacklist_ips), log: MetaLogger::new(), }; let mut ip_req = diff --git a/src/layer_4/icmpv4.rs b/src/layer_4/icmpv4.rs index 7075cf0..becef8d 100644 --- a/src/layer_4/icmpv4.rs +++ b/src/layer_4/icmpv4.rs @@ -80,8 +80,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let mut icmp_req = diff --git a/src/layer_4/icmpv6.rs b/src/layer_4/icmpv6.rs index c4820b8..00c53f4 100644 --- a/src/layer_4/icmpv6.rs +++ b/src/layer_4/icmpv6.rs @@ -40,7 +40,7 @@ pub fn nd_ns_repl<'a, 'b>( * check that the dest. IP address of the packet is one of * those handled by masscanned - otherwise, drop the packet. **/ - if let Some(addresses) = masscanned.ip_addresses { + if let Some(addresses) = masscanned.self_ip_list { if !addresses.contains(&IpAddr::V6(nd_ns_req.get_target_addr())) { return None; } @@ -172,8 +172,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; /* Legitimate solicitation */ @@ -246,8 +246,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; let mut icmpv6_echo_req = MutableIcmpv6Packet::owned(vec![ diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index ba4ff2f..a562646 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -145,8 +145,8 @@ mod tests { fn test_tcp_fin_ack() { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), @@ -197,8 +197,8 @@ mod tests { fn test_tcp_fin_ack_wrap() { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), @@ -249,8 +249,8 @@ mod tests { fn test_synack_cookie_ipv4() { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), @@ -300,8 +300,8 @@ mod tests { fn test_synack_cookie_ipv6() { let masscanned = Masscanned { mac: MacAddr(0, 0, 0, 0, 0, 0), - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, synack_key: [0x06a0a1d63f305e9b, 0xd4d4bcbb7304875f], iface: None, log: MetaLogger::new(), diff --git a/src/masscanned.rs b/src/masscanned.rs index 592fbc2..ea442ce 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -56,8 +56,8 @@ pub struct Masscanned<'a> { pub mac: MacAddr, /* iface is an Option to make tests easier */ pub iface: Option<&'a NetworkInterface>, - pub ip_addresses: Option<&'a HashSet>, - pub ignored_ip_addresses: Option<&'a HashSet>, + pub self_ip_list: Option<&'a HashSet>, + pub remote_ip_deny_list: Option<&'a HashSet>, /* loggers */ pub log: MetaLogger, } @@ -123,27 +123,29 @@ fn main() { .num_args(1), ) .arg( - Arg::new("ipfile") - .long("ip-addr-file") - .help("File with the list of IP addresses to impersonate") + Arg::new("selfipfile") + .long("self-ip-file") + .help("File with the list of IP addresses handled by masscanned") .num_args(1), ) .arg( - Arg::new("iplist") - .long("ip-addr") - .help("Inline list of IP addresses to impersonate, comma-separated") + Arg::new("selfiplist") + .long("self-ip-list") + .help("Inline list of IP addresses handled by masscanned, comma-separated") .num_args(1), ) .arg( - Arg::new("ignoredipfile") - .long("ignored-ip-addr-file") - .help("File with the list of IP addresses to NOT respond to") + Arg::new("remoteipdenyfile") + .long("remote-ip-deny-file") + .help( + "File with the list of IP addresses from which masscanned will ignore packets", + ) .num_args(1), ) .arg( - Arg::new("ignorediplist") - .long("ignored-ip-addr") - .help("Inline list of IP addresses to NOT respond to, comma-separated") + Arg::new("remoteipdenylist") + .long("remote-ip-deny-list") + .help("Inline list of IP addresses from which masscanned will ignore packets") .num_args(1), ) .arg( @@ -207,9 +209,9 @@ fn main() { }; /* Parse ip address file specified */ /* FIXME: .and_then(|path| File::open(path).map(|file| )).unwrap_or_default() ? */ - let mut ip_list = if let Some(ref path) = args.get_one::("ipfile") { + let mut ip_list = if let Some(ref path) = args.get_one::("selfipfile") { if let Ok(file) = File::open(path) { - info!("parsing ip address file: {}", &path); + info!("parsing self ip file: {}", &path); file.extract_ip_addresses_only(None) } else { HashSet::new() @@ -217,10 +219,10 @@ fn main() { } else { HashSet::new() }; - if let Some(ip_inline_list) = args.get_one::("iplist") { - ip_list.extend(ip_inline_list.extract_ip_addresses_only(None)); + if let Some(ip_inline) = args.get_one::("selfiplist") { + ip_list.extend(ip_inline.extract_ip_addresses_only(None)); } - let ip_addresses = if !ip_list.is_empty() { + let self_ip_list = if !ip_list.is_empty() { for ip in &ip_list { info!("binding........{}", ip); } @@ -230,9 +232,10 @@ fn main() { info!("binding........::"); None }; - let mut ignored_ip_list = if let Some(ref path) = args.get_one::("ignoredipfile") { + /* Parse remote ip deny file specified */ + let mut ip_list = if let Some(ref path) = args.get_one::("remoteipdenyfile") { if let Ok(file) = File::open(path) { - info!("parsing ignored ip address file: {}", &path); + info!("parsing remote ip deny file: {}", &path); file.extract_ip_addresses_only(None) } else { HashSet::new() @@ -240,14 +243,14 @@ fn main() { } else { HashSet::new() }; - if let Some(ignored_ip_inline_list) = args.get_one::("ignorediplist") { - ignored_ip_list.extend(ignored_ip_inline_list.extract_ip_addresses_only(None)); + if let Some(ip_inline) = args.get_one::("remoteipdenylist") { + ip_list.extend(ip_inline.extract_ip_addresses_only(None)); } - let ignored_ip_addresses = if !ignored_ip_list.is_empty() { - for ip in &ignored_ip_list { + let remote_ip_deny_list = if !ip_list.is_empty() { + for ip in &ip_list { info!("ignoring.......{}", ip); } - Some(&ignored_ip_list) + Some(&ip_list) } else { None }; @@ -256,8 +259,8 @@ fn main() { synack_key: [0, 0], mac, iface: Some(&iface), - ip_addresses, - ignored_ip_addresses, + self_ip_list, + remote_ip_deny_list, log: MetaLogger::new(), }; info!("interface......{}", masscanned.iface.unwrap().name); diff --git a/src/proto/dns/header.rs b/src/proto/dns/header.rs index d4cd4ce..e8a8d6e 100644 --- a/src/proto/dns/header.rs +++ b/src/proto/dns/header.rs @@ -292,8 +292,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -316,8 +316,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -341,8 +341,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -366,8 +366,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); diff --git a/src/proto/dns/mod.rs b/src/proto/dns/mod.rs index b51e15a..0498791 100644 --- a/src/proto/dns/mod.rs +++ b/src/proto/dns/mod.rs @@ -628,8 +628,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let mut client_info = ClientInfo::new(); diff --git a/src/proto/dns/query.rs b/src/proto/dns/query.rs index 639a21c..95fb205 100644 --- a/src/proto/dns/query.rs +++ b/src/proto/dns/query.rs @@ -238,8 +238,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let ip_src = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); @@ -306,8 +306,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); diff --git a/src/proto/mod.rs b/src/proto/mod.rs index aed6d5a..87cfe3c 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -215,8 +215,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; /***** TEST STUN - MAGIC *****/ @@ -276,8 +276,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; /***** TEST SSH *****/ @@ -318,8 +318,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; /***** TEST GHOST *****/ @@ -352,8 +352,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; /***** TEST COMPLETE REQUEST *****/ @@ -374,8 +374,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let mut client_info = ClientInfo::new(); diff --git a/src/proto/smb.rs b/src/proto/smb.rs index 26e49ee..41f9519 100644 --- a/src/proto/smb.rs +++ b/src/proto/smb.rs @@ -1199,8 +1199,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -1268,8 +1268,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -1332,8 +1332,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); @@ -1394,8 +1394,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:00:00:00:00:00").expect("error parsing default MAC address"), iface: None, - ip_addresses: None, - ignored_ip_addresses: None, + self_ip_list: None, + remote_ip_deny_list: None, log: MetaLogger::new(), }; let client_info = ClientInfo::new(); diff --git a/src/proto/stun.rs b/src/proto/stun.rs index 80780e6..ae8c749 100644 --- a/src/proto/stun.rs +++ b/src/proto/stun.rs @@ -442,8 +442,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; let payload_resp = if let Some(r) = repl(payload, &masscanned, &mut client_info, None) { @@ -503,8 +503,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V6(test_ip_addr)); @@ -556,8 +556,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); @@ -607,8 +607,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; client_info.ip.src = Some(IpAddr::V4(test_ip_addr)); diff --git a/src/proto/tcb.rs b/src/proto/tcb.rs index bf41175..0f2a815 100644 --- a/src/proto/tcb.rs +++ b/src/proto/tcb.rs @@ -111,8 +111,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); @@ -166,8 +166,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); @@ -227,8 +227,8 @@ mod tests { synack_key: [0, 0], mac: MacAddr::from_str("00:11:22:33:44:55").expect("error parsing MAC address"), iface: None, - ip_addresses: Some(&ips), - ignored_ip_addresses: None, + self_ip_list: Some(&ips), + remote_ip_deny_list: None, log: MetaLogger::new(), }; let cookie = synackcookie::generate(&client_info, &masscanned.synack_key).unwrap(); From deb7df490b4b14717bbc9e6237d633f0a181d91a Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 8 Dec 2022 21:28:50 +0100 Subject: [PATCH 146/317] Update README with new options --- README.md | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e81cafc..9e81dd4 100644 --- a/README.md +++ b/README.md @@ -86,24 +86,33 @@ A documentation on how to deploy an instance of **masscanned** on a VPS is comin ### Supported options ``` -Network responder - answer them all 0.2.0 Network answering machine for various network protocols (L2-L3-L4 + applications) -USAGE: - masscanned [OPTIONS] --iface +Usage: masscanned [OPTIONS] --iface -OPTIONS: - -h, --help Print help information - -i, --iface the interface to use for receiving/sending packets - --ip-addr Inline list of IP addresses to impersonate, comma-separated - --ip-addr-file File with the list of IP addresses to impersonate - --ignored-ip-addr Inline list of IP addresses to NOT respond to, comma-separated - --ignored-ip-addr-file File with the list of IP addresses to NOT respond to - -m, --mac-addr MAC address to use in the response packets - -q, --quiet Quiet mode: does not output anything on stdout - --format Format in which to output logs [default: console] [others: logfmt] - -v Increase message verbosity - -V, --version Print version information +Options: + -i, --iface + the interface to use for receiving/sending packets + -m, --mac-addr + MAC address to use in the response packets + --self-ip-file + File with the list of IP addresses handled by masscanned + --self-ip-list + Inline list of IP addresses handled by masscanned, comma-separated + --remote-ip-deny-file + File with the list of IP addresses from which masscanned will ignore packets + --remote-ip-deny-list + Inline list of IP addresses from which masscanned will ignore packets + -v... + Increase message verbosity + -q, --quiet + Quiet mode: do not output anything on stdout + --format + Format in which to output logs [default: console] [possible values: console, logfmt] + -h, --help + Print help information + -V, --version + Print version information ``` ## Supported protocols - details From 58fba4bf317c5a225bf737ce28bfa0f287ce4904 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Thu, 8 Dec 2022 21:40:38 +0100 Subject: [PATCH 147/317] Fix command line options in tests --- test/test_masscanned.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 6b9e5b4..5b32e5f 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -163,7 +163,7 @@ masscanned = subprocess.Popen( "-vvvvv", "-i", f"{IFACE}b", - "--ip-addr-file", + "--self-ip-file", ipfile.name, "-m", MAC_ADDR, From 089c971ae9904edd8d5b72d2d6ded06aa0c108d9 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 22 Dec 2022 17:17:32 +0100 Subject: [PATCH 148/317] Fix randomly failing tests --- test/src/tests/rpc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/src/tests/rpc.py b/test/src/tests/rpc.py index 86cd140..82c97a6 100644 --- a/test/src/tests/rpc.py +++ b/test/src/tests/rpc.py @@ -61,11 +61,15 @@ def test_rpc_nmap(): "tcp" if scan == "S" else "udp" ), f"Unexpected proto {port['protocol']} for scan {scan}" assert port["service_name"] in { - "rpcbind", "nfs", + "rpcbind", + "rstatd", + "rusersd", }, f"Unexpected service_name: {port['service_name']}" assert port["service_extrainfo"] in { "RPC #100000", + "RPC #100001", + "RPC #100002", "RPC #100003", }, f"Unexpected service_extrainfo: {port['service_extrainfo']}" assert ( From 9f4a14abbf24355fa4fac3256599d1d38797e643 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Dec 2022 16:27:47 +0000 Subject: [PATCH 149/317] Bump clap from 4.0.29 to 4.0.30 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.29 to 4.0.30. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.29...v4.0.30) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57b9660..cfc9fd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.29" +version = "4.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" +checksum = "656ad1e55e23d287773f7d8192c300dc715c3eeded93b3da651d11c42cfd74d2" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index a296975..27ea1c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.0.29" +clap = "4.0.30" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From e0c2a87e0b3f4a21f6f80095b75944fad78f377d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Dec 2022 00:13:40 +0000 Subject: [PATCH 150/317] Bump clap from 4.0.30 to 4.0.32 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.30 to 4.0.32. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.30...v4.0.32) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfc9fd1..43d0ece 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.30" +version = "4.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656ad1e55e23d287773f7d8192c300dc715c3eeded93b3da651d11c42cfd74d2" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index 27ea1c7..270f901 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.0.30" +clap = "4.0.32" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From cc644e81aad7b1a9b693226ef559d665143b897a Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 28 Dec 2022 22:27:45 +0100 Subject: [PATCH 151/317] Fix DNS tests after Scapy 2.5.0 release --- test/src/tests/dns.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py index 01b24b4..9261bbb 100644 --- a/test/src/tests/dns.py +++ b/test/src/tests/dns.py @@ -70,11 +70,11 @@ def test_ipv4_udp_dns_in_a(): dns_req.qd[0] ), "query in request and response do not match" assert raw(dns_rep.qd[0].qname) == raw( - dns_req.qd[0].qname + b"." - ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + dns_req.qd[0].qname + ), "qname query in request and response do not match" assert ( - dns_rep.an[0].rrname == dns_req.qd[0].qname + b"." - ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + dns_rep.an[0].rrname == dns_req.qd[0].qname + ), "rrname in answer does not match qname in request" assert ( dns_rep.an[0].rclass == dns_req.qd[0].qclass ), "class in answer does not match query" @@ -132,17 +132,17 @@ def test_ipv4_udp_dns_in_a_multiple_queries(): for i, q in enumerate(qd): assert raw(dns_rep.qd[i]) == raw( dns_req.qd[i] - ), "query in request and response do not match" + ), f"query in request and response do not match ({i})" assert raw(dns_rep.qd[i].qname) == raw( - dns_req.qd[i].qname + b"." - ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + dns_req.qd[i].qname + ), f"qname query in request and response do not match ({i})" assert ( - dns_rep.an[i].rrname == dns_req.qd[i].qname + b"." - ), "if this test fails, it may mean that scapy fixed the bug in dns.py L134 - if that is so, remove \" + b'.'\" in the test" + dns_rep.an[i].rrname == dns_req.qd[i].qname + ), f"rrname in answer does not match qname in request ({i})" assert ( dns_rep.an[i].rclass == dns_req.qd[i].qclass - ), "class in answer does not match query" + ), f"class in answer does not match query ({i})" assert ( dns_rep.an[i].type == dns_req.qd[i].qtype - ), "type in answer does not match query" + ), f"type in answer does not match query ({i})" assert dns_rep.an[i].rdata == IPV4_ADDR From 42e3e908ab506da763841d4809f24214a72440df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 01:26:33 +0000 Subject: [PATCH 152/317] Bump clap from 4.0.32 to 4.1.1 Bumps [clap](https://github.com/clap-rs/clap) from 4.0.32 to 4.1.1. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.0.32...v4.1.1) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43d0ece..96584e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.32" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index 270f901..d324e37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.0.32" +clap = "4.1.1" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From e63da23be0fdfad01f4ea30b080bb3db930db11c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 00:16:19 +0000 Subject: [PATCH 153/317] Bump clap from 4.1.1 to 4.1.3 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.1 to 4.1.3. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.1.1...v4.1.3) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96584e1..2e3ec56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.1" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" +checksum = "d8d93d855ce6a0aa87b8473ef9169482f40abaa2e9e0993024c35c902cbd5920" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index d324e37..b7056e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.1.1" +clap = "4.1.3" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From e3ea48444d4594026e9de38542aa2c3903e6555e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Jan 2023 00:16:20 +0000 Subject: [PATCH 154/317] Bump clap from 4.1.3 to 4.1.4 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.3 to 4.1.4. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.3...v4.1.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e3ec56..56a4dba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.3" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d93d855ce6a0aa87b8473ef9169482f40abaa2e9e0993024c35c902cbd5920" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index b7056e4..499b0e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.1.3" +clap = "4.1.4" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 27aac1c444eb47857cace8ed375b3280d8602cca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 01:11:36 +0000 Subject: [PATCH 155/317] Bump pnet from 0.31.0 to 0.33.0 Bumps [pnet](https://github.com/libpnet/libpnet) from 0.31.0 to 0.33.0. - [Release notes](https://github.com/libpnet/libpnet/releases) - [Commits](https://github.com/libpnet/libpnet/compare/v0.31.0...v0.33.0) --- updated-dependencies: - dependency-name: pnet dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 84 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56a4dba..33e828f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "heck" @@ -254,9 +254,9 @@ dependencies = [ [[package]] name = "ipnetwork" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f84f1612606f3753f205a4e9a2efd6fe5b4c573a6269b2cc6c3003d44a0d127" +checksum = "bf466541e9d546596ee94f9f69590f89473455f88372423e0008fc1a7daf100e" dependencies = [ "serde", ] @@ -299,9 +299,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.134" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libloading" @@ -448,9 +448,9 @@ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "pnet" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0caaf5b11fd907ff15cf14a4477bfabca4b37ab9e447a4f8dead969a59cdafad" +checksum = "cd959a8268165518e2bf5546ba84c7b3222744435616381df3c456fe8d983576" dependencies = [ "ipnetwork", "pnet_base", @@ -462,18 +462,18 @@ dependencies = [ [[package]] name = "pnet_base" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d3a993d49e5fd5d4d854d6999d4addca1f72d86c65adf224a36757161c02b6" +checksum = "872e46346144ebf35219ccaa64b1dffacd9c6f188cd7d012bd6977a2a838f42e" dependencies = [ "no-std-net", ] [[package]] name = "pnet_datalink" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e466faf03a98ad27f6e15cd27a2b7cc89e73e640a43527742977bc503c37f8aa" +checksum = "c302da22118d2793c312a35fb3da6846cb0fab6c3ad53fd67e37809b06cdafce" dependencies = [ "ipnetwork", "libc", @@ -484,30 +484,30 @@ dependencies = [ [[package]] name = "pnet_macros" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dd52a5211fac27e7acb14cfc9f30ae16ae0e956b7b779c8214c74559cef4c3" +checksum = "2a780e80005c2e463ec25a6e9f928630049a10b43945fea83207207d4a7606f4" dependencies = [ "proc-macro2", - "quote 1.0.21", + "quote 1.0.23", "regex", - "syn 1.0.101", + "syn 1.0.107", ] [[package]] name = "pnet_macros_support" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89de095dc7739349559913aed1ef6a11e73ceade4897dadc77c5e09de6740750" +checksum = "e6d932134f32efd7834eb8b16d42418dac87086347d1bc7d142370ef078582bc" dependencies = [ "pnet_base", ] [[package]] name = "pnet_packet" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3b5111e697c39c8b9795b9fdccbc301ab696699e88b9ea5a4e4628978f495f" +checksum = "8bde678bbd85cb1c2d99dc9fc596e57f03aa725f84f3168b0eaf33eeccb41706" dependencies = [ "glob", "pnet_base", @@ -517,9 +517,9 @@ dependencies = [ [[package]] name = "pnet_sys" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328e231f0add6d247d82421bf3790b4b33b39c8930637f428eef24c4c6a90805" +checksum = "faf7a58b2803d818a374be9278a1fe8f88fce14b936afbe225000cfcd9c73f16" dependencies = [ "libc", "winapi", @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "pnet_transport" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff597185e6f1f5671b3122e4dba892a1c73e17c17e723d7669bd9299cbe7f124" +checksum = "813d1c0e4defbe7ee22f6fe1755f122b77bfb5abe77145b1b5baaf463cab9249" dependencies = [ "libc", "pnet_base", @@ -545,9 +545,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro2" -version = "1.0.46" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] @@ -566,9 +566,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -605,9 +605,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -685,9 +685,9 @@ checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", "proc-macro2", - "quote 1.0.21", + "quote 1.0.23", "rustversion", - "syn 1.0.101", + "syn 1.0.107", ] [[package]] @@ -703,12 +703,12 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.101" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", - "quote 1.0.21", + "quote 1.0.23", "unicode-ident", ] @@ -746,8 +746,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", - "quote 1.0.21", - "syn 1.0.101", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -814,8 +814,8 @@ dependencies = [ "log", "once_cell", "proc-macro2", - "quote 1.0.21", - "syn 1.0.101", + "quote 1.0.23", + "syn 1.0.107", "wasm-bindgen-shared", ] @@ -825,7 +825,7 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ - "quote 1.0.21", + "quote 1.0.23", "wasm-bindgen-macro-support", ] @@ -836,8 +836,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", - "quote 1.0.21", - "syn 1.0.101", + "quote 1.0.23", + "syn 1.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 499b0e9..846c4f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ log = "0.4.11" netdevice = "0.1.1" pcap = "1.0.0" pcap-file = "1.1.1" -pnet = { version = "0.31.0", features = ["std"] } +pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.4" From 498c811323251f7b0a066d4c2611f0204561bcaf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 08:10:09 +0000 Subject: [PATCH 156/317] Bump pcap-file from 1.1.1 to 2.0.0 Bumps [pcap-file](https://github.com/courvoif/pcap-file) from 1.1.1 to 2.0.0. - [Release notes](https://github.com/courvoif/pcap-file/releases) - [Commits](https://github.com/courvoif/pcap-file/commits) --- updated-dependencies: - dependency-name: pcap-file dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 80 ++++++++++++++++++++---------------------------------- Cargo.toml | 2 +- 2 files changed, 30 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33e828f..ce037e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,6 +67,15 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "byteorder_slice" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b294e30387378958e8bf8f4242131b930ea615ff81e8cac2440cea0a6013190" +dependencies = [ + "byteorder", +] + [[package]] name = "cc" version = "1.0.73" @@ -133,12 +142,13 @@ dependencies = [ [[package]] name = "derive-into-owned" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576fce04d31d592013a5887ba8d9c3830adff329e5096d7e1eb5e8e61262ca62" +checksum = "2c9d94d81e3819a7b06a8638f448bc6339371ca9b6076a99d4a43eece3c4c923" dependencies = [ - "quote 0.3.15", - "syn 0.11.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -431,11 +441,11 @@ dependencies = [ [[package]] name = "pcap-file" -version = "1.1.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ad13fed1a83120159aea81b265074f21d753d157dd16b10cc3790ecba40a341" +checksum = "1fc1f139757b058f9f37b76c48501799d12c9aa0aa4c0d4c980b062ee925d1b2" dependencies = [ - "byteorder", + "byteorder_slice", "derive-into-owned", "thiserror", ] @@ -489,9 +499,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a780e80005c2e463ec25a6e9f928630049a10b43945fea83207207d4a7606f4" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote", "regex", - "syn 1.0.107", + "syn", ] [[package]] @@ -558,12 +568,6 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -[[package]] -name = "quote" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" - [[package]] name = "quote" version = "1.0.23" @@ -685,20 +689,9 @@ checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", "proc-macro2", - "quote 1.0.23", + "quote", "rustversion", - "syn 1.0.107", -] - -[[package]] -name = "syn" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -dependencies = [ - "quote 0.3.15", - "synom", - "unicode-xid", + "syn", ] [[package]] @@ -708,19 +701,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote", "unicode-ident", ] -[[package]] -name = "synom" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -dependencies = [ - "unicode-xid", -] - [[package]] name = "termcolor" version = "1.1.3" @@ -746,8 +730,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", - "quote 1.0.23", - "syn 1.0.107", + "quote", + "syn", ] [[package]] @@ -776,12 +760,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" -[[package]] -name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" - [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -814,8 +792,8 @@ dependencies = [ "log", "once_cell", "proc-macro2", - "quote 1.0.23", - "syn 1.0.107", + "quote", + "syn", "wasm-bindgen-shared", ] @@ -825,7 +803,7 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ - "quote 1.0.23", + "quote", "wasm-bindgen-macro-support", ] @@ -836,8 +814,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", - "quote 1.0.23", - "syn 1.0.107", + "quote", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 846c4f2..6f91fd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ lazy_static = "1.4.0" log = "0.4.11" netdevice = "0.1.1" pcap = "1.0.0" -pcap-file = "1.1.1" +pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "0.3" From 3159ecf743255c51e26c79ee1e87c41a03faf8be Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Tue, 14 Feb 2023 00:16:46 +0100 Subject: [PATCH 157/317] pcap-file: switch to 2.0 API --- src/utils/parsers.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utils/parsers.rs b/src/utils/parsers.rs index 6198c7d..e2a9ac7 100644 --- a/src/utils/parsers.rs +++ b/src/utils/parsers.rs @@ -5,12 +5,12 @@ use std::io::BufReader; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use log::*; -use pcap_file::pcap::{Packet, PcapReader}; +use pcap_file::pcap::{PcapPacket, PcapReader}; use pnet::packet::{ ethernet::{EtherTypes, EthernetPacket}, ipv4::Ipv4Packet, ipv6::Ipv6Packet, - Packet as Pkt, + Packet, }; /* Generic IP packet (either IPv4 or IPv6) */ @@ -173,7 +173,7 @@ impl IpAddrParser for &str { } /* Get the IP address of source and dest. from an IP packet. * works with both IPv4 and IPv6 packets/addresses */ -fn extract_ip(pkt: Packet) -> Option<(IpAddr, IpAddr)> { +fn extract_ip(pkt: PcapPacket) -> Option<(IpAddr, IpAddr)> { let eth = EthernetPacket::new(&pkt.data).expect("error parsing Ethernet packet"); let payload = eth.payload(); let ip = match eth.get_ethertype() { @@ -206,13 +206,13 @@ impl IpAddrParser for PcapReader { /* Extract IP addresses (v4 and v6) from a capture and count occurrences of * each. */ fn extract_ip_addresses_with_count( - self: PcapReader, + mut self: PcapReader, blacklist: Option>, ) -> HashMap { let mut ip_addresses = HashMap::new(); // pcap.map(fn) , map_Ok // .iter, into_iter - for pkt in self { + while let Some(pkt) = self.next_packet() { match pkt { Ok(pkt) => { // map_Some map_None @@ -246,13 +246,13 @@ impl IpAddrParser for PcapReader { ip_addresses } fn extract_ip_addresses_only( - self: PcapReader, + mut self: PcapReader, blacklist: Option>, ) -> HashSet { let mut ip_addresses = HashSet::new(); // pcap.map(fn) , map_Ok // .iter, into_iter - for pkt in self { + while let Some(pkt) = self.next_packet() { match pkt { Ok(pkt) => { // map_Some map_None From 7c6d8258ef3cf4669f9adf8cc923872aea3d9209 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Tue, 31 Jan 2023 18:03:32 +0100 Subject: [PATCH 158/317] Fix build warning --- src/proto/ssh.rs | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/proto/ssh.rs b/src/proto/ssh.rs index 34434da..82ecd1b 100644 --- a/src/proto/ssh.rs +++ b/src/proto/ssh.rs @@ -57,27 +57,6 @@ impl ProtocolState { } } -/* Reconstruct client's banner from the parsed information */ -fn ssh_banner(pstate: &ProtocolState) -> Vec { - let mut banner = b"SSH-".to_vec(); - for b in &pstate.ssh_version { - banner.push(*b); - } - banner.push(b'-'); - for b in &pstate.ssh_software { - banner.push(*b); - } - if pstate.ssh_comment.len() > 0 { - banner.push(b' '); - for b in &pstate.ssh_comment { - banner.push(*b); - } - } - banner.push(b'\r'); - banner.push(b'\n'); - banner -} - fn ssh_parse(pstate: &mut ProtocolState, data: &[u8]) { /* RFC 4253: * @@ -205,6 +184,27 @@ pub fn repl<'a>( mod tests { use super::*; + /* Reconstruct client's banner from the parsed information */ + fn ssh_banner(pstate: &ProtocolState) -> Vec { + let mut banner = b"SSH-".to_vec(); + for b in &pstate.ssh_version { + banner.push(*b); + } + banner.push(b'-'); + for b in &pstate.ssh_software { + banner.push(*b); + } + if pstate.ssh_comment.len() > 0 { + banner.push(b' '); + for b in &pstate.ssh_comment { + banner.push(*b); + } + } + banner.push(b'\r'); + banner.push(b'\n'); + banner + } + #[test] fn ssh_2_banner_parse() { /* all at once */ From 643d5868aafcbda24a7e4877514ec51c56ec7a50 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Tue, 14 Feb 2023 00:31:11 +0100 Subject: [PATCH 159/317] Update dependencies --- Cargo.lock | 277 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 185 insertions(+), 92 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce037e9..f14e753 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] @@ -57,9 +57,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bumpalo" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byteorder" @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -118,13 +118,23 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" dependencies = [ "os_str_bytes", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -140,6 +150,50 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "cxx" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90d59d9acd2a682b4e40605a242f6670eaa58c5957471cbf85e8aa6a0b97a5e8" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebfa40bda659dd5c864e65f4c9a2b0aff19bea56b017b9b77c73d3766a453a38" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "457ce6757c5c70dc6ecdbda6925b958aae7f959bda7d8fb9bde889e34a09dc03" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebf883b7aacd7b2aeb2a7b338648ee19f57c140d4ee8e52c68979c6b2f7f2263" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive-into-owned" version = "0.2.0" @@ -163,9 +217,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "errno" @@ -200,9 +254,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -217,9 +271,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -232,34 +286,42 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "iana-time-zone" -version = "0.1.50" +version = "0.1.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" dependencies = [ "android_system_properties", "core-foundation-sys", + "iana-time-zone-haiku", "js-sys", "wasm-bindgen", "winapi", ] [[package]] -name = "io-lifetimes" -version = "1.0.1" +name = "iana-time-zone-haiku" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7d367024b3f3414d8e01f437f704f41a9f64ab36f9067fa73e526ad4c763c87" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" dependencies = [ "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -273,14 +335,14 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" +checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -294,9 +356,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -324,10 +386,19 @@ dependencies = [ ] [[package]] -name = "linux-raw-sys" -version = "0.1.3" +name = "link-cplusplus" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "log" @@ -414,15 +485,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "os_str_bytes" -version = "6.3.0" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] name = "pcap" @@ -452,9 +523,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "pnet" @@ -549,9 +620,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" @@ -620,35 +691,41 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rustix" -version = "0.36.4" +version = "0.36.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23" +checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ "bitflags 1.3.2", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" + +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "siphasher" @@ -716,18 +793,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", @@ -736,18 +813,19 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -756,9 +834,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "wasi" @@ -774,9 +858,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -784,9 +868,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", @@ -799,9 +883,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -809,9 +893,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", @@ -822,9 +906,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "winapi" @@ -872,24 +956,33 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.42.1", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] name = "windows_aarch64_msvc" @@ -899,9 +992,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" @@ -911,9 +1004,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" @@ -923,9 +1016,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" @@ -935,15 +1028,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" @@ -953,6 +1046,6 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" From ba358181d4a76f585efed202bdbf18a39671453b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Feb 2023 01:02:46 +0000 Subject: [PATCH 160/317] Bump clap from 4.1.4 to 4.1.6 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.4 to 4.1.6. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.4...v4.1.6) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f14e753..15e4514 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.4" +version = "4.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" +checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index 6f91fd9..e32ec19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.1.4" +clap = "4.1.6" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 1cdc68c298ff512a8b415e046f72be2ef7d7afe8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Feb 2023 01:05:11 +0000 Subject: [PATCH 161/317] Bump clap from 4.1.6 to 4.1.7 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.6 to 4.1.7. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.6...v4.1.7) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15e4514..ebfb332 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.6" +version = "4.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3" +checksum = "2f3061d6db6d8fcbbd4b05e057f2acace52e64e96b498c08c2d7a4e65addd340" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index e32ec19..2b0cc69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.1.6" +clap = "4.1.7" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 43b2cfe499d074c19afdc5b5e42796bdfa21da9f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 01:10:52 +0000 Subject: [PATCH 162/317] Bump clap from 4.1.7 to 4.1.8 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.7 to 4.1.8. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.7...v4.1.8) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebfb332..8ebe1e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.7" +version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3061d6db6d8fcbbd4b05e057f2acace52e64e96b498c08c2d7a4e65addd340" +checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index 2b0cc69..20c475b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.23" -clap = "4.1.7" +clap = "4.1.8" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 4af980411018d9d7e82e62e9a8c6d0ae4253553a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Mar 2023 01:33:24 +0000 Subject: [PATCH 163/317] Bump chrono from 0.4.23 to 0.4.24 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.23 to 0.4.24. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.23...v0.4.24) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ebe1e0..d18b9cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,9 +90,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 20c475b..c7a1632 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "1.2.1" byteorder = "1.4.3" -chrono = "0.4.23" +chrono = "0.4.24" clap = "4.1.8" dns-parser = "0.8.0" flate2 = "1.0" From bbe78bcae9e6ea6df6343edb5e4807772d169a3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 01:03:14 +0000 Subject: [PATCH 164/317] Bump clap from 4.1.8 to 4.1.9 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.8 to 4.1.9. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.8...v4.1.9) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d18b9cc..07e3bfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.8" +version = "4.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +checksum = "9a9d6ada83c1edcce028902ea27dd929069c70df4c7600b131b4d9a1ad2879cc" dependencies = [ "bitflags 1.3.2", "clap_lex", diff --git a/Cargo.toml b/Cargo.toml index c7a1632..11b5f8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.1.8" +clap = "4.1.9" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 70d57214720db0dba004582d2c33b54adbba3b7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 01:31:56 +0000 Subject: [PATCH 165/317] Bump clap from 4.1.9 to 4.1.11 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.9 to 4.1.11. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.9...v4.1.11) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 +++++++++--- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07e3bfd..5b6df8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,6 +55,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" + [[package]] name = "bumpalo" version = "3.12.0" @@ -105,11 +111,11 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.9" +version = "4.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9d6ada83c1edcce028902ea27dd929069c70df4c7600b131b4d9a1ad2879cc" +checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.0.2", "clap_lex", "is-terminal", "strsim", diff --git a/Cargo.toml b/Cargo.toml index 11b5f8d..46e6a59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.1.9" +clap = "4.1.11" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From ed44da5267f3c771791f8544dedcfacfe376105e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Mar 2023 01:01:36 +0000 Subject: [PATCH 166/317] Bump clap from 4.1.11 to 4.1.13 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.11 to 4.1.13. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.11...v4.1.13) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 +++--------- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b6df8e..1f78b4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,12 +55,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" - [[package]] name = "bumpalo" version = "3.12.0" @@ -111,11 +105,11 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.11" +version = "4.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" +checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" dependencies = [ - "bitflags 2.0.2", + "bitflags 1.3.2", "clap_lex", "is-terminal", "strsim", diff --git a/Cargo.toml b/Cargo.toml index 46e6a59..8a80550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.1.11" +clap = "4.1.13" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From f63b43f0b5df9194ce023f4eb746293bbca05be9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 01:02:36 +0000 Subject: [PATCH 167/317] Bump clap from 4.1.13 to 4.2.1 Bumps [clap](https://github.com/clap-rs/clap) from 4.1.13 to 4.2.1. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.1.13...v4.2.1) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 118 ++++++++++++++++++++++++++++++++++++++++++----------- Cargo.toml | 2 +- 2 files changed, 96 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f78b4d..b62bb5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,6 +26,46 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-wincon", + "concolor-override", + "concolor-query", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" + +[[package]] +name = "anstyle-parse" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-wincon" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" +dependencies = [ + "anstyle", + "windows-sys 0.45.0", +] + [[package]] name = "atty" version = "0.2.14" @@ -105,25 +145,31 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.13" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" +checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f" +dependencies = [ + "anstream", + "anstyle", "bitflags 1.3.2", "clap_lex", - "is-terminal", "strsim", - "termcolor", ] [[package]] name = "clap_lex" -version = "0.3.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" -dependencies = [ - "os_str_bytes", -] +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] name = "codespan-reporting" @@ -135,6 +181,21 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "concolor-override" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f" + +[[package]] +name = "concolor-query" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" +dependencies = [ + "windows-sys 0.45.0", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -232,6 +293,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.45.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -335,9 +407,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", @@ -396,9 +468,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "cd550e73688e6d578f0ac2119e32b797a327631a42f9433e59d02e139c8df60d" [[package]] name = "log" @@ -489,12 +561,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" -[[package]] -name = "os_str_bytes" -version = "6.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" - [[package]] name = "pcap" version = "1.0.0" @@ -502,7 +568,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d536b12f51fa925b590a6681765ed2bd9f1beb1d2953fa5fe5a20f7c1087b994" dependencies = [ "bitflags 1.3.2", - "errno", + "errno 0.2.8", "libc", "libloading", "pkg-config", @@ -697,12 +763,12 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rustix" -version = "0.36.8" +version = "0.37.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "62b24138615de35e32031d041a09032ef3487a616d901ca4db224e7d557efae2" dependencies = [ "bitflags 1.3.2", - "errno", + "errno 0.3.0", "io-lifetimes", "libc", "linux-raw-sys", @@ -844,6 +910,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 8a80550..dc8650c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.1.13" +clap = "4.2.1" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From a2fa57c64cec90dc7d59c2113e88b5a0ec5a81ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Apr 2023 00:59:36 +0000 Subject: [PATCH 168/317] Bump clap from 4.2.1 to 4.2.2 Bumps [clap](https://github.com/clap-rs/clap) from 4.2.1 to 4.2.2. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.2.1...v4.2.2) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 126 ++++++++++++++++++++++++++++++++++++++++------------- Cargo.toml | 2 +- 2 files changed, 97 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b62bb5e..38f93bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,42 +28,51 @@ dependencies = [ [[package]] name = "anstream" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f" +checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" dependencies = [ "anstyle", "anstyle-parse", + "anstyle-query", "anstyle-wincon", - "concolor-override", - "concolor-query", + "colorchoice", "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "0.3.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" [[package]] name = "anstyle-parse" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] [[package]] -name = "anstyle-wincon" -version = "0.2.0" +name = "anstyle-query" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" dependencies = [ "anstyle", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -145,18 +154,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" +checksum = "9b802d85aaf3a1cdb02b224ba472ebdea62014fccfcb269b95a4d76443b5ee5a" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.2.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f" +checksum = "14a1a858f532119338887a4b8e1af9c60de8249cd7bafd68036a489e261e37b6" dependencies = [ "anstream", "anstyle", @@ -182,19 +191,10 @@ dependencies = [ ] [[package]] -name = "concolor-override" +name = "colorchoice" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f" - -[[package]] -name = "concolor-query" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" -dependencies = [ - "windows-sys 0.45.0", -] +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "core-foundation-sys" @@ -1032,7 +1032,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.1", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -1041,21 +1050,42 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.1", "windows_aarch64_msvc 0.42.1", "windows_i686_gnu 0.42.1", "windows_i686_msvc 0.42.1", "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.1", "windows_x86_64_msvc 0.42.1", ] +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" @@ -1068,6 +1098,12 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.36.1" @@ -1080,6 +1116,12 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.36.1" @@ -1092,6 +1134,12 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" @@ -1104,12 +1152,24 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" @@ -1121,3 +1181,9 @@ name = "windows_x86_64_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" diff --git a/Cargo.toml b/Cargo.toml index dc8650c..61099f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.2.1" +clap = "4.2.2" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From e8fe8bd8e9aa7eec6e2e914085dbd80889e4ba09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 00:59:27 +0000 Subject: [PATCH 169/317] Bump clap from 4.2.2 to 4.2.4 Bumps [clap](https://github.com/clap-rs/clap) from 4.2.2 to 4.2.4. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.2.2...v4.2.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38f93bd..b64389b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,18 +154,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.2" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b802d85aaf3a1cdb02b224ba472ebdea62014fccfcb269b95a4d76443b5ee5a" +checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.2.2" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14a1a858f532119338887a4b8e1af9c60de8249cd7bafd68036a489e261e37b6" +checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 61099f7..38012f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.2.2" +clap = "4.2.4" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 774fbb694add390ad49d9458c39d465d93866fa9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Apr 2023 00:59:34 +0000 Subject: [PATCH 170/317] Bump clap from 4.2.4 to 4.2.5 Bumps [clap](https://github.com/clap-rs/clap) from 4.2.4 to 4.2.5. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.2.4...v4.2.5) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b64389b..20fd7a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,18 +154,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.4" +version = "4.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" +checksum = "8a1f23fa97e1d1641371b51f35535cb26959b8e27ab50d167a8b996b5bada819" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.2.4" +version = "4.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" +checksum = "0fdc5d93c358224b4d6867ef1356d740de2303e9892edc06c5340daeccd96bab" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 38012f8..861e263 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.2.4" +clap = "4.2.5" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 60ec9e9b002143ad1fc4e35705842eec729025ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 01:13:34 +0000 Subject: [PATCH 171/317] Bump flate2 from 1.0.25 to 1.0.26 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.25 to 1.0.26. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/commits) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20fd7a3..fd31ae4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -316,9 +316,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "miniz_oxide", @@ -513,9 +513,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] From d9c9edd1361fa2e50c8878e5c73df3ca5f82cdb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 May 2023 00:59:13 +0000 Subject: [PATCH 172/317] Bump clap from 4.2.5 to 4.2.7 Bumps [clap](https://github.com/clap-rs/clap) from 4.2.5 to 4.2.7. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.2.5...v4.2.7) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd31ae4..e0d0665 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,18 +154,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.5" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a1f23fa97e1d1641371b51f35535cb26959b8e27ab50d167a8b996b5bada819" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.2.5" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdc5d93c358224b4d6867ef1356d740de2303e9892edc06c5340daeccd96bab" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 861e263..e55dc3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.2.5" +clap = "4.2.7" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From c86752057d7e8ca6fdf0033bfea1f18e8a0a6941 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 01:25:58 +0000 Subject: [PATCH 173/317] Bump pcap from 1.0.0 to 1.1.0 Bumps [pcap](https://github.com/rust-pcap/pcap) from 1.0.0 to 1.1.0. - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/compare/v1.0.0...v1.1.0) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0d0665..3cb66f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -563,9 +563,9 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "pcap" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d536b12f51fa925b590a6681765ed2bd9f1beb1d2953fa5fe5a20f7c1087b994" +checksum = "cbaa01d616eb84eb35cd085fdeaa8671dc8d951bdc4a75bfc414466e76b039ce" dependencies = [ "bitflags 1.3.2", "errno 0.2.8", diff --git a/Cargo.toml b/Cargo.toml index e55dc3d..623b987 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.10.3" lazy_static = "1.4.0" log = "0.4.11" netdevice = "0.1.1" -pcap = "1.0.0" +pcap = "1.1.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" From 3afb763a42bd11db450cd3905b77c21696520783 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 01:28:16 +0000 Subject: [PATCH 174/317] Bump clap from 4.2.7 to 4.3.0 Bumps [clap](https://github.com/clap-rs/clap) from 4.2.7 to 4.3.0. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.2.7...clap_complete-v4.3.0) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cb66f2..6d9409e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,18 +154,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.7" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" +checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.2.7" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" dependencies = [ "anstream", "anstyle", @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "codespan-reporting" diff --git a/Cargo.toml b/Cargo.toml index 623b987..df7ffc1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.24" -clap = "4.2.7" +clap = "4.3.0" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From a32335b6df3b551de2484fe3231137a368fe42d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 01:27:28 +0000 Subject: [PATCH 175/317] Bump log from 0.4.17 to 0.4.18 Bumps [log](https://github.com/rust-lang/log) from 0.4.17 to 0.4.18. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.17...0.4.18) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 7 ++----- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d9409e..f4c5821 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,12 +474,9 @@ checksum = "cd550e73688e6d578f0ac2119e32b797a327631a42f9433e59d02e139c8df60d" [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "masscanned" diff --git a/Cargo.toml b/Cargo.toml index df7ffc1..d1832a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" lazy_static = "1.4.0" -log = "0.4.11" +log = "0.4.18" netdevice = "0.1.1" pcap = "1.1.0" pcap-file = "2.0.0" From 0a07dc2b3da1617020ddd4d7369980ff8e1fc2a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 May 2023 00:59:09 +0000 Subject: [PATCH 176/317] Bump chrono from 0.4.24 to 0.4.25 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.24 to 0.4.25. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.24...v0.4.25) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 22 +++++++++------------- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4c5821..355a6d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -139,13 +145,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "fdbc37d37da9e5bce8173f3a41b71d9bf3c674deebbaceacd0ebdabde76efb03" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", "time", "wasm-bindgen", @@ -533,16 +539,6 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index d1832a3..1d23dc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "1.2.1" byteorder = "1.4.3" -chrono = "0.4.24" +chrono = "0.4.25" clap = "4.3.0" dns-parser = "0.8.0" flate2 = "1.0" From fd3ee36dd0da85b9daa277a2b9c389cf801d57b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 01:00:12 +0000 Subject: [PATCH 177/317] Bump chrono from 0.4.25 to 0.4.26 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.25 to 0.4.26. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.25...v0.4.26) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 355a6d6..1aad7f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,9 +145,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbc37d37da9e5bce8173f3a41b71d9bf3c674deebbaceacd0ebdabde76efb03" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 1d23dc7..5f60a7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "1.2.1" byteorder = "1.4.3" -chrono = "0.4.25" +chrono = "0.4.26" clap = "4.3.0" dns-parser = "0.8.0" flate2 = "1.0" From 968bd4ac7f2b30ed863d0e6a86bd991b49a025b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 01:23:19 +0000 Subject: [PATCH 178/317] Bump clap from 4.3.0 to 4.3.1 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.0 to 4.3.1. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.3.0...clap_complete-v4.3.1) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1aad7f0..d7acff7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,18 +160,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "b4ed2379f8603fa2b7509891660e802b88c70a79a6427a70abb5968054de2c28" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 5f60a7b..d69cfa8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.0" +clap = "4.3.1" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 0e1d391d7447822cfe047ea0fde660b1c3bee99e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 00:59:11 +0000 Subject: [PATCH 179/317] Bump clap from 4.3.1 to 4.3.2 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.1 to 4.3.2. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.3.1...v4.3.2) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7acff7..c9e171f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,9 +160,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.1" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ed2379f8603fa2b7509891660e802b88c70a79a6427a70abb5968054de2c28" +checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" dependencies = [ "clap_builder", ] diff --git a/Cargo.toml b/Cargo.toml index d69cfa8..8c1ef8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.1" +clap = "4.3.2" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 09c0a9176f221f5fe5918eb61fd7eabdad9342ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 01:21:02 +0000 Subject: [PATCH 180/317] Bump log from 0.4.18 to 0.4.19 Bumps [log](https://github.com/rust-lang/log) from 0.4.18 to 0.4.19. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.18...0.4.19) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9e171f..16e3c83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -480,9 +480,9 @@ checksum = "cd550e73688e6d578f0ac2119e32b797a327631a42f9433e59d02e139c8df60d" [[package]] name = "log" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "masscanned" diff --git a/Cargo.toml b/Cargo.toml index 8c1ef8c..fdd1903 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" lazy_static = "1.4.0" -log = "0.4.18" +log = "0.4.19" netdevice = "0.1.1" pcap = "1.1.0" pcap-file = "2.0.0" From 0fd38bb0e6145f4410755d660a01e53e814d1a3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 01:21:12 +0000 Subject: [PATCH 181/317] Bump clap from 4.3.2 to 4.3.3 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.2 to 4.3.3. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.2...v4.3.3) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9e171f..ef62a66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,18 +160,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.2" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" +checksum = "ca8f255e4b8027970e78db75e78831229c9815fdbfa67eb1a1b777a62e24b4a0" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.1" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" +checksum = "acd4f3c17c83b0ba34ffbc4f8bbd74f079413f747f84a6f89292f138057e36ab" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 8c1ef8c..c9e6a64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.2" +clap = "4.3.3" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From f9d272c2ddf22f11fed8397b4f1f7dd37b0f7ae8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:59:44 +0000 Subject: [PATCH 182/317] Bump clap from 4.3.3 to 4.3.4 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.3 to 4.3.4. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.3...v4.3.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3abfd97..2ae7d57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,18 +160,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.3" +version = "4.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8f255e4b8027970e78db75e78831229c9815fdbfa67eb1a1b777a62e24b4a0" +checksum = "80672091db20273a15cf9fdd4e47ed43b5091ec9841bf4c6145c9dfbbcae09ed" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.3" +version = "4.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd4f3c17c83b0ba34ffbc4f8bbd74f079413f747f84a6f89292f138057e36ab" +checksum = "c1458a1df40e1e2afebb7ab60ce55c1fa8f431146205aa5f4887e0b111c27636" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index cd2127f..6846d92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.3" +clap = "4.3.4" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From 938661663bbe88dca2e7431e7c16e1f8a05e643e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 01:18:29 +0000 Subject: [PATCH 183/317] Bump strum from 0.24.1 to 0.25.0 Bumps [strum](https://github.com/Peternator7/strum) from 0.24.1 to 0.25.0. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ae7d57..598c949 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -813,9 +813,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" diff --git a/Cargo.toml b/Cargo.toml index 6846d92..5cee9fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.4" -strum = "0.24.1" +strum = "0.25.0" strum_macros = "0.24.2" [[bin]] From 4297389cd3ab56d1041d38bde8eb1132b51b645e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 07:19:59 +0000 Subject: [PATCH 184/317] Bump strum_macros from 0.24.3 to 0.25.0 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.24.3 to 0.25.0. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 39 +++++++++++++++++++++++++-------------- Cargo.toml | 2 +- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 598c949..7ccd90c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,7 +241,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.107", ] [[package]] @@ -258,7 +258,7 @@ checksum = "ebf883b7aacd7b2aeb2a7b338648ee19f57c140d4ee8e52c68979c6b2f7f2263" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -269,7 +269,7 @@ checksum = "2c9d94d81e3819a7b06a8638f448bc6339371ca9b6076a99d4a43eece3c4c923" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -631,7 +631,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 1.0.107", ] [[package]] @@ -685,9 +685,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" dependencies = [ "unicode-ident", ] @@ -700,9 +700,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.23" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -819,15 +819,15 @@ checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "fe9f3bd7d2e45dcc5e265fbb88d6513e4747d8ef9444cf01a533119bce28a157" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.18", ] [[package]] @@ -841,6 +841,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -867,7 +878,7 @@ checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -942,7 +953,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-shared", ] @@ -964,7 +975,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 5cee9fd..7506b1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.4" strum = "0.25.0" -strum_macros = "0.24.2" +strum_macros = "0.25.0" [[bin]] name = "masscanned" From 47b681742cd60bbe738cce84626a52498d997b4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jun 2023 01:00:00 +0000 Subject: [PATCH 185/317] Bump clap from 4.3.4 to 4.3.5 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.4 to 4.3.5. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.4...v4.3.5) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ccd90c..fd30ac0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,18 +160,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.4" +version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80672091db20273a15cf9fdd4e47ed43b5091ec9841bf4c6145c9dfbbcae09ed" +checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.4" +version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1458a1df40e1e2afebb7ab60ce55c1fa8f431146205aa5f4887e0b111c27636" +checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 7506b1c..2eba299 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.4" +clap = "4.3.5" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From c69fd9012e3234c41754a3f6de1e8e7e37645db2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Jun 2023 00:59:23 +0000 Subject: [PATCH 186/317] Bump itertools from 0.10.5 to 0.11.0 Bumps [itertools](https://github.com/rust-itertools/itertools) from 0.10.5 to 0.11.0. - [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-itertools/itertools/compare/v0.10.5...v0.11.0) --- updated-dependencies: - dependency-name: itertools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd30ac0..d041eb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -425,9 +425,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.5" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" dependencies = [ "either", ] diff --git a/Cargo.toml b/Cargo.toml index 2eba299..4827ca3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ chrono = "0.4.26" clap = "4.3.5" dns-parser = "0.8.0" flate2 = "1.0" -itertools = "0.10.3" +itertools = "0.11.0" lazy_static = "1.4.0" log = "0.4.19" netdevice = "0.1.1" From 0dd011be04bd5bb3945a872570c859e86ca4c1bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 01:30:12 +0000 Subject: [PATCH 187/317] Bump clap from 4.3.5 to 4.3.8 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.5 to 4.3.8. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.5...v4.3.8) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d041eb4..69b285f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,18 +160,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.5" +version = "4.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc" +checksum = "d9394150f5b4273a1763355bd1c2ec54cc5a2593f790587bcd6b2c947cfa9211" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.5" +version = "4.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae" +checksum = "9a78fbdd3cc2914ddf37ba444114bc7765bbdcb55ec9cbe6fa054f0137400717" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 4827ca3..a9aafc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.5" +clap = "4.3.8" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From d48e20971e06ff9e98eb1de4a3e48a2873c1ffe2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Jun 2023 00:12:52 +0000 Subject: [PATCH 188/317] Bump clap from 4.3.8 to 4.3.9 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.8 to 4.3.9. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.8...v4.3.9) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 69b285f..9349938 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,18 +160,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.8" +version = "4.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9394150f5b4273a1763355bd1c2ec54cc5a2593f790587bcd6b2c947cfa9211" +checksum = "bba77a07e4489fb41bd90e8d4201c3eb246b3c2c9ea2ba0bddd6c1d1df87db7d" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.8" +version = "4.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a78fbdd3cc2914ddf37ba444114bc7765bbdcb55ec9cbe6fa054f0137400717" +checksum = "2c9b4a88bb4bc35d3d6f65a21b0f0bafe9c894fa00978de242c555ec28bea1c0" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index a9aafc5..0464cd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.8" +clap = "4.3.9" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 45810978a97c0b245503fab66c956c6c3e985691 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 00:36:52 +0000 Subject: [PATCH 189/317] Bump clap from 4.3.9 to 4.3.10 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.9 to 4.3.10. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.9...v4.3.10) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 9 ++++----- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9349938..f22bdba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,22 +160,21 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.9" +version = "4.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba77a07e4489fb41bd90e8d4201c3eb246b3c2c9ea2ba0bddd6c1d1df87db7d" +checksum = "384e169cc618c613d5e3ca6404dda77a8685a63e08660dcc64abaf7da7cb0c7a" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.9" +version = "4.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9b4a88bb4bc35d3d6f65a21b0f0bafe9c894fa00978de242c555ec28bea1c0" +checksum = "ef137bbe35aab78bdb468ccfba75a5f4d8321ae011d34063770780545176af2d" dependencies = [ "anstream", "anstyle", - "bitflags 1.3.2", "clap_lex", "strsim", ] diff --git a/Cargo.toml b/Cargo.toml index 0464cd7..48de93f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.9" +clap = "4.3.10" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 66f2d6138d1ee4767c4388e39905daaf9e800b7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 14:53:55 +0000 Subject: [PATCH 190/317] Bump bitflags from 1.3.2 to 2.3.3 Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.3.2 to 2.3.3. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/1.3.2...2.3.3) --- updated-dependencies: - dependency-name: bitflags dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 +++++++- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f22bdba..6810986 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,6 +110,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bumpalo" version = "3.12.0" @@ -487,7 +493,7 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.3.3", "byteorder", "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 48de93f..645269b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "1.2.1" +bitflags = "2.3.3" byteorder = "1.4.3" chrono = "0.4.26" clap = "4.3.10" From cc17dec2d557bed57dbaab3d4f3a30d19ff0827a Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 3 Jul 2023 18:26:13 +0200 Subject: [PATCH 191/317] Update SmackFlags to support Copy Needed to update bitflags from 1.x to 2.x --- src/smack/smack_utils.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/smack/smack_utils.rs b/src/smack/smack_utils.rs index 79bb459..bed3b6e 100644 --- a/src/smack/smack_utils.rs +++ b/src/smack/smack_utils.rs @@ -1,4 +1,5 @@ bitflags! { + #[derive(Clone, Copy)] pub struct SmackFlags: usize { const EMPTY = 0x00; const ANCHOR_BEGIN = 0x01; From 4134008d115cb093a0fccaf56d36198616a9068f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 00:20:13 +0000 Subject: [PATCH 192/317] Bump strum_macros from 0.25.0 to 0.25.1 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.25.0 to 0.25.1. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6810986..623d405 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -824,9 +824,9 @@ checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9f3bd7d2e45dcc5e265fbb88d6513e4747d8ef9444cf01a533119bce28a157" +checksum = "6069ca09d878a33f883cc06aaa9718ede171841d3832450354410b718b097232" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 645269b..93aec7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.4" strum = "0.25.0" -strum_macros = "0.25.0" +strum_macros = "0.25.1" [[bin]] name = "masscanned" From c132c39ebf17d40e212228304c6432451fd0273d Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:20:06 +0200 Subject: [PATCH 193/317] Fix syn (#102) * Add unit test for TCP SYN replies * Add functional test for TCP SYN+flag packets * Fix bug: prevent anwsers to SYN+flag first packets * Fix TCP behaviour to match Linux network stack * Update the documentation according to the new behaviour for TCP SYN packets --- README.md | 6 ++- src/layer_4/tcp.rs | 101 +++++++++++++++++++++++++++++++++++++++++- test/src/tests/tcp.py | 24 ++++++++++ 3 files changed, 128 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9e81dd4..d4363c2 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,11 @@ code `0` and the same payload as the incoming packet, as specified by [RFC 792]( a supported protocol (Layer 5/6/7) has been detected, * if the received packet has flag `ACK`, it is ignored, * if the received packet has flag `RST` or `FIN-ACK`, it is ignored, -* if the received packet has flag `SYN`, then `masscanned` answers with a `SYN-ACK` packet, setting a **SYNACK-cookie** in the sequence number. +* if the received packet has flag `SYN`, then `masscanned` tries to imitate the behaviour +of a standard Linux stack - which is: + * if there are additional flags that are not among `PSH`, `URG`, `CWR`, `ECE`, then the `SYN` is ignored, + * if the flags `CWR` and`ECE` are simultaneously set, then the `SYN` is ignored, + * in any other case, `masscanned` answers with a `SYN-ACK` packet, setting a **SYNACK-cookie** in the sequence number. #### UDP diff --git a/src/layer_4/tcp.rs b/src/layer_4/tcp.rs index a562646..82ad0c2 100644 --- a/src/layer_4/tcp.rs +++ b/src/layer_4/tcp.rs @@ -104,8 +104,14 @@ pub fn repl<'a, 'b>( tcp_repl.set_acknowledgement(tcp_req.get_sequence().wrapping_add(1)); tcp_repl.set_sequence(tcp_req.get_acknowledgement()); } - /* Answer to SYN */ - flags if flags & TcpFlags::SYN == TcpFlags::SYN => { + /* Answer to SYN + P|U|C|E + !(C && E) to imitate Linux network stack */ + flags + if (flags & TcpFlags::SYN) == TcpFlags::SYN && + /* no other flag than S,P,U,C,E */ + (flags & !(TcpFlags::SYN | TcpFlags::PSH | TcpFlags::URG | TcpFlags::CWR | TcpFlags::ECE)) == 0 && + /* not C && E */ + ((flags & TcpFlags::CWR == 0) || (flags & TcpFlags::ECE == 0)) => + { tcp_repl = MutableTcpPacket::owned(vec![0; MutableTcpPacket::minimum_packet_size()]) .expect("error constructing a TCP packet"); tcp_repl.set_flags(TcpFlags::ACK); @@ -141,6 +147,97 @@ mod tests { use crate::logger::MetaLogger; + #[test] + fn test_tcp_syn() { + let masscanned = Masscanned { + mac: MacAddr(0, 0, 0, 0, 0, 0), + self_ip_list: None, + remote_ip_deny_list: 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 = 1234567; + let ack = 0; + 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, + }; + /* flags OK - list is exhaustive */ + /* aim at imitating a Linux network stack */ + let flags_ok = [ + TcpFlags::SYN, + TcpFlags::SYN | TcpFlags::PSH, + TcpFlags::SYN | TcpFlags::URG, + TcpFlags::SYN | TcpFlags::CWR, + TcpFlags::SYN | TcpFlags::ECE, + TcpFlags::SYN | TcpFlags::PSH | TcpFlags::URG, + TcpFlags::SYN | TcpFlags::PSH | TcpFlags::CWR, + TcpFlags::SYN | TcpFlags::PSH | TcpFlags::ECE, + TcpFlags::SYN | TcpFlags::PSH | TcpFlags::ECE, + TcpFlags::SYN | TcpFlags::URG | TcpFlags::CWR, + TcpFlags::SYN | TcpFlags::URG | TcpFlags::ECE, + TcpFlags::SYN | TcpFlags::PSH | TcpFlags::URG | TcpFlags::CWR, + TcpFlags::SYN | TcpFlags::PSH | TcpFlags::URG | TcpFlags::ECE, + ]; + for flags in flags_ok { + 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(flags); + let some_tcp_repl = repl(&tcp_req.to_immutable(), &masscanned, &mut client_info); + if some_tcp_repl == None { + panic!("expected a reply, got none for flags: {:?}", flags); + } + let tcp_repl = some_tcp_repl.unwrap(); + /* check reply flags */ + assert!(tcp_repl.get_flags() == (TcpFlags::SYN | TcpFlags::ACK)); + /* check reply seq and ack */ + assert!(tcp_repl.get_acknowledgement() == seq.wrapping_add(1)); + } + /* flags KO - list is *not* exhaustive */ + let flags_ko = [ + TcpFlags::SYN | TcpFlags::ACK, + TcpFlags::SYN | TcpFlags::FIN, + TcpFlags::SYN | TcpFlags::CWR | TcpFlags::ECE, + TcpFlags::SYN | TcpFlags::PSH | TcpFlags::URG | TcpFlags::CWR | TcpFlags::ECE, + TcpFlags::PSH, + ]; + for flags in flags_ko { + 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(flags); + let some_tcp_repl = repl(&tcp_req.to_immutable(), &masscanned, &mut client_info); + if some_tcp_repl != None { + panic!("expected no reply, got one"); + } + } + } + #[test] fn test_tcp_fin_ack() { let masscanned = Masscanned { diff --git a/test/src/tests/tcp.py b/test/src/tests/tcp.py index f42e4fa..1eef702 100644 --- a/test/src/tests/tcp.py +++ b/test/src/tests/tcp.py @@ -277,3 +277,27 @@ def test_ipv6_tcp_psh_ack(): assert TCP in ack, "expecting TCP, got %r" % ack.summary() ack = ack[TCP] assert ack.flags == "A", "expecting TCP A, got %r" % syn_ack.flags + + +@test +def test_tcp_syn_with_flags(): + # send a SYN packet with other TCP flags, should not be answered + for flags in ["SA", "SR", "SF", "SPUCE"]: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags=flags, dport=80, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is None, "expecting no answer, got one" + # some should be accepted to imitate a Linux network stack + for flags in ["SP", "SU", "SC", "SE", "SPU", "SPC", "SPE", "SPUC", "SPUE"]: + seq_init = int(RandInt()) + syn = ( + Ether(dst=MAC_ADDR) + / IP(dst=IPV4_ADDR) + / TCP(flags=flags, dport=80, seq=seq_init) + ) + syn_ack = srp1(syn, timeout=1) + assert syn_ack is not None, "expecting answer, got None" From dd25bcb6f846d75fd954323ae73352d7b75d4b5b Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Thu, 6 Jul 2023 01:08:34 +0200 Subject: [PATCH 194/317] Add a Docker image --- docker/Dockerfile | 41 +++++++++++++++++++++++++++++++++++++++++ docker/runmasscanned | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 docker/Dockerfile create mode 100755 docker/runmasscanned diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..973ac96 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,41 @@ +# This file is part of masscanned. +# Copyright 2021 - 2023 The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +FROM debian:12 AS builder + +ENV DEBIAN_FRONTEND noninteractive + +RUN echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list.d/testing.list && \ + apt-get -q update && \ + apt-get -qy --no-install-recommends install cargo ca-certificates curl && \ + curl -L https://github.com/ivre/masscanned/archive/refs/heads/master.tar.gz | tar zxf - && \ + cd masscanned-master && \ + cargo build --release + +FROM debian:12 +LABEL maintainer="Pierre LALET " + +COPY --from=builder /masscanned-master/target/release/masscanned /usr/local/bin/masscanned + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get -q update && \ + apt-get -qy --no-install-recommends install iproute2 iptables && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY runmasscanned /usr/local/bin/runmasscanned + +CMD /usr/local/bin/runmasscanned diff --git a/docker/runmasscanned b/docker/runmasscanned new file mode 100755 index 0000000..7953cb6 --- /dev/null +++ b/docker/runmasscanned @@ -0,0 +1,35 @@ +#! /bin/bash +# This file is part of masscanned. +# Copyright 2021 - 2023 The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +iface="$(ip route get 0.0.0.1 | awk '/^0\.0\.0\.1 via / {print $5}')" +addrs="$(ip a show eth0 | awk '/ inet6? / {print $2}' | sed 's#/.*##' | tr '\n' ',' | sed 's#,$##')" + +if ! capsh --print | awk '/^Current: / {print $2}' | tr ',' '\n' | grep -q '^cap_net_admin$'; then + echo "WARNING: cannot run iptables (need capability cap_net_admin)" >&2 + exit 1 +fi + +for v in '' 6; do + for c in INPUT OUTPUT FORWARD; do + ip${v}tables -P $c DROP + done +done + +echo Interface: "$iface" +echo Addresses: "$addrs" + +/usr/local/bin/masscanned -i "$iface" --self-ip-list "$addrs" From 496d40c03cc18d8b61d10a75d2cd08c0ae4dcd19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 00:52:20 +0000 Subject: [PATCH 195/317] Bump clap from 4.3.10 to 4.3.11 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.10 to 4.3.11. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.10...v4.3.11) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 623d405..bd8a671 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.10" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384e169cc618c613d5e3ca6404dda77a8685a63e08660dcc64abaf7da7cb0c7a" +checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.10" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef137bbe35aab78bdb468ccfba75a5f4d8321ae011d34063770780545176af2d" +checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 93aec7b..30b2e54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.3.3" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.10" +clap = "4.3.11" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 3e075de237fbfc7b4f286f3fe50a17997399b972 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 00:54:46 +0000 Subject: [PATCH 196/317] Bump clap from 4.3.11 to 4.3.12 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.11 to 4.3.12. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.11...v4.3.12) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd8a671..c119d03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.11" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.11" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 30b2e54..c9d61e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.3.3" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.11" +clap = "4.3.12" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 4ede8c06cc42fd5bce5eb722d46d23dd7ac802bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jul 2023 00:18:56 +0000 Subject: [PATCH 197/317] Bump clap from 4.3.12 to 4.3.16 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.12 to 4.3.16. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.12...v4.3.16) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c119d03..7ed2abd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.12" +version = "4.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" +checksum = "74bb1b4028935821b2d6b439bba2e970bdcf740832732437ead910c632e30d7d" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.12" +version = "4.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" +checksum = "5ae467cbb0111869b765e13882a1dbbd6cb52f58203d8b80c44f667d4dd19843" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index c9d61e3..37d012a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.3.3" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.12" +clap = "4.3.16" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 8c396bce577af5bbb4211935091972595a4c4317 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 00:37:00 +0000 Subject: [PATCH 198/317] Bump clap from 4.3.16 to 4.3.17 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.16 to 4.3.17. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.16...v4.3.17) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ed2abd..d4b3109 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.16" +version = "4.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74bb1b4028935821b2d6b439bba2e970bdcf740832732437ead910c632e30d7d" +checksum = "5b0827b011f6f8ab38590295339817b0d26f344aa4932c3ced71b45b0c54b4a9" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.16" +version = "4.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ae467cbb0111869b765e13882a1dbbd6cb52f58203d8b80c44f667d4dd19843" +checksum = "9441b403be87be858db6a23edb493e7f694761acdc3343d5a0fcaafd304cbc9e" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 37d012a..9ef8c13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.3.3" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.16" +clap = "4.3.17" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 4b6a53caf3929d6a56e764748f9be2feeb34c2a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 00:47:45 +0000 Subject: [PATCH 199/317] Bump clap from 4.3.17 to 4.3.19 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.17 to 4.3.19. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.17...v4.3.19) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4b3109..3094d84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.17" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0827b011f6f8ab38590295339817b0d26f344aa4932c3ced71b45b0c54b4a9" +checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.17" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9441b403be87be858db6a23edb493e7f694761acdc3343d5a0fcaafd304cbc9e" +checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 9ef8c13..5426415 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.3.3" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.17" +clap = "4.3.19" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 12a4ba04d80ddaf441f0a4d4162053714dc98d7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 00:49:39 +0000 Subject: [PATCH 200/317] Bump strum_macros from 0.25.1 to 0.25.2 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.25.1 to 0.25.2. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3094d84..bdf7fd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -824,9 +824,9 @@ checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.25.1" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6069ca09d878a33f883cc06aaa9718ede171841d3832450354410b718b097232" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 5426415..ec3f52e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ rand = "0.8.4" siphasher = "0.3" stderrlog = "0.5.4" strum = "0.25.0" -strum_macros = "0.25.1" +strum_macros = "0.25.2" [[bin]] name = "masscanned" From 3b328be1b8ee920d2537f716d98a4dc51dc638cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 00:15:47 +0000 Subject: [PATCH 201/317] Bump clap from 4.3.19 to 4.3.21 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.19 to 4.3.21. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.19...v4.3.21) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdf7fd0..ba7679b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.19" +version = "4.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index ec3f52e..8538cc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.3.3" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.19" +clap = "4.3.21" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From bc8fbaaf9915b7858a67abb2d5f9e49a21da1080 Mon Sep 17 00:00:00 2001 From: _Frky <3105926+Frky@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:13:30 +0200 Subject: [PATCH 202/317] Add Docker documentation in README --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index d4363c2..d61c5f9 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ protocols. ## Try it locally +### On your host + 1. Build **masscanned** ``` $ cargo build @@ -74,6 +76,29 @@ $ cargo build ... ``` +### In a Docker + +1. Install docker: +``` +# apt install docker.io +``` +1. Build docker container: +``` +$ cd masscanned/docker && docker build -t masscanned:test . +``` +1. Run docker container: +``` +$ docker run --cap-add=NET_ADMIN masscanned:test +``` +1. Send packets to **masscanned** +``` +# arping 172.17.0.2 +# ping 172.17.0.2 +# nc -n -v 172.17.0.2 80 +# nc -n -v -u 172.17.0.2 80 +... +``` + ## Use it A good use of **masscanned** is to deploy it on a VPS with one or more public IP addresses. From 039dc811399d24fdd16d367d47e27e4fd9d5d257 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 01:10:40 +0000 Subject: [PATCH 203/317] Bump log from 0.4.19 to 0.4.20 Bumps [log](https://github.com/rust-lang/log) from 0.4.19 to 0.4.20. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.19...0.4.20) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba7679b..49fc733 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -485,9 +485,9 @@ checksum = "cd550e73688e6d578f0ac2119e32b797a327631a42f9433e59d02e139c8df60d" [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "masscanned" diff --git a/Cargo.toml b/Cargo.toml index 8538cc7..3cd385b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" lazy_static = "1.4.0" -log = "0.4.19" +log = "0.4.20" netdevice = "0.1.1" pcap = "1.1.0" pcap-file = "2.0.0" From 4662692ab800683fdd529e5b90b7b92087b63edf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 01:11:06 +0000 Subject: [PATCH 204/317] Bump bitflags from 2.3.3 to 2.4.0 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.3.3 to 2.4.0. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.3.3...2.4.0) --- updated-dependencies: - dependency-name: bitflags dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba7679b..d0e49f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,9 +112,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bumpalo" @@ -493,7 +493,7 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "byteorder", "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 8538cc7..11cb0d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.3.3" +bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.26" clap = "4.3.21" From 34c5dcc31bee711bb7013b94932e7b3890423ac5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Aug 2023 01:01:52 +0000 Subject: [PATCH 205/317] Bump flate2 from 1.0.26 to 1.0.27 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.26 to 1.0.27. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.26...1.0.27) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2315ac8..0fe383a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,9 +327,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "miniz_oxide", From 3ebe8c604b74c4c5d9e871b3ac21bf65d7c0454e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 00:04:57 +0000 Subject: [PATCH 206/317] Bump clap from 4.3.21 to 4.3.22 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.21 to 4.3.22. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.21...v4.3.22) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fe383a..0ecb968 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.21" +version = "4.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "b417ae4361bca3f5de378294fc7472d3c4ed86a5ef9f49e93ae722f432aae8d2" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "9c90dc0f0e42c64bff177ca9d7be6fcc9ddb0f26a6e062174a61c84dd6c644d4" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 565a91f..dec8243 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.21" +clap = "4.3.22" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 7fcb05cb2aa4e5d4818328b18a674fe18b745350 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 01:02:14 +0000 Subject: [PATCH 207/317] Bump clap from 4.3.22 to 4.3.23 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.22 to 4.3.23. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.22...v4.3.23) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ecb968..48a7288 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.22" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b417ae4361bca3f5de378294fc7472d3c4ed86a5ef9f49e93ae722f432aae8d2" +checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.22" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c90dc0f0e42c64bff177ca9d7be6fcc9ddb0f26a6e062174a61c84dd6c644d4" +checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index dec8243..b9fd152 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.22" +clap = "4.3.23" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 14a271b9f42478e2697c60539ef85f30a22bb559 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 00:11:25 +0000 Subject: [PATCH 208/317] Bump clap from 4.3.23 to 4.3.24 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.23 to 4.3.24. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.23...v4.3.24) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48a7288..262f796 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,18 +166,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.23" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" +checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.23" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" +checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index b9fd152..e8b3ac4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.23" +clap = "4.3.24" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 130a7601cb689358a9624d79ec6fc26f4676f5fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 00:11:32 +0000 Subject: [PATCH 209/317] Bump siphasher from 0.3.10 to 1.0.0 Bumps [siphasher](https://github.com/jedisct1/rust-siphash) from 0.3.10 to 1.0.0. - [Commits](https://github.com/jedisct1/rust-siphash/compare/0.3.10...1.0.0) --- updated-dependencies: - dependency-name: siphasher dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48a7288..f444900 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -793,9 +793,9 @@ checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "siphasher" -version = "0.3.10" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" [[package]] name = "stderrlog" diff --git a/Cargo.toml b/Cargo.toml index b9fd152..2049675 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ pcap = "1.1.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" -siphasher = "0.3" +siphasher = "1.0" stderrlog = "0.5.4" strum = "0.25.0" strum_macros = "0.25.2" From e654f416d302e44b2b03c2dec0ed63f87b557348 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 00:28:18 +0000 Subject: [PATCH 210/317] Bump clap from 4.3.24 to 4.4.0 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.24 to 4.4.0. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.24...clap_complete-v4.4.0) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 152 +++++------------------------------------------------ Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 140 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4902a2f..0c59072 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,16 +34,15 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] @@ -73,9 +72,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -87,7 +86,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", "winapi", ] @@ -166,18 +165,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.24" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" +checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.24" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" +checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" dependencies = [ "anstream", "anstyle", @@ -304,17 +303,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "errno" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.45.0", -] - [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -367,12 +355,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - [[package]] name = "iana-time-zone" version = "0.1.53" @@ -397,16 +379,6 @@ dependencies = [ "cxx-build", ] -[[package]] -name = "io-lifetimes" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" -dependencies = [ - "libc", - "windows-sys 0.45.0", -] - [[package]] name = "ipnetwork" version = "0.20.0" @@ -416,18 +388,6 @@ dependencies = [ "serde", ] -[[package]] -name = "is-terminal" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" -dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix", - "windows-sys 0.45.0", -] - [[package]] name = "itertools" version = "0.11.0" @@ -477,12 +437,6 @@ dependencies = [ "cc", ] -[[package]] -name = "linux-raw-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd550e73688e6d578f0ac2119e32b797a327631a42f9433e59d02e139c8df60d" - [[package]] name = "log" version = "0.4.20" @@ -566,7 +520,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbaa01d616eb84eb35cd085fdeaa8671dc8d951bdc4a75bfc414466e76b039ce" dependencies = [ "bitflags 1.3.2", - "errno 0.2.8", + "errno", "libc", "libloading", "pkg-config", @@ -759,20 +713,6 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" -[[package]] -name = "rustix" -version = "0.37.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b24138615de35e32031d041a09032ef3487a616d901ca4db224e7d557efae2" -dependencies = [ - "bitflags 1.3.2", - "errno 0.3.0", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.45.0", -] - [[package]] name = "rustversion" version = "1.0.11" @@ -1035,37 +975,13 @@ dependencies = [ "windows_x86_64_msvc 0.36.1", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.1", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows-targets", ] [[package]] @@ -1074,21 +990,15 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_gnullvm", "windows_aarch64_msvc 0.48.0", "windows_i686_gnu 0.48.0", "windows_i686_msvc 0.48.0", "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_gnullvm", "windows_x86_64_msvc 0.48.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" @@ -1101,12 +1011,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" @@ -1119,12 +1023,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" -[[package]] -name = "windows_i686_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" - [[package]] name = "windows_i686_gnu" version = "0.48.0" @@ -1137,12 +1035,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" - [[package]] name = "windows_i686_msvc" version = "0.48.0" @@ -1155,24 +1047,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" @@ -1185,12 +1065,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index a2e17ef..4d7f90f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.3.24" +clap = "4.4.0" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From b498d706022981632a126b674bd8ea414136871b Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Sat, 26 Aug 2023 22:32:10 +0200 Subject: [PATCH 211/317] Remove unneeded `mut` --- src/proto/stun.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto/stun.rs b/src/proto/stun.rs index ae8c749..24b209c 100644 --- a/src/proto/stun.rs +++ b/src/proto/stun.rs @@ -354,7 +354,7 @@ impl Into> for StunPacket { pub fn repl<'a>( data: &'a [u8], _masscanned: &Masscanned, - mut client_info: &mut ClientInfo, + client_info: &mut ClientInfo, _tcb: Option<&mut TCPControlBlock>, ) -> Option> { debug!("receiving STUN data"); From bec538b52f7eb41574c3d2c8d4bf670f57fbff41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 00:55:28 +0000 Subject: [PATCH 212/317] Bump clap from 4.4.0 to 4.4.1 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.0 to 4.4.1. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.4.0...v4.4.1) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c59072..8487aa3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,18 +165,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" +checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" +checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 4d7f90f..a831c67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.26" -clap = "4.4.0" +clap = "4.4.1" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From caab648c48dac5b20bcc2d88ad38ceb35d289c4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Aug 2023 00:43:44 +0000 Subject: [PATCH 213/317] Bump chrono from 0.4.26 to 0.4.27 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.26 to 0.4.27. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.26...v0.4.27) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8487aa3..4ddc6ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,9 +150,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" dependencies = [ "android-tzdata", "iana-time-zone", @@ -160,7 +160,7 @@ dependencies = [ "num-traits", "time", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a831c67..888e723 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.0" byteorder = "1.4.3" -chrono = "0.4.26" +chrono = "0.4.27" clap = "4.4.1" dns-parser = "0.8.0" flate2 = "1.0" From bc99e527abb2ca40548450b8baeef66324043a1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Aug 2023 00:07:37 +0000 Subject: [PATCH 214/317] Bump chrono from 0.4.27 to 0.4.28 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.27 to 0.4.28. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.27...v0.4.28) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ddc6ed..63752a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,9 +150,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 888e723..2147c10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.0" byteorder = "1.4.3" -chrono = "0.4.27" +chrono = "0.4.28" clap = "4.4.1" dns-parser = "0.8.0" flate2 = "1.0" From 74474df673e97c32de27598194168ffc2f5cdeea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 00:54:57 +0000 Subject: [PATCH 215/317] Bump clap from 4.4.1 to 4.4.2 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.1 to 4.4.2. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.1...v4.4.2) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63752a3..61c560b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,18 +165,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 2147c10..c8536c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.28" -clap = "4.4.1" +clap = "4.4.2" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 4513e93a926572f947fdf3f35619b2b8cbec2e84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:48:51 +0000 Subject: [PATCH 216/317] Bump chrono from 0.4.28 to 0.4.29 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.28 to 0.4.29. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.28...v0.4.29) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61c560b..c198971 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,9 +150,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "d87d9d13be47a5b7c3907137f1290b0459a7f80efb26be8c52afb11963bccb02" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index c8536c4..8a04b18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.0" byteorder = "1.4.3" -chrono = "0.4.28" +chrono = "0.4.29" clap = "4.4.2" dns-parser = "0.8.0" flate2 = "1.0" From a28d450eb196fe2d8136bfbdd9f1565d3bb46366 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 00:50:00 +0000 Subject: [PATCH 217/317] Bump chrono from 0.4.29 to 0.4.30 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.29 to 0.4.30. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.29...v0.4.30) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 24 +++--------------------- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c198971..786eb44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,15 +150,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87d9d13be47a5b7c3907137f1290b0459a7f80efb26be8c52afb11963bccb02" +checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "time", "wasm-bindgen", "windows-targets", ] @@ -331,7 +330,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -836,17 +835,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "unicode-ident" version = "1.0.6" @@ -865,12 +853,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 8a04b18..5e9c9c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.0" byteorder = "1.4.3" -chrono = "0.4.29" +chrono = "0.4.30" clap = "4.4.2" dns-parser = "0.8.0" flate2 = "1.0" From 50c9984f5401834982872e5092009f511b1ebbcb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 00:10:32 +0000 Subject: [PATCH 218/317] Bump clap from 4.4.2 to 4.4.3 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.2 to 4.4.3. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.2...v4.4.3) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 786eb44..b1ef95f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,9 +164,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.2" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" dependencies = [ "clap_builder", ] diff --git a/Cargo.toml b/Cargo.toml index 5e9c9c7..2cebcb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.30" -clap = "4.4.2" +clap = "4.4.3" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 1f676ae06d4762218ab6994015085174c7e47296 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 01:08:26 +0000 Subject: [PATCH 219/317] Bump chrono from 0.4.30 to 0.4.31 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.30 to 0.4.31. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.30...v0.4.31) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1ef95f..75920b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,9 +150,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 2cebcb4..3aba3bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.0" byteorder = "1.4.3" -chrono = "0.4.30" +chrono = "0.4.31" clap = "4.4.3" dns-parser = "0.8.0" flate2 = "1.0" From f804962dd39e401d6837a09bb31d8c7e149b7871 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 00:19:55 +0000 Subject: [PATCH 220/317] Bump clap from 4.4.3 to 4.4.4 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.3 to 4.4.4. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.3...v4.4.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75920b8..868a481 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,18 +164,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.3" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" +checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 3aba3bf..24a7786 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.31" -clap = "4.4.3" +clap = "4.4.4" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 0ada44b2291ac2f40e418898c04cec91b592743a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 00:18:52 +0000 Subject: [PATCH 221/317] Bump clap from 4.4.4 to 4.4.5 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.4 to 4.4.5. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.4...v4.4.5) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 868a481..f0dfe4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,18 +164,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.4" +version = "4.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" +checksum = "824956d0dca8334758a5b7f7e50518d66ea319330cbceedcf76905c2f6ab30e3" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.4" +version = "4.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" +checksum = "122ec64120a49b4563ccaedcbea7818d069ed8e9aa6d829b82d8a4128936b2ab" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 24a7786..88645ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.31" -clap = "4.4.4" +clap = "4.4.5" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From ffcbc5470232f46717973d3ae6dfe56228d47f3b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 00:30:46 +0000 Subject: [PATCH 222/317] Bump clap from 4.4.5 to 4.4.6 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.5 to 4.4.6. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.5...v4.4.6) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0dfe4a..7c9a961 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "f6cd65a4b849ace0b7f6daeebcc1a1d111282227ca745458c61dbf670e52a597" dependencies = [ "anstyle", "anstyle-parse", @@ -72,9 +72,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "0238ca56c96dfa37bdf7c373c8886dd591322500aceeeccdb2216fe06dc2f796" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -164,18 +164,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.5" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824956d0dca8334758a5b7f7e50518d66ea319330cbceedcf76905c2f6ab30e3" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.5" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122ec64120a49b4563ccaedcbea7818d069ed8e9aa6d829b82d8a4128936b2ab" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 88645ef..6abdf1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.0" byteorder = "1.4.3" chrono = "0.4.31" -clap = "4.4.5" +clap = "4.4.6" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 66d4622238a59aca3e1bced81fd056e888b040d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 00:11:58 +0000 Subject: [PATCH 223/317] Bump byteorder from 1.4.3 to 1.5.0 Bumps [byteorder](https://github.com/BurntSushi/byteorder) from 1.4.3 to 1.5.0. - [Changelog](https://github.com/BurntSushi/byteorder/blob/master/CHANGELOG.md) - [Commits](https://github.com/BurntSushi/byteorder/compare/1.4.3...1.5.0) --- updated-dependencies: - dependency-name: byteorder dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c9a961..60afb00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "byteorder_slice" diff --git a/Cargo.toml b/Cargo.toml index 6abdf1f..0f7cb31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ edition = "2018" [dependencies] bitflags = "2.4.0" -byteorder = "1.4.3" +byteorder = "1.5.0" chrono = "0.4.31" clap = "4.4.6" dns-parser = "0.8.0" From 538392768406b7cffbfdf8986cc8b318eb2e0926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Tom=C3=A9=20Santana?= Date: Mon, 9 Oct 2023 10:50:41 -0300 Subject: [PATCH 224/317] chore: remove netdevice dependency --- Cargo.lock | 21 ++------------------- Cargo.toml | 1 - 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60afb00..eb815dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,12 +97,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bitflags" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" - [[package]] name = "bitflags" version = "1.3.2" @@ -413,9 +407,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libloading" @@ -455,7 +449,6 @@ dependencies = [ "itertools", "lazy_static", "log", - "netdevice", "pcap", "pcap-file", "pnet", @@ -481,16 +474,6 @@ dependencies = [ "adler", ] -[[package]] -name = "netdevice" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e2f7ba898cd2fef0e36f91c9cd2bf3b849a2a31510d5f7e1cf515cbf698198" -dependencies = [ - "bitflags 0.7.0", - "libc", -] - [[package]] name = "no-std-net" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 0f7cb31..0381c2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ flate2 = "1.0" itertools = "0.11.0" lazy_static = "1.4.0" log = "0.4.20" -netdevice = "0.1.1" pcap = "1.1.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } From a0b857208905ca1264264038c4c9607306abcae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Tom=C3=A9=20Santana?= Date: Mon, 9 Oct 2023 10:50:58 -0300 Subject: [PATCH 225/317] fix: remove netdevice crate usage --- src/masscanned.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index ea442ce..5198dec 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -196,7 +196,7 @@ fn main() { ); return; }; - if iface.flags & (netdevice::IFF_UP.bits() as u32) == 0 { + if !iface.is_up() { error!("specified interface is DOWN"); return; } @@ -286,7 +286,7 @@ fn main() { let (mut tx, mut rx) = get_channel(masscanned.iface.unwrap()); loop { /* check if network interface is still up */ - if masscanned.iface.unwrap().flags & (netdevice::IFF_UP.bits() as u32) == 0 { + if !masscanned.iface.unwrap().is_up() { error!("interface is DOWN - aborting"); break; } From c02ea0d62e4775979587bb605cddfa44fdeb3fd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 01:02:18 +0000 Subject: [PATCH 226/317] Bump bitflags from 2.4.0 to 2.4.1 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.4.0...2.4.1) --- updated-dependencies: - dependency-name: bitflags dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb815dd..47d5bbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,9 +105,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bumpalo" @@ -440,7 +440,7 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "byteorder", "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 0381c2b..891e7af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.4.0" +bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" clap = "4.4.6" From 521236b60c4a9835d400ab11fd6c2c0aad1c510e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 01:02:23 +0000 Subject: [PATCH 227/317] Bump strum_macros from 0.25.2 to 0.25.3 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.25.2 to 0.25.3. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb815dd..361db6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -746,9 +746,9 @@ checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 0381c2b..4db1b29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ rand = "0.8.4" siphasher = "1.0" stderrlog = "0.5.4" strum = "0.25.0" -strum_macros = "0.25.2" +strum_macros = "0.25.3" [[bin]] name = "masscanned" From 07b9af36f3b2529e31696eb76ca5c815ae4e6689 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 01:02:31 +0000 Subject: [PATCH 228/317] Bump flate2 from 1.0.27 to 1.0.28 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.27 to 1.0.28. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.27...1.0.28) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb815dd..b186184 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,9 +308,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", From b642c34e42bf4505ec49ab774cd28f92813679dd Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Wed, 18 Oct 2023 02:18:22 +0200 Subject: [PATCH 229/317] Remove unneeded .clone() call `pattern` is a reference, and according to `cargo test` output: "the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed". --- src/smack/smack.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smack/smack.rs b/src/smack/smack.rs index bb37358..8248ec1 100644 --- a/src/smack/smack.rs +++ b/src/smack/smack.rs @@ -61,7 +61,7 @@ pub struct Smack { } fn make_copy_of_pattern(pattern: &[u8], is_nocase: bool) -> Vec { - let mut p = pattern.clone().to_vec(); + let mut p = pattern.to_vec(); for i in 0..p.len() { if is_nocase { p[i] = p[i].to_ascii_lowercase(); From 006bf6713a501a076837c66c134ab7c6c4d93884 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 00:48:11 +0000 Subject: [PATCH 230/317] Bump clap from 4.4.6 to 4.4.7 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.6 to 4.4.7. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.6...v4.4.7) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74b1b48..d2397a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", @@ -179,9 +179,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "codespan-reporting" diff --git a/Cargo.toml b/Cargo.toml index 48a5fa1..be7dd9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.6" +clap = "4.4.7" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From 4ea3a8df38ded424570b41521f6f62e0799cdae8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 00:27:57 +0000 Subject: [PATCH 231/317] Bump clap from 4.4.7 to 4.4.8 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.7 to 4.4.8. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.7...v4.4.8) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2397a7..86529e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index be7dd9f..915eecf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.7" +clap = "4.4.8" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.11.0" From d134404860d1d2fe70733ba061afacf9d976746e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Nov 2023 00:06:40 +0000 Subject: [PATCH 232/317] Bump itertools from 0.11.0 to 0.12.0 Bumps [itertools](https://github.com/rust-itertools/itertools) from 0.11.0 to 0.12.0. - [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-itertools/itertools/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: itertools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86529e9..9eb4e8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -383,9 +383,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" dependencies = [ "either", ] diff --git a/Cargo.toml b/Cargo.toml index 915eecf..9f95683 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ chrono = "0.4.31" clap = "4.4.8" dns-parser = "0.8.0" flate2 = "1.0" -itertools = "0.11.0" +itertools = "0.12.0" lazy_static = "1.4.0" log = "0.4.20" pcap = "1.1.0" From e96cb84ed4aea88ac5a30ed194a2c3e68d479d77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 01:02:14 +0000 Subject: [PATCH 233/317] Bump clap from 4.4.8 to 4.4.9 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.8 to 4.4.9. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.8...v4.4.9) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9eb4e8d..0bf17c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.8" +version = "4.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "46ca43acc1b21c6cc2d1d3129c19e323a613935b5bc28fb3b33b5b2e5fb00030" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 9f95683..d82c584 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.8" +clap = "4.4.9" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From f2ae05b3af1d9c9e726868ea0c36b0545b9c49aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 00:50:14 +0000 Subject: [PATCH 234/317] Bump clap from 4.4.9 to 4.4.10 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.9 to 4.4.10. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.9...v4.4.10) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bf17c2..8e0adce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.9" +version = "4.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46ca43acc1b21c6cc2d1d3129c19e323a613935b5bc28fb3b33b5b2e5fb00030" +checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" dependencies = [ "clap_builder", ] diff --git a/Cargo.toml b/Cargo.toml index d82c584..4f4b22b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.9" +clap = "4.4.10" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From 104a91839a90928b0d54576f909499d73a9d3d81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 00:59:01 +0000 Subject: [PATCH 235/317] Bump clap from 4.4.10 to 4.4.11 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.10 to 4.4.11. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.10...v4.4.11) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e0adce..37a887c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.10" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.9" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 4f4b22b..8737d04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.10" +clap = "4.4.11" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From 254e6ebc7ecd174ebc41ba9a511974723a24abaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jan 2024 00:44:28 +0000 Subject: [PATCH 236/317] Bump clap from 4.4.11 to 4.4.13 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.11 to 4.4.13. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.11...v4.4.13) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37a887c..a370012 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "52bdc885e4cacc7f7c9eedc1ef6da641603180c783c41a15c264944deeaab642" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 8737d04..8e6333d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.11" +clap = "4.4.13" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From 627d1ec22b4bf1b33072d351c5b54210ade3bad2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 00:11:54 +0000 Subject: [PATCH 237/317] Bump clap from 4.4.13 to 4.4.14 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.13 to 4.4.14. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.13...v4.4.14) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a370012..6468241 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.13" +version = "4.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52bdc885e4cacc7f7c9eedc1ef6da641603180c783c41a15c264944deeaab642" +checksum = "33e92c5c1a78c62968ec57dbc2440366a2d6e5a23faf829970ff1585dc6b18e2" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.12" +version = "4.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" +checksum = "f4323769dc8a61e2c39ad7dc26f6f2800524691a44d74fe3d1071a5c24db6370" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 8e6333d..9bd9b78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.13" +clap = "4.4.14" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From fa7c35049d06c114b74b39cc09a74357c934a6bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 00:24:38 +0000 Subject: [PATCH 238/317] Bump clap from 4.4.14 to 4.4.15 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.14 to 4.4.15. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.14...v4.4.15) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6468241..01aea66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.14" +version = "4.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e92c5c1a78c62968ec57dbc2440366a2d6e5a23faf829970ff1585dc6b18e2" +checksum = "c12ed66a79a555082f595f7eb980d08669de95009dd4b3d61168c573ebe38fc9" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.14" +version = "4.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4323769dc8a61e2c39ad7dc26f6f2800524691a44d74fe3d1071a5c24db6370" +checksum = "0f4645eab3431e5a8403a96bea02506a8b35d28cd0f0330977dd5d22f9c84f43" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 9bd9b78..1396fac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.14" +clap = "4.4.15" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From 9d9b8b2757e139ebd01c0d9cb4ba9c315d68f0b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 00:49:49 +0000 Subject: [PATCH 239/317] Bump clap from 4.4.15 to 4.4.17 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.15 to 4.4.17. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.15...v4.4.17) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 92 ++++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- 2 files changed, 80 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01aea66..3777985 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.1" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6cd65a4b849ace0b7f6daeebcc1a1d111282227ca745458c61dbf670e52a597" +checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", @@ -72,12 +72,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0238ca56c96dfa37bdf7c373c8886dd591322500aceeeccdb2216fe06dc2f796" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -153,23 +153,23 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.0", ] [[package]] name = "clap" -version = "4.4.15" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c12ed66a79a555082f595f7eb980d08669de95009dd4b3d61168c573ebe38fc9" +checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.15" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4645eab3431e5a8403a96bea02506a8b35d28cd0f0330977dd5d22f9c84f43" +checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" dependencies = [ "anstream", "anstyle", @@ -946,7 +946,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -955,21 +964,42 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", "windows_i686_gnu 0.48.0", "windows_i686_msvc 0.48.0", "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.48.0", "windows_x86_64_msvc 0.48.0", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" @@ -982,6 +1012,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.36.1" @@ -994,6 +1030,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.36.1" @@ -1006,6 +1048,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" @@ -1018,12 +1066,24 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" @@ -1035,3 +1095,9 @@ name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/Cargo.toml b/Cargo.toml index 1396fac..e11e5a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.15" +clap = "4.4.17" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From e0aa8ae62cfe16df585c5a3fcb90e64819ffa11a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:52:54 +0000 Subject: [PATCH 240/317] Bump bitflags from 2.4.1 to 2.4.2 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.4.1 to 2.4.2. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.4.1...2.4.2) --- updated-dependencies: - dependency-name: bitflags dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3777985..82781ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,9 +105,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bumpalo" @@ -440,7 +440,7 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "byteorder", "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index e11e5a5..aa2fe06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.4.1" +bitflags = "2.4.2" byteorder = "1.5.0" chrono = "0.4.31" clap = "4.4.17" From 513cc8f43a00cf8345b86df567751e03cc33013b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:53:07 +0000 Subject: [PATCH 241/317] Bump clap from 4.4.17 to 4.4.18 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.17 to 4.4.18. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.17...v4.4.18) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3777985..0b2d848 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,18 +158,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.17" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.17" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index e11e5a5..f575879 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.1" byteorder = "1.5.0" chrono = "0.4.31" -clap = "4.4.17" +clap = "4.4.18" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.0" From 10c353940f51ac27754ec7c0f3321049183589ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 01:12:22 +0000 Subject: [PATCH 242/317] Bump pcap from 1.1.0 to 1.2.0 Bumps [pcap](https://github.com/rust-pcap/pcap) from 1.1.0 to 1.2.0. - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/compare/v1.1.0...v1.2.0) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6764307..5e5b9be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -497,9 +497,9 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "pcap" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbaa01d616eb84eb35cd085fdeaa8671dc8d951bdc4a75bfc414466e76b039ce" +checksum = "77452fdf9d211d9ca35d092aeefe4d4b3f0c4eb529ffb87a8a3b8fe2bb7c37c3" dependencies = [ "bitflags 1.3.2", "errno", diff --git a/Cargo.toml b/Cargo.toml index 63e1e40..8fd272b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ flate2 = "1.0" itertools = "0.12.0" lazy_static = "1.4.0" log = "0.4.20" -pcap = "1.1.0" +pcap = "1.2.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" From 80abf6b6852eab0fe3f0423a69a249bbaeba3f3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 01:00:57 +0000 Subject: [PATCH 243/317] Bump chrono from 0.4.31 to 0.4.33 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.31 to 0.4.33. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.31...v0.4.33) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e5b9be..4a3aaca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,16 +144,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.48.0", + "windows-targets 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8fd272b..6b196a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.2" byteorder = "1.5.0" -chrono = "0.4.31" +chrono = "0.4.33" clap = "4.4.18" dns-parser = "0.8.0" flate2 = "1.0" From 283cf235b80fec04ecadef63d2a53fb26bdb9a3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:01:28 +0000 Subject: [PATCH 244/317] Bump strum_macros from 0.25.3 to 0.26.1 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.25.3 to 0.26.1. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a3aaca..54b7a4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -746,9 +746,9 @@ checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.25.3" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 6b196a0..798d74e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ rand = "0.8.4" siphasher = "1.0" stderrlog = "0.5.4" strum = "0.25.0" -strum_macros = "0.25.3" +strum_macros = "0.26.1" [[bin]] name = "masscanned" From 541b1c2887ab2f5fa3506448714d96984aac6c2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:42:04 +0000 Subject: [PATCH 245/317] Bump itertools from 0.12.0 to 0.12.1 Bumps [itertools](https://github.com/rust-itertools/itertools) from 0.12.0 to 0.12.1. - [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-itertools/itertools/compare/v0.12.0...v0.12.1) --- updated-dependencies: - dependency-name: itertools dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a3aaca..cc7bd96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -383,9 +383,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] diff --git a/Cargo.toml b/Cargo.toml index 6b196a0..27ff221 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ chrono = "0.4.33" clap = "4.4.18" dns-parser = "0.8.0" flate2 = "1.0" -itertools = "0.12.0" +itertools = "0.12.1" lazy_static = "1.4.0" log = "0.4.20" pcap = "1.2.0" From dc1d0740ad311f063aa74b31116386783616ab62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 00:31:31 +0000 Subject: [PATCH 246/317] Bump stderrlog from 0.5.4 to 0.6.0 Bumps [stderrlog](https://github.com/cardoe/stderrlog-rs) from 0.5.4 to 0.6.0. - [Release notes](https://github.com/cardoe/stderrlog-rs/releases) - [Changelog](https://github.com/cardoe/stderrlog-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/cardoe/stderrlog-rs/compare/v0.5.4...v0.6.0) --- updated-dependencies: - dependency-name: stderrlog dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 66 +++++++++++++++++++++++++++++++++++++----------------- Cargo.toml | 2 +- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a3aaca..4ec71db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,17 +80,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -296,6 +285,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -341,12 +340,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "iana-time-zone" @@ -381,6 +377,17 @@ dependencies = [ "serde", ] +[[package]] +name = "is-terminal" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "itertools" version = "0.12.0" @@ -430,6 +437,12 @@ dependencies = [ "cc", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "log" version = "0.4.20" @@ -502,7 +515,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77452fdf9d211d9ca35d092aeefe4d4b3f0c4eb529ffb87a8a3b8fe2bb7c37c3" dependencies = [ "bitflags 1.3.2", - "errno", + "errno 0.2.8", "libc", "libloading", "pkg-config", @@ -695,6 +708,19 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +[[package]] +name = "rustix" +version = "0.38.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +dependencies = [ + "bitflags 2.4.2", + "errno 0.3.8", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + [[package]] name = "rustversion" version = "1.0.11" @@ -721,12 +747,12 @@ checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" [[package]] name = "stderrlog" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69a26bbf6de627d389164afa9783739b56746c6c72c4ed16539f4ff54170327b" +checksum = "61c910772f992ab17d32d6760e167d2353f4130ed50e796752689556af07dc6b" dependencies = [ - "atty", "chrono", + "is-terminal", "log", "termcolor", "thread_local", diff --git a/Cargo.toml b/Cargo.toml index 6b196a0..8763891 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "1.0" -stderrlog = "0.5.4" +stderrlog = "0.6.0" strum = "0.25.0" strum_macros = "0.25.3" From 1cdc7b0b3109ad8b42cf4be416683efda421ceb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:38:21 +0000 Subject: [PATCH 247/317] Bump strum from 0.25.0 to 0.26.1 Bumps [strum](https://github.com/Peternator7/strum) from 0.25.0 to 0.26.1. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a8b6cd..32fcfdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,9 +766,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.25.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" [[package]] name = "strum_macros" diff --git a/Cargo.toml b/Cargo.toml index c3f39ab..9f0f7e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "1.0" stderrlog = "0.6.0" -strum = "0.25.0" +strum = "0.26.1" strum_macros = "0.26.1" [[bin]] From d1d035890aa330be1371bdd38802fa53fe0b3560 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 01:12:33 +0000 Subject: [PATCH 248/317] chore(deps): bump chrono from 0.4.33 to 0.4.34 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.33 to 0.4.34. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.33...v0.4.34) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32fcfdc..3d4322e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,9 +133,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 9f0f7e5..a897b45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.2" byteorder = "1.5.0" -chrono = "0.4.33" +chrono = "0.4.34" clap = "4.4.18" dns-parser = "0.8.0" flate2 = "1.0" From 647ca441ad3f95bb75ef07af63e27c1cb30a36eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:32:46 +0000 Subject: [PATCH 249/317] chore(deps): bump clap from 4.4.18 to 4.5.0 Bumps [clap](https://github.com/clap-rs/clap) from 4.4.18 to 4.5.0. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.18...clap_complete-v4.5.0) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d4322e..b3daf08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "codespan-reporting" @@ -760,9 +760,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" diff --git a/Cargo.toml b/Cargo.toml index a897b45..ba29485 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.2" byteorder = "1.5.0" chrono = "0.4.34" -clap = "4.4.18" +clap = "4.5.0" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.1" From 9ca4609b661566e6bf2a1871e85f0e0f03a85fcf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:16:19 +0000 Subject: [PATCH 250/317] chore(deps): bump clap from 4.5.0 to 4.5.1 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.0 to 4.5.1. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.0...clap_complete-v4.5.1) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3daf08..1a4b860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index ba29485..7127ad3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.2" byteorder = "1.5.0" chrono = "0.4.34" -clap = "4.5.0" +clap = "4.5.1" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.1" From db8d1dbf52748e6e6aa89495db779dfbe946b7f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 00:32:25 +0000 Subject: [PATCH 251/317] chore(deps): bump log from 0.4.20 to 0.4.21 Bumps [log](https://github.com/rust-lang/log) from 0.4.20 to 0.4.21. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.20...0.4.21) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a4b860..ba40c8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,9 +445,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "masscanned" diff --git a/Cargo.toml b/Cargo.toml index 7127ad3..dc99d20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.1" lazy_static = "1.4.0" -log = "0.4.20" +log = "0.4.21" pcap = "1.2.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } From b29a95da7b0a59b3041e28e9b0565259de8d8911 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Fri, 1 Mar 2024 01:28:13 +0100 Subject: [PATCH 252/317] Docker: usr rust image as builder (latest version) --- docker/Dockerfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 973ac96..bbd46d9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ # This file is part of masscanned. -# Copyright 2021 - 2023 The IVRE project +# Copyright 2021 - 2024 The IVRE project # # Masscanned is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -14,17 +14,21 @@ # You should have received a copy of the GNU General Public License # along with Masscanned. If not, see . -FROM debian:12 AS builder +FROM debian:12 AS fetcher -ENV DEBIAN_FRONTEND noninteractive +RUN apt-get -q update && \ + apt-get -qy --no-install-recommends install ca-certificates curl && \ + curl -L https://github.com/ivre/masscanned/archive/refs/heads/master.tar.gz | tar zxf - -RUN echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list.d/testing.list && \ - apt-get -q update && \ - apt-get -qy --no-install-recommends install cargo ca-certificates curl && \ - curl -L https://github.com/ivre/masscanned/archive/refs/heads/master.tar.gz | tar zxf - && \ - cd masscanned-master && \ + +FROM rust AS builder + +COPY --from=fetcher /masscanned-master /masscanned-master + +RUN cd masscanned-master && \ cargo build --release + FROM debian:12 LABEL maintainer="Pierre LALET " From 4a24a30ee6ddccceac8f6fc7771ac9abab617ad9 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Fri, 1 Mar 2024 01:46:38 +0100 Subject: [PATCH 253/317] CI: add a Docker build job --- .github/workflows/test.yml | 19 ++++++++++++++++++- docker/Dockerfile-local | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 docker/Dockerfile-local diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05c8984..87e3b23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ # This file is part of masscanned. -# Copyright 2021 - The IVRE project +# Copyright 2021 - 2024 The IVRE project # # Masscanned is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -101,3 +101,20 @@ jobs: - name: Display logs run: echo STDOUT; cat test/res/masscanned.stdout && echo && echo STDERR && cat test/res/masscanned.stderr if: failure() + + docker: + runs-on: ubuntu-latest + steps: + + - name: Git checkout + uses: actions/checkout@v2 + + - name: Build archive + run: git archive --format=tar --prefix=masscanned-master/ HEAD -o docker/masscanned.tar + + - name: Build image + uses: docker/build-push-action@v5 + with: + push: false + context: docker/ + file: docker/Dockerfile-local diff --git a/docker/Dockerfile-local b/docker/Dockerfile-local new file mode 100644 index 0000000..e046e01 --- /dev/null +++ b/docker/Dockerfile-local @@ -0,0 +1,38 @@ +# This file is part of masscanned. +# Copyright 2021 - 2024 The IVRE project +# +# Masscanned is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Masscanned is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Masscanned. If not, see . + +FROM rust AS builder + +ADD masscanned.tar ./ + +RUN cd masscanned-master && \ + cargo build --release + + +FROM debian:12 +LABEL maintainer="Pierre LALET " + +COPY --from=builder /masscanned-master/target/release/masscanned /usr/local/bin/masscanned + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get -q update && \ + apt-get -qy --no-install-recommends install iproute2 iptables && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY runmasscanned /usr/local/bin/runmasscanned + +CMD /usr/local/bin/runmasscanned From 70e9edb8eac6e79416470da8465dfca1a496b4cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Mar 2024 00:26:47 +0000 Subject: [PATCH 254/317] chore(deps): bump clap from 4.5.1 to 4.5.2 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.1 to 4.5.2. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.1...v4.5.2) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba40c8b..ed0396a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index dc99d20..ec967f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.2" byteorder = "1.5.0" chrono = "0.4.34" -clap = "4.5.1" +clap = "4.5.2" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.1" From 9e7e816cdd18729bb958c21c613dbd5a4f17eb90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:35:34 +0000 Subject: [PATCH 255/317] chore(deps): bump chrono from 0.4.34 to 0.4.35 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.34 to 0.4.35. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.34...v0.4.35) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed0396a..de208de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,9 +133,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index ec967f6..e884f16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.4.2" byteorder = "1.5.0" -chrono = "0.4.34" +chrono = "0.4.35" clap = "4.5.2" dns-parser = "0.8.0" flate2 = "1.0" From f1bb7c40da366f0c841ae151819ebefcf65e67fa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:43:22 +0000 Subject: [PATCH 256/317] chore(deps): bump strum from 0.26.1 to 0.26.2 Bumps [strum](https://github.com/Peternator7/strum) from 0.26.1 to 0.26.2. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de208de..c97b4b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,9 +766,9 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" [[package]] name = "strum_macros" diff --git a/Cargo.toml b/Cargo.toml index e884f16..db95e97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "1.0" stderrlog = "0.6.0" -strum = "0.26.1" +strum = "0.26.2" strum_macros = "0.26.1" [[bin]] From 42821d2ae70dc22ea7a5fea8411dace8360ee088 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:05:54 +0000 Subject: [PATCH 257/317] chore(deps): bump strum_macros from 0.26.1 to 0.26.2 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.26.1 to 0.26.2. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c97b4b6..f7a175f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -772,9 +772,9 @@ checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" [[package]] name = "strum_macros" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index db95e97..9507520 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ rand = "0.8.4" siphasher = "1.0" stderrlog = "0.6.0" strum = "0.26.2" -strum_macros = "0.26.1" +strum_macros = "0.26.2" [[bin]] name = "masscanned" From f903d9db86672e57778075e1fac842b4a119f00f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 00:48:53 +0000 Subject: [PATCH 258/317] chore(deps): bump siphasher from 1.0.0 to 1.0.1 Bumps [siphasher](https://github.com/jedisct1/rust-siphash) from 1.0.0 to 1.0.1. - [Commits](https://github.com/jedisct1/rust-siphash/compare/1.0.0...1.0.1) --- updated-dependencies: - dependency-name: siphasher dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7a175f..65a18f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -741,9 +741,9 @@ checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "siphasher" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "stderrlog" From 7787da5a5da2d0fe097c4196f2bd08e061a6d9cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 00:49:09 +0000 Subject: [PATCH 259/317] chore(deps): bump clap from 4.5.2 to 4.5.3 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.2 to 4.5.3. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.5.2...v4.5.3) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7a175f..a772c19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", ] diff --git a/Cargo.toml b/Cargo.toml index 9507520..952849b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.4.2" byteorder = "1.5.0" chrono = "0.4.35" -clap = "4.5.2" +clap = "4.5.3" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.1" From 20f422dfba3be90fa83ce82aa40b386dd0e16c78 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 00:49:22 +0000 Subject: [PATCH 260/317] chore(deps): bump pcap from 1.2.0 to 1.3.0 Bumps [pcap](https://github.com/rust-pcap/pcap) from 1.2.0 to 1.3.0. - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/commits) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7a175f..0a888ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -510,9 +510,9 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "pcap" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77452fdf9d211d9ca35d092aeefe4d4b3f0c4eb529ffb87a8a3b8fe2bb7c37c3" +checksum = "99e935fc73d54a89fff576526c2ccd42bbf8247aae05b358693475b14fd4ff79" dependencies = [ "bitflags 1.3.2", "errno 0.2.8", diff --git a/Cargo.toml b/Cargo.toml index 9507520..e978f65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ flate2 = "1.0" itertools = "0.12.1" lazy_static = "1.4.0" log = "0.4.21" -pcap = "1.2.0" +pcap = "1.3.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" From a3e0f468c23dbe140de698c0e5aed97386c7f467 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:03:36 +0000 Subject: [PATCH 261/317] chore(deps): bump bitflags from 2.4.2 to 2.5.0 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.4.2 to 2.5.0. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.4.2...2.5.0) --- updated-dependencies: - dependency-name: bitflags dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5003cf..91a87da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,9 +94,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bumpalo" @@ -453,7 +453,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "byteorder", "chrono", "clap", @@ -714,7 +714,7 @@ version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno 0.3.8", "libc", "linux-raw-sys", diff --git a/Cargo.toml b/Cargo.toml index 54fe528..d3ab6d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.4.2" +bitflags = "2.5.0" byteorder = "1.5.0" chrono = "0.4.35" clap = "4.5.3" From bd799eaed7324e4a2d739cc3983100355054ec1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 00:04:00 +0000 Subject: [PATCH 262/317] chore(deps): bump clap from 4.5.3 to 4.5.4 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.3 to 4.5.4. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.5.3...v4.5.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91a87da..55d1eac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", ] diff --git a/Cargo.toml b/Cargo.toml index d3ab6d8..693363a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.5.0" byteorder = "1.5.0" chrono = "0.4.35" -clap = "4.5.3" +clap = "4.5.4" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.12.1" From fb547aff3bdb7fbc4f4f9da945fa127ee0a8ab18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:44:05 +0000 Subject: [PATCH 263/317] chore(deps): bump chrono from 0.4.35 to 0.4.37 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.35 to 0.4.37. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.35...v0.4.37) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55d1eac..3ae1215 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,9 +133,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 693363a..bc01b30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.5.0" byteorder = "1.5.0" -chrono = "0.4.35" +chrono = "0.4.37" clap = "4.5.4" dns-parser = "0.8.0" flate2 = "1.0" From 126425833e95e70b5ae9def8fafa06768d371ccb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 00:44:38 +0000 Subject: [PATCH 264/317] chore(deps): bump chrono from 0.4.37 to 0.4.38 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.37 to 0.4.38. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.37...v0.4.38) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ae1215..c6aae4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,9 +133,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index bc01b30..25e1f8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.5.0" byteorder = "1.5.0" -chrono = "0.4.37" +chrono = "0.4.38" clap = "4.5.4" dns-parser = "0.8.0" flate2 = "1.0" From 65e053e842da39f31224e58d98c14e53d321ce1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:12:32 +0200 Subject: [PATCH 265/317] chore(deps): bump pcap from 1.3.0 to 2.0.0 (#228) * chore(deps): bump pcap from 1.3.0 to 2.0.0 Bumps [pcap](https://github.com/rust-pcap/pcap) from 1.3.0 to 2.0.0. - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/commits) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6aae4e..7cf4bd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,12 +420,12 @@ checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libloading" -version = "0.6.7" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "winapi", + "windows-targets 0.52.0", ] [[package]] @@ -510,9 +510,9 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "pcap" -version = "1.3.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e935fc73d54a89fff576526c2ccd42bbf8247aae05b358693475b14fd4ff79" +checksum = "45f1686828a29fd8002fbf9c01506b4b2dd575c2305e1b884da3731abae8b9e0" dependencies = [ "bitflags 1.3.2", "errno 0.2.8", diff --git a/Cargo.toml b/Cargo.toml index 25e1f8e..241921c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ flate2 = "1.0" itertools = "0.12.1" lazy_static = "1.4.0" log = "0.4.21" -pcap = "1.3.0" +pcap = "2.0.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" From 6c34c625f1437cebdb0aa387978bd91b8d675330 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 01:00:54 +0000 Subject: [PATCH 266/317] chore(deps): bump flate2 from 1.0.28 to 1.0.29 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.28 to 1.0.29. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.28...1.0.29) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7cf4bd8..f5ff4e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "4556222738635b7a3417ae6130d8f52201e45a0c4d1a907f0826383adb5f85e7" dependencies = [ "crc32fast", "miniz_oxide", From 570829cee66fd2b6c0367a83bebf179007731469 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 00:34:22 +0000 Subject: [PATCH 267/317] chore(deps): bump flate2 from 1.0.29 to 1.0.30 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.29 to 1.0.30. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.29...1.0.30) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5ff4e1..4fc97c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4556222738635b7a3417ae6130d8f52201e45a0c4d1a907f0826383adb5f85e7" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", From 101a62c0900706f7e2fd72eba35a259f96f6360f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 00:24:29 +0000 Subject: [PATCH 268/317] chore(deps): bump itertools from 0.12.1 to 0.13.0 Bumps [itertools](https://github.com/rust-itertools/itertools) from 0.12.1 to 0.13.0. - [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-itertools/itertools/compare/v0.12.1...v0.13.0) --- updated-dependencies: - dependency-name: itertools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fc97c9..3e00088 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,9 +390,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] diff --git a/Cargo.toml b/Cargo.toml index 241921c..c27f392 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ chrono = "0.4.38" clap = "4.5.4" dns-parser = "0.8.0" flate2 = "1.0" -itertools = "0.12.1" +itertools = "0.13.0" lazy_static = "1.4.0" log = "0.4.21" pcap = "2.0.0" From 91ec1d2b1bc31ac769656125bdd0b26ff942fee3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 00:52:29 +0000 Subject: [PATCH 269/317] chore(deps): bump strum_macros from 0.26.2 to 0.26.4 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.26.2 to 0.26.4. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e00088..103dd0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -334,9 +334,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -772,9 +772,9 @@ checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index c27f392..39ef5ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ rand = "0.8.4" siphasher = "1.0" stderrlog = "0.6.0" strum = "0.26.2" -strum_macros = "0.26.2" +strum_macros = "0.26.4" [[bin]] name = "masscanned" From 24be84814c779e0a571a5010b99b1e55a58679c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:30:03 +0000 Subject: [PATCH 270/317] chore(deps): bump clap from 4.5.4 to 4.5.6 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.4 to 4.5.6. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.4...v4.5.6) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e00088..4acc051 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index c27f392..e02a5a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.5.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.4" +clap = "4.5.6" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From 04ab094f0fc4c9dffe92e9de598934c6444db803 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 00:28:18 +0000 Subject: [PATCH 271/317] chore(deps): bump clap from 4.5.6 to 4.5.7 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.6 to 4.5.7. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.5.6...v4.5.7) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33ed584..92d1b2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 29b83bc..a5738dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.5.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.6" +clap = "4.5.7" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From 3d3058dc945140faa4ed6388dd0e4e62e3c24048 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 00:56:29 +0000 Subject: [PATCH 272/317] chore(deps): bump strum from 0.26.2 to 0.26.3 Bumps [strum](https://github.com/Peternator7/strum) from 0.26.2 to 0.26.3. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/compare/v0.26.2...v0.26.3) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92d1b2c..b55f0ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,9 +766,9 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" [[package]] name = "strum_macros" diff --git a/Cargo.toml b/Cargo.toml index a5738dc..a5039b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "1.0" stderrlog = "0.6.0" -strum = "0.26.2" +strum = "0.26.3" strum_macros = "0.26.4" [[bin]] From d563bb36a52cd0daf1f28d6ee41cc5273ab38362 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:42:27 +0000 Subject: [PATCH 273/317] chore(deps): bump bitflags from 2.5.0 to 2.6.0 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.5.0 to 2.6.0. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.5.0...2.6.0) --- updated-dependencies: - dependency-name: bitflags dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92d1b2c..2fd4b27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,9 +94,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bumpalo" @@ -453,7 +453,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "byteorder", "chrono", "clap", @@ -714,7 +714,7 @@ version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno 0.3.8", "libc", "linux-raw-sys", diff --git a/Cargo.toml b/Cargo.toml index a5738dc..bf78a05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.5.0" +bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.38" clap = "4.5.7" From a78934b911010783fb536df177ac581a25527614 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 00:52:16 +0000 Subject: [PATCH 274/317] chore(deps): bump log from 0.4.21 to 0.4.22 Bumps [log](https://github.com/rust-lang/log) from 0.4.21 to 0.4.22. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.21...0.4.22) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92d1b2c..98d6810 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,9 +445,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "masscanned" diff --git a/Cargo.toml b/Cargo.toml index a5738dc..0790504 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" lazy_static = "1.4.0" -log = "0.4.21" +log = "0.4.22" pcap = "2.0.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } From 08a8c7f3a9a9c3442349f796bcc9908fc9ed0c38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 00:52:46 +0000 Subject: [PATCH 275/317] chore(deps): bump clap from 4.5.7 to 4.5.8 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.7 to 4.5.8. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.7...v4.5.8) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92d1b2c..46ef319 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index a5738dc..c167a26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.5.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.7" +clap = "4.5.8" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From e540a1e0f541f312063c9637cf6205719d14ea66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 20:37:00 +0000 Subject: [PATCH 276/317] chore(deps): bump lazy_static from 1.4.0 to 1.5.0 Bumps [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/rust-lang-nursery/lazy-static.rs/releases) - [Commits](https://github.com/rust-lang-nursery/lazy-static.rs/compare/1.4.0...1.5.0) --- updated-dependencies: - dependency-name: lazy_static dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3d0ee9..053be14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -408,9 +408,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" diff --git a/Cargo.toml b/Cargo.toml index e0617fa..f233f59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ clap = "4.5.8" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" -lazy_static = "1.4.0" +lazy_static = "1.5.0" log = "0.4.22" pcap = "2.0.0" pcap-file = "2.0.0" From 1428fec25b066c1490c43dfa2246c0d6de55075c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 00:56:43 +0000 Subject: [PATCH 277/317] chore(deps): bump clap from 4.5.8 to 4.5.9 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.8 to 4.5.9. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.5.8...v4.5.9) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 053be14..b5e3427 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index f233f59..ed82426 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.8" +clap = "4.5.9" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From 0969f3f59b73a7ce4f11bdb86d0a6bcf445c7902 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:19:34 +0000 Subject: [PATCH 278/317] chore(deps): bump clap from 4.5.9 to 4.5.11 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.9 to 4.5.11. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.9...clap_complete-v4.5.11) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5e3427..868aa6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index ed82426..741c31f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.9" +clap = "4.5.11" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From 28da801ceb4dfa682b595f437c6690785c85a56f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 00:27:36 +0000 Subject: [PATCH 279/317] chore(deps): bump flate2 from 1.0.30 to 1.0.31 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.30 to 1.0.31. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/commits) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 868aa6a..cc87f79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", From 515a4752a097eb9d0ec0c3ad1261c9db35be5f42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:46:30 +0000 Subject: [PATCH 280/317] chore(deps): bump clap from 4.5.11 to 4.5.16 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.11 to 4.5.16. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.11...clap_complete-v4.5.16) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 868aa6a..bc74a5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,9 +48,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.11" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.11" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 741c31f..35d6b8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.11" +clap = "4.5.16" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From e07aacd2a34aed245007819e9f2c6d61564f1d02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 00:29:19 +0000 Subject: [PATCH 281/317] chore(deps): bump flate2 from 1.0.31 to 1.0.33 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.31 to 1.0.33. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Changelog](https://github.com/rust-lang/flate2-rs/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.31...1.0.33) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ac01e8..8405da0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,10 +3,10 @@ version = 3 [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", "miniz_oxide", @@ -480,11 +480,11 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] From 6e133021b77e8e42d4be4b999feda95e94845d82 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 00:32:06 +0000 Subject: [PATCH 282/317] chore(deps): bump pcap from 2.0.0 to 2.1.0 Bumps [pcap](https://github.com/rust-pcap/pcap) from 2.0.0 to 2.1.0. - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/compare/v2.0.0...v2.1.0) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ac01e8..cd9cc9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -510,9 +510,9 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "pcap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45f1686828a29fd8002fbf9c01506b4b2dd575c2305e1b884da3731abae8b9e0" +checksum = "fe4d339439e5e7f8ce32d58c2b58d5e304790e66f3aa0bd391dd6a9dc676e054" dependencies = [ "bitflags 1.3.2", "errno 0.2.8", diff --git a/Cargo.toml b/Cargo.toml index 35d6b8c..e3f3bf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ flate2 = "1.0" itertools = "0.13.0" lazy_static = "1.5.0" log = "0.4.22" -pcap = "2.0.0" +pcap = "2.1.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" From 436026f83cea668cc0f5c89b9509d5e27791c346 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 00:34:15 +0000 Subject: [PATCH 283/317] chore(deps): bump pcap from 2.1.0 to 2.2.0 Bumps [pcap](https://github.com/rust-pcap/pcap) from 2.1.0 to 2.2.0. - [Changelog](https://github.com/rust-pcap/pcap/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-pcap/pcap/compare/v2.1.0...v2.2.0) --- updated-dependencies: - dependency-name: pcap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95151e8..9b35dde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -510,9 +510,9 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "pcap" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4d339439e5e7f8ce32d58c2b58d5e304790e66f3aa0bd391dd6a9dc676e054" +checksum = "499125886165f62fbc0c095ead9189b253f48eb1c5fcab49f81a270f2f220652" dependencies = [ "bitflags 1.3.2", "errno 0.2.8", diff --git a/Cargo.toml b/Cargo.toml index e3f3bf4..82e6eef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ flate2 = "1.0" itertools = "0.13.0" lazy_static = "1.5.0" log = "0.4.22" -pcap = "2.1.0" +pcap = "2.2.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" From 5b99525852cc42414de84c0bbaa693e666c177ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 00:31:52 +0000 Subject: [PATCH 284/317] chore(deps): bump clap from 4.5.16 to 4.5.17 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.16 to 4.5.17. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.16...clap_complete-v4.5.17) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b35dde..1a9db97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 82e6eef..1a131f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.16" +clap = "4.5.17" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From f5d40dd1a8305cce0590262894617090d9a9f0a4 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 14 Oct 2024 02:03:39 +0200 Subject: [PATCH 285/317] chore(deps): bump {down,up}load-artifact from v2 to v4 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87e3b23..62cf039 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,7 @@ jobs: run: tar cf masscanned.tar target/debug/masscanned - name: Upload binary - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: masscanned.tar path: masscanned.tar @@ -68,7 +68,7 @@ jobs: uses: actions/checkout@v2 - name: Get binary - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: masscanned.tar From c8526809309c27f103551be73e4c4d1124c3f7a9 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 14 Oct 2024 02:15:23 +0200 Subject: [PATCH 286/317] Tests: add values to assert messages --- test/src/tests/dns.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py index 9261bbb..d360650 100644 --- a/test/src/tests/dns.py +++ b/test/src/tests/dns.py @@ -44,8 +44,12 @@ def test_ipv4_udp_dns_in_a(): check_ip_checksum(resp) assert UDP in resp, "no UDP layer found" udp = resp[UDP] - assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport) - assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport) + assert ( + udp.sport == dport + ), f"unexpected UDP sport: {udp.sport!r} ({domain})" + assert ( + udp.dport == sport + ), f"unexpected UDP dport: {udp.dport!r} ({domain})" if DNS not in udp: try: dns_rep = DNS(udp.load) @@ -53,7 +57,9 @@ def test_ipv4_udp_dns_in_a(): raise AssertionError("no DNS layer found") else: dns_rep = udp[DNS] - assert dns_rep.id == 1234, f"unexpected id value: {dns_rep.id}" + assert ( + dns_rep.id == 1234 + ), f"unexpected id value: {dns_rep.id!r} ({domain})" assert dns_rep.qr, "unexpected qr value" assert dns_rep.opcode == 0, "unexpected opcode value" assert dns_rep.aa, "unexpected aa value" @@ -62,7 +68,9 @@ def test_ipv4_udp_dns_in_a(): assert not dns_rep.ra, "unexpected ra value" assert dns_rep.z == 0, "unexpected z value" assert dns_rep.rcode == 0, "unexpected rcode value" - assert dns_rep.qdcount == 1, "unexpected qdcount value" + assert ( + dns_rep.qdcount == 1 + ), f"unexpected qdcount value: {dns_rep.qdcount!r} vs 1 ({domain})" assert dns_rep.ancount == 1, "unexpected ancount value" assert dns_rep.nscount == 0, "unexpected nscount value" assert dns_rep.arcount == 0, "unexpected arcount value" @@ -125,7 +133,9 @@ def test_ipv4_udp_dns_in_a_multiple_queries(): assert not dns_rep.ra, "unexpected ra value" assert dns_rep.z == 0, "unexpected z value" assert dns_rep.rcode == 0, "unexpected rcode value" - assert dns_rep.qdcount == 3, "unexpected qdcount value" + assert ( + dns_rep.qdcount == 3 + ), f"unexpected qdcount value: {dns_rep.qdcount} vs 3" assert dns_rep.ancount == 3, "unexpected ancount value" assert dns_rep.nscount == 0, "unexpected nscount value" assert dns_rep.arcount == 0, "unexpected arcount value" From fe0312b066477780c728ded54e868a106230e180 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 14 Oct 2024 03:06:56 +0200 Subject: [PATCH 287/317] Tests: lock Scapy version to 2.5.0 --- test/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/requirements.txt b/test/requirements.txt index fd8f3e8..2774d67 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -1,3 +1,3 @@ ivre -scapy +scapy==2.5.0 requests From 64698a66258dc7b25859a4eb7deebcdc94e9bae6 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 14 Oct 2024 18:38:31 +0200 Subject: [PATCH 288/317] Tests: update Scapy to current stable --- test/requirements.txt | 2 +- test/src/tests/dns.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/requirements.txt b/test/requirements.txt index 2774d67..fd8f3e8 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -1,3 +1,3 @@ ivre -scapy==2.5.0 +scapy requests diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py index d360650..93ab1ac 100644 --- a/test/src/tests/dns.py +++ b/test/src/tests/dns.py @@ -98,11 +98,11 @@ def test_ipv4_udp_dns_in_a_multiple_queries(): dports = [53, 5353, 80, 161, 24732] for sport in sports: for dport in dports: - qd = ( - DNSQR(qname="www.example1.com", qtype="A", qclass="IN") - / DNSQR(qname="www.example2.com", qtype="A", qclass="IN") - / DNSQR(qname="www.example3.com", qtype="A", qclass="IN") - ) + qd = [ + DNSQR(qname="www.example1.com", qtype="A", qclass="IN"), + DNSQR(qname="www.example2.com", qtype="A", qclass="IN"), + DNSQR(qname="www.example3.com", qtype="A", qclass="IN"), + ] dns_req = DNS(id=1234, rd=False, opcode=0, qd=qd) req = ( Ether(dst=MAC_ADDR) From 34ca9b6ae0083e4ff6c6720c5473b807678f238b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:36:45 +0000 Subject: [PATCH 289/317] chore(deps): bump clap from 4.5.17 to 4.5.20 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.17 to 4.5.20. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.17...clap_complete-v4.5.20) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a9db97..436d9b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 1a131f5..75010e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.17" +clap = "4.5.20" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From 695b132605536d631135ab186749ef62e3ba2b66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:37:01 +0000 Subject: [PATCH 290/317] chore(deps): bump flate2 from 1.0.33 to 1.0.34 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.33 to 1.0.34. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Changelog](https://github.com/rust-lang/flate2-rs/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.33...1.0.34) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a9db97..e0f897a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", From e7d573b4db0bcd2dd08846630551f9c14d69dec6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:50:33 +0000 Subject: [PATCH 291/317] chore(deps): bump flate2 from 1.0.34 to 1.0.35 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.34 to 1.0.35. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Changelog](https://github.com/rust-lang/flate2-rs/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.34...1.0.35) --- updated-dependencies: - dependency-name: flate2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8be11a2..863ac1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", From d43ab4716f9bb0c868b6a77a0e5216555842b2bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 00:09:33 +0000 Subject: [PATCH 292/317] chore(deps): bump clap from 4.5.20 to 4.5.23 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.20 to 4.5.23. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.20...clap_complete-v4.5.23) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8be11a2..6a637f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "codespan-reporting" diff --git a/Cargo.toml b/Cargo.toml index 75010e8..8e87594 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.38" -clap = "4.5.20" +clap = "4.5.23" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From a01f63839c6fa907b866d786ecadb03a5d5e05ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 22:46:53 +0000 Subject: [PATCH 293/317] chore(deps): bump chrono from 0.4.38 to 0.4.39 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.38 to 0.4.39. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.38...v0.4.39) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b290bc..02f51c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,9 +133,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 8e87594..e766356 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.6.0" byteorder = "1.5.0" -chrono = "0.4.38" +chrono = "0.4.39" clap = "4.5.23" dns-parser = "0.8.0" flate2 = "1.0" From 0e971f0306925280099c7a9b0207901b274054d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 00:55:49 +0000 Subject: [PATCH 294/317] chore(deps): bump itertools from 0.13.0 to 0.14.0 Bumps [itertools](https://github.com/rust-itertools/itertools) from 0.13.0 to 0.14.0. - [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-itertools/itertools/compare/v0.13.0...v0.14.0) --- updated-dependencies: - dependency-name: itertools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f51c3..1955d13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,9 +390,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] diff --git a/Cargo.toml b/Cargo.toml index e766356..070cc88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ chrono = "0.4.39" clap = "4.5.23" dns-parser = "0.8.0" flate2 = "1.0" -itertools = "0.13.0" +itertools = "0.14.0" lazy_static = "1.5.0" log = "0.4.22" pcap = "2.2.0" From 966bf7fad3765e36b16501d1c6e52216483f7661 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 00:26:28 +0000 Subject: [PATCH 295/317] chore(deps): bump strum from 0.26.3 to 0.27.1 Bumps [strum](https://github.com/Peternator7/strum) from 0.26.3 to 0.27.1. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/compare/v0.26.3...v0.27.1) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f51c3..b3453f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,9 +766,9 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" -version = "0.26.3" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" [[package]] name = "strum_macros" diff --git a/Cargo.toml b/Cargo.toml index e766356..4eedeb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ pnet = { version = "0.33.0", features = ["std"] } rand = "0.8.4" siphasher = "1.0" stderrlog = "0.6.0" -strum = "0.26.3" +strum = "0.27.1" strum_macros = "0.26.4" [[bin]] From 9ba56354f3fc4ce98484a6a69b3e9603d8c43463 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 00:14:53 +0000 Subject: [PATCH 296/317] chore(deps): bump bitflags from 2.6.0 to 2.9.0 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.6.0 to 2.9.0. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.6.0...2.9.0) --- updated-dependencies: - dependency-name: bitflags dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f51c3..4fb3ed0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -94,9 +94,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "bumpalo" @@ -453,7 +453,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "byteorder", "chrono", "clap", @@ -714,7 +714,7 @@ version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "errno 0.3.8", "libc", "linux-raw-sys", diff --git a/Cargo.toml b/Cargo.toml index e766356..af30565 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.6.0" +bitflags = "2.9.0" byteorder = "1.5.0" chrono = "0.4.39" clap = "4.5.23" From ec1d564897fc50cfa4046fd535e1840e39b83bbc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 01:51:07 +0000 Subject: [PATCH 297/317] chore(deps): bump log from 0.4.22 to 0.4.27 Bumps [log](https://github.com/rust-lang/log) from 0.4.22 to 0.4.27. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.22...0.4.27) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f51c3..5966a64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -445,9 +445,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.22" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "masscanned" diff --git a/Cargo.toml b/Cargo.toml index e766356..8179f5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" lazy_static = "1.5.0" -log = "0.4.22" +log = "0.4.27" pcap = "2.2.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } From e9dca669e9e8dde96a6e49e9d340d00b3734eeaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Mar 2025 00:57:48 +0000 Subject: [PATCH 298/317] chore(deps): bump clap from 4.5.23 to 4.5.34 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.23 to 4.5.34. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.23...clap_complete-v4.5.34) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f51c3..ed5a2b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index e766356..886a93c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.6.0" byteorder = "1.5.0" chrono = "0.4.39" -clap = "4.5.23" +clap = "4.5.34" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.13.0" From d5feca7d215e3051b6719b5bb270c9691cce6c94 Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 5 May 2025 22:07:23 +0200 Subject: [PATCH 299/317] CI: apply flake8 fixes (#288) --- test/src/core.py | 4 +--- test/test_masscanned.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/test/src/core.py b/test/src/core.py index 35681e6..829f314 100644 --- a/test/src/core.py +++ b/test/src/core.py @@ -1,5 +1,5 @@ # This file is part of masscanned. -# Copyright 2021 - The IVRE project +# Copyright 2021 - 2025 - The IVRE project # # Masscanned is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -39,7 +39,6 @@ ERRORS = [] # decorator to automatically add a function to tests def test(f): - global ERRORS, TESTS OK = "\033[1mOK\033[0m" KO = "\033[1m\033[1;%dmKO\033[0m" % 31 fname = f.__name__.ljust(50, ".") @@ -61,7 +60,6 @@ def test(f): def test_all(m): - global ERRORS, TESTS # execute tests for t in TESTS: # perform unit test diff --git a/test/test_masscanned.py b/test/test_masscanned.py index 5b32e5f..e3b37a6 100755 --- a/test/test_masscanned.py +++ b/test/test_masscanned.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # This file is part of masscanned. -# Copyright 2021 - The IVRE project +# Copyright 2021 - 2025 - The IVRE project # # Masscanned is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -39,7 +39,6 @@ from src.conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR, OUTDIR def cleanup_net(iface): - global ipfile subprocess.check_call(["ip", "link", "delete", iface]) subprocess.check_call( [ @@ -64,7 +63,6 @@ def cleanup_net(iface): def setup_net(iface): - global IPV4_ADDR # create the interfaces pair atexit.register(functools.partial(cleanup_net, f"{iface}a")) subprocess.check_call( From 4f54661828e624a26027d783c475dd6c53a2a88b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 20:44:26 +0000 Subject: [PATCH 300/317] chore(deps): bump clap from 4.5.34 to 4.5.37 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.34 to 4.5.37. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.34...clap_complete-v4.5.37) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.37 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dab8a4a..a1e1475 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.34" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.34" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 669feee..80c9511 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.9.0" byteorder = "1.5.0" chrono = "0.4.39" -clap = "4.5.34" +clap = "4.5.37" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.14.0" From 3d2ae6a62a482808bcca25c1fd8a0b6e2418ff19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 20:44:42 +0000 Subject: [PATCH 301/317] chore(deps): bump rand from 0.8.5 to 0.9.1 Bumps [rand](https://github.com/rust-random/rand) from 0.8.5 to 0.9.1. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.8.5...rand_core-0.9.1) --- updated-dependencies: - dependency-name: rand dependency-version: 0.9.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 46 ++++++++++++++++++++++++++++++++-------------- Cargo.toml | 2 +- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dab8a4a..830514c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,12 +317,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", "libc", + "r-efi", "wasi", ] @@ -414,9 +415,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libloading" @@ -662,21 +663,26 @@ dependencies = [ ] [[package]] -name = "rand" -version = "0.8.5" +name = "r-efi" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "rand" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ - "libc", "rand_chacha", "rand_core", ] [[package]] name = "rand_chacha" -version = "0.3.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", "rand_core", @@ -684,9 +690,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom", ] @@ -864,9 +870,12 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] [[package]] name = "wasm-bindgen" @@ -1127,3 +1136,12 @@ name = "windows_x86_64_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.0", +] diff --git a/Cargo.toml b/Cargo.toml index 669feee..5c995c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ log = "0.4.27" pcap = "2.2.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } -rand = "0.8.4" +rand = "0.9.1" siphasher = "1.0" stderrlog = "0.6.0" strum = "0.27.1" From 93807104c456c4c6fa78a6242d610461a732fe80 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 20:44:54 +0000 Subject: [PATCH 302/317] chore(deps): bump flate2 from 1.0.35 to 1.1.1 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.35 to 1.1.1. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.35...1.1.1) --- updated-dependencies: - dependency-name: flate2 dependency-version: 1.1.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dab8a4a..b1d1c5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "miniz_oxide", @@ -480,9 +480,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", ] diff --git a/Cargo.toml b/Cargo.toml index 669feee..434a38b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ byteorder = "1.5.0" chrono = "0.4.39" clap = "4.5.34" dns-parser = "0.8.0" -flate2 = "1.0" +flate2 = "1.1" itertools = "0.14.0" lazy_static = "1.5.0" log = "0.4.27" From 5d8c332043ac3d94fbf720df349525a7e9a24a0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 20:45:15 +0000 Subject: [PATCH 303/317] chore(deps): bump strum_macros from 0.26.4 to 0.27.1 Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.26.4 to 0.27.1. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits/v0.27.1) --- updated-dependencies: - dependency-name: strum_macros dependency-version: 0.27.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dab8a4a..980eaaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -772,9 +772,9 @@ checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" [[package]] name = "strum_macros" -version = "0.26.4" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 669feee..a3de6c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ rand = "0.8.4" siphasher = "1.0" stderrlog = "0.6.0" strum = "0.27.1" -strum_macros = "0.26.4" +strum_macros = "0.27.1" [[bin]] name = "masscanned" From aa91ed8c26e6ceb3adbc38f0002a7d1d5e79b7a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 21:03:19 +0000 Subject: [PATCH 304/317] chore(deps): bump chrono from 0.4.39 to 0.4.41 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.39 to 0.4.41. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.39...v0.4.41) --- updated-dependencies: - dependency-name: chrono dependency-version: 0.4.41 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 +++++++++--- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10ba074..2e58dc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,16 +133,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.0", + "windows-link", ] [[package]] @@ -962,6 +962,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + [[package]] name = "windows-sys" version = "0.36.1" diff --git a/Cargo.toml b/Cargo.toml index 5bab535..54a2398 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.9.0" byteorder = "1.5.0" -chrono = "0.4.39" +chrono = "0.4.41" clap = "4.5.37" dns-parser = "0.8.0" flate2 = "1.1" From 9c04957c327f0d137bdcc7edad7ab21c9b5e1198 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 00:32:45 +0000 Subject: [PATCH 305/317] chore(deps): bump clap from 4.5.37 to 4.5.38 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.37 to 4.5.38. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.37...clap_complete-v4.5.38) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.38 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e58dc1..47a5db2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" +checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" +checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 54a2398..49d1c07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.9.0" byteorder = "1.5.0" chrono = "0.4.41" -clap = "4.5.37" +clap = "4.5.38" dns-parser = "0.8.0" flate2 = "1.1" itertools = "0.14.0" From 70d74ce84014eb0cbfe803af2ce6cf542c0dd52b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 May 2025 00:13:01 +0000 Subject: [PATCH 306/317] chore(deps): bump bitflags from 2.9.0 to 2.9.1 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.9.0...2.9.1) --- updated-dependencies: - dependency-name: bitflags dependency-version: 2.9.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47a5db2..aba3701 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,9 +94,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "bumpalo" @@ -454,7 +454,7 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "byteorder", "chrono", "clap", @@ -720,7 +720,7 @@ version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno 0.3.8", "libc", "linux-raw-sys", @@ -1149,5 +1149,5 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] diff --git a/Cargo.toml b/Cargo.toml index 49d1c07..266c368 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.9.0" +bitflags = "2.9.1" byteorder = "1.5.0" chrono = "0.4.41" clap = "4.5.38" From e31cab4b4f17dbdc45dee6676a67282b57fe372e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 00:19:35 +0000 Subject: [PATCH 307/317] chore(deps): bump flate2 from 1.1.1 to 1.1.2 Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.1.1 to 1.1.2. - [Release notes](https://github.com/rust-lang/flate2-rs/releases) - [Commits](https://github.com/rust-lang/flate2-rs/compare/1.1.1...1.1.2) --- updated-dependencies: - dependency-name: flate2 dependency-version: 1.1.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aba3701..49d1353 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", "miniz_oxide", From 2f3dccfd7f68488a389bc4440179f90d53aa0cd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 00:30:36 +0000 Subject: [PATCH 308/317] chore(deps): bump clap from 4.5.38 to 4.5.40 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.38 to 4.5.40. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.38...clap_complete-v4.5.40) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.40 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aba3701..ca195d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.38" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" +checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.38" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" +checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 266c368..908847b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.9.1" byteorder = "1.5.0" chrono = "0.4.41" -clap = "4.5.38" +clap = "4.5.40" dns-parser = "0.8.0" flate2 = "1.1" itertools = "0.14.0" From a52ae83fdd5612332a72979e44a71b52a270c9e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 23:07:04 +0200 Subject: [PATCH 309/317] chore(deps): bump pcap from 2.2.0 to 2.3.0 (#295) --- updated-dependencies: - dependency-name: pcap dependency-version: 2.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c987ff9..add0498 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -511,9 +511,9 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "pcap" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "499125886165f62fbc0c095ead9189b253f48eb1c5fcab49f81a270f2f220652" +checksum = "83cdabc34a80d9ec3563694cc31423fba6bb9bab4f31a9a5d5b85f29bd6d660a" dependencies = [ "bitflags 1.3.2", "errno 0.2.8", diff --git a/Cargo.toml b/Cargo.toml index 908847b..a0a9e52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ flate2 = "1.1" itertools = "0.14.0" lazy_static = "1.5.0" log = "0.4.27" -pcap = "2.2.0" +pcap = "2.3.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } rand = "0.9.1" From b5b8dbd3281b127fbe88663db5f5d39ea6d60e67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 23:14:19 +0200 Subject: [PATCH 310/317] chore(deps): bump rand from 0.9.1 to 0.9.2 (#296) --- updated-dependencies: - dependency-name: rand dependency-version: 0.9.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index add0498..9674295 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -670,9 +670,9 @@ checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "rand" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha", "rand_core", diff --git a/Cargo.toml b/Cargo.toml index a0a9e52..d9ce75a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ log = "0.4.27" pcap = "2.3.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } -rand = "0.9.1" +rand = "0.9.2" siphasher = "1.0" stderrlog = "0.6.0" strum = "0.27.1" From 48070b0fcafaf7b6aec3afe900dc6ad37c16dcfc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 23:14:54 +0200 Subject: [PATCH 311/317] chore(deps): bump strum_macros from 0.27.1 to 0.27.2 (#297) --- updated-dependencies: - dependency-name: strum_macros dependency-version: 0.27.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 11 ++--------- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9674295..5345d25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -727,12 +727,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rustversion" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" - [[package]] name = "scratch" version = "1.0.3" @@ -778,14 +772,13 @@ checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" [[package]] name = "strum_macros" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ "heck", "proc-macro2", "quote", - "rustversion", "syn 2.0.18", ] diff --git a/Cargo.toml b/Cargo.toml index d9ce75a..6484a77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ rand = "0.9.2" siphasher = "1.0" stderrlog = "0.6.0" strum = "0.27.1" -strum_macros = "0.27.1" +strum_macros = "0.27.2" [[bin]] name = "masscanned" From 68db6e757e4c076588a536c7cdc65dce84158df4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 23:42:09 +0200 Subject: [PATCH 312/317] chore(deps): bump strum from 0.27.1 to 0.27.2 (#298) --- updated-dependencies: - dependency-name: strum dependency-version: 0.27.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5345d25..d925b8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,9 +766,9 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" [[package]] name = "strum_macros" diff --git a/Cargo.toml b/Cargo.toml index 6484a77..c20aa43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ pnet = { version = "0.33.0", features = ["std"] } rand = "0.9.2" siphasher = "1.0" stderrlog = "0.6.0" -strum = "0.27.1" +strum = "0.27.2" strum_macros = "0.27.2" [[bin]] From 76704c71c425a4611d6365ec7519fd13be0c2e61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 23:59:25 +0200 Subject: [PATCH 313/317] chore(deps): bump clap from 4.5.40 to 4.5.42 (#299) Bumps [clap](https://github.com/clap-rs/clap) from 4.5.40 to 4.5.42. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.40...clap_complete-v4.5.42) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.42 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d925b8e..5ae331a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.40" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.40" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index c20aa43..becccf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.9.1" byteorder = "1.5.0" chrono = "0.4.41" -clap = "4.5.40" +clap = "4.5.42" dns-parser = "0.8.0" flate2 = "1.1" itertools = "0.14.0" From de8d6bfafc8651f9471a99b6688f02750f87020b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 15:38:31 +0000 Subject: [PATCH 314/317] chore(deps): bump clap from 4.5.42 to 4.5.47 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.42 to 4.5.47. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.42...clap_complete-v4.5.47) --- updated-dependencies: - dependency-name: clap dependency-version: 4.5.47 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ae331a..50452b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,18 +147,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.42" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" +checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.42" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index becccf8..976006f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "2.9.1" byteorder = "1.5.0" chrono = "0.4.41" -clap = "4.5.42" +clap = "4.5.47" dns-parser = "0.8.0" flate2 = "1.1" itertools = "0.14.0" From ebf55aff4757d1099baa1dfc431e7300cac662f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 08:58:31 +0000 Subject: [PATCH 315/317] chore(deps): bump log from 0.4.27 to 0.4.28 Bumps [log](https://github.com/rust-lang/log) from 0.4.27 to 0.4.28. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.27...0.4.28) --- updated-dependencies: - dependency-name: log dependency-version: 0.4.28 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ae331a..d732c25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -446,9 +446,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "masscanned" diff --git a/Cargo.toml b/Cargo.toml index becccf8..0c2267c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ dns-parser = "0.8.0" flate2 = "1.1" itertools = "0.14.0" lazy_static = "1.5.0" -log = "0.4.27" +log = "0.4.28" pcap = "2.3.0" pcap-file = "2.0.0" pnet = { version = "0.33.0", features = ["std"] } From 6fd6872372f8b9a17a071ee4c98ba7a8fcb23863 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 21:59:33 +0000 Subject: [PATCH 316/317] chore(deps): bump bitflags from 2.9.1 to 2.9.4 Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.9.1 to 2.9.4. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/2.9.1...2.9.4) --- updated-dependencies: - dependency-name: bitflags dependency-version: 2.9.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d6d8e7..507d1d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,9 +94,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" [[package]] name = "bumpalo" @@ -454,7 +454,7 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" name = "masscanned" version = "0.2.0" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "byteorder", "chrono", "clap", @@ -720,7 +720,7 @@ version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "errno 0.3.8", "libc", "linux-raw-sys", @@ -1142,5 +1142,5 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", ] diff --git a/Cargo.toml b/Cargo.toml index 4a0c9a7..c7b59a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ authors = ["_Frky <3105926+Frky@users.noreply.github.com>"] edition = "2018" [dependencies] -bitflags = "2.9.1" +bitflags = "2.9.4" byteorder = "1.5.0" chrono = "0.4.41" clap = "4.5.47" From d47b3d7b625c09c8db6d3931be262166651fc572 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Sep 2025 00:04:13 +0000 Subject: [PATCH 317/317] chore(deps): bump chrono from 0.4.41 to 0.4.42 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.41 to 0.4.42. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.41...v0.4.42) --- updated-dependencies: - dependency-name: chrono dependency-version: 0.4.42 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 15 ++++----------- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 507d1d5..30cd324 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,12 +17,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - [[package]] name = "android_system_properties" version = "0.1.5" @@ -133,11 +127,10 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" dependencies = [ - "android-tzdata", "iana-time-zone", "js-sys", "num-traits", @@ -957,9 +950,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-link" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" +checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" [[package]] name = "windows-sys" diff --git a/Cargo.toml b/Cargo.toml index c7b59a7..6cd59b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ edition = "2018" [dependencies] bitflags = "2.9.4" byteorder = "1.5.0" -chrono = "0.4.41" +chrono = "0.4.42" clap = "4.5.47" dns-parser = "0.8.0" flate2 = "1.1"