|
75 | 75 | from lib.core.enums import HTTP_HEADER |
76 | 76 | from lib.core.enums import HTTPMETHOD |
77 | 77 | from lib.core.enums import MOBILES |
| 78 | +from lib.core.enums import OPTION_TYPE |
78 | 79 | from lib.core.enums import PAYLOAD |
79 | 80 | from lib.core.enums import PRIORITY |
80 | 81 | from lib.core.enums import PROXY_TYPE |
|
120 | 121 | from lib.core.settings import PROBLEMATIC_CUSTOM_INJECTION_PATTERNS |
121 | 122 | from lib.core.settings import SITE |
122 | 123 | from lib.core.settings import SQLITE_ALIASES |
| 124 | +from lib.core.settings import SQLMAP_ENVIRONMENT_PREFIX |
123 | 125 | from lib.core.settings import SUPPORTED_DBMS |
124 | 126 | from lib.core.settings import SUPPORTED_OS |
125 | 127 | from lib.core.settings import SYBASE_ALIASES |
@@ -1823,16 +1825,16 @@ def _saveCmdline(): |
1823 | 1825 | datatype = datatype[0] |
1824 | 1826 |
|
1825 | 1827 | if value is None: |
1826 | | - if datatype == "boolean": |
| 1828 | + if datatype == OPTION_TYPE.BOOLEAN: |
1827 | 1829 | value = "False" |
1828 | | - elif datatype in ("integer", "float"): |
| 1830 | + elif datatype in (OPTION_TYPE.INTEGER, OPTION_TYPE.FLOAT): |
1829 | 1831 | if option in ("threads", "verbose"): |
1830 | 1832 | value = "1" |
1831 | 1833 | elif option == "timeout": |
1832 | 1834 | value = "10" |
1833 | 1835 | else: |
1834 | 1836 | value = "0" |
1835 | | - elif datatype == "string": |
| 1837 | + elif datatype == OPTION_TYPE.STRING: |
1836 | 1838 | value = "" |
1837 | 1839 |
|
1838 | 1840 | if isinstance(value, basestring): |
@@ -1903,6 +1905,37 @@ def _mergeOptions(inputOptions, overrideOptions): |
1903 | 1905 | if hasattr(conf, key) and conf[key] is None: |
1904 | 1906 | conf[key] = value |
1905 | 1907 |
|
| 1908 | + _ = {} |
| 1909 | + for key, value in os.environ.items(): |
| 1910 | + if key.upper().startswith(SQLMAP_ENVIRONMENT_PREFIX): |
| 1911 | + _[key[len(SQLMAP_ENVIRONMENT_PREFIX):].upper()] = value |
| 1912 | + |
| 1913 | + types_ = {} |
| 1914 | + for group in optDict.keys(): |
| 1915 | + types_.update(optDict[group]) |
| 1916 | + |
| 1917 | + for key in conf: |
| 1918 | + if key.upper() in _: |
| 1919 | + value = _[key.upper()] |
| 1920 | + |
| 1921 | + if types_[key] == OPTION_TYPE.BOOLEAN: |
| 1922 | + try: |
| 1923 | + value = bool(value) |
| 1924 | + except ValueError: |
| 1925 | + value = False |
| 1926 | + elif types_[key] == OPTION_TYPE.INTEGER: |
| 1927 | + try: |
| 1928 | + value = int(value) |
| 1929 | + except ValueError: |
| 1930 | + value = 0 |
| 1931 | + elif types_[key] == OPTION_TYPE.FLOAT: |
| 1932 | + try: |
| 1933 | + value = float(value) |
| 1934 | + except ValueError: |
| 1935 | + value = 0.0 |
| 1936 | + |
| 1937 | + conf[key] = value |
| 1938 | + |
1906 | 1939 | mergedOptions.update(conf) |
1907 | 1940 |
|
1908 | 1941 | def _setTrafficOutputFP(): |
|
0 commit comments