Options for fuzz(). Based on can-hax (--fuzz mode).

interface FuzzOptions {
    adaptive?: boolean;
    canId?: string;
    fingerprint: Record<string, string> | CanFingerprint;
    onAfterSend?: (
        ctx: FuzzContext,
    ) => boolean | void | Promise<boolean | void>;
    onBeforeSend?: (
        ctx: FuzzContext,
    ) => boolean | void | Promise<boolean | void>;
    onCanIdEnd?: (canId: string, frameCount: number) => void | Promise<void>;
    onCanIdStart?: (canId: string, template: string) => void | Promise<void>;
    quick?: boolean;
    superQuick?: boolean;
    timing?: number;
}

Properties

adaptive?: boolean

Adaptive quickness per CAN ID. For complex templates (more N/H chars), automatically use reduced sets: complexity > 9 → superquick, > 5 → quick. Corresponds to --adaptive / -a in can-hax.

canId?: string

Only fuzz this CAN ID. Optional. Corresponds to --canid / -I in can-hax.

fingerprint: Record<string, string> | CanFingerprint

Fingerprint data. From fingerprintFromCanMessages() or loaded JSON. Corresponds to --input / -i (fingerprint file) in can-hax.

onAfterSend?: (ctx: FuzzContext) => boolean | void | Promise<boolean | void>

Called after each frame is sent. Use to verify ECU health (e.g. UDS TesterPresent). Return false to stop fuzzing (e.g. ECU no longer responding).

onBeforeSend?: (ctx: FuzzContext) => boolean | void | Promise<boolean | void>

Called before each frame is sent. Return false to skip this frame (don't send). Use for pre-send checks or filtering.

onCanIdEnd?: (canId: string, frameCount: number) => void | Promise<void>

Called when finished fuzzing a CAN ID.

onCanIdStart?: (canId: string, template: string) => void | Promise<void>

Called when starting to fuzz a new CAN ID.

quick?: boolean

Use restricted value set for quicker fuzzing:

  • N (decimal): 0, 1, 5, 9
  • H (hex): 0, 1, 9, A, B, F Corresponds to --quick / -q in can-hax.
superQuick?: boolean

Use minimal value set for fastest fuzzing:

  • N (decimal): 0, 9
  • H (hex): 0, F Corresponds to --superquick / -s in can-hax.
timing?: number

Time delay in milliseconds between each frame. Default 20. Corresponds to --timing / -t in can-hax (can-hax uses seconds).