@@ -116,7 +116,36 @@ function extractVaultFromFile (data) {
116116 }
117117 }
118118
119- // attempt 6: chromium 000005.ldb on windows
119+ // attemp 6: When the backup file is not a valid json, it tries to extract the keyring controller object from the string.
120+ {
121+ const matches = data . match (
122+ / (?< = " K e y r i n g C o n t r o l l e r " : ) ( .* ?) (? = , " [ a - z A - z ] + " : { ) /
123+ ) ;
124+ if ( matches && matches . length ) {
125+ try {
126+ const keyringControllerStateFragment = matches [ 1 ] ;
127+ const dataRegex = / \\ " d a t a \\ " : \\ " ( [ A - Z a - z 0 - 9 + \/ ] * = * ) / u;
128+ const ivRegex = / , \\ " i v \\ " : \\ " ( [ A - Z a - z 0 - 9 + \/ ] { 10 , 40 } = * ) / u;
129+ const saltRegex = / , \\ " s a l t \\ " : \\ " ( [ A - Z a - z 0 - 9 + \/ ] { 10 , 100 } = * ) \\ " / ;
130+ const keyMetaRegex = / , \\ " k e y M e t a d a t a \\ " : ( .* } } ) / ;
131+
132+ const vaultParts = [ dataRegex , ivRegex , saltRegex , keyMetaRegex ]
133+ . map ( ( reg ) => keyringControllerStateFragment . match ( reg ) )
134+ . map ( ( match ) => match [ 1 ] ) ;
135+
136+ return {
137+ data : vaultParts [ 0 ] ,
138+ iv : vaultParts [ 1 ] ,
139+ salt : vaultParts [ 2 ] ,
140+ keyMetadata : JSON . parse ( vaultParts [ 3 ] . replaceAll ( "\\" , "" ) ) ,
141+ } ;
142+ } catch ( err ) {
143+ // Not valid JSON: continue
144+ }
145+ }
146+ }
147+
148+ // attempt 7: chromium 000005.ldb on windows
120149 const matchRegex = / K e y r i n g [ 0 - 9 ] [ ^ \} ] * ( \{ [ ^ \{ \} ] * \\ " \} ) / gu
121150 const captureRegex = / K e y r i n g [ 0 - 9 ] [ ^ \} ] * ( \{ [ ^ \{ \} ] * \\ " \} ) / u
122151 const ivRegex = / \\ " i v .{ 1 , 4 } [ ^ A - Z a - z 0 - 9 + \/ ] { 1 , 10 } ( [ A - Z a - z 0 - 9 + \/ ] { 10 , 40 } = * ) / u
0 commit comments