import zipfile zip_ref = zipfile.ZipFile('malicious.zip', 'r') def extract(): zip_ref.extractall('./') def get_size(): # checks the size of the uncompressed data res = 0 for i in range(len(zip_ref.filelist)): res += zip_ref.filelist[i].file_size return res if __name__ == "__main__": total_size = get_size() print("The size of the uncompressed data is: %s bytes" % total_size) if total_size < 1024: # e.g. extract the data only if the uncompressed size is less than 1KB. extract() # The uncompressed size is more than 20GB :) zip_ref.close()