
एक सरल, विश्वसनीय और काफी तेज़ नेटवर्क कैप्चर विश्लेषक।
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)]
| 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 | डिबगिंग के लिए विस्तृत (verbose) लॉगिंग सक्षम करें। |
1. एकल PCAP का विश्लेषण करें और परिणाम सहेजें:
sharker my_capture.pcap
यह heavy श्रेणी के फ़िल्टरों को छोड़कर सभी फ़िल्टर चलाएगा और आउटपुट को sharker_out/ निर्देशिका में सहेजेगा। creds श्रेणी के फ़िल्टर भी stdout पर प्रिंट होंगे।
2. सभी फ़िल्टर लागू करें और जितना संभव हो उतनी तेज़ी से चलाने का प्रयास करें:
sharker -A -F my_captures.pcap
यह सभी फ़िल्टर लागू करेगा और सब कुछ फ़ाइलों में आउटपुट करेगा, कंसोल पर कोई परिणाम प्रिंट नहीं होगा।
3. PCAPs की निर्देशिका का विश्लेषण करें, क्रेडेंशियल्स पर ध्यान केंद्रित करते हुए:
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 प्रतिनिधित्व में देखने योग्य कुंजियाँ। यदि फ़िल्टर में कोई 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 विधि को कॉल करें।यह प्रोजेक्ट निम्नलिखित बेहतरीन ओपन-सोर्स प्रोजेक्ट्स के काम से प्रेरित था: