diff --git a/lib/core/option.py b/lib/core/option.py index 781d85e36..692d137d5 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1041,7 +1041,7 @@ def _setSocketPreConnect(): return def _(): - while kb.threadContinue and not conf.disablePrecon: + while kb.get("threadContinue") and not conf.get("disablePrecon"): try: for key in socket._ready: if len(socket._ready[key]) < SOCKET_PRE_CONNECT_QUEUE_SIZE: @@ -1776,6 +1776,17 @@ def _cleanupOptions(): threadData = getCurrentThreadData() threadData.reset() +def _cleanupEnvironment(): + """ + Cleanup environment (e.g. from leftovers after --sqlmap-shell). + """ + + if issubclass(urllib2.socket.socket, socks.socksocket): + socks.unwrapmodule(urllib2) + + if hasattr(socket, "_ready"): + socket._ready.clear() + def _dirtyPatches(): """ Place for "dirty" Python related patches @@ -2620,6 +2631,7 @@ def init(): _saveConfig() _setRequestFromFile() _cleanupOptions() + _cleanupEnvironment() _dirtyPatches() _purgeOutput() _checkDependencies()