Uploaded Day 3 Files

This commit is contained in:
Dom Sec 2023-03-15 20:32:46 -04:00 committed by GitHub
parent 48a061701e
commit cd1a869bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2556 additions and 0 deletions

10
sha1_cracker/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "sha1_cracker"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sha-1 = "0.10"
hex = "0.4"

40
sha1_cracker/src/main.rs Normal file
View File

@ -0,0 +1,40 @@
use sha1::Digest;
use std::{
env,
error::Error,
fs::File,
io::{BufRead, BufReader},
};
const SHA1_HEX_STRING_LENGTH: usize = 40;
fn main() -> Result<(), Box<dyn Error>> {
let args: Vec<String> = env::args().collect();
if args.len() != 3{
println!("Usage:");
println!("sha1_cracker: <wordlist.txt> <sha1_hash>");
return Ok(());
}
let hash_to_crack = args[2].trim();
if hash_to_crack.len() != SHA1_HEX_STRING_LENGTH {
return Err("sha1 hash is not valid".into());
}
let wordlist_file = File::open(&args[1])?;
let reader = BufReader::new(&wordlist_file);
for line in reader.lines() {
let line = line?;
let common_password = line.trim();
if hash_to_crack == &hex::encode(sha1::Sha1::digest(common_password.as_bytes())) {
println!("Password found: {}", &common_password);
return Ok(());
}
}
println!("password not found in wordlist :(");
Ok(())
}

2506
sha1_cracker/wordlist.txt Normal file

File diff suppressed because it is too large Load Diff