Exemplo n.º 1
0
def get_interface_table(require_ip=False):
    
    rows = [
            [iface,t[0],'\n'.join(t[1])] for iface,t in
            get_interfaces(require_ip).items()
    ]
    

    return tabulate(
        rows,
        ['Interface','MAC','IP Addresses']
    )
Exemplo n.º 2
0
    # Analyze and exit
    if args.cmd == 'analyze':

        if not args.pcap_files and not args.sqlite_files:
            print('- Analyze command requires at least one input file.')
            exit()

        analyze(**args.__dict__,
                sender_lists=sender_lists,
                target_lists=target_lists)

    # Capture and exit
    elif args.cmd == 'capture':

        interfaces = get_interfaces()
        if args.interface not in interfaces or not interfaces[args.interface][1]:
            valids = ', '.join([i for i,vs in interfaces.items() if vs[1]])
            print(f'Invalid interface provided: {args.interface}' \
            f'\n\nValid interfaces:\n\n{get_interface_table(True)}\n' \
            '\nFYI: An interface is valid only when it has an IP\n\n' \
            'Exiting!')
            exit()


        capture(**args.__dict__,
            sender_lists=sender_lists,
            target_lists=target_lists)

        print('- Done! Exiting')