Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
sharker — 一款简单、可靠且速度合理的网络抓包分析器。 | Kitploit
工具/GitHubGitHub/synacktiv/sharker
数据包嗅探与分析密码破解信息收集Web安全网络安全数字取证
GitHubsynacktiv/sharker

sharker

一款简单、可靠且速度合理的网络抓包分析器。

查看仓库
33153个月前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

Sharker:Wireshark 的终点,我们的起点

Sharker 是一个功能强大且可扩展的工具,用于从 PCAP 文件或实时接口中提取有价值的数据。它利用 tshark 的强大功能来高效解析网络捕获,并应用灵活的过滤系统来精准定位和提取关键信息。

主要特性

  • 可扩展的过滤: 创建基于 Python 的过滤器,从网络数据包中提取任意数据。
  • 强大的过滤引擎: 可选择性地启用或禁用过滤器及过滤器类别,以微调并加速你的分析。
  • 多种输入源: 分析 .pcap 文件、包含捕获文件的目录,甚至来自网络接口的实时流量。
  • 灵活的输出来: 将结果保存到组织有序的文本文件中、打印到控制台,或两者兼而有之。

环境要求

  • tshark: Wireshark 的命令行伴生工具是必需的。通常可以通过系统的包管理器安装(例如,apt-get install tshark、brew install wireshark)。
  • Python 3
  • Python 库: 所需的库列在 requirements.txt 中,可以通过 pip/pipx 安装。

安装

你可以使用 pipx(推荐)或标准的 pip 和 venv 环境来安装 Sharker。

使用 pipx(推荐)

root@kitploit:~
# Install from this repository
pipx install git+https://github.com/synacktiv/sharker.git

# Verify the installation
sharker -h

使用 pip 和 venv

root@kitploit:~
# Clone the repository
git clone https://github.com/synacktiv/sharker.git
cd sharker

# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate

# Install Sharker
pip install .

# Verify the installation
sharker -h

使用方法

Sharker 的基本语法为:

root@kitploit:~
sharker [OPTIONS] [PCAP_FILE(s)]

常用选项

主要选项

过滤选项

使用示例

1. 分析单个 PCAP 并保存结果:

root@kitploit:~
sharker my_capture.pcap

这将运行除 heavy 类别之外的所有过滤器,并将输出保存到 sharker_out/ 目录中。creds 类别中的过滤器也会打印到标准输出。

2. 应用所有过滤器并尽可能快地运行:

root@kitploit:~
sharker -A -F my_captures.pcap

这将应用所有过滤器并将所有内容输出到文件,不会有结果打印到控制台。

3. 分析目录中的 PCAP,重点关注凭据:

root@kitploit:~
sharker -d /path/to/pcaps -c creds

该命令处理指定目录中的所有 PCAP 文件,但仅运行 creds 类别中的过滤器。

4. 捕获实时流量并将 HTTP 相关信息打印到控制台:

root@kitploit:~
sudo sharker -i eth0 -c http -m console

这将从 eth0 接口捕获流量,仅运行 http 类别过滤器,并将所有结果直接打印到终端。

5. 列出所有可用过滤器:

root@kitploit:~
sharker -L

帮助输出

点击查看完整帮助输出
root@kitploit:~
$ sharker -h
Usage: sharker [OPTIONS] [PCAP[ PCAP[ ...]]

  Sharker: A reasonably fast network protocol analysis tool with extensible
  filters.

Options:
  Input Source:
    -d, --pcap-dir DIR            Path to a directory containing PCAP files to
                                  parse.
    -i, --interface IFACE         Network interface to capture live data from
                                  (e.g., eth0, wlan0).
  Output Handling:                By default, everything is written to file,
                                  and only creds category is printed to
                                  console. For very large PCAPs, advised to
                                  disable console output or at least colors,
                                  since it slows down the parsing.
    -m, --output-mode [file|console|both|develop]
                                  Which output mode to enable.  [default:
                                  both]
    -u, --unique                  Output only unique results, will gradually
                                  take more and more RAM.
    -F, --fast                    Fastest configuration (do not affect filter
                                  selection).
  Output file mode:
    -o, --output-dir DIR          Output directory.
    -op, --output-prefix NAME     Prefix to use for the output files, defaults
                                  to the PCAP/interface name.
  Output console mode:
    -P                            Send all filters to console (default in
                                  console output mode).
    -C                            Do not use colors in console output, will
                                  speed up sharker when lot of stuff is
                                  printed.
    -pf FILT[,FILT[...]]          Send specific filters output to console.
    -xpf FILT[,FILT[...]]         Do not send specific filters to console.
    -pc CAT[,CAT[...]]            Send specific filter categories to console.
    -xpc CAT[,CAT[...]]           Do not send specific categories to console.
    -nwf FILT[,FILT[...]]         Do not write filters output to file.
    -nwc CAT[,CAT[...]]           Do not write filter categories to file.
  Filter Selection:
    -A, --all                     Enable all filters, will be slower.
    -f, --filters FILT[,FILT[...]]
                                  Only run specified filters.
    -nf, --not-filters FILT[,FILT[...]]
                                  Exclude specified filters.
    -c, --categories CAT[,CAT[...]]
                                  Only run specified categories of filters.
    -nc, --not-categories CAT[,CAT[...]]
                                  Exclude specified categories of filters.
  Filter Information:
    -l, --list-filters            List filters that would be active with
                                  current filtering options.
    -L, --list-all-filters        List all available filters.
    -Lc, --list-all-filter-categories
                                  List all available filter categories.
  Debugging:
    -v, --verbose                 Verbose mode.
  -h, --help                      Show this message and exit.

过滤系统

Sharker 的强大之处在于其过滤器,它们位于 sharker/filters/ 目录中。每个过滤器都是一个 Python 类,定义了:

  • name:过滤器的唯一名称。
  • description:对过滤器功能的简要说明。
  • pcap_filter:一个 tshark 显示过滤器,用于为该过滤器选择相关的数据包。
  • categories:该过滤器所属类别的列表(例如,creds、dns、http)。对于会匹配大量数据包或执行缓慢操作的过滤器,可以使用 heavy。
  • mandatory_selectors 和 optional_selectors:在数据包的 JSON 表示中查找的键,以识别感兴趣的数据。如果过滤器中未定义 parser 函数,Sharker 将使用这些属性来输出数据。
  • parser():处理数据包数据并返回提取信息的函数。

默认情况下,Sharker 会运行除 heavy 类别之外的所有过滤器。你可以通过 -c、-nc、-f 和 -nf 选项自定义此行为。

点击查看 NTLM 哈希提取示例
root@kitploit:~
from .base import FilterConfigBase


class FilterConfig(FilterConfigBase):
    name = 'ntlmssp'
    description = 'Extract Net-NTLM hashes for cracking purposes'

    categories = [
        'creds',
        'windows'
    ]

    pcap_filter = 'gss-api || ntlmssp'

    mandatory_selectors = [
        'ntlmssp'
    ]

    def __init__(self, *args, **kwargs):
        self.challenges = {}
        super().__init__(*args, **kwargs)

    def parser(self, data):
        tcp_conn = data['tcp.stream'][0]
        msg_type = int(data['ntlmssp.messagetype'][0], 16) if 'ntlmssp.messagetype' in data else 0

        if msg_type == 1:
            # NTLM NEGOTIATE: nothing to do
            pass
        elif msg_type == 2:
            # NTLM CHALLENGE
            self.challenges[tcp_conn] = data['ntlmssp.ntlmserverchallenge'][0].replace(':', '')
        elif msg_type == 3:
            if tcp_conn not in self.challenges:
                self.log.error('Found an NTLM message type 3 (AUTH), but no type 2 (CHALLENGE) was received beforehand -> check in pcap if the challenge was not sent in an unsupported by tshark manner from the server, like in a Proxy-Authenticate HTTP header.')
                return 0

            ntresp = data['ntlmssp.auth.ntresponse'][0].replace(':', '')
            lmresp = data['ntlmssp.auth.lmresponse'][0].replace(':', '')
            user = data['ntlmssp.auth.username'][0]
            domain = data['ntlmssp.auth.domain'][0]
            workstation = data['ntlmssp.auth.hostname'][0]

            ntlm_hash = ''
            if len(ntresp) == 24 * 2:
                # NTLMv1 response
                if domain != '':
                    ntlm_hash = f'{user}::{domain}:{lmresp}:{ntresp}:{self.challenges[tcp_conn]}'
                else:
                    ntlm_hash = f'{user}::{workstation}:{lmresp}:{ntresp}:{self.challenges[tcp_conn]}'
            else:
                # NTLMv2 response
                if domain != '':
                    ntlm_hash = f'{user}::{domain}:{self.challenges[tcp_conn]}:{ntresp[:32]}:{ntresp[32:]}'
                else:
                    ntlm_hash = f'{user}::{workstation}:{self.challenges[tcp_conn]}:{ntresp[:32]}:{ntresp[32:]}'

            del self.challenges[tcp_conn]
            self.output(ntlm_hash)
            return 1

        return 0

开发

如果你想为 Sharker 做贡献或开发自己的过滤器,可以设置一个开发环境。

root@kitploit:~
# Clone the repository
git clone https://github.com/synacktiv/sharker.git
cd sharker

# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate

# Install in editable mode
pip install -e .

# Now you can run sharker and your changes will be reflected immediately
sharker -h

创建新过滤器

  1. 在 sharker/filters/ 目录中创建一个新的 Python 文件。
  2. 在该文件中,创建一个继承自 FilterConfigBase(在 sharker/filters/base.py 中定义)的类。
  3. 定义必需的属性(name、description、pcap_filter 等)。
  4. 实现 parser() 方法以提取所需数据。
    • 调用 self.output 方法来输出数据。
  5. Sharker 会自动发现并加载你的新过滤器。

灵感与参考

该项目的灵感来自以下非常优秀的开源项目:

  • PCredz
  • CredSLayer
  • Wireshark captures
下载工具
选项描述
-i, --interface <IFACE>从网络接口捕获实时流量(例如,eth0)。
-d, --pcap-dir <DIR>分析目录中的所有 PCAP 文件。
-o, --output-dir <DIR>指定输出文件的目录(默认:./sharker_out)。
-m, --output-mode <MODE>设置输出模式:file、console、both 或 develop(默认:both)。
-u, --unique仅输出唯一结果。
-F, --fast最快配置(不影响过滤器选择)。
-A, --all启用所有过滤器,速度会变慢。
选项描述
-c, --categories <CATS>要运行的过滤器类别列表,以逗号分隔(例如,creds,http)。
-nc, --not-categories <CATS>要排除的过滤器类别列表,以逗号分隔(例如,heavy)。默认情况下,会排除 heavy。
-f, --filters <FILTERS>要运行的特定过滤器列表,以逗号分隔。
-nf, --not-filters <FILTERS>要排除的特定过滤器列表,以逗号分隔。
-L, --list-all-filters显示所有可用过滤器及其描述的列表。
-Lc, --list-all-filter-categories显示所有可用过滤器类别的列表。
-l, --list-filters显示在当前命令行选项下将启用的过滤器。
-v, --verbose启用详细日志以进行调试。