コード例 #1
0
def get_linux_config(browser: str) -> dict:
    """Get the settings for Chrome/Chromium cookies on Linux.

    Args:
        browser: Either "Chrome" or "Chromium"
    Returns:
        Config dictionary for Chrome/Chromium cookie decryption

    """
    bus = secretstorage.dbus_init()
    collection = secretstorage.get_any_collection(bus)  ## login keyring
    # Verify supported browser, fail early otherwise
    if browser.lower() == "chrome":
        cookie_file = "~/.config/google-chrome/Default/Cookies"
    elif browser.lower() == "chromium":
        cookie_file = "~/.config/chromium/Default/Cookies"
    else:
        raise ValueError("Browser must be either Chrome or Chromium.")

    # Set the default linux password
    config = {
        "my_pass": "******",
        "iterations": 1,
        "cookie_file": cookie_file
    }
    if not collection.is_locked():
        label_to_check = f"{browser.capitalize()} Safe Storage"
        items1 = collection.get_all_items()
        for item in items1:
            if item.get_label() == label_to_check:
                config["my_pass"] = item.get_secret()
    else:
        print("keyring is locked")
        exit(1)
    return config
コード例 #2
0
ファイル: __init__.py プロジェクト: swipswaps/pytblocklib
    def get_linux_pass(self, cookie_file: str) -> bytes:
        """
        Adapted from 
        https://github.com/n8henrie/pycookiecheat/issues/27
        
        Get the settings for Chrome/Chromium cookies on Linux.

        Parameter:
            cookie_file: Path of cookie file
        Return:
            pass for decryption
        """
        bus = secretstorage.dbus_init()
        collection = secretstorage.get_any_collection(bus)  ## login keyring
        # Set the default linux password
        my_pass = "******".encode('utf-8')
        browser = ''
        if 'chrome' in cookie_file:
            browser = 'Chrome'
        elif 'chromium' in cookie_file:
            browser = 'Chromium'
        else:
            raise BrowserCookieError(
                'Browser cookie type is not supported.'
                'See and change the setting in config.ini.')
        if not collection.is_locked():
            label_to_check = f"{browser} Safe Storage"
            items1 = collection.get_all_items()
            for item in items1:
                if item.get_label() == label_to_check:
                    my_pass = item.get_secret()
        else:
            raise BrowserCookieError("keyring is locked")
        return my_pass
コード例 #3
0
ファイル: test_item.py プロジェクト: mitya57/secretstorage
	def setUp(self) -> None:
		self.connection = dbus_init()
		self.collection = get_any_collection(self.connection)
		self.created_timestamp = time.time()
		self.item = self.collection.create_item('My item', ATTRIBUTES,
			b'pa$$word')
		self.other_item = self.collection.create_item('My item',
			ATTRIBUTES, b'', content_type='data/null')
コード例 #4
0
ファイル: test_item.py プロジェクト: msabramo/secretstorage
	def setUpClass(cls):
		cls.bus = dbus_init(main_loop=False)
		cls.collection = get_any_collection(cls.bus)
		cls.created_timestamp = time.time()
		cls.item = cls.collection.create_item('My item', ATTRIBUTES,
			b'pa$$word')
		cls.other_item = cls.collection.create_item('My item',
			ATTRIBUTES, '', content_type='data/null')
コード例 #5
0
ファイル: test_item.py プロジェクト: zrhoffman/secretstorage
 def setUp(self) -> None:
     self.connection = dbus_init()
     self.collection = get_any_collection(self.connection)
     self.created_timestamp = time.time()
     self.item = self.collection.create_item('My item', ATTRIBUTES,
                                             b'pa$$word')
     self.other_item = self.collection.create_item('My item',
                                                   ATTRIBUTES,
                                                   b'',
                                                   content_type='data/null')
コード例 #6
0
 def setUpClass(cls):
     cls.bus = dbus_init(main_loop=False)
     cls.collection = get_any_collection(cls.bus)
     cls.created_timestamp = time.time()
     cls.item = cls.collection.create_item('My item', ATTRIBUTES,
                                           b'pa$$word')
     cls.other_item = cls.collection.create_item('My item',
                                                 ATTRIBUTES,
                                                 '',
                                                 content_type='data/null')
コード例 #7
0
ファイル: cookie.py プロジェクト: BhasherBEL/LDMv2
    def execute(self) -> bool:
        if not super().execute():
            return False

        bus = secretstorage.dbus_init()
        collection = secretstorage.get_any_collection(bus)  ## login keyring

        # Set the default linux password
        # https://github.com/n8henrie/pycookiecheat/issues/27
        my_pass = "******"
        if not collection.is_locked():
            poss = ['Chrome', 'Chromium']
            items1 = collection.get_all_items()
            for item in items1:
                for pos in poss:
                    if item.get_label() == f"{pos} Safe Storage":
                        my_pass = item.get_secret()

        enc_key = pbkdf2_hmac(hash_name='sha1',
                              password=my_pass.encode('utf8')
                              if type(my_pass) == str else my_pass,
                              salt=b'saltysalt',
                              iterations=1,
                              dklen=16)

        for profile in self.get_profiles():
            cookie_path = profile + '/Cookies'
            if os.path.isfile(cookie_path):
                self.log(profile.split('/')[-1] + ':')
                connection = sqlite3.connect(cookie_path)
                cursor = connection.cursor()
                try:
                    cursor.execute(
                        'SELECT host_key, name, value, encrypted_value FROM cookies'
                    )
                except sqlite3.OperationalError:
                    self.executenot(cookie_path + ' database is locked', 1)
                    return False

                self.log('url,name,value')
                for host_key, name, value, encrypted_value in cursor.fetchall(
                ):
                    self.log(host_key + ',' + name + ',' +
                             str(value if value else self.
                                 decrypt(encrypted_value, enc_key)))

        return True
コード例 #8
0
	def setUp(self) -> None:
		self.connection = dbus_init()
		self.collection = get_any_collection(self.connection)
コード例 #9
0
 def test_dbus_init_works_as_a_context_manager(self) -> None:
     with dbus_init() as connection:
         collection = get_any_collection(connection)
         self.assertIsNotNone(collection)
         label = collection.get_label()
         self.assertIsNotNone(label)
コード例 #10
0
 def setUp(self) -> None:
     self.connection = secretstorage.dbus_init()
     self.collection = secretstorage.get_any_collection(self.connection)
コード例 #11
0
	def setUpClass(cls):
		cls.bus = dbus_init(main_loop=False)
		cls.collection = get_any_collection(cls.bus)
コード例 #12
0
	def setUp(self) -> None:
		self.connection = secretstorage.dbus_init()
		self.collection = secretstorage.get_any_collection(self.connection)
コード例 #13
0
	def test_create_connection(self) -> None:
		with create_connection() as connection:
			collection = get_any_collection(connection)
			self.assertIsNotNone(collection)
			label = collection.get_label()
			self.assertIsNotNone(label)
コード例 #14
0
	def setUp(self) -> None:
		self.connection = dbus_init()
		self.collection = get_any_collection(self.connection)
コード例 #15
0
	def setUpClass(cls):
		cls.bus = secretstorage.dbus_init(main_loop=False)
		cls.collection = secretstorage.get_any_collection(cls.bus)
コード例 #16
0
 def test_closing_context_manager(self) -> None:
     with closing(dbus_init()) as connection:
         collection = get_any_collection(connection)
         self.assertIsNotNone(collection)
         label = collection.get_label()
         self.assertIsNotNone(label)
コード例 #17
0
 def setUpClass(cls):
     cls.bus = dbus_init(main_loop=False)
     cls.collection = get_any_collection(cls.bus)