🎉 init

This commit is contained in:
JMARyA 2025-04-01 13:36:22 +02:00
commit 1429089795
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 2651 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

2562
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "cookiex"
version = "0.1.0"
edition = "2024"
[dependencies]
clap = "4.5.34"
rookie = "0.5.6"

14
README.md Normal file
View file

@ -0,0 +1,14 @@
# CookieX
Extract cookies from your browser session
```
Usage: cookiex [OPTIONS] [DOMAINS]
Arguments:
[DOMAINS] List of domains to process
Options:
-b, --browser <BROWSER> The browser to extract cookies from [firefox / chromium / chrome]
-h, --help Print help
-V, --version Print version
```

66
src/main.rs Executable file
View file

@ -0,0 +1,66 @@
use clap::{Arg, Command};
use rookie::enums::Cookie;
fn main() {
let matches = Command::new("cookiex")
.version("1.0")
.author("JMARyA <jmarya@hydrar.de>")
.about("Extract cookies from your browser session")
.arg(
Arg::new("browser")
.short('b')
.long("browser")
.value_name("BROWSER")
.help("The browser to extract cookies from [firefox / chromium / chrome]"),
)
.arg(
Arg::new("domains")
.help("List of domains to process")
.value_name("DOMAINS"),
)
.get_matches();
let browser: Option<&String> = matches.get_one("browser");
let domains: Option<&String> = matches.get_one::<String>("domains");
let domains = domains.map(|x| {
x.split(',')
.map(std::string::ToString::to_string)
.collect::<Vec<_>>()
});
let cookies = match browser
.map_or("firefox".to_string(), |x| x.to_lowercase())
.as_str()
{
"firefox" => rookie::firefox(domains).unwrap(),
"chromium" => rookie::chromium(domains).unwrap(),
"chrome" => rookie::chrome(domains).unwrap(),
_ => {
std::process::exit(1);
}
};
for cookie in cookies {
let line = cookie.netscape();
println!("{line}");
}
}
pub trait NetscapeCookie {
fn netscape(&self) -> String;
}
impl NetscapeCookie for Cookie {
fn netscape(&self) -> String {
format!(
"{}\t{}\t{}\t{}\t{}\t{}\t{}",
self.domain,
self.http_only.to_string().to_uppercase(),
self.path,
self.secure.to_string().to_uppercase(),
self.expires.unwrap_or(u64::MAX),
self.name,
self.value
)
}
}