Skip to content

Commit

Permalink
feat: v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
skifli authored Oct 3, 2024
1 parent c80a33b commit b0ed25a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bruty_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bruty_client"
authors = ["skifli"]
version = "0.3.0"
version = "0.3.1"
edition = "2021"

[dependencies]
Expand Down
7 changes: 1 addition & 6 deletions bruty_client/src/client_threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ struct IDCheckingStats {

pub async fn results_handler(client_channels: &bruty_share::types::ClientChannels) {
let mut results_map: ahash::AHashMap<Vec<char>, IDCheckingStats> = ahash::AHashMap::new();
let mut completed_checks: u64 = 0;
let start_time = std::time::Instant::now();

loop {
let video = client_channels.results_receiver.recv_async().await;
Expand All @@ -36,18 +34,15 @@ pub async fn results_handler(client_channels: &bruty_share::types::ClientChannel
}

if stats.total_checked == 4096 {
completed_checks += 1;

let base_id_clone_clone = base_id_clone.clone();

let positives_len = stats.positives.len();

log::info!(
"Tested {} with {} hit{}, client @{}/s",
"Tested {} with {} hit{}",
base_id_clone.iter().collect::<String>(),
positives_len,
if positives_len == 1 { "" } else { "s" },
completed_checks as f64 * 4069.0 / start_time.elapsed().as_secs_f64(),
);

client_channels
Expand Down
4 changes: 2 additions & 2 deletions bruty_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ struct Args {
short = 'a',
long = "advanced-generations",
help = "Number of IDs to be generated in advance (multiply by 64^2)",
default_value_t = 8
default_value_t = 256
)]
advanced_generations: u8,
advanced_generations: u16,
}

/// Handles a WebSocket message.
Expand Down
2 changes: 1 addition & 1 deletion bruty_server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bruty_server"
authors = ["skifli"]
version = "0.3.0"
version = "0.3.1"
edition = "2021"

[dependencies]
Expand Down
10 changes: 8 additions & 2 deletions bruty_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,13 @@ async fn handle_websocket(
}

log::info!(
"Forwaded awaiting result from {} (ID {}) to the next session.",
"Forwaded {} awaiting result{} from {} (ID {}) to the next session.",
session.awaiting_results.len(),
if session.awaiting_results.len() == 1 {
""
} else {
"s"
},
session.user.name,
session.user.id
);
Expand Down Expand Up @@ -376,7 +382,7 @@ async fn main(
let (results_sender, results_receiver) = flume::unbounded(); // Create a channel for when the server receives results, to send to the result handler.
let (results_awaiting_sender, results_awaiting_receiver) = flume::unbounded(); // Create a channel for when the server is awaiting results.
let (results_received_sender, results_received_receiver) = flume::unbounded(); // Create a channel for when the server receives results.
let (current_id_sender, current_id_receiver) = flume::bounded(1); // Create a channel for when the current project ID changes.
let (current_id_sender, current_id_receiver) = flume::unbounded(); // Create a channel for when the current project ID changes.

let id_sender_clone = id_sender.clone();
let results_awaiting_sender_clone = results_awaiting_sender.clone();
Expand Down
2 changes: 1 addition & 1 deletion bruty_server/src/payload_handlers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{SplitSinkExt, WebSocketSender};
use futures_util::SinkExt;

const ALLOWED_CLIENT_VERSIONS: &[&str] = &["0.3.0"];
const ALLOWED_CLIENT_VERSIONS: &[&str] = &["0.3.1"];

/// Checks if the connection is authenticated.
/// If not, it sends an InvalidSession OP code and closes the connection.
Expand Down
9 changes: 6 additions & 3 deletions bruty_server/src/server_threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn permutation_generator(
current_id_sender: &flume::Sender<Vec<char>>,
) {
if starting_id.len() == 9 {
while id_sender.len() > 0 {
while id_sender.len() > 256 {
// Wait for IDs
}

Expand Down Expand Up @@ -79,6 +79,7 @@ pub async fn results_progress_handler(
let mut awaiting_current_id_update = Vec::new();

let mut cant_update_awaiting_results = Vec::new();
let mut start_times = Vec::new();

loop {
let current_id_receiver_try = current_id_receiver.try_recv();
Expand All @@ -87,6 +88,7 @@ pub async fn results_progress_handler(
log::info!("Finished generating {}", id.iter().collect::<String>());

awaiting_current_id_update.push(id.clone());
start_times.push(std::time::Instant::now());
cant_update_awaiting_results.clear();
}

Expand Down Expand Up @@ -136,8 +138,9 @@ pub async fn results_progress_handler(
persist.save("server_state", state.clone()).unwrap(); // Save the current ID to the database

log::info!(
"Finished checking {}",
state.current_id.iter().collect::<String>()
"Finished checking {} @{}/s",
state.current_id.iter().collect::<String>(),
262144 / start_times.remove(0).elapsed().as_secs()
);
} else {
if cant_update_awaiting_results != awaiting_current_id_update {
Expand Down
5 changes: 2 additions & 3 deletions bruty_share/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ impl ErrorCode {
ErrorCode::DecodeError => InvalidSessionData {
code: ErrorCode::DecodeError,
description: "Decode error".to_string(),
explanation: "The server
received an invalid payload."
explanation: "The server received an invalid payload."
.to_string(),
},
ErrorCode::AuthenticationFailed => InvalidSessionData {
Expand Down Expand Up @@ -103,7 +102,7 @@ pub enum OperationCode {
/// Data sent with an Identify OP code
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct IdentifyData {
pub advanced_generations: u8,
pub advanced_generations: u16,
pub client_version: String,
pub id: u8,
pub secret: String,
Expand Down

0 comments on commit b0ed25a

Please sign in to comment.