Advertisement
Guest User

Untitled

a guest
Aug 7th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.05 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Runtime.InteropServices;
  4. using System.Data;
  5. using SQLiteWrapper;
  6. using System.Text;
  7.  
  8. namespace DarkSelFFDecryptor
  9. {
  10. //Firefox 3.5 and 3.6 Decryptor
  11. //Coded by DarkSel
  12. //Email and MSN: darksel.ltd@live.com
  13. //Websites:
  14. //http://www.leetcoders.org
  15. //Made January 30, 2010
  16.  
  17. //Credits to CodeProject for the SQLiteWrapper class
  18. //Shouts to Steve, Son1cBl4st, Farhan878, Fenimin, Aeonhack,
  19. //Albertino, JapaBrz, and all the other coders I grew up with!
  20.  
  21. //If you used this in your program, add me in the credits!
  22.  
  23. static class FFDecryptor
  24. {
  25. public class SHITEMID
  26. {
  27. public static long cb;
  28. public static byte[] abID;
  29. }
  30. [StructLayout(LayoutKind.Sequential)]
  31. public struct TSECItem
  32. {
  33. public int SECItemType;
  34. public int SECItemData;
  35. public int SECItemLen;
  36. }
  37.  
  38. [DllImport("kernel32.dll")]
  39. private static extern IntPtr LoadLibrary(string dllFilePath);
  40. static IntPtr NSS3;
  41. [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  42. static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
  43. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  44. public delegate long DLLFunctionDelegate(string configdir);
  45. public static long NSS_Init(string configdir)
  46. {
  47. string MozillaPath = Environment.GetEnvironmentVariable("PROGRAMFILES") + @"\Mozilla Firefox\";
  48. LoadLibrary(MozillaPath + "mozcrt19.dll");
  49. LoadLibrary(MozillaPath + "nspr4.dll");
  50. LoadLibrary(MozillaPath + "plc4.dll");
  51. LoadLibrary(MozillaPath + "plds4.dll");
  52. LoadLibrary(MozillaPath + "ssutil3.dll");
  53. LoadLibrary(MozillaPath + "sqlite3.dll");
  54. LoadLibrary(MozillaPath + "nssutil3.dll");
  55. LoadLibrary(MozillaPath + "softokn3.dll");
  56. NSS3 = LoadLibrary(MozillaPath + "nss3.dll");
  57. IntPtr pProc = GetProcAddress(NSS3, "NSS_Init");
  58. DLLFunctionDelegate dll = (DLLFunctionDelegate)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate));
  59. return dll(configdir);
  60. }
  61. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  62. public delegate long DLLFunctionDelegate2();
  63. public static long PK11_GetInternalKeySlot()
  64. {
  65. IntPtr pProc = GetProcAddress(NSS3, "PK11_GetInternalKeySlot");
  66. DLLFunctionDelegate2 dll = (DLLFunctionDelegate2)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate2));
  67. return dll();
  68. }
  69. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  70. public delegate long DLLFunctionDelegate3(long slot, bool loadCerts, long wincx);
  71. public static long PK11_Authenticate(long slot, bool loadCerts, long wincx)
  72. {
  73. IntPtr pProc = GetProcAddress(NSS3, "PK11_Authenticate");
  74. DLLFunctionDelegate3 dll = (DLLFunctionDelegate3)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate3));
  75. return dll(slot, loadCerts, wincx);
  76. }
  77. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  78. public delegate int DLLFunctionDelegate4(IntPtr arenaOpt,IntPtr outItemOpt, StringBuilder inStr, int inLen);
  79. public static int NSSBase64_DecodeBuffer(IntPtr arenaOpt, IntPtr outItemOpt, StringBuilder inStr, int inLen)
  80. {
  81. IntPtr pProc = GetProcAddress(NSS3, "NSSBase64_DecodeBuffer");
  82. DLLFunctionDelegate4 dll = (DLLFunctionDelegate4)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate4));
  83. return dll(arenaOpt, outItemOpt, inStr, inLen);
  84. }
  85. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  86. public delegate int DLLFunctionDelegate5(ref TSECItem data, ref TSECItem result, int cx);
  87. public static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx)
  88. {
  89. IntPtr pProc = GetProcAddress(NSS3, "PK11SDR_Decrypt");
  90. DLLFunctionDelegate5 dll = (DLLFunctionDelegate5)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate5));
  91. return dll(ref data, ref result, cx);
  92. }
  93. //PK11_GetInternalKeySlot
  94.  
  95. public static string signon;
  96. static void Main(string[] args)
  97. {
  98. Console.Title = "Firefox 3.5 & 3.6 Decryptor";
  99. Console.WriteLine("Firefox 3.5 & 3.6 Decryptor in C#");
  100. Console.WriteLine("Coded by DarkSel (darksel.ltd@live.com)");
  101. Console.WriteLine();
  102. bool FoundFile = false;
  103. long KeySlot = 0;
  104. string MozillaPath = Environment.GetEnvironmentVariable("PROGRAMFILES") + @"\Mozilla Firefox\";
  105. string DefaultPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles";
  106. string[] Dirs = Directory.GetDirectories(DefaultPath);
  107. foreach (string dir in Dirs)
  108. {
  109. if (!FoundFile)
  110. {
  111. string[] Files = Directory.GetFiles(dir);
  112. foreach (string CurrFile in Files)
  113. {
  114. if (!FoundFile)
  115. {
  116. if (System.Text.RegularExpressions.Regex.IsMatch(CurrFile, "signons.sqlite"))
  117. {
  118. NSS_Init(dir);
  119. signon = CurrFile;
  120. }
  121. }
  122.  
  123. else
  124. {
  125. break;
  126. }
  127. }
  128. }
  129. else
  130. {
  131. break;
  132. }
  133. }
  134.  
  135. string dataSource = signon;
  136. TSECItem tSec = new TSECItem();
  137. TSECItem tSecDec = new TSECItem();
  138. TSECItem tSecDec2 = new TSECItem();
  139. byte[] bvRet;
  140. SQLiteBase db = new SQLiteBase(dataSource);
  141.  
  142. DataTable table = db.ExecuteQuery("SELECT * FROM moz_logins;");
  143. DataTable table2 = db.ExecuteQuery("SELECT * FROM moz_disabledHosts;");
  144. Console.WriteLine("---Excluded hosts---");
  145. foreach (DataRow row in table2.Rows)
  146. {
  147. Console.WriteLine(row["hostname"].ToString());
  148. }
  149. Console.WriteLine();
  150. Console.WriteLine();
  151. KeySlot = PK11_GetInternalKeySlot();
  152. PK11_Authenticate(KeySlot, true, 0);
  153. Console.WriteLine("---Saved Users & Passwords---");
  154. foreach (System.Data.DataRow Zeile in table.Rows)
  155. {
  156. string formurl = System.Convert.ToString(Zeile["formSubmitURL"].ToString());
  157. Console.WriteLine("URL: " + formurl);
  158. StringBuilder se = new StringBuilder(Zeile["encryptedUsername"].ToString());
  159. int hi2 = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se, se.Length);
  160. TSECItem item = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi2), typeof(TSECItem));
  161. if (PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0)
  162. {
  163. if (tSecDec.SECItemLen != 0)
  164. {
  165. bvRet = new byte[tSecDec.SECItemLen];
  166. Marshal.Copy(new IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen);
  167. Console.WriteLine("USER: " + System.Text.Encoding.ASCII.GetString(bvRet));
  168. }
  169. }
  170. StringBuilder se2 = new StringBuilder(Zeile["encryptedPassword"].ToString());
  171. int hi22 = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se2, se2.Length);
  172. TSECItem item2 = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi22), typeof(TSECItem));
  173. if (PK11SDR_Decrypt(ref item2, ref tSecDec2, 0) == 0)
  174. {
  175. if (tSecDec2.SECItemLen != 0)
  176. {
  177. bvRet = new byte[tSecDec2.SECItemLen];
  178. Marshal.Copy(new IntPtr(tSecDec2.SECItemData), bvRet, 0, tSecDec2.SECItemLen);
  179. Console.WriteLine("PASSWORD: " + System.Text.Encoding.ASCII.GetString(bvRet));
  180. }
  181. }
  182. Console.WriteLine();
  183. }
  184. Console.ReadKey();
  185. }
  186.  
  187. }
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement