-
-
Save daniel-e/38100cf8b012a916d54106b15cd36e5e to your computer and use it in GitHub Desktop.
Concurrent search of MD5-hashed IP through the entire IPv4 space in Rust
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
// [dependencies] | |
// rust-crypto = "0.2.36" | |
extern crate crypto; | |
use std::thread; | |
use crypto::md5::Md5; | |
use crypto::digest::Digest; | |
use std::process; | |
fn main() { | |
let wanted = "f0fdb4c3f58e3e3f"; // <- Modify me | |
let n_threads = 8; // <- Modify me | |
let mut threads = Vec::new(); | |
for i in 0..n_threads { | |
let bs = 256/n_threads; | |
threads.push(thread::spawn(move || { | |
let start = bs*i; | |
for ii in 0..bs { | |
for j in 0..256 { | |
println!("{}{}.{}.", "\t".repeat(i), ii+start, j); | |
for k in 0..256 { | |
for l in 0..256 { | |
let ip = format!("{}.{}.{}.{}", ii+start, j, k, l); | |
let mut md5 = Md5::new(); | |
md5.input_str(&ip); | |
let result = md5.result_str(); | |
if result.as_str().starts_with(wanted) { | |
println!("MATCH! Hash: {} IP: {}", result, ip); | |
process::exit(0); | |
} | |
} | |
} | |
} | |
} | |
})); | |
} | |
threads.into_iter().map(|x| x.join().expect("Join failed.")).count(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment