Skip to content

Commit

Permalink
feat(sa_dump_seeds): Add sleep parameter and output seed length
Browse files Browse the repository at this point in the history
  • Loading branch information
emedav authored and rumpelsepp committed Aug 19, 2024
1 parent 565fff7 commit c39e783
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/gallia/commands/scan/uds/sa_dump_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

import asyncio
import binascii
import sys
import time
Expand Down Expand Up @@ -84,6 +85,12 @@ def configure_parser(self) -> None:
default=b"",
help="Append an optional data record to each seed request",
)
self.parser.add_argument(
"--sleep",
type=float,
metavar="FLOAT",
help="Attempt to fool brute force protection by sleeping for N seconds between seed requests.",
)

async def request_seed(self, level: int, data: bytes) -> bytes | None:
resp = await self.ecu.security_access_request_seed(
Expand Down Expand Up @@ -168,6 +175,8 @@ async def main(self, args: Namespace) -> None:
# Errors are already logged in .request_seed()
continue

logger.info(f"Received seed of length {len(seed)}")

await file.write(seed)
if last_seed == seed:
logger.warning("Received the same seed as before")
Expand Down Expand Up @@ -209,6 +218,10 @@ async def main(self, args: Namespace) -> None:
# Re-enter session. Checking/logging will be done at the beginning of next iteration
await self.ecu.set_session(session)

if args.sleep is not None:
logger.info(f"Sleeping for {args.sleep} seconds between seed requests…")
await asyncio.sleep(args.sleep)

await file.close()
self.log_size(seeds_file, time.time() - start_time)
await self.ecu.leave_session(session, sleep=args.power_cycle_sleep)

0 comments on commit c39e783

Please sign in to comment.