Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion smbcmp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,26 @@ def smb_summaries(pcap):
cmd += ['-r', pcap, TSHARK_FILTER_FLAG, '!browser && (smb||smb2)']
out = subprocess.check_output(cmd).decode('utf-8')
pkts = {}

ip_map = {
'192.168.123.22': 'A',
'192.168.123.1': 'Relay',
'192.168.123.4': 'C'
};

for line in out.split('\n'):
m = re.match(r'''\s*(\d+).+?SMB2?\s*\d+\s*(.+)''', line)
ips = re.match(r'''.* (\d+\.\d+\.\d+\.\d+) → (\d+\.\d+\.\d+\.\d+).*''', line)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a proof of concept; I believe it might be better to use the xml output of tshark -T pdml -r ../smb.pcapng '!browser && (smb||smb2)' to gather the required fields ip.src_host / ip.dst_host - potentially with alias support in smbcmp itself for matching arbitrary src/dst ips/hostnames to user defined hostnames

ip_info = ""

if ips:
ip_1 = ip_map.get(ips.group(1), ips.group(1))
ip_2 = ip_map.get(ips.group(2), ips.group(2))
ip_info = ip_1 + " -> " + ip_2 + ": "

if m:
pkts[int(m.group(1))] = m.group(2)
pkts[int(m.group(1))] = ip_info + m.group(2)

return pkts


Expand Down