Configure mutable input bits with -b
masterTo modify non-contiguous bits instead of appending bytes, use the -b flag. This allows you to specify which bits in the original message are allowed to be changed to reach the target checksum.
Syntax: -b l:r:s (Python-style slices)
l: Start position (inclusive)r: End position (exclusive)s: Step (distance between bits)
Bit Addressing:
Positions can be specified as byte.bit (e.g., 0.32 is the 32nd bit in the 0th byte). Within a byte, bits are numbered 0 (LSB) to 7 (MSB).
Advanced Selection:
- Negative positions: Treated as offsets from the end of the input.
- Arithmetic: Supports
+,-,*,/and0xhex prefixes. - Relative end: Use
+to defineendrelative tostart(e.g.,+.8*32). - Brace expansion: Supports
{start-end}syntax (e.g.,.{0-2}:-1:1).
Requirement: You must provide at least w mutable bits, where w is the CRC register size (e.g., 32 bits for CRC-32).
# Select bits 1..2, 3..5, and 6..7
echo "aXbXXcXd" | ./crchack -b1:2 -b3:5 -b6:7 - cafebabe
# Select all bits starting from byte 4
echo "1234PQPQ" | ./crchack -b 4: - 12345678
# Use complex bit selection with arithmetic
echo "A"*32 | ./crchack -b "0.5:+.8*32:.8" - 1337c0de