Bad Character Filtering Bypass
- •
What it is
- •
Re-encode an input or instruction so the delivered bytes avoid a filter's forbidden values without changing the intended operation.
- •
- •
How it works
- •
Substitute instruction encodings that don't happen to contain the forbidden byte:
xor reg, reginstead ofmov reg, 0(avoids the embedded0x00), narrower register forms to drop unwanted prefix bytes, or building a target constant piecewise via shifts/arithmetic instead of one literal immediate.
- •
- •
When to use it
- •
An explicit byte filter or an input routine constrains what arrives. Check the actual routine: null termination and newline/whitespace handling differ.
- •
- •
- •
pwntools
- •
banned = {0x00, 0x48} assert not (set(shellcode) & banned)
- •
- •
Debugging
- •
x/20xb $rip # Inspect raw bytes. x/10i $rip # Compare with decoded instructions.
- •
- •
- •
- •
Cards
- •
What's the general strategy for avoiding a forbidden byte in shellcode?
- •
Re-encode the same effect with a different instruction/register width that doesn't happen to produce that byte.
- •
- •
Why does
mov reg, 0often cause bad-byte problems?- •
The zero immediate embeds literal
0x00bytes;xor reg, regachieves the same result without any null bytes.
- •
- •