self extracting zipefile (windows) and (standard module) zipefile

W

Werner

Hi,


I try to read (and extract) some "self extracting" zipefiles on a
Windows system. The standard module zipefile seems not to be able to
handle this.
False

Is there a wrapper or has some one experience with other libaries to
extract those files?


Thanks in advance
Werner
 
K

kyosohma

Hi,

I try to read (and extract) some "self extracting" zipefiles on a
Windows system. The standard module zipefile seems not to be able to
handle this.


False

Is there a wrapper or has some one experience with other libaries to
extract those files?

Thanks in advance
Werner

Since it's an executable, why not just use the subprocess module?

I did find this set of scripts, but I don't know if they will help:
http://www.example-code.com/python/zip.asp

I did find how to extract via the command line, which you could use in
conjunction with the subprocess module:
http://help.globalscape.com/help/cutezip2/Creating_and_extracting_archives.htm

Mike
 
H

Hyuga

First of all, there's really no such thing as a "self extracting
zipefile". I mean, obviously you have to do something to unzip it. A
file doesn't just execute itself. What you're dealing with is not a
_zip file_. It's an executable that has a zip file bundled with it,
and the code to unzip it, most likely into your current directory
(though some such executables allow you to provide a path to unzip
to). You'll have to execute it--there's no way you can operate on it
like a normal zip file.
 
G

Grant Edwards

I try to read (and extract) some "self extracting" zipefiles
on a Windows system. The standard module zipefile seems not to
be able to handle this. [...]

First of all, there's really no such thing as a "self
extracting zipefile".

Perhaps there isn't "really such a thing," but that's the
commonly used name for the type of file the OP is dealing with.
[...] You'll have to execute it--there's no way you can
operate on it like a normal zip file.

Executing the file is a huge, huge security risk.

Other zip tools (e.g. the "unzip" utility for Linux) seem know
how to work with self-extracting zipfiles. Unfortunately there
are multiple slightly different zip formats along with mutlple
"self-extracting zip file" formats. Nonetheless, I've never run
across one I couldn't unzip without executing it. On Linux,
I'd probably just try exec'ing the "unzip" program.

Another option is to search through the file from the beginning
looking for whatever signature matches the beginning of a
"normal" zip file. The self-extracting zipfiles that I've
dissected are just an executable image concatenated with a
"normal" zipfile. If you just start searching from the
beginning of the file, it's simple to find the actual zip data
and copy it into a separate file which then can be unzipped
like any other plain zipfile. I haven't done that for many
years since the normal zip tools that I use can operate on
self-extracting files.
 
S

Scott David Daniels

Grant Edwards wrote:
....
Another option is to search through the file from the beginning
looking for whatever signature matches the beginning of a
"normal" zip file. The self-extracting zipfiles that I've
dissected are just an executable image concatenated with a
"normal" zipfile. If you just start searching from the
beginning of the file, it's simple to find the actual zip data
and copy it into a separate file which then can be unzipped
like any other plain zipfile.

Actually, the zip format is defined from the _end_ rather than
the _beginning_ of the file. Some random file with a zip file
concatenated on the end will have the same contents as the zip
file. You can even point Python itself at such files and get
data via:
import zipfile
zf = zipfile.ZipFile('something.exe')
...

-Scott David Daniels
(e-mail address removed)
 
W

Werner

Since it's an executable, why not just use the subprocess module?

I did find this set of scripts, but I don't know if they will help:http://www.example-code.com/python/zip.asp

I did find how to extract via the command line, which you could use in
conjunction with the subprocess module:http://help.globalscape.com/help/cutezip2/Creating_and_extracting_arc...

Mike- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

thank you for answer. I found, that WinZip aund 7-ZIP may handle my
files (I'm not shure, if it's really zip...) So, I thing I try the 7-
zip command line tool (but I'd prefered a Python buildin version)

Werner
 
W

Werner

Grant Edwards wrote:

...


Actually, the zip format is defined from the _end_ rather than
the _beginning_ of the file. Some random file with a zip file
concatenated on the end will have the same contents as the zip
file. You can even point Python itself at such files and get
data via:
import zipfile
zf = zipfile.ZipFile('something.exe')
...

-Scott David Daniels
(e-mail address removed)

I hoped, this would work, but I got "<class 'zipfile.BadZipfile'>:
File is not a zip file"...
WinZip and 7-ZIP may handle this file, so I take the command line
version of 7-Zip (but I'd prefered a Python only version)

Thanks
Werner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top