Skip to content

Commit e1a8d26

Browse files
committed
fix for UPX linux/macos
1 parent 8d8fc2b commit e1a8d26

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/core/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,11 @@ def __del__():
14101410
return retVal
14111411

14121412
def decloakToMkstemp(filepath, **kwargs):
1413-
name = mkstemp(**kwargs)[1]
1413+
handle, name = mkstemp(**kwargs)
1414+
1415+
fptr = os.fdopen(handle)
1416+
fptr.close() # close low level handle (causing problems latter)
1417+
14141418
retVal = open(name, 'w+b')
14151419

14161420
retVal.write(decloak(filepath))

lib/takeover/upx.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
import os
12+
import stat
1213
import time
1314

1415
from subprocess import PIPE
@@ -19,6 +20,7 @@
1920
from lib.core.common import decloakToMkstemp
2021
from lib.core.data import logger
2122
from lib.core.data import paths
23+
from lib.core.settings import IS_WIN
2224
from lib.core.settings import PLATFORM
2325
from lib.core.subprocessng import pollProcess
2426

@@ -51,6 +53,9 @@ def __initialize(self, srcFile, dstFile=None):
5153
self.__upxPath = self.__upxTemp.name
5254
self.__upxTemp.close() #needed for execution rights
5355

56+
if not IS_WIN:
57+
os.chmod(self.__upxPath, stat.S_IXUSR)
58+
5459
self.__upxCmd = "%s -9 -qq %s" % (self.__upxPath, srcFile)
5560

5661
if dstFile:

0 commit comments

Comments
 (0)