-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic JSON endpoint (no features yet). Choice of two CLI reporters "ticker" and "spinner".
- Loading branch information
1 parent
a89ecb9
commit 924be44
Showing
9 changed files
with
131 additions
and
90 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,6 +1,6 @@ | ||
[package] | ||
name = "abrute" | ||
version = "0.1.6" | ||
version = "0.1.7" | ||
authors = ["Daniel P. Clark <[email protected]>"] | ||
description = "AESCrypt Brute force attempter." | ||
documentation = "http:https://danielpclark.github.io/abrute/index.html" | ||
|
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
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
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
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,63 +1,19 @@ | ||
use std::time::SystemTime; | ||
extern crate serde; | ||
use self::serde::ser::{Serialize, Serializer, SerializeStruct}; | ||
extern crate serde_json; | ||
use std::sync::{Arc, Mutex}; | ||
pub mod ticker_tape; | ||
pub mod spinner; | ||
use ::ITERATIONS; | ||
use std::sync::atomic::Ordering; | ||
use ::Digits; | ||
use std::ops::Deref; | ||
|
||
pub mod prelude { | ||
pub use reporter::ticker_tape::*; | ||
pub use reporter::spinner::*; | ||
pub use reporter::Reporter; | ||
#[derive(Debug)] | ||
pub enum CliReporter { | ||
TickerTape, | ||
Spinner, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct ReportData { | ||
pub cores: u8, | ||
pub chunk: usize, | ||
pub cluster: Option<(usize,usize)>, | ||
pub character_set: String, | ||
pub start_time: SystemTime, | ||
pub start_at: String, | ||
pub adjacent_limit: Option<u8>, | ||
pub five_min_progress: Arc<Mutex<(usize, String)>>, // Mutex try_lock | ||
} | ||
|
||
impl Serialize for ReportData { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where S: Serializer { | ||
|
||
let mut struct_fields = 8; | ||
if self.cluster.is_some() { struct_fields += 2; } | ||
if self.adjacent_limit.is_some() { struct_fields += 1; } | ||
|
||
let mut state = serializer.serialize_struct("ReportData", struct_fields)?; | ||
state.serialize_field("cores", &self.cores)?; | ||
state.serialize_field("chunk", &self.chunk)?; | ||
if let Some((node, cluster_size)) = self.cluster { | ||
state.serialize_field("cluster_node", &node)?; | ||
state.serialize_field("cluster_size", &cluster_size)?; | ||
impl CliReporter { | ||
#[inline] | ||
pub fn report(&self, data: &Digits) { | ||
match *self { | ||
ref _thingy @ CliReporter::TickerTape => ticker_tape::report(data), | ||
ref _thingy @ CliReporter::Spinner => spinner::report(data), | ||
} | ||
state.serialize_field("character_set", &self.character_set)?; | ||
state.serialize_field("start_time", &self.start_time)?; | ||
state.serialize_field("start_at", &self.start_at)?; | ||
if let Some(adj) = self.adjacent_limit { | ||
state.serialize_field("adjacent_limit", &adj)?; | ||
} | ||
state.serialize_field("iterations", &ITERATIONS.load(Ordering::SeqCst))?; | ||
let getter = self.five_min_progress.lock().unwrap(); | ||
let &(five_min_iters, ref last_string) = getter.deref(); | ||
state.serialize_field("last_five_minute_iterations", &five_min_iters)?; | ||
state.serialize_field("last_attempt", &last_string)?; | ||
state.end() | ||
} | ||
} | ||
|
||
pub trait Reporter { | ||
fn report(data: &Digits); | ||
} |
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,14 +1,16 @@ | ||
use ::reporter::Reporter; | ||
use ::{Digits,ITERATIONS}; | ||
use std::sync::atomic::Ordering; | ||
use std::io::{self, Write}; | ||
|
||
const SPINNER: [char; 10] = ['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏']; | ||
|
||
struct Spinner; | ||
|
||
impl Reporter for Spinner { | ||
fn report(_data: &Digits) { | ||
print!(":"); | ||
io::stdout().flush().unwrap(); | ||
} | ||
pub fn report(data: &Digits) { | ||
let global_iterations = ITERATIONS.load(Ordering::SeqCst); | ||
print!( | ||
"\x1b[1000D {} Iterations: {} String: {}", | ||
SPINNER[global_iterations % 10], | ||
global_iterations, | ||
data.to_s() | ||
); | ||
io::stdout().flush().unwrap(); | ||
} |
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,11 +1,7 @@ | ||
use std::io::{self, Write}; | ||
use ::reporter::Reporter; | ||
use ::Digits; | ||
pub struct TickerTape; | ||
|
||
impl Reporter for TickerTape { | ||
fn report(data: &Digits) { | ||
print!("{}..", data.to_s()); | ||
io::stdout().flush().unwrap(); | ||
} | ||
pub fn report(data: &Digits) { | ||
print!("{}..", data.to_s()); | ||
io::stdout().flush().unwrap(); | ||
} |
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
Oops, something went wrong.