le4f / pcap-analyzer

online pcap forensic

Home Page:http://le4f.net/post/post/pcap-online-analyzer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add default tshark_path for CentOS7

kkxue opened this issue · comments

Hi,when i try pcap-analyzer in CentOS7,TSharkNotFoundException occured.

TSharkNotFoundException: TShark not found in the following locations: C:\Program Files\Wireshark\tshark.exe, /usr/bin/tshark, /usr/lib/tshark, /usr/local/bin/tshark Either place tshark there or add more paths to the config file.

the reason is default tshark path "/usr/sbin/tshark" of CentOS7 is not in all your possible_paths.
so why not add it? even though i can add it to config.ini.

def get_tshark_path():
    """
    Finds the path of the tshark executable. If the user has specified a
    location in config.ini it will be used. Otherwise default locations
    will be searched.

    :raises TSharkNotFoundException in case TShark is not found in any location.
    """
    config = get_config()

    if sys.platform.startswith('win'):
        win32_progs = os.environ.get('ProgramFiles(x86)', '')
        win64_progs = os.environ.get('ProgramFiles', '')
        tshark_path = ('Wireshark', 'tshark.exe')
        possible_paths = [config.get('tshark', 'tshark_path'),
                          os.path.join(win32_progs, *tshark_path),
                          os.path.join(win64_progs, *tshark_path)]
    else:
        possible_paths = [config.get('tshark', 'tshark_path'),
                          '/usr/bin/tshark',
                          '/usr/sbin/tshark',
                          '/usr/lib/tshark',
                          '/usr/local/bin/tshark']

    for path in possible_paths:
        if os.path.exists(path):
            return path
    raise TSharkNotFoundException('TShark not found in the following locations: ' + ', '.join(possible_paths) +
                                  ' Either place tshark there or add more paths to the config file.')

commented

Hi,
Tshark may in default path if wireshark has been installed.

Hi,i have installed wireshark,but it's not in all your possible_paths.my tshatk's path is "/usr/sbin/tshark",