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

Skip to content

Commit 1e60378

Browse files
committed
Minor refactoring
1 parent 22c7bc5 commit 1e60378

6 files changed

Lines changed: 30 additions & 28 deletions

File tree

lib/core/common.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ def setPaths(rootPath):
12971297
paths.PGSQL_XML = os.path.join(paths.SQLMAP_XML_BANNER_PATH, "postgresql.xml")
12981298

12991299
for path in paths.values():
1300-
if any(path.endswith(_) for _ in (".txt", ".xml", ".zip")):
1300+
if any(path.endswith(_) for _ in (".md5", ".txt", ".xml", ".zip")):
13011301
checkFile(path)
13021302

13031303
def weAreFrozen():
@@ -1427,7 +1427,7 @@ def parseTargetUrl():
14271427
errMsg += "on this platform"
14281428
raise SqlmapGenericException(errMsg)
14291429

1430-
if not re.search(r"^http[s]*://", conf.url, re.I) and not re.search(r"^ws[s]*://", conf.url, re.I):
1430+
if not re.search(r"^https?://", conf.url, re.I) and not re.search(r"^wss?://", conf.url, re.I):
14311431
if re.search(r":443\b", conf.url):
14321432
conf.url = "https://%s" % conf.url
14331433
else:
@@ -1528,14 +1528,14 @@ def expandAsteriskForColumns(expression):
15281528
the SQL query string (expression)
15291529
"""
15301530

1531-
asterisk = re.search(r"(?i)\ASELECT(\s+TOP\s+[\d]+)?\s+\*\s+FROM\s+`?([^`\s()]+)", expression)
1531+
match = re.search(r"(?i)\ASELECT(\s+TOP\s+[\d]+)?\s+\*\s+FROM\s+`?([^`\s()]+)", expression)
15321532

1533-
if asterisk:
1533+
if match:
15341534
infoMsg = "you did not provide the fields in your query. "
15351535
infoMsg += "sqlmap will retrieve the column names itself"
15361536
logger.info(infoMsg)
15371537

1538-
_ = asterisk.group(2).replace("..", '.').replace(".dbo.", '.')
1538+
_ = match.group(2).replace("..", '.').replace(".dbo.", '.')
15391539
db, conf.tbl = _.split('.', 1) if '.' in _ else (None, _)
15401540

15411541
if db is None:
@@ -4284,9 +4284,11 @@ def extractExpectedValue(value, expected):
42844284
value = value.strip().lower()
42854285
if value in ("true", "false"):
42864286
value = value == "true"
4287+
elif value in ('t', 'f'):
4288+
value = value == 't'
42874289
elif value in ("1", "-1"):
42884290
value = True
4289-
elif value == "0":
4291+
elif value == '0':
42904292
value = False
42914293
else:
42924294
value = None

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

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

lib/takeover/xp_cmdshell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def xpCmdshellWriteFile(self, fileContent, tmpPath, randDestFile):
136136

137137
for line in lines:
138138
echoedLine = "echo %s " % line
139-
echoedLine += ">> \"%s\%s\"" % (tmpPath, randDestFile)
139+
echoedLine += ">> \"%s\\%s\"" % (tmpPath, randDestFile)
140140
echoedLines.append(echoedLine)
141141

142142
for echoedLine in echoedLines:

plugins/dbms/mssqlserver/filesystem.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ def _updateDestChunk(self, fileContent, tmpPath):
6767
chunkName = randomStr(lowercase=True)
6868
fileScrLines = self._dataToScr(fileContent, chunkName)
6969

70-
logger.debug("uploading debug script to %s\%s, please wait.." % (tmpPath, randScr))
70+
logger.debug("uploading debug script to %s\\%s, please wait.." % (tmpPath, randScr))
7171

7272
self.xpCmdshellWriteFile(fileScrLines, tmpPath, randScr)
7373

74-
logger.debug("generating chunk file %s\%s from debug script %s" % (tmpPath, chunkName, randScr))
74+
logger.debug("generating chunk file %s\\%s from debug script %s" % (tmpPath, chunkName, randScr))
7575

7676
commands = (
7777
"cd \"%s\"" % tmpPath,
@@ -174,10 +174,10 @@ def _stackedWriteFilePS(self, tmpPath, wFileContent, dFile, fileType):
174174

175175
encodedFileContent = base64encode(wFileContent)
176176
encodedBase64File = "tmpf%s.txt" % randomStr(lowercase=True)
177-
encodedBase64FilePath = "%s\%s" % (tmpPath, encodedBase64File)
177+
encodedBase64FilePath = "%s\\%s" % (tmpPath, encodedBase64File)
178178

179179
randPSScript = "tmpps%s.ps1" % randomStr(lowercase=True)
180-
randPSScriptPath = "%s\%s" % (tmpPath, randPSScript)
180+
randPSScriptPath = "%s\\%s" % (tmpPath, randPSScript)
181181

182182
wFileSize = len(encodedFileContent)
183183
chunkMaxSize = 1024
@@ -212,15 +212,15 @@ def _stackedWriteFileDebugExe(self, tmpPath, wFile, wFileContent, dFile, fileTyp
212212
logger.info(infoMsg)
213213

214214
dFileName = ntpath.basename(dFile)
215-
sFile = "%s\%s" % (tmpPath, dFileName)
215+
sFile = "%s\\%s" % (tmpPath, dFileName)
216216
wFileSize = os.path.getsize(wFile)
217217
debugSize = 0xFF00
218218

219219
if wFileSize < debugSize:
220220
chunkName = self._updateDestChunk(wFileContent, tmpPath)
221221

222-
debugMsg = "renaming chunk file %s\%s to %s " % (tmpPath, chunkName, fileType)
223-
debugMsg += "file %s\%s and moving it to %s" % (tmpPath, dFileName, dFile)
222+
debugMsg = "renaming chunk file %s\\%s to %s " % (tmpPath, chunkName, fileType)
223+
debugMsg += "file %s\\%s and moving it to %s" % (tmpPath, dFileName, dFile)
224224
logger.debug(debugMsg)
225225

226226
commands = (
@@ -248,7 +248,7 @@ def _stackedWriteFileDebugExe(self, tmpPath, wFile, wFileContent, dFile, fileTyp
248248
debugMsg = "appending chunk "
249249
copyCmd = "copy /B /Y %s+%s %s" % (dFileName, chunkName, dFileName)
250250

251-
debugMsg += "%s\%s to %s file %s\%s" % (tmpPath, chunkName, fileType, tmpPath, dFileName)
251+
debugMsg += "%s\\%s to %s file %s\\%s" % (tmpPath, chunkName, fileType, tmpPath, dFileName)
252252
logger.debug(debugMsg)
253253

254254
commands = (
@@ -275,7 +275,7 @@ def _stackedWriteFileVbs(self, tmpPath, wFileContent, dFile, fileType):
275275

276276
randVbs = "tmps%s.vbs" % randomStr(lowercase=True)
277277
randFile = "tmpf%s.txt" % randomStr(lowercase=True)
278-
randFilePath = "%s\%s" % (tmpPath, randFile)
278+
randFilePath = "%s\\%s" % (tmpPath, randFile)
279279

280280
vbs = """Dim inputFilePath, outputFilePath
281281
inputFilePath = "%s"
@@ -338,7 +338,7 @@ def _stackedWriteFileVbs(self, tmpPath, wFileContent, dFile, fileType):
338338

339339
self.xpCmdshellWriteFile(encodedFileContent, tmpPath, randFile)
340340

341-
logger.debug("uploading a visual basic decoder stub %s\%s, please wait.." % (tmpPath, randVbs))
341+
logger.debug("uploading a visual basic decoder stub %s\\%s, please wait.." % (tmpPath, randVbs))
342342

343343
self.xpCmdshellWriteFile(vbs, tmpPath, randVbs)
344344

@@ -359,7 +359,7 @@ def _stackedWriteFileCertutilExe(self, tmpPath, wFile, wFileContent, dFile, file
359359
chunkMaxSize = 500
360360

361361
randFile = "tmpf%s.txt" % randomStr(lowercase=True)
362-
randFilePath = "%s\%s" % (tmpPath, randFile)
362+
randFilePath = "%s\\%s" % (tmpPath, randFile)
363363

364364
encodedFileContent = base64encode(wFileContent)
365365

plugins/generic/takeover.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def regRead(self):
372372
else:
373373
regVal = conf.regVal
374374

375-
infoMsg = "reading Windows registry path '%s\%s' " % (regKey, regVal)
375+
infoMsg = "reading Windows registry path '%s\\%s' " % (regKey, regVal)
376376
logger.info(infoMsg)
377377

378378
return self.readRegKey(regKey, regVal, True)
@@ -417,7 +417,7 @@ def regAdd(self):
417417
else:
418418
regType = conf.regType
419419

420-
infoMsg = "adding Windows registry path '%s\%s' " % (regKey, regVal)
420+
infoMsg = "adding Windows registry path '%s\\%s' " % (regKey, regVal)
421421
infoMsg += "with data '%s'. " % regData
422422
infoMsg += "This will work only if the user running the database "
423423
infoMsg += "process has privileges to modify the Windows registry."
@@ -449,12 +449,12 @@ def regDel(self):
449449
regVal = conf.regVal
450450

451451
message = "are you sure that you want to delete the Windows "
452-
message += "registry path '%s\%s? [y/N] " % (regKey, regVal)
452+
message += "registry path '%s\\%s? [y/N] " % (regKey, regVal)
453453

454454
if not readInput(message, default='N', boolean=True):
455455
return
456456

457-
infoMsg = "deleting Windows registry path '%s\%s'. " % (regKey, regVal)
457+
infoMsg = "deleting Windows registry path '%s\\%s'. " % (regKey, regVal)
458458
infoMsg += "This will work only if the user running the database "
459459
infoMsg += "process has privileges to modify the Windows registry."
460460
logger.info(infoMsg)

txt/checksum.md5

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ c7443613a0a2505b1faec931cee2a6ef lib/controller/handler.py
2828
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
2929
0adf547455a76dc71e6a599e52da1ed9 lib/core/agent.py
3030
fd8f239e259afaf5f24bcf34a0ad187f lib/core/bigarray.py
31-
2131176e2fca7d400ccd0e2da6f8b77b lib/core/common.py
31+
de53dd81bda04541d0992852aee0f2b3 lib/core/common.py
3232
0d082da16c388b3445e656e0760fb582 lib/core/convert.py
3333
9f87391b6a3395f7f50830b391264f27 lib/core/data.py
3434
72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py
@@ -48,7 +48,7 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4848
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
4949
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5050
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
51-
475b8df4fbbb3b5108ccb1e856fe2a61 lib/core/settings.py
51+
9c991557b5b0a38f14c5667d627ead76 lib/core/settings.py
5252
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
5353
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5454
12bed9603b6fba3e5ffda11d584bc449 lib/core/target.py
@@ -88,7 +88,7 @@ acc1db3667bf910b809eb279b60595eb lib/takeover/icmpsh.py
8888
fb9e34d558293b5d6b9727f440712886 lib/takeover/registry.py
8989
48575dde7bb867b7937769f569a98309 lib/takeover/udf.py
9090
f6f835e4190a55e42d13c1e7ca3f728f lib/takeover/web.py
91-
f1decf0a987bd3a4bc757212cbe6a6c8 lib/takeover/xp_cmdshell.py
91+
debc36a3ff80ba915aeeee69b21a8ddc lib/takeover/xp_cmdshell.py
9292
09beb19c2ec9fdd14329f1c0b59a2d05 lib/techniques/blind/inference.py
9393
1e5532ede194ac9c083891c2f02bca93 lib/techniques/blind/__init__.py
9494
1e5532ede194ac9c083891c2f02bca93 lib/techniques/dns/__init__.py
@@ -163,7 +163,7 @@ e7d44671ae26c0bcd5fe8448be070bbd plugins/dbms/maxdb/syntax.py
163163
bf7842bb291e2297c3c8d1023eb3e550 plugins/dbms/maxdb/takeover.py
164164
decc645344bb93aca504a71ba2e4cad4 plugins/dbms/mssqlserver/connector.py
165165
f1f1541a54faf67440179fa521f99849 plugins/dbms/mssqlserver/enumeration.py
166-
177e1d55d28ed3190bc0079b8126c6be plugins/dbms/mssqlserver/filesystem.py
166+
65911fdc86fa6322e72319e6488a0bb8 plugins/dbms/mssqlserver/filesystem.py
167167
08914da79141713bd69a25c3cc7f06a8 plugins/dbms/mssqlserver/fingerprint.py
168168
f25c50a95e5390ecd32be5a011637349 plugins/dbms/mssqlserver/__init__.py
169169
612be1929108e7b4512a49a4a3837bbc plugins/dbms/mssqlserver/syntax.py
@@ -214,7 +214,7 @@ f5d5419efddfe04648ea5e953c650793 plugins/generic/fingerprint.py
214214
f7874230e5661910d5fd21544c7d1022 plugins/generic/misc.py
215215
b1d2a7f3170f9b69e71335aa47f9b08b plugins/generic/search.py
216216
a70cc0ada4b0cc9e7df23cb6d48a4a0c plugins/generic/syntax.py
217-
e522c294676ede15bee751107e9bb449 plugins/generic/takeover.py
217+
4adc07051b727f1525cf0a2d619221f8 plugins/generic/takeover.py
218218
4419b13a4b78d7e9e4a2632302344a1a plugins/generic/users.py
219219
1e5532ede194ac9c083891c2f02bca93 plugins/__init__.py
220220
5dc693e22f5d020c5c568d7325bd4226 shell/backdoors/backdoor.asp_

0 commit comments

Comments
 (0)