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


Python string.letters方法代码示例

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


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

示例1: __forgePacket

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def __forgePacket(self):
        '''
        Forge the malicious NetprPathCompare packet

        Reference: http://msdn.microsoft.com/en-us/library/cc247259.aspx

        long NetprPathCompare(
          [in, string, unique] SRVSVC_HANDLE ServerName,
          [in, string] WCHAR* PathName1,
          [in, string] WCHAR* PathName2,
          [in] DWORD PathType,
          [in] DWORD Flags
        );
        '''

        self.__path = ''.join([choice(letters) for _ in xrange(0, 3)])

        self.__request  = ndr_unique(pointer_value=0x00020000, data=ndr_wstring(data='')).serialize()
        self.__request += ndr_wstring(data='\\%s\\..\\%s' % ('A'*5, self.__path)).serialize()
        self.__request += ndr_wstring(data='\\%s' % self.__path).serialize()
        self.__request += ndr_long(data=1).serialize()
        self.__request += ndr_long(data=0).serialize() 
开发者ID:SECFORCE,项目名称:sparta,代码行数:24,代码来源:ms08-067_check.py

示例2: __executeRemote

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def __executeRemote(self, data):
        self.__tmpServiceName = ''.join([random.choice(string.letters) for _ in range(8)]).encode('utf-16le')
        command = self.__shell + 'echo ' + data + ' ^> ' + self.__output + ' > ' + self.__batchFile + ' & ' + \
                  self.__shell + self.__batchFile
        command += ' & ' + 'del ' + self.__batchFile

        self.__serviceDeleted = False
        resp = scmr.hRCreateServiceW(self.__scmr, self.__scManagerHandle, self.__tmpServiceName, self.__tmpServiceName,
                                     lpBinaryPathName=command)
        service = resp['lpServiceHandle']
        try:
           scmr.hRStartServiceW(self.__scmr, service)
        except:
           pass
        scmr.hRDeleteService(self.__scmr, service)
        self.__serviceDeleted = True
        scmr.hRCloseServiceHandle(self.__scmr, service) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:19,代码来源:secretsdump.py

示例3: auto_inject_phpfile

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def auto_inject_phpfile(self, filename, webshell_content):
        Log.info("Auto injecting : [%s] => [%s]" % (filename, repr(webshell_content)))
        Log.info("Code : [%s]" % (repr(webshell_content)))
        Log.info("Length : [%d]" % (len(webshell_content)))
        Log.info("Getting writable dirs...")
        writable_dirs = self.get_writable_directory()
        urls = []
        if len(writable_dirs) == 0:
            Log.error("No writable dirs...")
            return False
        else:
            for writable_dir in writable_dirs:
                writable_dir += "/"
                filename = ".%s.php" % (random_string(16, string.letters + string.digits))
                Log.info("Writing [%s] into : [%s]" % (repr(webshell_content), writable_dir))
                php_code = "file_put_contents('%s',base64_decode('%s'));" % ("%s/%s" % (writable_dir, filename), webshell_content.encode("base64").replace("\n",""))
                self.php_code_exec(php_code)
                base_url = "%s%s" % ("".join(["%s/" % (i) for i in self.url.split("/")[0:3]]), writable_dir.replace("%s" % (self.webroot), ""))
                webshell_url = ("%s%s" % (base_url, filename)).replace("//", "/").replace("https:/", "https://").replace("http:/", "http://")
                with open("Webshell.txt", "a+") as f:
                    log_content = "%s => %s\n" % (webshell_url, repr(webshell_content))
                    f.write(log_content)
                urls.append(webshell_url)
        return urls 
开发者ID:WangYihang,项目名称:Webshell-Sniper,代码行数:26,代码来源:WebShell.py

示例4: run

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def run(self, m_cmd, t_cmd, r_path, timeout):
        """
        Main thread for testing, will do clean up afterwards
        """
        pid_file = "/tmp/pid_file_%s" % "".join(random.sample(string.letters,
                                                              4))
        monitor = threading.Thread(target=self.monitor_thread, args=(m_cmd,
                                                                     pid_file, r_path))
        test_runner = threading.Thread(target=self.test_thread, args=(m_cmd,
                                                                      t_cmd, pid_file))

        monitor.start()
        test_runner.start()
        monitor.join(timeout)
        if self.kill_thread_flag:
            self.thread_kill(m_cmd, pid_file)
            self.thread_kill(t_cmd, pid_file)
            self.kill_thread_flag = False 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:20,代码来源:cmd_runner.py

示例5: url_validator

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def url_validator(key, data, errors, context):
    ''' Checks that the provided value (if it is present) is a valid URL '''
    import urlparse
    import string

    model = context['model']
    session = context['session']

    url = data.get(key, None)
    if not url:
        return

    pieces = urlparse.urlparse(url)
    if all([pieces.scheme, pieces.netloc]) and \
       set(pieces.netloc) <= set(string.letters + string.digits + '-.') and \
       pieces.scheme in ['http', 'https']:
       return

    errors[key].append(_('Please provide a valid URL')) 
开发者ID:italia,项目名称:daf-recipes,代码行数:21,代码来源:validators.py

示例6: is_base64_encoded

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def is_base64_encoded(sample):
   '''
   Check if a sample is likely base64-encoded
   
   sample - (string) The sample to evaluate
   '''
   base64chars = string.letters + string.digits + string.whitespace
   base64chars += '/+='
   # Turns out a lot of crazy things will b64-decode happily with
   # sample.decode('base64'). This is the fix.
   if any([char not in base64chars for char in sample]):
      return False
   try:
      sample.decode('base64')
      return True
   except:
      return False 
开发者ID:nccgroup,项目名称:featherduster,代码行数:19,代码来源:helpers.py

示例7: ping

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def ping(self, user, text = None):
        """
        Measure round-trip delay to another IRC client.
        """
        if self._pings is None:
            self._pings = {}

        if text is None:
            chars = string.letters + string.digits + string.punctuation
            key = ''.join([random.choice(chars) for i in range(12)])
        else:
            key = str(text)
        self._pings[(user, key)] = time.time()
        self.ctcpMakeQuery(user, [('PING', key)])

        if len(self._pings) > self._MAX_PINGRING:
            # Remove some of the oldest entries.
            byValue = [(v, k) for (k, v) in self._pings.items()]
            byValue.sort()
            excess = self._MAX_PINGRING - len(self._pings)
            for i in xrange(excess):
                del self._pings[byValue[i][1]] 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:irc.py

示例8: readColor

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def readColor(text):
    """Read color names or tuples, RGB or CMYK, and return a Color object."""
    if not text:
        return None
    from reportlab.lib import colors
    from string import letters
    if text[0] in letters:
        return colors.__dict__[text]
    tup = lengthSequence(text)

    msg = "Color tuple must have 3 (or 4) elements for RGB (or CMYC)."
    assert 3 <= len(tup) <= 4, msg
    msg = "Color tuple must have all elements <= 1.0."
    for i in range(len(tup)):
        assert tup[i] <= 1.0, msg

    if len(tup) == 3:
        colClass = colors.Color
    elif len(tup) == 4:
        colClass = colors.CMYKColor
    return colClass(*tup) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:para.py

示例9: _translate_db

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def _translate_db(db, name = None):
    return {
        "name": name if name is not None else ("random_%s" % "".join(random.choice(string.letters + string.digits) for _ in range(32))),
        "architecture": {
            "type": db.architecture_name,
            "size": {32: "b32", 64: "b64"}[db.architecture_bits],
            "endian": {"little": "le", "big": "be"}[db.architecture_endianness],
        },
        "functions": [{
            "name": func.name,
            "id": func.entry_point,
            "call": func.calls,
            "api": func.apis,
            "sea": func.entry_point,
            "see": max(chunk.end for chunk in func.chunks),
            "blocks": [{
                "id": bb.id,
                "sea": bb.start + (1 if bb.thumb else 0),
                "eea": bb.end,
                "name": bb.name,
                "bytes": "".join("%02x" % ord(x) for x in bb.bytes),
                "dat": dict((hd.address, "".join("%02x" % ord(y) for y in db.get_bytes(hd.data_refs[0], hd.data_refs[0] + 8))) \
                        for hd in bb.code_heads if len(hd.data_refs) >= 1 and db.get_bytes(hd.data_refs[0], hd.data_refs[0] + 8) is not None),
                "src": [("0x%X" % hd.address, hd.disassembly.split()[0]) + tuple(op["opnd"] for op in hd.data["operands"]) \
                        for hd in bb.code_heads if hd.mnemonic != ""],
                "call": [succ.id for succ in bb.successors]} for bb in func.basic_blocks],
        } for func in db.functions],
    } 
开发者ID:Cisco-Talos,项目名称:BASS,代码行数:30,代码来源:kamino.py

示例10: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def __init__(self, length):

        self.string = ''.join(random.choice(string.letters) for _ in xrange(length))
        self.fitness = -1 
开发者ID:tmsquill,项目名称:simple-ga,代码行数:6,代码来源:simple-ga.py

示例11: mutation

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def mutation(agents):

    for agent in agents:

        for idx, param in enumerate(agent.string):

            if random.uniform(0.0, 1.0) <= 0.1:

                agent.string = agent.string[0:idx] + random.choice(string.letters) + agent.string[idx+1:in_str_len]

    return agents 
开发者ID:tmsquill,项目名称:simple-ga,代码行数:13,代码来源:simple-ga.py

示例12: gen_salt

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def gen_salt():
    salt = ''
    chars = string.letters + string.digits
    
    for i in range(5):
            salt += random.choice(chars)
            
    return salt 
开发者ID:elsigh,项目名称:browserscope,代码行数:10,代码来源:utils.py

示例13: get_boundary_and_content

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def get_boundary_and_content(self):
    """Returns the message boundary and entire content body for the form."""
    boundary = '----=' + ''.join(random.choice(string.letters + string.digits)
                                 for _ in range(25))
    s = cStringIO.StringIO()

    for name, value, sub_type in self._data:
      s.write('--%s\r\n' % boundary)
      s.write('Content-Type: text/%s; charset="UTF-8"\r\n' % sub_type)
      s.write('Content-Disposition: form-data; name="%s"\r\n' % name)
      s.write('\r\n')
      s.write('%s\r\n' % value.encode('utf-8'))
    s.write('--%s--\r\n' % boundary)
    return boundary, s.getvalue() 
开发者ID:elsigh,项目名称:browserscope,代码行数:16,代码来源:xmpp_request_handler.py

示例14: test_loom_guess_schema_nominal

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def test_loom_guess_schema_nominal():
    """Test to make sure that LoomBackend handles the case where the user
    provides a nominal variable with more than 256 distinct values. In this
    case, Loom automatically specifies the unbounded_nominal type.
    """
    with tempdir('bayeslite-loom') as loom_store_path:
        with bayesdb_open(':memory:') as bdb:
            bayesdb_register_backend(bdb,
                LoomBackend(loom_store_path=loom_store_path))
            bdb.sql_execute('create table t (v)')
            vals_to_insert = []
            for i in xrange(300):
                word = ""
                for _j in xrange(20):
                    letter_index = bdb._prng.weakrandom_uniform(
                        len(string.letters))
                    word += string.letters[letter_index]
                vals_to_insert.append(word)
            for i in xrange(len(vals_to_insert)):
                bdb.sql_execute('''
                    insert into t (v) values (?)
                ''', (vals_to_insert[i],))

            bdb.execute('create population p for t (v nominal)')
            bdb.execute('create generator g for p using loom')
            bdb.execute('initialize 1 model for g')
            bdb.execute('analyze g for 50 iterations')
            bdb.execute('drop models from g')
            bdb.execute('drop generator g')
            bdb.execute('drop population p')
            bdb.execute('drop table t') 
开发者ID:probcomp,项目名称:bayeslite,代码行数:33,代码来源:test_loom_backend.py

示例15: GenPasswd1

# 需要导入模块: import string [as 别名]
# 或者: from string import letters [as 别名]
def GenPasswd1(len):
   passwd = ''
   chars = string.letters + string.digits
   for i in range(len):
      passwd = passwd + choice(chars)
   return passwd 
开发者ID:jose-delarosa,项目名称:sysadmin-tools,代码行数:8,代码来源:genpasswd.py


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