|
31 | 31 | from lib.core.common import parseTargetUrl |
32 | 32 | from lib.core.common import paths |
33 | 33 | from lib.core.common import randomRange |
| 34 | +from lib.core.common import readInput |
34 | 35 | from lib.core.common import runningAsAdmin |
35 | 36 | from lib.core.common import sanitizeStr |
36 | 37 | from lib.core.common import UnicodeRawConfigParser |
|
47 | 48 | from lib.core.exception import sqlmapMissingPrivileges |
48 | 49 | from lib.core.exception import sqlmapSyntaxException |
49 | 50 | from lib.core.exception import sqlmapUnsupportedDBMSException |
| 51 | +from lib.core.exception import sqlmapUserQuitException |
50 | 52 | from lib.core.optiondict import optDict |
| 53 | +from lib.core.priority import PRIORITY |
51 | 54 | from lib.core.settings import IS_WIN |
52 | 55 | from lib.core.settings import PLATFORM |
53 | 56 | from lib.core.settings import PYVERSION |
@@ -521,6 +524,11 @@ def __setTamperingFunctions(): |
521 | 524 | """ |
522 | 525 |
|
523 | 526 | if conf.tamper: |
| 527 | + last_priority = PRIORITY.LOWEST |
| 528 | + check_priority = True |
| 529 | + resolve_priorities = False |
| 530 | + priorities = [] |
| 531 | + |
524 | 532 | for tfile in conf.tamper.split(','): |
525 | 533 | found = False |
526 | 534 |
|
@@ -556,16 +564,41 @@ def __setTamperingFunctions(): |
556 | 564 | except ImportError, msg: |
557 | 565 | raise sqlmapSyntaxException, "can not import tamper script '%s' (%s)" % (filename[:-3], msg) |
558 | 566 |
|
| 567 | + priority = PRIORITY.NORMAL if not hasattr(module, '__priority__') else module.__priority__ |
| 568 | + |
559 | 569 | for name, function in inspect.getmembers(module, inspect.isfunction): |
560 | 570 | if name == "tamper" and function.func_code.co_argcount == 1: |
561 | 571 | kb.tamperFunctions.append(function) |
562 | 572 | found = True |
563 | 573 |
|
| 574 | + if check_priority and priority < last_priority: |
| 575 | + message = "it seems that you've probably " |
| 576 | + message += "mixed order of tamper scripts.\n" |
| 577 | + message += "do you want to auto resolve this? [Y/n/q]" |
| 578 | + test = readInput(message, default="Y") |
| 579 | + |
| 580 | + if not test or test[0] in ("y", "Y"): |
| 581 | + resolve_priorities = True |
| 582 | + elif test[0] in ("n", "N"): |
| 583 | + resolve_priorities = False |
| 584 | + elif test[0] in ("q", "Q"): |
| 585 | + raise sqlmapUserQuitException |
| 586 | + |
| 587 | + check_priority = False |
| 588 | + |
| 589 | + priorities.append((priority, function)) |
| 590 | + last_priority = priority |
564 | 591 | break |
565 | 592 |
|
566 | 593 | if not found: |
567 | 594 | raise sqlmapGenericException, "missing function 'tamper(value)' in tamper script '%s'" % tfile |
568 | 595 |
|
| 596 | + if resolve_priorities and priorities: |
| 597 | + priorities.sort() |
| 598 | + kb.tamperFunctions = [] |
| 599 | + for _, function in priorities: |
| 600 | + kb.tamperFunctions.append(function) |
| 601 | + |
569 | 602 | def __setThreads(): |
570 | 603 | if not isinstance(conf.threads, int) or conf.threads <= 0: |
571 | 604 | conf.threads = 1 |
|
0 commit comments