<commit_before>#!/usr/bin/env python

# region Import
from sys import path
from os.path import dirname, abspath

project_root_path = dirname(dirname(dirname(abspath(__file__))))
utils_path = project_root_path + "/Utils/"
path.append(utils_path)

from base import Base
from scanner import Scanner
from argparse import ArgumentParser
from socket import socket, AF_PACKET, SOCK_RAW
from network import ICMPv6_raw
from time import sleep
from icmpv6_scan import ICMPv6Scan

# endregion

# region Check user, platform and create threads
Base = Base()
Base.check_user()
Base.check_platform()
icmpv6 = ICMPv6_raw()
icmpv6_scan = ICMPv6Scan()
scanner = Scanner()
# endregion

# region Parse script arguments
parser = ArgumentParser(description='NA (Neighbor Advertisement) spoofing')

parser.add_argument('-i', '--interface', help='Set interface name for send ARP packets')
parser.add_argument('-t', '--target_ip', help='Set target IPv6 link local address', default=None)
parser.add_argument('-m', '--target_mac', help='Set target MAC address', default=None)
parser.add_argument('-g', '--gateway_ip', help='Set gateway IPv6 link local address', default=None)
parser.add_argument('-d', '--dns_ip', help='Set DNS server IPv6 link local address', default=None)
parser.add_argument('-q', '--quiet', action='store_true', help='Minimal output')

args = parser.parse_args()
# endregion

# region Print banner if argument quit is not set
if not args.quiet:
    Base.print_banner()
# endregion

# region Get your network settings
if args.interface is None:
    Base.print_warning("Please set a network interface for sniffing ICMPv6 responses ...")
current_network_interface = Base.netiface_selection(args.interface)

your_mac_address = Base.get_netiface_mac_address(current_network_interface)
if your_mac_address is None:
    Base.print_error("Network interface: ", current_network_interface, " do not have MAC address!")
    exit(1)

your_ipv6_link_address = Base.get_netiface_ipv6_link_address(current_network_interface)
if your_ipv6_link_address is None:
    Base.print_error("Network interface: ", current_network_interface, " do not have link local IPv6 address!")
    exit(1)
# endregion

# region Global variables
target_ipv6_address = None
target_mac_address = None
gateway_ipv6_address = None
gateway_mac_address = None
dns_ipv6_address = None
# endregion

# region Create global raw socket
socket_global = socket(AF_PACKET, SOCK_RAW)
socket_global.bind((current_network_interface, 0))
# endregion

# region General output
if not args.quiet:
    Base.print_info("Network interface: ", current_network_interface)
    Base.print_info("Your IPv6 address: ", your_ipv6_link_address)
    Base.print_info("Your MAC address: ", your_mac_address)
# endregion

# region Main function
if __name__ == "__main__":

    # region Check arguments: gateway_ip and dns_ip

    # region Set variable for scan results
    router_advertisement_data = None
    # endregion

    # region Search Gateway and DNS servers
    if args.gateway_ip is None and args.dns_ip is None:

        Base.print_info("Search IPv6 gateway ....")
        router_advertisement_data = icmpv6_scan.search_router(current_network_interface, 5, 3)<commit_msg>Change output; script: na_spoof.py<commit_after>#!/usr/bin/env python

# region Import
from sys import path
from os.path import dirname, abspath

project_root_path = dirname(dirname(dirname(abspath(__file__))))
utils_path = project_root_path + "/Utils/"
path.append(utils_path)

from base import Base
from scanner import Scanner
from argparse import ArgumentParser
from socket import socket, AF_PACKET, SOCK_RAW
from network import ICMPv6_raw
from time import sleep
from icmpv6_scan import ICMPv6Scan

# endregion

# region Check user, platform and create threads
Base = Base()
Base.check_user()
Base.check_platform()
icmpv6 = ICMPv6_raw()
icmpv6_scan = ICMPv6Scan()
scanner = Scanner()
# endregion

# region Parse script arguments
parser = ArgumentParser(description='NA (Neighbor Advertisement) spoofing')

parser.add_argument('-i', '--interface', help='Set interface name for send ARP packets')
parser.add_argument('-t', '--target_ip', help='Set target IPv6 link local address', default=None)
parser.add_argument('-m', '--target_mac', help='Set target MAC address', default=None)
parser.add_argument('-g', '--gateway_ip', help='Set gateway IPv6 link local address', default=None)
parser.add_argument('-d', '--dns_ip', help='Set DNS server IPv6 link local address', default=None)
parser.add_argument('-q', '--quiet', action='store_true', help='Minimal output')

args = parser.parse_args()
# endregion

# region Print banner if argument quit is not set
if not args.quiet:
    Base.print_banner()
# endregion

# region Get your network settings
if args.interface is None:
    Base.print_warning("Please set a network interface for sniffing ICMPv6 responses ...")
current_network_interface = Base.netiface_selection(args.interface)

your_mac_address = Base.get_netiface_mac_address(current_network_interface)
if your_mac_address is None:
    Base.print_error("Network interface: ", current_network_interface, " do not have MAC address!")
    exit(1)

your_ipv6_link_address = Base.get_netiface_ipv6_link_address(current_network_interface)
if your_ipv6_link_address is None:
    Base.print_error("Network interface: ", current_network_interface, " do not have link local IPv6 address!")
    exit(1)
# endregion

# region Global variables
target_ipv6_address = None
target_mac_address = None
gateway_ipv6_address = None
gateway_mac_address = None
dns_ipv6_address = None
# endregion

# region Create global raw socket
socket_global = socket(AF_PACKET, SOCK_RAW)
socket_global.bind((current_network_interface, 0))
# endregion

# region General output
if not args.quiet:
    Base.print_info("Network interface: ", current_network_interface)
    Base.print_info("Your IPv6 address: ", your_ipv6_link_address)
    Base.print_info("Your MAC address: ", your_mac_address)
# endregion

# region Main function
if __name__ == "__main__":

    # region Check arguments: gateway_ip and dns_ip

    # region Set variable for scan results
    router_advertisement_data = None
    # endregion

    # region Search Gateway and DNS servers
    if args.gateway_ip is None and args.dns_ip is None:

        Base.print_info("Search IPv6 Gateway and DNS server ....")
        router_advertisement_data = icmpv6_scan.search_router(current_network_interface, 5, 3)
{'fraction_non_alphanumeric': 0.0945358584290593, 'fraction_numerical': 0.008382489909965849, 'mean_word_length': 5.5610997963340125, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2069348', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1986, 'n_words': 567}