Is there a tool to extract a file from a ZIP archive when that file is not present in central directory but has its own LFH? - zip

I'm looking for a tool that can extract files by searching aggressively through a ZIP archive. The compressed files are preceded with LFHs but no CDHs are present. Unzip outputs an empty folder.
I found one called 'binwalk' but even though it finds the hidden files inside ZIP archives it seems not to know how to extract them.
Thank You in advance.

You can try sunzip. It reads the zip file as a stream, and will extract files as it encounters the local headers and compressed data.
Use the -r option to retain the files decompressed in the event of an error. You will be left with a temporary directory starting with _z containing the extracted files, but with temporary, random names.

Related

How can I read specifc file by filename when using yauzl?

I have to extract files from a zip archive and after that process it.
The thing is that each archive will have it own manifest file, and I have to check if its valid. How can I firstly check the manifest file and processed only if its available and is valid?

I want to add addtional files to existing archives (ZIP / RAR) or have the files added when compressing

I know how to do this for one archive at a time, but I want to add files, to multiple archives, in the same folder, simultaneously; if that is possible. I understand that I can do this with a batch file... but I don't know how to write the script / text.
So... I have several zip files in one folder. I want to add a specific text file and a specific image file to each/all of those zips. I don't want any other modifications of the zip files.
Or... is there a way to set WinRAR so that specific files will be automatically added whenever an archive is created?
Thanks
import zipfile
z = zipfile.ZipFile('cal.zip', mode='a', compression=zipfile.ZIP_DEFLATED)
z.write('/your/file/path') # or, z.writestr('your-filename', 'file-content')
z.close()

How can i archive every 2 files in a folder with 7zip

How can i archive every 2 files in a folder with 7zip. I want 7zip to take the name of the first file for the archive. Is it possible.
It is possible but only with a split rar file (files with extensions like part1.zip , part2.zip etc. ) If the files were not splitted then extract them in a single folder with a name that you want for archive and then create archive by splitting the folder in 2 parts . Next time whenever you will extract them , they will be extracted in a single folder having the name of first folder

Deleting Zip Entry from Zip archive using Minizip API

I am using Minizip API to zip and unzip file to and from my archive. I have a requirement to delete the zip entry from the zip as soon as i extract it.
if the zip archive has multiple zip entries , i am able to delete a particular zip entry soon as i extract it and then able to zip archive with the remaining zip entries. i am able to achieve this using a temp zip .
But when i have a single file inside the zip archive, i am only able to delete the zip after complete extraction....Can there be a optimize way for this situation where i can extract and delete the zip entry in chunks. there is no direct API's in minizip to delete, i am using raw write and read.
Thanks in advance,
JP
No, there is no way to delete part of a file in a ZIP archive, short of extracting the whole file and archiving the part you don't want. (Which doesn't make sense here, since you're already trying to extract the file!)

How to add the contents of a directory to a zip file?

How would I add the contents of an entire directory to an already existing zip file using python? The directory to be added to the zip file will also include other folders as well and there will be duplicates in the zip file that will need to be overwritten. Any help would be appreciated. Thanks in advance!
P.S. If it is possible to zip the directory then combine both files that would also work.
Python's zipfile module allows you to manipular ZIP compressed archives. The ZipFile.namelist() method returns a list of files in an archive, and the ZipFile.write() method lets you add files to the archive.
z = zipfile.ZipFile('myfile.zip')
The os.walk method allows you to iterate over all the files contained in a directory tree.
for root, dirs, files in os.walk('mydir'):
for filename in files:
z.write(os.path.join(root, filename))
Replacing a file in an archive appears to be tricky; you can removed items by creating a temporary archive and then replacing the original when you're done as described in this question.
It might be easier just to call the zip command instead, but put these together and you should be able to get to where you want.

Resources