mirror of
https://github.com/nelsbrock/fingerprunk.git
synced 2026-08-15 00:16:47 +02:00
Compare commits
3
Commits
4388ae2c5c
...
6c7a0b7461
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c7a0b7461
|
||
|
|
6620aa898d
|
||
|
|
bbc17385a7
|
@@ -13,8 +13,9 @@ cargo install fingerprunk
|
||||
|
||||
## Usage
|
||||
|
||||
Let's say you want to find keys whose fingerprints begin with `C0FFEE` and store them `secret.asc`.
|
||||
The regex for this is `^C0FFEE`. Now, simply use the following command to start the search:
|
||||
Let's say you want to find keys whose fingerprints begin with `C0FFEE` and store them
|
||||
at `secret.asc`. The regex for this is `^C0FFEE`. Now, simply use the following command to start
|
||||
the search:
|
||||
|
||||
```sh
|
||||
fingerprunk -r '^C0FFEE' >> secret.asc
|
||||
@@ -49,25 +50,25 @@ Also see <https://en.wikipedia.org/wiki/Hexspeak> for some further examples of "
|
||||
|
||||
### How long does it take?
|
||||
|
||||
On my machine with an AMD Ryzen 7 5800X Processor, Fingerprunk is able to generate and check about
|
||||
43300 keys per second. This means that for finding a fingerprint with a string of *n* specific
|
||||
On my machine with an AMD Ryzen 7 5800X processor, Fingerprunk is able to generate and check about
|
||||
41000 keys per second. This means that for finding a fingerprint with a string of *n* specific
|
||||
hexadecimal digits at a specific place, I could expect the following runtimes until finding the
|
||||
first key:
|
||||
|
||||
| *n* | expected tries | expected time |
|
||||
| --: | --------------: | ------------: |
|
||||
| *n* | 16ⁿ | 43300s / 16ⁿ |
|
||||
| 2 | 256 | 0.0059 secs |
|
||||
| 3 | 4096 | 0.0946 secs |
|
||||
| 4 | 65536 | 1.5 secs |
|
||||
| 5 | 1028576 | 24 secs |
|
||||
| 6 | 16777216 | 6.5 mins |
|
||||
| 7 | 268435456 | 103 mins |
|
||||
| 8 | 4294967296 | 27 hours |
|
||||
| 9 | 68719476736 | 18 days |
|
||||
| 10 | 1099511627776 | 293 days |
|
||||
| 11 | 17592186044416 | 13 years |
|
||||
| 12 | 281474976710656 | 206 years |
|
||||
| *n* | estimate tries | estimate time |
|
||||
| --: | ---------------------: | ------------: |
|
||||
| 1 | 16 = 16¹ | < 0.1 secs |
|
||||
| 2 | 256 = 16² | < 0.1 secs |
|
||||
| 3 | 4096 = 16³ | 0.1 secs |
|
||||
| 4 | 65536 = 16⁴ | 1.6 secs |
|
||||
| 5 | 1048576 = 16⁵ | 26 secs |
|
||||
| 6 | 16777216 = 16⁶ | 7 mins |
|
||||
| 7 | 268435456 = 16⁷ | 2 hours |
|
||||
| 8 | 4294967296 = 16⁸ | 1 days |
|
||||
| 9 | 68719476736 = 16⁹ | 19 days |
|
||||
| 10 | 1099511627776 = 16¹⁰ | 310 days |
|
||||
| 11 | 17592186044416 = 16¹¹ | 14 years |
|
||||
| 12 | 281474976710656 = 16¹² | 218 years |
|
||||
|
||||
As you can see, anything above 8 or 9 fixed digits is pretty much unfeasible, at least with
|
||||
a normal personal computer.
|
||||
As you can see, anything above 10 fixed digits is pretty much unfeasible, at least with a normal
|
||||
personal computer.
|
||||
+33
-10
@@ -14,7 +14,7 @@ use std::{
|
||||
use fancy_regex::Regex;
|
||||
use num_integer::Integer;
|
||||
use sequoia_openpgp::{
|
||||
Cert, Packet,
|
||||
Cert, Packet, armor,
|
||||
crypto::Password,
|
||||
packet::{
|
||||
Key,
|
||||
@@ -22,7 +22,7 @@ use sequoia_openpgp::{
|
||||
prelude::SignatureBuilder,
|
||||
},
|
||||
serialize::Serialize,
|
||||
types::{HashAlgorithm, SignatureType, SymmetricAlgorithm},
|
||||
types::{Curve, HashAlgorithm, SignatureType, SymmetricAlgorithm},
|
||||
};
|
||||
|
||||
type SecretKey = Key<SecretParts, PrimaryRole>;
|
||||
@@ -92,7 +92,8 @@ impl Fingerprunk {
|
||||
let mut fingerprint_hex = String::with_capacity(20 * 2);
|
||||
|
||||
loop {
|
||||
let key = Key4::generate_ed25519().expect("should be able to generate key");
|
||||
let key =
|
||||
Key4::generate_ecc(true, Curve::Ed25519).expect("should be able to generate key");
|
||||
fingerprint_hex.clear();
|
||||
write!(fingerprint_hex, "{:X}", key.fingerprint())
|
||||
.expect("should write into string without error");
|
||||
@@ -117,15 +118,14 @@ impl Fingerprunk {
|
||||
let mut stdout = io::stdout().lock();
|
||||
|
||||
for key in matches_rx {
|
||||
let result = self
|
||||
let cert = self
|
||||
.key_to_cert(&key)
|
||||
.and_then(|cert| cert.as_tsk().armored().serialize(&mut stdout));
|
||||
.expect("should be able to create certificate");
|
||||
|
||||
if let Err(err) = result {
|
||||
eprintln!("Error: {err}");
|
||||
} else {
|
||||
self.counter_found.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
self.serialize_cert(cert, &mut stdout)
|
||||
.expect("should be able to serialize certificate");
|
||||
|
||||
self.counter_found.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +157,29 @@ impl Fingerprunk {
|
||||
Cert::try_from(vec![secret_key_packet, Packet::from(sig)])
|
||||
}
|
||||
|
||||
fn serialize_cert(&self, cert: Cert, to: impl io::Write) -> anyhow::Result<()> {
|
||||
let mut comments = cert.armor_headers();
|
||||
comments.push(format!(
|
||||
"Generated with Fingerprunk. Regex: {}",
|
||||
self.config.regex
|
||||
));
|
||||
|
||||
let headers: Vec<_> = comments
|
||||
.into_iter()
|
||||
.map(|s| ("Comment".to_string(), s))
|
||||
.collect();
|
||||
|
||||
let mut writer = armor::Writer::with_headers(to, armor::Kind::SecretKey, headers)?;
|
||||
|
||||
// Set the profile to RFC4880 because we generate v4 keys.
|
||||
writer.set_profile(sequoia_openpgp::Profile::RFC4880)?;
|
||||
|
||||
cert.serialize(&mut writer)?;
|
||||
writer.finalize()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn status_displayer_thread(&self) {
|
||||
struct DurationDhms(Duration);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user