FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

parse_pcap_klap: require source host by rytilahti · Pull Request #1137 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 10 additions & 3 deletions devtools/parse_pcap_klap.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def main(
username,
password,
device_ip,
source_host,
pcap_file_path,
output_json_name=None,
):
Expand All @@ -232,7 +233,6 @@ def main(
)

operator = Operator(KlapTransportV2(config=fake_device), creds)

packets = []

# pyshark is a little weird in how it handles iteration,
Expand All @@ -241,6 +241,8 @@ def main(
try:
packet = capture.next()
packet_number = capture._current_packet
if packet.ip.src != source_host:
continue
# we only care about http packets
if hasattr(
packet, "http"
Expand Down Expand Up @@ -325,6 +327,11 @@ def main(
required=True,
help="the IP of the smart device as it appears in the pcap file.",
)
@click.option(
"--source-host",
required=True,
help="the IP of the device communicating with the smart device.",
)
@click.option(
"--username",
required=True,
Expand All @@ -348,14 +355,14 @@ def main(
required=False,
help="The name of the output file, relative to the current directory.",
)
async def cli(username, password, host, pcap_file_path, output):
async def cli(username, password, host, source_host, pcap_file_path, output):
"""Export KLAP data in JSON format from a PCAP file."""
# pyshark does not work within a running event loop and we don't want to
# install click as well as asyncclick so run in a new thread.
loop = asyncio.new_event_loop()
thread = Thread(
target=main,
args=[loop, username, password, host, pcap_file_path, output],
args=[loop, username, password, host, source_host, pcap_file_path, output],
daemon=True,
)
thread.start()
Expand Down

Back | FazBrowse Home | New Git URL