Skip to content

Instantly share code, notes, and snippets.

@haxelion
Created March 15, 2015 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haxelion/c0b44bae5ee0c1f0fba1 to your computer and use it in GitHub Desktop.
Save haxelion/c0b44bae5ee0c1f0fba1 to your computer and use it in GitHub Desktop.
extern crate sha;
use std::default::Default;
use sha::sha1::Sha1;
use sha::utils::{Digest, DigestExt};
use std::thread;
use std::iter;
use std::str::StrExt;
use std::str;
fn main() {
let valid = "ff7b948953ac";
let relations = [0x6bu8, 0x76u8, 0x12u8];
let ncore = 2;
for l in 8..9 {
let mut joinguards = Vec::<thread::JoinHandle>::new();
println!("Bruteforcing lenght {}", l);
for i in 0..ncore {
let g = thread::spawn(move || {
let mut pass : Vec<u8> = iter::repeat(0u8).take(l).collect();
let mut pass_bin : Vec<u8> = iter::repeat(0u8).take(l).collect();
pass[3] += i;
while pass[l-1] < 52 {
for j in 3..l {
if pass[j] >= 26 {
pass_bin[j] = pass[j] - 26 + 97;
}
else {
pass_bin[j] = pass[j] + 65;
}
}
let mut alpha = true;
for j in 0..3 {
pass_bin[j] = relations[j];
let mut k = j+4;
while k < l {
pass_bin[j] ^= pass_bin[k];
k += 4;
}
if pass_bin[j] < 65 || (pass_bin[j] > 90 && pass_bin[j] < 97) || pass_bin[j] > 122 {
alpha = false;
}
}
if alpha {
if Sha1::default().digest(&pass_bin[..]).to_hex().as_slice().starts_with(valid) {
println!("Found: {}", str::from_utf8(&pass_bin[..]).unwrap());
}
}
pass[3] += ncore;
for j in 3..l-1 {
if pass[j] >= 52{
pass[j] = pass[j]%52;
pass[j+1] += 1;
}
else {
break;
}
}
}
});
joinguards.push(g);
}
for g in joinguards {
g.join();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment