It requires dlls from Firefox package to work (freebl3.dll, mozglue.dll, nss3.dll, softokn3.dll).
Also requires at least cert9.db and key4.db profile files (taken from profile folder), to perform decryption of profile databases.
Profile databases are files like "cookies.sqlite", "places.sqlite", storing different things like browsing history, etc.
The encrypted strings from databases can be obtained by reading them in any way (using soft like SQLlitedatabaseBrowser or in-code, or even by opening in notepad, if so much lazy).
So generally this code can decrypt those strings, if they are not additionaly protected with master-password.
If master-password was used, it will be required (and some different code here).
Should work with any actual Firefox version.
I don't know for what someone may need it, maybe for some recovery in some cases. But let it be at least for experimental purposes ^^
Code: Select all
EnableExplicit
;{ NSS3 }
Structure SECItem
type.i
*Data
len.i
EndStructure
Global nss3Lib
PrototypeC PK11SDR_Decrypt(inp, out, None): Global PK11SDR_Decrypt.PK11SDR_Decrypt
PrototypeC NSS_Init(ProfilePath.p-utf8): Global NSS_Init.NSS_Init
; Initiates all the stuff used for decryption
; RETURN: true if all loaded OK, false else
Procedure NSSInit()
Protected Ret = 1
; this one is not used directly, but must be loaded for nss to work
ret & Bool(OpenLibrary(#PB_Any, "softokn3.dll"))
; load NSS
nss3Lib = OpenLibrary(#PB_Any, "nss3.dll")
ret & Bool(nss3Lib)
; Get functions
If IsLibrary(nss3Lib)
PK11SDR_Decrypt = GetFunction(nss3Lib, "PK11SDR_Decrypt")
NSS_Init = GetFunction(nss3Lib, "NSS_Init")
EndIf
ret & Bool(PK11SDR_Decrypt)
ret & Bool(NSS_Init)
ProcedureReturn ret
EndProcedure
;}
If NSSInit()
Else
MessageRequester("Init failed", "Cannot init libraries." + #CRLF$ + " Check If there are correct nss3.dll and softokn3.dll files present.", #PB_MessageRequester_Error)
End
EndIf
; init FF decryption
Define FirefoxProfilePath$ = "full_path_to_firefox_profile_folder"
Debug NSS_Init(FirefoxProfilePath$)
; first, perform base-64 decode of given data
Define *TD = AllocateMemory(2048)
Define DecodedLen = Base64Decoder("some_base64_encoded_string_from_firefox_db", *Td, 2048)
; put decoded data and it's size into SECitem
Define A.SECItem
A\Data = *TD
A\len = DecodedLen
; allocate output buffer
Define OUT.SECItem
; decrypt
Debug PK11SDR_Decrypt(A, OUT, 0)
; results
Debug PeekS(OUT\Data, OUT\len, #PB_UTF8)