Hello.
I would like to decrypt the logins.json file created by Firefox.
So I have picked a username out of my logins.json file to try it.
The code I actually have is the following:
Does anyone know how to do it or where I can find a code?
I would like to decrypt the logins.json file created by Firefox.
So I have picked a username out of my logins.json file to try it.
The code I actually have is the following:
Code
Option Strict On
Option Infer Off
Imports System.IO, System.Text.RegularExpressions, System.Runtime.InteropServices, System.Text
Module Module1
Sub Main()
Test()
Console.ReadKey()
End Sub
'Private Sub Readdata()
' Dim BasePat As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Mozilla\Firefox")
' Dim Paa As String = Path.Combine(BasePat, "profiles.ini")
' Dim LoginFile As String = String.Empty
' Using Sr As StreamReader = New StreamReader(Paa)
' LoginFile = Path.Combine(BasePat, Regex.Match(Sr.ReadToEnd, "Path=([^\s]+)").Groups(1).Value.Replace("/", "\"), "logins.json")
' End Using
' If Not File.Exists(LoginFile) Then Console.WriteLine("Datei existiert nicht!")
'End Sub
#Region "Decrypt"
Private Sub Test()
NSS_Init()
Dim Keyslot As Long = PK11_GetInternalKeySlot()
PK11_Authenticate(Keyslot, True, 0)
Dim tSecDec As New TSECItem()
Dim se As New StringBuilder("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECJzPAPMf8j23BAi0mf0nNAVlaQ==")
Dim hi2 As Integer = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se, se.Length)
Dim item As TSECItem = DirectCast(Marshal.PtrToStructure(New IntPtr(hi2), GetType(TSECItem)), TSECItem)
If PK11SDR_Decrypt(item, tSecDec, 0) = 0 AndAlso tSecDec.SECItemLen <> 0 Then
Dim bvRet As Byte() = New Byte(tSecDec.SECItemLen - 1) {}
Marshal.Copy(New IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen)
Console.WriteLine(String.Concat("Account : ", Encoding.ASCII.GetString(bvRet)))
End If
End Sub
<StructLayout(LayoutKind.Sequential)> Public Structure TSECItem
Public SECItemType, SECItemData, SECItemLen As Integer
End Structure
<DllImport("Kernel32.Dll")> Private Function LoadLibrary(dllFilePath As String) As IntPtr
End Function
Private NSS3 As IntPtr = IntPtr.Zero
<DllImport("Kernel32.Dll", CharSet:=CharSet.Ansi, ExactSpelling:=True, SetLastError:=True)> Private Function GetProcAddress(hModule As IntPtr, procName As String) As IntPtr
End Function
<UnmanagedFunctionPointer(CallingConvention.Cdecl)> Public Delegate Function DLLFunctionDelegate(configdir As String) As Long
Public Function NSS_Init() As Long
Dim Ppat As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Mozilla Firefox")
'LoadLibrary(Path.Combine(Ppat, "AccessibleMarshal.dll"))
'LoadLibrary(Path.Combine(Ppat, "breakpadinjector.dll"))
'LoadLibrary(Path.Combine(Ppat, "D3DCompiler_43.dll"))
'LoadLibrary(Path.Combine(Ppat, "d3dcompiler_46.dll"))
'LoadLibrary(Path.Combine(Ppat, "freebl3.dll"))
'LoadLibrary(Path.Combine(Ppat, "gkmedias.dll"))
'LoadLibrary(Path.Combine(Ppat, "icudt52.dll"))
'LoadLibrary(Path.Combine(Ppat, "icuin52.dll"))
'LoadLibrary(Path.Combine(Ppat, "icuuc52.dll"))
'LoadLibrary(Path.Combine(Ppat, "libEGL.dll"))
'LoadLibrary(Path.Combine(Ppat, "libGLESv2.dll"))
'LoadLibrary(Path.Combine(Ppat, "mozalloc.dll"))
LoadLibrary(Path.Combine(Ppat, "mozglue.dll"))
'LoadLibrary(Path.Combine(Ppat, "mozjs.dll"))
'LoadLibrary(Path.Combine(Ppat, "msvcp100.dll"))
'LoadLibrary(Path.Combine(Ppat, "msvcr100.dll"))
'LoadLibrary(Path.Combine(Ppat, "nssckbi.dll"))
'LoadLibrary(Path.Combine(Ppat, "nssdbm3.dll"))
'LoadLibrary(Path.Combine(Ppat, "softokn3.dll"))
'LoadLibrary(Path.Combine(Ppat, "xul.dll"))
NSS3 = LoadLibrary(Path.Combine(Ppat, "nss3.dll"))
Dim pProc As IntPtr = GetProcAddress(NSS3, "NSS_Init")
Dim dll As DLLFunctionDelegate = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate)), DLLFunctionDelegate)
Return dll(Ppat)
End Function
<UnmanagedFunctionPointer(CallingConvention.Cdecl)> Public Delegate Function DLLFunctionDelegate2() As Long
Public Function PK11_GetInternalKeySlot() As Long
Dim pProc As IntPtr = GetProcAddress(NSS3, "PK11_GetInternalKeySlot")
Dim dll As DLLFunctionDelegate2 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate2)), DLLFunctionDelegate2)
Return dll()
End Function
<UnmanagedFunctionPointer(CallingConvention.Cdecl)> Public Delegate Function DLLFunctionDelegate3(slot As Long, loadCerts As Boolean, wincx As Long) As Long
Public Function PK11_Authenticate(slot As Long, loadCerts As Boolean, wincx As Long) As Long
Dim pProc As IntPtr = GetProcAddress(NSS3, "PK11_Authenticate")
Dim dll As DLLFunctionDelegate3 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate3)), DLLFunctionDelegate3)
Return dll(slot, loadCerts, wincx)
End Function
<UnmanagedFunctionPointer(CallingConvention.Cdecl)> Public Delegate Function DLLFunctionDelegate4(arenaOpt As IntPtr, outItemOpt As IntPtr, inStr As StringBuilder, inLen As Integer) As Integer
Public Function NSSBase64_DecodeBuffer(arenaOpt As IntPtr, outItemOpt As IntPtr, inStr As StringBuilder, inLen As Integer) As Integer
Dim pProc As IntPtr = GetProcAddress(NSS3, "NSSBase64_DecodeBuffer")
Dim dll As DLLFunctionDelegate4 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate4)), DLLFunctionDelegate4)
Return dll(arenaOpt, outItemOpt, inStr, inLen)
End Function
<UnmanagedFunctionPointer(CallingConvention.Cdecl)> Public Delegate Function DLLFunctionDelegate5(ByRef data As TSECItem, ByRef result As TSECItem, cx As Integer) As Integer
Public Function PK11SDR_Decrypt(ByRef data As TSECItem, ByRef result As TSECItem, cx As Integer) As Integer
Dim pProc As IntPtr = GetProcAddress(NSS3, "PK11SDR_Decrypt")
Dim dll As DLLFunctionDelegate5 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate5)), DLLFunctionDelegate5)
Return dll(data, result, cx)
End Function
#End Region
End ModuleDoes anyone know how to do it or where I can find a code?
