mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-07-25 07:29:47 +03:00
Optimized imports on swipedown.py.
Working on integrating sql.py with webscrape to make it automated. Renamed errmsg variables to be reflective of their origin. Editor threw an error for each former errmsg variable.
This commit is contained in:
parent
de38351ce4
commit
cbb7847b37
279
sqlmap.py
279
sqlmap.py
|
@ -117,17 +117,17 @@ def checkEnvironment():
|
|||
try:
|
||||
os.path.isdir(modulePath())
|
||||
except UnicodeEncodeError:
|
||||
errMsg = "your system does not properly handle non-ASCII paths. "
|
||||
errMsg += "Please move the sqlmap's directory to the other location"
|
||||
logger.critical(errMsg)
|
||||
Uni_errMsg = '''your system does not properly handle non-ASCII paths. \n
|
||||
Please move the sqlmap's directory to the other location'''
|
||||
logger.critical(Uni_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
if LooseVersion(VERSION) < LooseVersion("1.0"):
|
||||
errMsg = "your runtime environment (e.g. PYTHONPATH) is "
|
||||
errMsg += "broken. Please make sure that you are not running "
|
||||
errMsg += "newer versions of sqlmap with runtime scripts for older "
|
||||
errMsg += "versions"
|
||||
logger.critical(errMsg)
|
||||
Loose_errMsg = '''your runtime environment (e.g. PYTHONPATH) is \n"
|
||||
broken. Please make sure that you are not running \n"
|
||||
newer versions of sqlmap with runtime scripts for older \n"
|
||||
versions'''
|
||||
logger.critical(Loose_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
# Patch for pip (import) environment
|
||||
|
@ -211,8 +211,8 @@ def main():
|
|||
crawl(target)
|
||||
except Exception as ex:
|
||||
if target and not isinstance(ex, SqlmapUserQuitException):
|
||||
errMsg = "problem occurred while crawling '%s' ('%s')" % (target, getSafeExString(ex))
|
||||
logger.error(errMsg)
|
||||
Quit_errMsg = "problem occurred while crawling '%s' ('%s')" % (target, getSafeExString(ex))
|
||||
logger.error(Quit_errMsg)
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
|
@ -224,16 +224,16 @@ def main():
|
|||
os._exitcode = 1
|
||||
|
||||
if "can't start new thread" in getSafeExString(ex):
|
||||
errMsg = "unable to start new threads. Please check OS (u)limits"
|
||||
logger.critical(errMsg)
|
||||
thread_errMsg = "unable to start new threads. Please check OS (u)limits"
|
||||
logger.critical(thread_errMsg)
|
||||
raise SystemExit
|
||||
else:
|
||||
raise
|
||||
|
||||
except SqlmapUserQuitException:
|
||||
if not conf.batch:
|
||||
errMsg = "user quit"
|
||||
logger.error(errMsg)
|
||||
user_errMsg = "user quit"
|
||||
logger.error(user_errMsg)
|
||||
|
||||
except (SqlmapSilentQuitException, bdb.BdbQuit):
|
||||
pass
|
||||
|
@ -242,8 +242,8 @@ def main():
|
|||
cmdLineOptions.sqlmapShell = False
|
||||
|
||||
except SqlmapBaseException as ex:
|
||||
errMsg = getSafeExString(ex)
|
||||
logger.critical(errMsg)
|
||||
base_errMsg = getSafeExString(ex)
|
||||
logger.critical(base_errMsg)
|
||||
|
||||
os._exitcode = 1
|
||||
|
||||
|
@ -258,182 +258,184 @@ def main():
|
|||
except EOFError:
|
||||
print()
|
||||
|
||||
errMsg = "exit"
|
||||
logger.error(errMsg)
|
||||
exit_errMsg = "exit"
|
||||
logger.error(exit_errMsg)
|
||||
|
||||
except SystemExit as ex:
|
||||
os._exitcode = ex.code or 0
|
||||
|
||||
except:
|
||||
print()
|
||||
errMsg = unhandledExceptionMessage()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Exception_errmsg = unhandledExceptionMessage()
|
||||
excMsg = traceback.format_exc()
|
||||
valid = checkIntegrity()
|
||||
|
||||
os._exitcode = 255
|
||||
|
||||
if any(_ in excMsg for _ in ("MemoryError", "Cannot allocate memory")):
|
||||
errMsg = "memory exhaustion detected"
|
||||
logger.critical(errMsg)
|
||||
mem_errMsg = "memory exhaustion detected"
|
||||
logger.critical(mem_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif any(_ in excMsg for _ in ("No space left", "Disk quota exceeded", "Disk full while accessing")):
|
||||
errMsg = "no space left on output device"
|
||||
logger.critical(errMsg)
|
||||
no_space_errMsg = "no space left on output device"
|
||||
logger.critical(no_space_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif any(_ in excMsg for _ in ("The paging file is too small",)):
|
||||
errMsg = "no space left for paging file"
|
||||
logger.critical(errMsg)
|
||||
page_small_errMsg = "no space left for paging file"
|
||||
logger.critical(page_small_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("Access is denied", "subprocess", "metasploit")):
|
||||
errMsg = "permission error occurred while running Metasploit"
|
||||
logger.critical(errMsg)
|
||||
no_root_errMsg = "permission error occurred while running Metasploit"
|
||||
logger.critical(no_root_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("Permission denied", "metasploit")):
|
||||
errMsg = "permission error occurred while using Metasploit"
|
||||
logger.critical(errMsg)
|
||||
permissions_errMsg = "permission error occurred while using Metasploit"
|
||||
logger.critical(permissions_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "Read-only file system" in excMsg:
|
||||
errMsg = "output device is mounted as read-only"
|
||||
logger.critical(errMsg)
|
||||
RO_errMsg = "output device is mounted as read-only"
|
||||
logger.critical(RO_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "Insufficient system resources" in excMsg:
|
||||
errMsg = "resource exhaustion detected"
|
||||
logger.critical(errMsg)
|
||||
no_ram_errMsg = "resource exhaustion detected"
|
||||
logger.critical(no_ram_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "OperationalError: disk I/O error" in excMsg:
|
||||
errMsg = "I/O error on output device"
|
||||
logger.critical(errMsg)
|
||||
IO_errMsg = "I/O error on output device"
|
||||
logger.critical(IO_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "Violation of BIDI" in excMsg:
|
||||
errMsg = "invalid URL (violation of Bidi IDNA rule - RFC 5893)"
|
||||
logger.critical(errMsg)
|
||||
BIDI_errMsg = "invalid URL (violation of Bidi IDNA rule - RFC 5893)"
|
||||
logger.critical(BIDI_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "Invalid IPv6 URL" in excMsg:
|
||||
errMsg = "invalid URL ('%s')" % excMsg.strip().split('\n')[-1]
|
||||
logger.critical(errMsg)
|
||||
bad_IPv6_errMsg = "invalid URL ('%s')" % excMsg.strip().split('\n')[-1]
|
||||
logger.critical(bad_IPv6_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "_mkstemp_inner" in excMsg:
|
||||
errMsg = "there has been a problem while accessing temporary files"
|
||||
logger.critical(errMsg)
|
||||
tmp_errMsg = "there has been a problem while accessing temporary files"
|
||||
logger.critical(tmp_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif any(_ in excMsg for _ in ("tempfile.mkdtemp", "tempfile.mkstemp", "tempfile.py")):
|
||||
errMsg = "unable to write to the temporary directory '%s'. " % tempfile.gettempdir()
|
||||
errMsg += "Please make sure that your disk is not full and "
|
||||
errMsg += "that you have sufficient write permissions to "
|
||||
errMsg += "create temporary files and/or directories"
|
||||
logger.critical(errMsg)
|
||||
temp_write_errMsg = '''unable to write to the temporary directory '%s'. " % tempfile.gettempdir() \n
|
||||
Please make sure that your disk is not full and \n
|
||||
that you have sufficient write permissions to \n
|
||||
create temporary files and/or directories'''
|
||||
logger.critical(temp_write_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "Permission denied: '" in excMsg:
|
||||
match = re.search(r"Permission denied: '([^']*)", excMsg)
|
||||
errMsg = "permission error occurred while accessing file '%s'" % match.group(1)
|
||||
logger.critical(errMsg)
|
||||
denied_errMsg = "permission error occurred while accessing file '%s'" % match.group(1)
|
||||
logger.critical(denied_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("twophase", "sqlalchemy")):
|
||||
errMsg = "please update the 'sqlalchemy' package (>= 1.1.11) "
|
||||
errMsg += "(Reference: 'https://qiita.com/tkprof/items/7d7b2d00df9c5f16fffe')"
|
||||
logger.critical(errMsg)
|
||||
update_errMsg = '''please update the 'sqlalchemy' package (>= 1.1.11) \n
|
||||
(Reference: 'https://qiita.com/tkprof/items/7d7b2d00df9c5f16fffe')'''
|
||||
logger.critical(update_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "invalid maximum character passed to PyUnicode_New" in excMsg and re.search(r"\A3\.[34]", sys.version) is not None:
|
||||
errMsg = "please upgrade the Python version (>= 3.5) "
|
||||
errMsg += "(Reference: 'https://bugs.python.org/issue18183')"
|
||||
logger.critical(errMsg)
|
||||
py_version_errMsg = '''please upgrade the Python version (>= 3.5) \n
|
||||
(Reference: 'https://bugs.python.org/issue18183')'''
|
||||
logger.critical(py_version_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("scramble_caching_sha2", "TypeError")):
|
||||
errMsg = "please downgrade the 'PyMySQL' package (=< 0.8.1) "
|
||||
errMsg += "(Reference: 'https://github.com/PyMySQL/PyMySQL/issues/700')"
|
||||
logger.critical(errMsg)
|
||||
PyMySQL_errMsg = '''please downgrade the 'PyMySQL' package (=< 0.8.1) \n
|
||||
(Reference: 'https://github.com/PyMySQL/PyMySQL/issues/700')'''
|
||||
logger.critical(PyMySQL_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "must be pinned buffer, not bytearray" in excMsg:
|
||||
errMsg = "error occurred at Python interpreter which "
|
||||
errMsg += "is fixed in 2.7. Please update accordingly "
|
||||
errMsg += "(Reference: 'https://bugs.python.org/issue8104')"
|
||||
logger.critical(errMsg)
|
||||
buffer_pin_errMsg = '''error occurred at Python interpreter which \n
|
||||
is fixed in 2.7. Please update accordingly \n
|
||||
(Reference: 'https://bugs.python.org/issue8104')'''
|
||||
logger.critical(buffer_pin_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("OSError: [Errno 22] Invalid argument: '", "importlib")):
|
||||
errMsg = "unable to read file '%s'" % extractRegexResult(r"OSError: \[Errno 22\] Invalid argument: '(?P<result>[^']+)", excMsg)
|
||||
logger.critical(errMsg)
|
||||
importlib_errMsg = "unable to read file '%s'" % extractRegexResult(r"OSError: \[Errno 22\] Invalid argument: '(?P<result>[^']+)", excMsg)
|
||||
logger.critical(importlib_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "hash_randomization" in excMsg:
|
||||
errMsg = "error occurred at Python interpreter which "
|
||||
errMsg += "is fixed in 2.7.3. Please update accordingly "
|
||||
errMsg += "(Reference: 'https://docs.python.org/2/library/sys.html')"
|
||||
logger.critical(errMsg)
|
||||
hash_random_errMsg = '''error occurred at Python interpreter which \n
|
||||
is fixed in 2.7.3. Please update accordingly \n
|
||||
(Reference: 'https://docs.python.org/2/library/sys.html')'''
|
||||
logger.critical(hash_random_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "AttributeError: unable to access item" in excMsg and re.search(r"3\.11\.\d+a", sys.version):
|
||||
errMsg = "there is a known issue when sqlmap is run with ALPHA versions of Python 3.11. "
|
||||
errMsg += "Please downgrade to some stable Python version"
|
||||
logger.critical(errMsg)
|
||||
alpha_errMsg = '''there is a known issue when sqlmap is run with ALPHA versions of Python 3.11. \n
|
||||
Please downgrade to some stable Python version.'''
|
||||
logger.critical(alpha_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("Resource temporarily unavailable", "os.fork()", "dictionaryAttack")):
|
||||
errMsg = "there has been a problem while running the multiprocessing hash cracking. "
|
||||
errMsg += "Please rerun with option '--threads=1'"
|
||||
logger.critical(errMsg)
|
||||
no_dict_attack_errMsg = '''there has been a problem while running the multiprocessing hash cracking. "
|
||||
Please rerun with option '--threads=1' '''
|
||||
logger.critical(no_dict_attack_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "can't start new thread" in excMsg:
|
||||
errMsg = "there has been a problem while creating new thread instance. "
|
||||
errMsg += "Please make sure that you are not running too many processes"
|
||||
new_thread_errMsg = '''there has been a problem while creating new thread instance. \n
|
||||
Please make sure that you are not running too many processes'''
|
||||
if not IS_WIN:
|
||||
errMsg += " (or increase the 'ulimit -u' value)"
|
||||
logger.critical(errMsg)
|
||||
new_thread_errMsg += " (or increase the 'ulimit -u' value)"
|
||||
logger.critical(new_thread_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "can't allocate read lock" in excMsg:
|
||||
errMsg = "there has been a problem in regular socket operation "
|
||||
errMsg += "('%s')" % excMsg.strip().split('\n')[-1]
|
||||
logger.critical(errMsg)
|
||||
new_line = '\n'
|
||||
socket_errMsg = f'''there has been a problem in regular socket operation "
|
||||
{'%s' % excMsg.strip().split(new_line)[-1]}'''
|
||||
logger.critical(socket_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("pymysql", "configparser")):
|
||||
errMsg = "wrong initialization of 'pymsql' detected (using Python3 dependencies)"
|
||||
logger.critical(errMsg)
|
||||
pymsql_errMsg = "wrong initialization of 'pymsql' detected (using Python3 dependencies)"
|
||||
logger.critical(pymsql_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("ntlm", "socket.error, err", "SyntaxError")):
|
||||
errMsg = "wrong initialization of 'python-ntlm' detected (using Python2 syntax)"
|
||||
logger.critical(errMsg)
|
||||
python_ntlm_errMsg = "wrong initialization of 'python-ntlm' detected (using Python2 syntax)"
|
||||
logger.critical(python_ntlm_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("drda", "to_bytes")):
|
||||
errMsg = "wrong initialization of 'drda' detected (using Python3 syntax)"
|
||||
logger.critical(errMsg)
|
||||
drda_errMsg = "wrong initialization of 'drda' detected (using Python3 syntax)"
|
||||
logger.critical(drda_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "'WebSocket' object has no attribute 'status'" in excMsg:
|
||||
errMsg = "wrong websocket library detected"
|
||||
errMsg += " (Reference: 'https://github.com/sqlmapproject/sqlmap/issues/4572#issuecomment-775041086')"
|
||||
logger.critical(errMsg)
|
||||
websocket_errMsg = '''wrong websocket library detected"
|
||||
(Reference: 'https://github.com/sqlmapproject/sqlmap/issues/4572#issuecomment-775041086')'''
|
||||
logger.critical(websocket_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("window = tkinter.Tk()",)):
|
||||
errMsg = "there has been a problem in initialization of GUI interface "
|
||||
errMsg += "('%s')" % excMsg.strip().split('\n')[-1]
|
||||
logger.critical(errMsg)
|
||||
new_line = '\n'
|
||||
GUI_errMsg = f'''there has been a problem in initialization of GUI interface \n
|
||||
{'%s' % excMsg.strip().split(new_line)[-1]}'''
|
||||
logger.critical(GUI_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif any(_ in excMsg for _ in ("unable to access item 'liveTest'",)):
|
||||
errMsg = "detected usage of files from different versions of sqlmap"
|
||||
logger.critical(errMsg)
|
||||
livetest_errMsg = "detected usage of files from different versions of sqlmap"
|
||||
logger.critical(livetest_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif kb.get("dumpKeyboardInterrupt"):
|
||||
|
@ -443,10 +445,10 @@ def main():
|
|||
raise SystemExit
|
||||
|
||||
elif valid is False:
|
||||
errMsg = "code integrity check failed (turning off automatic issue creation). "
|
||||
errMsg += "You should retrieve the latest development version from official GitHub "
|
||||
errMsg += "repository at '%s'" % GIT_PAGE
|
||||
logger.critical(errMsg)
|
||||
integrity_errMsg = f'''code integrity check failed (turning off automatic issue creation). \n
|
||||
You should retrieve the latest development version from official GitHub \n
|
||||
repository at {'%s' % GIT_PAGE}'''
|
||||
logger.critical(integrity_errMsg)
|
||||
print()
|
||||
dataToStdout(excMsg)
|
||||
raise SystemExit
|
||||
|
@ -458,62 +460,65 @@ def main():
|
|||
raise SystemExit
|
||||
|
||||
elif any(_ in excMsg for _ in ("ImportError", "ModuleNotFoundError", "<frozen", "Can't find file for module", "SAXReaderNotAvailable", "source code string cannot contain null bytes", "No module named", "tp_name field", "module 'sqlite3' has no attribute 'OperationalError'")):
|
||||
errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip()
|
||||
logger.critical(errMsg)
|
||||
module_bad_runtime_errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip()
|
||||
logger.critical(module_bad_runtime_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("SyntaxError: Non-ASCII character", ".py on line", "but no encoding declared")):
|
||||
errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip()
|
||||
logger.critical(errMsg)
|
||||
non_ascii_errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip()
|
||||
logger.critical(non_ascii_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("PermissionError: [WinError 5]", "multiprocessing")):
|
||||
errMsg = "there is a permission problem in running multiprocessing on this system. "
|
||||
errMsg += "Please rerun with '--disable-multi'"
|
||||
logger.critical(errMsg)
|
||||
win_error_5_errMsg = f'''there is a permission problem in running multiprocessing on this system. \n
|
||||
Please rerun with '--disable-multi' '''
|
||||
logger.critical(win_error_5_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("No such file", "_'")):
|
||||
errMsg = "corrupted installation detected ('%s'). " % excMsg.strip().split('\n')[-1]
|
||||
errMsg += "You should retrieve the latest development version from official GitHub "
|
||||
errMsg += "repository at '%s'" % GIT_PAGE
|
||||
logger.critical(errMsg)
|
||||
new_line = '\n'
|
||||
corrupt_install_errMsg = f'''corrupted installation detected {'%s' % excMsg.strip().split(new_line)[-1]}. \n
|
||||
You should retrieve the latest development version from official GitHub "
|
||||
repository at {'%s' % GIT_PAGE}'''
|
||||
logger.critical(corrupt_install_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("No such file", "sqlmap.conf", "Test")):
|
||||
errMsg = "you are trying to run (hidden) development tests inside the production environment"
|
||||
logger.critical(errMsg)
|
||||
sqlmap_conf_errMsg = "you are trying to run (hidden) development tests inside the production environment"
|
||||
logger.critical(sqlmap_conf_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif all(_ in excMsg for _ in ("HTTPNtlmAuthHandler", "'str' object has no attribute 'decode'")):
|
||||
errMsg = "package 'python-ntlm' has a known compatibility issue with the "
|
||||
errMsg += "Python 3 (Reference: 'https://github.com/mullender/python-ntlm/pull/61')"
|
||||
logger.critical(errMsg)
|
||||
HTTPNtlmAuthHandler_errMsg = '''package 'python-ntlm' has a known compatibility issue with the \n
|
||||
Python 3 (Reference: 'https://github.com/mullender/python-ntlm/pull/61')'''
|
||||
logger.critical(HTTPNtlmAuthHandler_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "'DictObject' object has no attribute '" in excMsg and all(_ in errMsg for _ in ("(fingerprinted)", "(identified)")):
|
||||
errMsg = "there has been a problem in enumeration. "
|
||||
errMsg += "Because of a considerable chance of false-positive case "
|
||||
errMsg += "you are advised to rerun with switch '--flush-session'"
|
||||
logger.critical(errMsg)
|
||||
elif "'DictObject' object has no attribute '" in excMsg and all(_ in Exception_errmsg for _ in ("(fingerprinted)", "(identified)")):
|
||||
dictobject_errMsg = '''there has been a problem in enumeration. \n
|
||||
Because of a considerable chance of false-positive case \n
|
||||
you are advised to rerun with switch '--flush-session' '''
|
||||
logger.critical(dictobject_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "database disk image is malformed" in excMsg:
|
||||
errMsg = "local session file seems to be malformed. Please rerun with '--flush-session'"
|
||||
logger.critical(errMsg)
|
||||
bad_session_errMsg = "local session file seems to be malformed. Please rerun with '--flush-session'"
|
||||
logger.critical(bad_session_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "AttributeError: 'module' object has no attribute 'F_GETFD'" in excMsg:
|
||||
errMsg = "invalid runtime (\"%s\") " % excMsg.split("Error: ")[-1].strip()
|
||||
errMsg += "(Reference: 'https://stackoverflow.com/a/38841364' & 'https://bugs.python.org/issue24944#msg249231')"
|
||||
logger.critical(errMsg)
|
||||
F_GETFD_errMsg = f'''invalid runtime {'%s' % excMsg.split("Error: ")[-1].strip()} \n
|
||||
(Reference: \n
|
||||
'https://stackoverflow.com/a/38841364' &\n
|
||||
'https://bugs.python.org/issue24944#msg249231')'''
|
||||
logger.critical(F_GETFD_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif "bad marshal data (unknown type code)" in excMsg:
|
||||
match = re.search(r"\s*(.+)\s+ValueError", excMsg)
|
||||
errMsg = "one of your .pyc files are corrupted%s" % (" ('%s')" % match.group(1) if match else "")
|
||||
errMsg += ". Please delete .pyc files on your system to fix the problem"
|
||||
logger.critical(errMsg)
|
||||
bad_marshal_errMsg = f'''one of your .pyc files are corrupted{'%s' % (" ('%s')" % match.group(1) if match else "")}. \n
|
||||
Please delete .pyc files on your system to fix the problem.'''
|
||||
logger.critical(bad_marshal_errMsg)
|
||||
raise SystemExit
|
||||
|
||||
for match in re.finditer(r'File "(.+?)", line', excMsg):
|
||||
|
@ -530,15 +535,15 @@ def main():
|
|||
file_ = re.sub(r"/{2,}", '/', file_)
|
||||
excMsg = excMsg.replace(match.group(1), file_)
|
||||
|
||||
errMsg = maskSensitiveData(errMsg)
|
||||
api_errMsg = maskSensitiveData(errMsg)
|
||||
excMsg = maskSensitiveData(excMsg)
|
||||
|
||||
if conf.get("api") or not valid:
|
||||
logger.critical("%s\n%s" % (errMsg, excMsg))
|
||||
logger.critical("%s\n%s" % (api_errMsg, excMsg))
|
||||
else:
|
||||
logger.critical(errMsg)
|
||||
logger.critical(api_errMsg)
|
||||
dataToStdout("%s\n" % setColor(excMsg.strip(), level=logging.CRITICAL))
|
||||
createGithubIssue(errMsg, excMsg)
|
||||
createGithubIssue(api_errMsg, excMsg)
|
||||
|
||||
finally:
|
||||
kb.threadContinue = False
|
||||
|
@ -575,8 +580,8 @@ def main():
|
|||
with openFile(conf.harFile, "w+b") as f:
|
||||
json.dump(conf.httpCollector.obtain(), fp=f, indent=4, separators=(',', ': '))
|
||||
except SqlmapBaseException as ex:
|
||||
errMsg = getSafeExString(ex)
|
||||
logger.critical(errMsg)
|
||||
base_errMsg = getSafeExString(ex)
|
||||
logger.critical(base_errMsg)
|
||||
|
||||
if conf.get("api"):
|
||||
conf.databaseCursor.disconnect()
|
||||
|
@ -603,12 +608,12 @@ if __name__ == "__main__":
|
|||
pass
|
||||
except SystemExit:
|
||||
raise
|
||||
except:
|
||||
except IOError:
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
# Reference: http://stackoverflow.com/questions/1635080/terminate-a-multi-thread-python-program
|
||||
if threading.active_count() > 1:
|
||||
os._exit(getattr(os, "_exitcode", 0))
|
||||
sys.exit(getattr(os, "_exitcode", 0))
|
||||
else:
|
||||
sys.exit(getattr(os, "_exitcode", 0))
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user