2013-02-14 15:32:17 +04:00
|
|
|
#!/usr/bin/env python
|
2008-10-15 19:38:22 +04:00
|
|
|
|
|
|
|
"""
|
2015-01-06 17:02:16 +03:00
|
|
|
Copyright (c) 2006-2015 sqlmap developers (http://sqlmap.org/)
|
2010-10-15 03:18:29 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
2008-10-15 19:38:22 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
from lib.core.data import logger
|
2009-06-11 19:01:48 +04:00
|
|
|
from lib.core.settings import IS_WIN
|
2009-04-22 15:48:07 +04:00
|
|
|
from lib.core.settings import PLATFORM
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2011-01-15 15:13:45 +03:00
|
|
|
_readline = None
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2011-01-15 15:13:45 +03:00
|
|
|
try:
|
2011-01-17 03:17:31 +03:00
|
|
|
from readline import *
|
2011-01-15 15:13:45 +03:00
|
|
|
import readline as _readline
|
2008-10-15 19:38:22 +04:00
|
|
|
except ImportError:
|
|
|
|
try:
|
2011-01-17 03:17:31 +03:00
|
|
|
from pyreadline import *
|
2011-01-15 15:13:45 +03:00
|
|
|
import pyreadline as _readline
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2011-01-15 15:13:45 +03:00
|
|
|
if IS_WIN and _readline:
|
2008-10-15 19:38:22 +04:00
|
|
|
try:
|
2011-01-15 15:13:45 +03:00
|
|
|
_outputfile = _readline.GetOutputFile()
|
2008-10-15 19:38:22 +04:00
|
|
|
except AttributeError:
|
2011-01-15 15:13:45 +03:00
|
|
|
debugMsg = "Failed GetOutputFile when using platform's "
|
2008-10-15 19:38:22 +04:00
|
|
|
debugMsg += "readline library"
|
|
|
|
logger.debug(debugMsg)
|
|
|
|
|
2011-01-15 15:13:45 +03:00
|
|
|
_readline = None
|
2008-10-15 19:38:22 +04:00
|
|
|
|
|
|
|
# Test to see if libedit is being used instead of GNU readline.
|
|
|
|
# Thanks to Boyd Waters for this patch.
|
|
|
|
uses_libedit = False
|
|
|
|
|
2011-01-15 15:13:45 +03:00
|
|
|
if PLATFORM == 'mac' and _readline:
|
2008-10-15 19:38:22 +04:00
|
|
|
import commands
|
|
|
|
|
2013-01-09 18:38:41 +04:00
|
|
|
(status, result) = commands.getstatusoutput("otool -L %s | grep libedit" % _readline.__file__)
|
2008-10-15 19:38:22 +04:00
|
|
|
|
|
|
|
if status == 0 and len(result) > 0:
|
|
|
|
# We are bound to libedit - new in Leopard
|
2011-01-15 15:13:45 +03:00
|
|
|
_readline.parse_and_bind("bind ^I rl_complete")
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2011-01-15 15:13:45 +03:00
|
|
|
debugMsg = "Leopard libedit detected when using platform's "
|
2008-10-15 19:38:22 +04:00
|
|
|
debugMsg += "readline library"
|
|
|
|
logger.debug(debugMsg)
|
|
|
|
|
|
|
|
uses_libedit = True
|
|
|
|
|
|
|
|
# the clear_history() function was only introduced in Python 2.4 and is
|
|
|
|
# actually optional in the readline API, so we must explicitly check for its
|
|
|
|
# existence. Some known platforms actually don't have it. This thread:
|
|
|
|
# http://mail.python.org/pipermail/python-dev/2003-August/037845.html
|
|
|
|
# has the original discussion.
|
2011-01-15 15:13:45 +03:00
|
|
|
if _readline:
|
2008-10-15 19:38:22 +04:00
|
|
|
try:
|
2011-01-15 15:13:45 +03:00
|
|
|
_readline.clear_history()
|
2008-10-15 19:38:22 +04:00
|
|
|
except AttributeError:
|
|
|
|
def clear_history():
|
|
|
|
pass
|
|
|
|
|
2011-01-15 15:13:45 +03:00
|
|
|
_readline.clear_history = clear_history
|