zip炸彈


  故障系統有人提了zip炸彈的故障,了解了一些關於zip炸彈的常識。 

       42.zip 是很有名的zip炸彈。一個42KB的文件,解壓完其實是個4.5PB的“炸彈”。

       更有甚者,一個叫做 droste.zip 的大小為 28 KB 的文件,一旦被打開了以后,就會無限解壓縮生成一份同樣的文件,直到永遠。

       zip炸彈文件中有大量刻意重復的數據,這種重復數據在壓縮的時候是可以被丟棄的,這也就是壓縮后的文件其實並不大的原因。

       可以看一下 https://blog.csdn.net/j2IaYU7Y/article/details/82321082

 

  

    How can I protect myself from a zip bomb?

       https://stackoverflow.com/questions/1459080/how-can-i-protect-myself-from-a-zip-bomb#

       文中沒有具體的解決方案,但是我覺得2個思路是挺不錯的:

        1. a robust solution is to stream the data out, and stop when you have had enough. In Java, use ZipInputStream rather than ZipFile. The latter also requires you to store the data in a temporary file, which is also not the greatest of ideas.

        嘗試解壓,超過設定的最大字節數后就報錯

       2.Deny any compressed files that contain compressed files. Use ZipFile.entries() to retrieve a list of files, then ZipEntry.getName() to find the file extension.

         壓縮文件中如果還包含壓縮文件則拒絕,內部的壓縮文件可以考慮前幾個字節的魔數來判斷,沒有實際驗證過。正常的壓縮文件類型都應該以固定的文件頭標識開始。

         

        各類文件的文件頭標志:  https://blog.csdn.net/rrrfff/article/details/7484109

       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM