onekey-sec / unblob

Extract files from any kind of container formats
https://unblob.org
Other
2.19k stars 80 forks source link

Handle UnicodeDecodeError on invalid CPIO entry #664

Closed qkaiser closed 1 year ago

qkaiser commented 1 year ago

Improve CPIO handler by raising InvalidInputFormat when the filename is not UTF-8.

This exception was raised and uncaught many times on false positive matches.

e3krisztian commented 1 year ago

Do we know that the ones raising the exception are non-utf-8 cpio archive, or are they really not a valid cpio archive?

qkaiser commented 1 year ago

Do we know that the ones raising the exception are non-utf-8 cpio archive, or are they really not a valid cpio archive?

Really not a valid CPIO archive. Example match:

00000000  c7 71 ff ff 63 24 01 00  e7 71 ed ff 00 10 20 00  |.q..c$...q.... .|
00000010  84 24 23 28 a6 00 02 19  05 00 00 31 03 00 0b 00  |.$#(.......1....|
00000020  60 10 00 00 88 8c 04 00  89 8c 01 00 07 71 08 00  |`............q..|
00000030  8a 8c 01 00 27 71 0c 00  8b 8c 01 00 47 71 ff ff  |....'q......Gq..|
00000040  63 24 01 00 67 71 f5 ff  00 10 10 00 84 24 23 28  |c$..gq.......$#(|
00000050  a6 00 c2 18 05 00 c0 30  03 00 07 00 60 10 00 00  |.......0....`...|
00000060  88 8c 04 00 89 8c 01 00  07 71 ff ff 63 24 01 00  |.........q..c$..|
00000070  27 71 f9 ff 00 10 08 00  84 24 23 28 a6 00 82 18  |'q.......$#(....|
00000080  05 00 80 30 03 00 03 00  60 10 00 00 88 8c 04 00  |...0....`.......|
00000090  84 24 01 00 07 71 23 28  a6 00 0f 00 a0 10 01 00  |.$...q#(........|
000000a0  a6 30 04 00 c0 14 00 00  00 00 01 00 88 88 09 00  |.0..............|
000000b0  00 10 02 44 08 00 02 00  a6 30 04 00 c0 14 00 00  |...D.....0......|
000000c0  00 00 00 00 88 88 03 00  00 10 02 46 08 00 02 00  |...........F....|
000000d0  88 88 02 42 08 00 01 00  07 71 10 48 00 00 12 40  |...B.....q.H...@|
000000e0  00 00 21 18 28 01 2b 58  68 00 02 00 60 11 00 00  |..!.(.+Xh...`...|
000000f0  00 00 01 00 63 24 02 4c  03 00 ff ff 6a 30 21 18  |....c$.L....j0!.|
00000100  2a 01 02 4c 03 00 ff ff  6a 30 21 18 2a 01 02 00  |*..L....j0!.*...|
00000110  40 10 00 00 00 00 a0 18  03 7c 27 10 60 00 08 00  |@........|'.`...|
00000120  e0 03 ff ff 42 30 30 ff  bd 27 cc 00 bf af c8 00  |....B00..'......|
00000130  be af c4 00 b7 af c0 00  b6 af bc 00 b5 af b8 00  |................|
00000140  b4 af b4 00 b3 af b0 00  b2 af ac 00 b1 af a8 00  |................|
00000150  b0 af 21 98 c0 00 e0 00  b7 8f e4 00 be 8f e8 00  |..!.............|
00000160  b5 8f ec 00 b6 8f dc 00  a7 a3 c0 10 06 00 ff 00  |................|