By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,142 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,142 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
>>fName = r"C:\tmp\mySelfExtratingFile.exe"
import zipfile
zipefile.is_zipfile(fName))
False

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

Aug 29 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Aug 29, 6:53 am, Werner <Werner.Me...@fujitsu-siemens.comwrote:
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.
>fName = r"C:\tmp\mySelfExtratingFile.exe"
import zipfile
zipefile.is_zipfile(fName))

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/cut...g_archives.htm

Mike

Aug 29 '07 #2

P: n/a
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.

On Aug 29, 7:53 am, Werner <Werner.Me...@fujitsu-siemens.comwrote:
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.
>fName = r"C:\tmp\mySelfExtratingFile.exe"
import zipfile
zipefile.is_zipfile(fName))

False

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

Thanks in advance
Werner
Aug 29 '07 #3

P: n/a
On 2007-08-29, Hyuga <hy**********@gmail.comwrote:
>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.

--
Grant Edwards grante Yow! NEWARK has been
at REZONED!! DES MOINES has
visi.com been REZONED!!
Aug 29 '07 #4

P: n/a
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
Sc***********@Acm.Org
Aug 30 '07 #5

P: n/a
On 29 Aug., 15:23, kyoso...@gmail.com wrote:
On Aug 29, 6:53 am, Werner <Werner.Me...@fujitsu-siemens.comwrote:


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.
>>fName = r"C:\tmp\mySelfExtratingFile.exe"
>>import zipfile
>>zipefile.is_zipfile(fName))
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/cut...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

Aug 30 '07 #6

P: n/a
On 30 Aug., 06:26, Scott David Daniels <dani...@dsl-only.netwrote:
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
Scott.Dani...@Acm.Org
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

Aug 30 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.