
간단하고 안정적이며 합리적으로 빠른 네트워크 캡처 분석기입니다.
Sharker는 PCAP 파일 또는 라이브 인터페이스에서 유용한 데이터를 추출하는 강력하고 확장 가능한 도구입니다. tshark의 강력한 기능을 활용하여 네트워크 캡처를 효율적으로 파싱하고, 유연한 필터링 시스템을 적용하여 중요한 정보를 정확히 찾아 추출합니다.
.pcap 파일, 캡처 디렉토리, 또는 인터페이스의 실시간 네트워크 트래픽을 분석합니다.apt-get install tshark, brew install wireshark).requirements.txt에 있으며 pip/pipx로 설치할 수 있습니다.Sharker는 pipx(권장) 또는 표준 pip 및 venv 환경을 사용하여 설치할 수 있습니다.
pipx 사용 (권장)# Install from this repository
pipx install git+https://github.com/synacktiv/sharker.git
# Verify the installation
sharker -h
pip 및 venv 사용# 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의 기본 구문은 다음과 같습니다:
sharker [OPTIONS] [PCAP_FILE(s)]
1. 단일 PCAP 분석 및 결과 저장:
sharker my_capture.pcap
heavy 카테고리의 필터를 제외한 모든 필터가 실행되고 출력이 sharker_out/ 디렉토리에 저장됩니다. creds 카테고리의 필터는 표준 출력(stdout)에도 출력됩니다.
2. 모든 필터를 적용하고 최대한 빠르게 실행:
sharker -A -F my_captures.pcap
모든 필터를 적용하고 결과를 파일로만 출력하며, 콘솔에는 아무 것도 출력되지 않습니다.
3. PCAP 디렉토리 분석, 자격 증명(credentials)에 초점:
sharker -d /path/to/pcaps -c creds
이 명령은 지정된 디렉토리의 모든 PCAP 파일을 처리하지만 creds 카테고리의 필터만 실행합니다.
4. 실시간 트래픽 캡처 및 HTTP 관련 정보를 콘솔에 출력:
sudo sharker -i eth0 -c http -m console
eth0 인터페이스에서 트래픽을 캡처하고 http 카테고리 필터만 실행한 다음 모든 결과를 터미널에 직접 출력합니다.
5. 사용 가능한 모든 필터 나열:
sharker -L
$ 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 표현에서 관심 데이터를 식별하기 위해 찾는 키(key)입니다. 필터에 parser 함수가 정의되어 있지 않으면 Sharker는 이러한 속성을 사용하여 데이터를 출력합니다.parser(): 패킷 데이터를 처리하고 추출된 정보를 반환하는 함수.기본적으로 Sharker는 heavy 카테고리의 필터를 제외한 모든 필터를 실행합니다. -c, -nc, -f, -nf 옵션으로 이 동작을 사용자 지정할 수 있습니다.
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에 기여하거나 자신만의 필터를 개발하려면 개발 환경을 설정할 수 있습니다.
# 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
sharker/filters/ 디렉토리에 새 Python 파일을 생성합니다.FilterConfigBase(sharker/filters/base.py에 정의됨)를 상속하는 클래스를 생성합니다.name, description, pcap_filter 등)을 정의합니다.parser() 메서드를 구현합니다.
self.output 메서드를 호출합니다.이 프로젝트는 다음과 같은 훌륭한 오픈소스 프로젝트들의 작업에서 영감을 받았습니다:
| Option | Description |
|---|
-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 | 모든 필터를 활성화합니다. 더 느려집니다. |
| Option | Description |
|---|
-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 | 디버깅을 위한 상세 로깅을 활성화합니다. |