当前位置: 首页>>代码示例>>Python>>正文


Python settings.UNICODE_ENCODING属性代码示例

本文整理汇总了Python中lib.core.settings.UNICODE_ENCODING属性的典型用法代码示例。如果您正苦于以下问题:Python settings.UNICODE_ENCODING属性的具体用法?Python settings.UNICODE_ENCODING怎么用?Python settings.UNICODE_ENCODING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在lib.core.settings的用法示例。


在下文中一共展示了settings.UNICODE_ENCODING属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: escape

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def escape(expression, quote=True):
        """
        >>> Backend.setVersion('2')
        ['2']
        >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar")
        "SELECT 'abcdefgh' FROM foobar"
        >>> Backend.setVersion('3')
        ['3']
        >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar")
        "SELECT CAST(X'6162636465666768' AS TEXT) FROM foobar"
        """

        def escaper(value):
            # Reference: http://stackoverflow.com/questions/3444335/how-do-i-quote-a-utf-8-string-literal-in-sqlite3
            return "CAST(X'%s' AS TEXT)" % binascii.hexlify(value.encode(UNICODE_ENCODING) if isinstance(value, unicode) else value)

        retVal = expression

        if isDBMSVersionAtLeast('3'):
            retVal = Syntax._escape(expression, quote, escaper)

        return retVal 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:24,代码来源:syntax.py

示例2: setOutputFile

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def setOutputFile(self):
        '''
        Initiates the xml file from the configuration.
        '''
        if (conf.xmlFile):
            try:
                self._outputFile = conf.xmlFile
                self.__root = None

                if os.path.exists(self._outputFile):
                    try:
                        self.__doc = xml.dom.minidom.parse(self._outputFile)
                        self.__root = self.__doc.childNodes[0]
                    except ExpatError:
                        self.__doc = Document()

                self._outputFP = codecs.open(self._outputFile, "w+", UNICODE_ENCODING)

                if self.__root is None:
                    self.__root = self.__doc.createElementNS(NAME_SPACE_ATTR, RESULTS_ELEM_NAME)
                    self.__root.setAttributeNode(self._createAttribute(XMLNS_ATTR, NAME_SPACE_ATTR))
                    self.__root.setAttributeNode(self._createAttribute(SCHEME_NAME_ATTR, SCHEME_NAME))
                    self.__doc.appendChild(self.__root)
            except IOError:
                raise SqlmapFilePathException("Wrong filename provided for saving the xml file: %s" % conf.xmlFile) 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:27,代码来源:xmldump.py

示例3: profile

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
    """
    This will run the program and present profiling data in a nice looking graph
    """

    try:
        from thirdparty.gprof2dot import gprof2dot
        from thirdparty.xdot import xdot
        import gobject
        import gtk
        import pydot
    except ImportError, e:
        errMsg = "profiling requires third-party libraries (%s). " % getUnicode(e, UNICODE_ENCODING)
        errMsg += "Quick steps:%s" % os.linesep
        errMsg += "1) sudo apt-get install python-pydot python-pyparsing python-profiler graphviz"
        logger.error(errMsg)

        return 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:20,代码来源:profiling.py

示例4: write

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def write(self, fp):
        """
        Write an .ini-format representation of the configuration state.
        """

        if self._defaults:
            fp.write("[%s]\n" % DEFAULTSECT)

            for (key, value) in self._defaults.items():
                fp.write("%s = %s\n" % (key, getUnicode(value, UNICODE_ENCODING).replace('\n', '\n\t')))

            fp.write("\n")

        for section in self._sections:
            fp.write("[%s]\n" % section)

            for (key, value) in self._sections[section].items():
                if key != "__name__":
                    if value is None:
                        fp.write("%s\n" % (key))
                    else:
                        fp.write("%s = %s\n" % (key, getUnicode(value, UNICODE_ENCODING).replace('\n', '\n\t')))

            fp.write("\n") 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:26,代码来源:common.py

示例5: oracle_old_passwd

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def oracle_old_passwd(password, username, uppercase=True):  # prior to version '11g'
    """
    Reference(s):
        http://www.notesbit.com/index.php/scripts-oracle/oracle-11g-new-password-algorithm-is-revealed-by-seclistsorg/

    >>> oracle_old_passwd(password='tiger', username='scott', uppercase=True)
    'F894844C34402B67'
    """

    IV, pad = "\0" * 8, "\0"

    if isinstance(username, unicode):
        username = unicode.encode(username, UNICODE_ENCODING)  # pyDes has issues with unicode strings

    unistr = "".join("\0%s" % c for c in (username + password).upper())

    cipher = des(hexdecode("0123456789ABCDEF"), CBC, IV, pad)
    encrypted = cipher.encrypt(unistr)
    cipher = des(encrypted[-8:], CBC, IV, pad)
    encrypted = cipher.encrypt(unistr)

    retVal = hexencode(encrypted[-8:])

    return retVal.upper() if uppercase else retVal.lower() 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:26,代码来源:hash.py

示例6: finish

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def finish(self, resultStatus, resultMsg=""):
        '''
        Finishes the dumper operation:
        1. Adds the session status to the xml
        2. Writes the xml to the file
        3. Closes the xml file
        '''
        if ((self._outputFP is not None) and not(self._outputFP.closed)):
            statusElem = self.__doc.createElement(STATUS_ELEM_NAME)
            statusElem.setAttributeNode(self._createAttribute(SUCESS_ATTR, getUnicode(resultStatus)))

            if not resultStatus:
                errorElem = self.__doc.createElement(ERROR_ELEM_NAME)

                if isinstance(resultMsg, Exception):
                    errorElem.setAttributeNode(self._createAttribute(TYPE_ATTR, type(resultMsg).__name__))
                else:
                    errorElem.setAttributeNode(self._createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE))

                errorElem.appendChild(self._createTextNode(getUnicode(resultMsg)))
                statusElem.appendChild(errorElem)

            self._addToRoot(statusElem)
            self.__write(prettyprint.formatXML(self.__doc, encoding=UNICODE_ENCODING))
            self._outputFP.close() 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:27,代码来源:xmldump.py

示例7: safeExpandUser

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def safeExpandUser(filepath):
    """
    @function Patch for a Python Issue18171 (http://bugs.python.org/issue18171)
    """

    retVal = filepath

    try:
        retVal = os.path.expanduser(filepath)
    except UnicodeDecodeError:
        _ = locale.getdefaultlocale()
        retVal = getUnicode(os.path.expanduser(filepath.encode(_[1] if _ and len(_) > 1 else UNICODE_ENCODING)))

    return retVal

#打开文件夹并批量读取内容,以行为单位,可以自定义全部小写lowercase、是都采用有序列表unique 
开发者ID:zer0yu,项目名称:ZEROScan,代码行数:18,代码来源:common.py

示例8: postgres_passwd

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def postgres_passwd(password, username, uppercase=False):
    """
    Reference(s):
        http://pentestmonkey.net/blog/cracking-postgres-hashes/

    >>> postgres_passwd(password='testpass', username='testuser', uppercase=False)
    'md599e5ea7a6f7c3269995cba3927fd0093'
    """

    if isinstance(username, unicode):
        username = unicode.encode(username, UNICODE_ENCODING)

    if isinstance(password, unicode):
        password = unicode.encode(password, UNICODE_ENCODING)

    retVal = "md5%s" % md5(password + username).hexdigest()

    return retVal.upper() if uppercase else retVal.lower() 
开发者ID:sabri-zaki,项目名称:EasY_HaCk,代码行数:20,代码来源:hash.py

示例9: tamper

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def tamper(payload, **kwargs):
    """
    Base64 all characters in a given payload

    >>> tamper("1' AND SLEEP(5)#")
    'MScgQU5EIFNMRUVQKDUpIw=='
    """

    return base64.b64encode(payload.encode(UNICODE_ENCODING)) if payload else payload 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:11,代码来源:base64encode.py

示例10: connect

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def connect(self):
        self.initConnection()

        if not self.hostname:
            self.checkFileDb()

        try:
            self.connector = kinterbasdb.connect(host=self.hostname.encode(UNICODE_ENCODING), database=self.db.encode(UNICODE_ENCODING), \
                user=self.user.encode(UNICODE_ENCODING), password=self.password.encode(UNICODE_ENCODING), charset="UTF8")  # Reference: http://www.daniweb.com/forums/thread248499.html
        except kinterbasdb.OperationalError, msg:
            raise SqlmapConnectionException(msg[1]) 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:13,代码来源:connector.py

示例11: storeHashesToFile

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def storeHashesToFile(attack_dict):
    if not attack_dict:
        return

    if kb.storeHashesChoice is None:
        message = "do you want to store hashes to a temporary file "
        message += "for eventual further processing with other tools [y/N] "
        test = readInput(message, default="N")
        kb.storeHashesChoice = test[0] in ("y", "Y")

    if not kb.storeHashesChoice:
        return

    handle, filename = tempfile.mkstemp(prefix="sqlmaphashes-", suffix=".txt")
    os.close(handle)

    infoMsg = "writing hashes to a temporary file '%s' " % filename
    logger.info(infoMsg)

    items = set()

    with open(filename, "w+") as f:
        for user, hashes in attack_dict.items():
            for hash_ in hashes:
                hash_ = hash_.split()[0] if hash_ and hash_.strip() else hash_
                if hash_ and hash_ != NULL and hashRecognition(hash_):
                    item = None
                    if user and not user.startswith(DUMMY_USER_PREFIX):
                        item = "%s:%s\n" % (user.encode(UNICODE_ENCODING), hash_.encode(UNICODE_ENCODING))
                    else:
                        item = "%s\n" % hash_.encode(UNICODE_ENCODING)

                    if item and item not in items:
                        f.write(item)
                        items.add(item) 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:37,代码来源:hash.py

示例12: hashKey

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def hashKey(key):
        key = key.encode(UNICODE_ENCODING) if isinstance(key, unicode) else repr(key)
        retVal = int(hashlib.md5(key).hexdigest()[:12], 16)
        return retVal 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:6,代码来源:hashdb.py

示例13: stdoutencode

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def stdoutencode(data):
    retVal = None

    try:
        data = data or ""

        # Reference: http://bugs.python.org/issue1602
        if IS_WIN:
            output = data.encode(sys.stdout.encoding, "replace")

            if '?' in output and '?' not in data:
                warnMsg = "cannot properly display Unicode characters "
                warnMsg += "inside Windows OS command prompt "
                warnMsg += "(http://bugs.python.org/issue1602). All "
                warnMsg += "unhandled occurances will result in "
                warnMsg += "replacement with '?' character. Please, find "
                warnMsg += "proper character representation inside "
                warnMsg += "corresponding output files. "
                singleTimeWarnMessage(warnMsg)

            retVal = output
        else:
            retVal = data.encode(sys.stdout.encoding)
    except:
        retVal = data.encode(UNICODE_ENCODING) if isinstance(data, unicode) else data

    return retVal 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:29,代码来源:convert.py

示例14: _setResultsFile

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def _setResultsFile():
    """
    Create results file for storing results of running in a
    multiple target mode.
    """

    if not conf.multipleTargets:
        return

    if not conf.resultsFP:
        conf.resultsFilename = os.path.join(paths.SQLMAP_OUTPUT_PATH, time.strftime(RESULTS_FILE_FORMAT).lower())
        try:
            conf.resultsFP = openFile(conf.resultsFilename, "w+", UNICODE_ENCODING, buffering=0)
        except (OSError, IOError), ex:
            try:
                warnMsg = "unable to create results file '%s' ('%s'). " % (conf.resultsFilename, getUnicode(ex))
                conf.resultsFilename = tempfile.mkstemp(prefix="sqlmapresults-", suffix=".csv")[1]
                conf.resultsFP = openFile(conf.resultsFilename, "w+", UNICODE_ENCODING, buffering=0)
                warnMsg += "Using temporary file '%s' instead" % conf.resultsFilename
                logger.warn(warnMsg)
            except IOError, _:
                errMsg = "unable to write to the temporary directory ('%s'). " % _
                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"
                raise SqlmapSystemException(errMsg) 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:28,代码来源:target.py

示例15: __init__

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import UNICODE_ENCODING [as 别名]
def __init__(self, parent, name, columns=None, create=True, typeless=False):
            self.parent = parent
            self.name = unsafeSQLIdentificatorNaming(name)
            self.columns = columns
            if create:
                try:
                    self.execute('DROP TABLE IF EXISTS "%s"' % self.name)
                    if not typeless:
                        self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s" %s' % (unsafeSQLIdentificatorNaming(colname), coltype) for colname, coltype in self.columns)))
                    else:
                        self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s"' % unsafeSQLIdentificatorNaming(colname) for colname in self.columns)))
                except Exception, ex:
                    errMsg = "problem occurred ('%s') while initializing the sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
                    errMsg += "located at '%s'" % self.parent.dbpath
                    raise SqlmapGenericException(errMsg) 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:17,代码来源:replication.py


注:本文中的lib.core.settings.UNICODE_ENCODING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。