mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 09:36:35 +03:00
cloaked upx for windows (used mkstemp because of execution and file access rights problem)
This commit is contained in:
parent
200518724c
commit
92817159dc
10
lib/contrib/upx/windows/README.txt
Normal file
10
lib/contrib/upx/windows/README.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
Due to the anti-virus positive detection of executable stored inside this folder,
|
||||
we needed to somehow circumvent this. As from the plain sqlmap users perspective nothing
|
||||
has to be done prior to its usage by sqlmap, but if you want to have access to the
|
||||
original executable use the decrypt functionality of the ../../../../extra/cloak/cloak.py utility.
|
||||
|
||||
To prepare the executable to the cloaked form use this command:
|
||||
python ../../../../extra/cloak/cloak.py -i upx.exe
|
||||
|
||||
To get back the original executable use this:
|
||||
python ../../../../extra/cloak/cloak.py -d -i upx.exe_
|
Binary file not shown.
BIN
lib/contrib/upx/windows/upx.exe_
Normal file
BIN
lib/contrib/upx/windows/upx.exe_
Normal file
Binary file not shown.
|
@ -34,6 +34,7 @@ import ntpath
|
|||
import posixpath
|
||||
|
||||
from tempfile import NamedTemporaryFile
|
||||
from tempfile import mkstemp
|
||||
|
||||
from extra.cloak.cloak import decloak
|
||||
from lib.contrib import magic
|
||||
|
@ -885,3 +886,10 @@ def decloakToNamedTemporaryFile(filepath, name=None):
|
|||
retVal.old_name = retVal.name
|
||||
retVal.name = name
|
||||
return retVal
|
||||
|
||||
def decloakToMkstemp(filepath, **kwargs):
|
||||
name = mkstemp(**kwargs)[1]
|
||||
retVal = open(name, 'w+b')
|
||||
retVal.write(decloak(filepath))
|
||||
retVal.seek(0)
|
||||
return retVal
|
||||
|
|
|
@ -30,6 +30,7 @@ from subprocess import STDOUT
|
|||
from subprocess import Popen as execute
|
||||
|
||||
from lib.core.common import dataToStdout
|
||||
from lib.core.common import decloakToMkstemp
|
||||
from lib.core.common import pollProcess
|
||||
from lib.core.data import logger
|
||||
from lib.core.data import paths
|
||||
|
@ -49,7 +50,9 @@ class UPX:
|
|||
self.__upxPath = "%s/upx/macosx/upx" % paths.SQLMAP_CONTRIB_PATH
|
||||
|
||||
elif "win" in PLATFORM:
|
||||
self.__upxPath = "%s\upx\windows\upx.exe" % paths.SQLMAP_CONTRIB_PATH
|
||||
self.__upxTempExe = decloakToMkstemp("%s\upx\windows\upx.exe_" % paths.SQLMAP_CONTRIB_PATH, suffix=".exe")
|
||||
self.__upxPath = self.__upxTempExe.name
|
||||
self.__upxTempExe.close() #needed for execution rights
|
||||
|
||||
elif "linux" in PLATFORM:
|
||||
self.__upxPath = "%s/upx/linux/upx" % paths.SQLMAP_CONTRIB_PATH
|
||||
|
@ -71,6 +74,9 @@ class UPX:
|
|||
|
||||
logger.debug("executing local command: %s" % self.__upxCmd)
|
||||
process = execute(self.__upxCmd, shell=True, stdout=PIPE, stderr=STDOUT)
|
||||
|
||||
if (self, hasattr('__upxTempExe')):
|
||||
os.remove(self.__upxTempExe.name)
|
||||
|
||||
dataToStdout("\r[%s] [INFO] compression in progress " % time.strftime("%X"))
|
||||
pollProcess(process)
|
||||
|
|
Loading…
Reference in New Issue
Block a user