pocs icon indicating copy to clipboard operation
pocs copied to clipboard

Minimise bitmap mini/bmp.bmp

Open ace-dent opened this issue 3 years ago • 2 comments

Smashed the 334 bytes original down to a slim 60 bytes, by hand crafting a v1.x BMP file.

All versions of the BMP format begin with a basic 14 byte file header. Next is the secondary DIB header; 12 bytes is the smallest possible (IBM OS/2 – v1.x BMP files).

Avoiding the more ‘advanced’ / modern bitmap file formats has a big impact for small files, while still widely supported and well documented.

Sources: http://www.fileformat.info/format/os2bmp/egff.htm http://www.fileformat.info/format/bmp/egff.htm http://en.wikipedia.org/wiki/BMP_file_format https://msdn.microsoft.com/en-us/library/dd183372(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/dd183374(v=vs.85).aspx

ace-dent avatar May 17 '21 15:05 ace-dent

The committed version is ‘clean’, zero bit padded -totally vanilla. data:image/bmp;base64,Qk08AAAAAAAAACAAAAAMAAAADQAHAAEAAQD///8AAAAAAAAAZUAAAFVAAABnYAAAV1AAAGVgAAAAAAAA

But since each row has to be padded to a 4 byte boundary, we actually have 19 bits of padding (32 bits - 13 bits). We might replace the last 2 bytes per row with a hidden image! data:image/bmp;base64,Qk08AAAAAAAAACAAAAAMAAAADQAHAAEAAQD///8AAAAAAAAAZUCm7FVAqIpnYOjKV1CoimVgRuwAAAAA

Changing ‘bcWidth’ at address 18 from 0x0D (decimal 13) to 0x20 (decimal 32), reveals our steganography… data:image/bmp;base64,Qk08AAAAAAAAACAAAAAMAAAAIAAHAAEAAQD///8AAAAAAAAAZUCm7FVAqIpnYOjKV1CoimVgRuwAAAAA

Or, we might choose to hide some other data in those bytes :-) data:image/bmp;base64,Qk08AAAAAAAAACAAAAAMAAAADQAHAAEAAQD///8AAAAAAENPZUBSS1VAQU1nYEkuV1BBTWVgUksAAENP

ace-dent avatar May 17 '21 15:05 ace-dent

Bump @angea :-)

ace-dent avatar Oct 18 '23 11:10 ace-dent