-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
timmy
committed
Feb 10, 2024
1 parent
cfcd653
commit 95fc457
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[workspace] | ||
members = ["crates/producer"] | ||
members = [ "crates/cracker","crates/producer"] | ||
|
||
[workspace.package] | ||
version = "2.0.1" | ||
|
@@ -9,6 +9,7 @@ authors = ["Mufeed VH <[email protected]>", "Pommaq"] | |
[workspace.dependencies] | ||
bytecount = "0.6.7" | ||
log = "0.4.19" | ||
pdf = "0.8.1" | ||
|
||
|
||
[package] | ||
|
@@ -25,9 +26,9 @@ anyhow = "1.0.72" | |
crossbeam = "0.8.2" | ||
pretty_env_logger = "0.5.0" | ||
colored = "2.0.4" | ||
pdf = "0.8.1" | ||
bytecount.workspace = true | ||
clap = { version = "4.4.13", features = ["derive"] } | ||
pdf.workspace = true | ||
|
||
[profile.release] | ||
lto = 'thin' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "cracker" | ||
version.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
log.workspace = true | ||
pdf.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::{fs, io}; | ||
|
||
use pdf::file::FileOptions; | ||
|
||
#[derive(Clone)] | ||
pub struct PDFCracker(Vec<u8>); | ||
|
||
impl PDFCracker { | ||
pub fn from_file(path: &str) -> Result<Self, io::Error> { | ||
let pdf_file: Vec<u8> = fs::read(path)?; | ||
Ok(Self(pdf_file)) | ||
} | ||
} | ||
|
||
impl PDFCracker { | ||
/// Attempt to crack the cryptography using the password, return true on success. | ||
pub fn attempt(&self, password: &[u8]) -> bool { | ||
FileOptions::cached() | ||
.password(password) | ||
.load(self.0.as_ref()) | ||
.is_ok() | ||
} | ||
} |