Skip to content

parse_pcap_klap: require source host #1137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2024
Merged
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
13 changes: 10 additions & 3 deletions devtools/parse_pcap_klap.py
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
Loading