Home python unpack the .exe file

unpack the .exe file




Trying to unpack the .exe file using:

from zipfile import zipfile
zf = zipfile ("/ TMP / test.exe", "R")
ZF.ExtractAll ("/ TMP / WSH")
zf.close ()

But I get such a mistake:

traceback (most recent call last):
 File "/root/pycharmprojects/manuf/wireshark.py", line 49, in & lt; module & gt;
  zf = zipfile ("/ TMP / test.exe", "R")
 File "/usr/lib/python3.9/zipfile.py", Line 1257, in __init__
  Self._RealgetContents ()
 File "/usr/lib/python3.9/zipfile.py", Line 1324, in _RealGetContents
  Raise Badzipfile ("File Is Not A Zip File")
zipfile.Badzipfile: File Is Not a Zip File

Tell me, please, how to unzip the .exe file, I need to unzip.

I need a method that removes the contents of the packaged .exe . Now I search for information, since I looked at this file info and found an interesting thing: test.exe: PE32 Executable (GUI) Intel 80386, for MS Windows, Nullsoft Installer Self-Extracting Archive

Answer 1, Authority 100%

Since the task is to directly execute on Linux OS, I solved the problem as follows, more precisely, it is not a problem, but bypassing it:

#! / usr / bin / env python3
Import subprocess
result = subprocess.popen (['7z', '-y', 'x', '-tmp/Test.exe', '-o / TMP / WSH'], stdout = subprocess.pipe, stderr = subprocess.pipe )
stdout, stderr = result.communicate ()
If Len (stderr) == 0:
  Print ("GGWP")
  Print ("bg")

Utility 7z Almost all Linux goes pre-installed.

Answer 2

Judging by the Big view of the ZIPFILE module features, it only works with ZIP archives and the error directly says: Badzipfile: File Is Not a Zip File .
It is important to understand what the exe file are you trying to unpack – is it a previously compiled python file?

went through Sofa and found a similar question, I don’t know if, but read, it can be what you need https://ru.stackoverflow.com/questions/877213/cax-ExEx- PY

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions