main.rs:
use crate::checker::check_channel;
use crate::cli::parse_args;
use crate::errors::AppError;
use crate::models::ChannelInfo;
use crate::models::PatternGroup;
use crate::pattern::analyze_patterns;
pub mod checker;
pub mod cli;
pub mod errors;
pub mod models;
pub mod pattern;
use colored::Colorize;
use indicatif::{ProgressBar, ProgressStyle};
use itertools::Itertools;
use prettytable::{cell, row, Table};
use rayon::prelude::*;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use reqwest::blocking::Client;
use std::collections::HashSet;
use std::fs;
use std::io::{self, BufRead};
use std::path::Path;
use std::time::Duration;
use tracing::{error, info};
use tracing_subscriber::fmt::format::FmtSpan;
// Parse command-line arguments
let matches = parse_args();
// Read wordlist from file or stdin
let wordlist = if let Some(input_path) = matches.get_one::<String>("input") {
read_wordlist_from_file(input_path)?
} else {
info!("Reading wordlist from stdin. Enter words followed by Enter. Press Ctrl+D (Unix) or Ctrl+Z (Windows) to finish:");
read_wordlist_from_stdin()?
};
// Deduplicate wordlist
let mut unique_wordlist: Vec<String> = wordlist.into_iter().unique().collect();
unique_wordlist.sort();
// Wordlist Augmentation
if let Some(prefixes_str) = matches.get_one::<String>("prefixes") {
let prefixes: Vec<&str> = prefixes_str.split(',').collect();
augment_wordlist_with_prefixes(&mut unique_wordlist, &prefixes);
info!("Augmented wordlist with prefixes.");
}
if let Some(suffixes_str) = matches.get_one::<String>("suffixes") {
let suffixes: Vec<&str> = suffixes_str.split(',').collect();
augment_wordlist_with_suffixes(&mut unique_wordlist, &suffixes);
info!("Augmented wordlist with suffixes.");
}
if let Some(num_random_str) = matches.get_one::<String>("random-strings") {
let num_random: usize = num_random_str.parse().unwrap_or(0);
augment_wordlist_with_random_strings(&mut unique_wordlist, num_random);
info!("Augmented wordlist with {} random strings.", num_random);
}
if unique_wordlist.is_empty() {
error!("Wordlist is empty. Please provide at least one word.");
return Ok(());
}
info!("Generating combinations...");
let combinations = generate_combinations(&unique_wordlist);
info!("Total combinations generated: {}", combinations.len());
// Configure HTTP client
let timeout = matches
.get_one::<String>("timeout")
.unwrap()
.parse::<u64>()
.unwrap_or(10);
let client = Client::builder()
.timeout(Duration::from_secs(timeout))
.build()?;
// Setup progress bar
let pb = ProgressBar::new(combinations.len() as u64);
pb.set_style(
ProgressStyle::default_bar()
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})")
.unwrap()
.progress_chars("#>-"),
);
let concurrency = matches
.get_one::<String>("concurrency")
.unwrap()
.parse::<usize>()
.unwrap_or(8);
rayon::ThreadPoolBuilder::new()
.num_threads(concurrency)
.build_global()
.unwrap();
info!("Starting channel checks with concurrency level: {}", concurrency);
// Process combinations in parallel
let results: Vec<ChannelInfo> = combinations
.par_iter()
.map(|combination| {
let result = check_channel(&client, combination);
pb.inc(1);
result
})
.filter_map(|res| res)
.collect();
pb.finish_with_message("Channel checks completed.");
info!("Analyzing channel patterns...");
let patterns = analyze_patterns(
&results
.iter()
.map(|c| c.original_channel.clone())
.collect::<Vec<_>>(),
);
// Display results in CLI
print_overview(&results, &patterns);
print_channels(&results);
print_patterns(&patterns);
// Save results to file if output path is provided
if let Some(output_path) = matches.get_one::<String>("output") {
info!("Saving results to {}", output_path);
save_results_to_file(&results, output_path)?;
}
Ok(())
}
// Reads wordlist from a file
fn read_wordlist_from_file<P: AsRef>(path: P) -> Result<Vec, AppError> {
info!("Reading wordlist from file: {:?}", path.as_ref());
let file = fs::File::open(path)?;
let reader = io::BufReader::new(file);
let wordlist = reader
.lines()
.filter_map(Result::ok)
.filter(|line| !line.trim().is_empty())
.collect();
Ok(wordlist)
}
// Reads wordlist from standard input
fn read_wordlist_from_stdin() -> Result<Vec, AppError> {
let stdin = io::stdin();
let wordlist = stdin
.lock()
.lines()
.filter_map(Result::ok)
.filter(|line| !line.trim().is_empty())
.collect();
Ok(wordlist)
}
// Generates combinations of words
fn generate_combinations(wordlist: &[String]) -> HashSet {
let mut combinations = HashSet::new();
let max_combination_length = 3; // Adjust as needed
code
for length in 1..=max_combination_length {
for combo in wordlist.iter().permutations(length) {
let concatenated = combo.into_iter().join("");
combinations.insert(concatenated);
}
}
combinations
}
// Augments the wordlist with prefixes
fn augment_wordlist_with_prefixes(wordlist: &mut Vec, prefixes: &[&str]) {
let mut new_words = Vec::new();
for prefix in prefixes {
for word in wordlist.iter() {
new_words.push(format!("{}{}", prefix, word));
}
}
wordlist.append(&mut new_words);
}
// Augments the wordlist with suffixes
fn augment_wordlist_with_suffixes(wordlist: &mut Vec, suffixes: &[&str]) {
let mut new_words = Vec::new();
for suffix in suffixes {
for word in wordlist.iter() {
new_words.push(format!("{}{}", word, suffix));
}
}
wordlist.append(&mut new_words);
}
// Augments the wordlist with random strings
fn augment_wordlist_with_random_strings(wordlist: &mut Vec, num_strings: usize) {
let rng = thread_rng();
for _ in 0..num_strings {
let random_string: String = rng.clone()
.sample_iter(&Alphanumeric)
.take(8) // Adjust the length of random strings as needed
.map(char::from)
.collect();
wordlist.push(random_string);
}
}
// Saves results to a JSON file
fn save_results_to_file(results: &[ChannelInfo], path: &str) -> Result<(), AppError> {
let json = serde_json::to_string_pretty(results)?;
fs::write(path, json)?;
Ok(())
}
// Prints an overview of the results
fn print_overview(results: &[ChannelInfo], patterns: &[PatternGroup]) {
println!("{}", "=== Overview ===".bold().underline());
println!("Total Valid Channels: {}", results.len());
code
let feature_channels = patterns
.iter()
.find(|p| p.pattern.to_lowercase().contains("feature"))
.map(|p| p.channels.len())
.unwrap_or(0);
println!(
"Channels with '{}' in their name: {}\n",
"feature".cyan(),
feature_channels
);
}
// Prints the details of each channel in a table
fn print_channels(results: &[ChannelInfo]) {
let mut table = Table::new();
table.add_row(row![
"Channel",
"Roblox.exe",
"DeployHistory.txt",
"Mac DeployHistory.txt",
"ClientSettings"
]);
code
for channel in results {
table.add_row(row![
channel.colored_channel.to_string(),
if channel.roblox_exe { "✅".green() } else { "❌".red() },
if channel.deploy_history { "✅".green() } else { "❌".red() },
if channel.mac_deploy_history { "✅".green() } else { "❌".red() },
if channel.client_settings { "✅".green() } else { "❌".red() },
]);
}
println!("{}", "=== Channels ===".bold().underline());
table.printstd();
println!(); // Add an empty line for better readability
}
// Prints the pattern analysis in a table
fn print_patterns(patterns: &[PatternGroup]) {
let mut table = Table::new();
table.add_row(row!["Pattern", "Number of Channels", "Channels"]);
code
for pattern in patterns {
let channel_count = pattern.channels.len();
let channels_joined = pattern.channels.join(", ");
table.add_row(row![
pattern.pattern.clone(),
channel_count,
channels_joined
]);
}
println!("{}", "=== Pattern Analysis ===".bold().underline());
table.printstd();
println!(); // Add an empty line for better readability
pub fn parse_args() -> clap::ArgMatches {
Command::new("Roblox Channel Checker")
.version("2.0")
.author("Your Name youremail@example.com")
.about("Checks for valid Roblox channels based on wordlist combinations and analyzes channel patterns")
.arg(
Arg::new("input")
.short('i')
.long("input")
.value_name("FILE")
.help("Sets a custom input wordlist file")
)
.arg(
Arg::new("output")
.short('o')
.long("output")
.value_name("FILE")
.help("Sets an output file to save results in JSON format")
)
.arg(
Arg::new("concurrency")
.short('c')
.long("concurrency")
.value_name("NUMBER")
.help("Sets the level of concurrency for HTTP requests")
.default_value("8"),
)
.arg(
Arg::new("timeout")
.short('t')
.long("timeout")
.value_name("SECONDS")
.help("Sets the timeout for HTTP requests in seconds")
.default_value("10"),
)
.arg(
Arg::new("verbose")
.short('v')
.long("verbose")
.help("Increases verbosity level")
)
.arg(
Arg::new("prefixes")
.short('p')
.long("prefixes")
.value_name("PREFIXES")
.help("Comma-separated list of prefixes to add to words")
)
.arg(
Arg::new("suffixes")
.short('s')
.long("suffixes")
.value_name("SUFFIXES")
.help("Comma-separated list of suffixes to add to words")
)
.arg(
Arg::new("random-strings")
.short('r')
.long("random-strings")
.value_name("NUMBER")
.help("Number of random alphanumeric strings to generate and add to the wordlist")
)
.get_matches()
}
Make this whole program waaaay more visually advanced.
It looks like you're encountering an issue where your pattern analysis isn't identifying expected patterns, such as "Harmony," and are seeking to enhance the visual output of your Rust program. Let's address both the bug in your pattern matching and provide suggestions to significantly improve the visual aspects of your application.
1. Debugging the Pattern Matching
Issue Explanation
From your provided output, all channels are being categorized under the "Others" pattern, even though you expect some channels (like featureharmony) to match specific patterns (e.g., zfeature\w+). Here's why this is happening:
Regex Patterns Expecting 'z' Prefix: Your regex patterns are defined to match channel names that start with a 'z'. For example, zfeature\w+ expects channel names like zfeatureXYZ.
rust
let patterns = vec![
regex_patterns("zfeature\\w+"),
regex_patterns("zproject\\w+"),
regex_patterns("zbugfix\\w+"),
regex_patterns("zcanary\\w*"),
// Add more patterns as needed
];
Channel Names Lack 'z' Prefix: In your output, channel names such as featureharmony do not have the 'z' prefix, so they don't match any of the defined regex patterns and are thus categorized as "Others."
code
| featureharmony | ✅ | ✅ | ✅ | ✅ |
Solution
To resolve this discrepancy, you have two main options:
Adjust the Regex Patterns:
If channel names do not consistently have a 'z' prefix, you should remove the 'z' from your regex patterns to match the actual channel names.
rust
let patterns = vec![
regex_patterns("feature\\w+"),
regex_patterns("project\\w+"),
regex_patterns("bugfix\\w+"),
regex_patterns("canary\\w*"),
// Add more patterns as needed
];
Ensure Channel Names Have 'z' Prefix:
If channel names should indeed start with a 'z', ensure that all channel names are prefixed with 'z' before pattern analysis.
a. Modify Wordlist Augmentation to Add 'z':
You can prepend 'z' to all channel names during the wordlist augmentation phase.
rust
// Augment the wordlist by adding 'z' as a prefix
fn augment_wordlist_with_z(wordlist: &mut Vec<String>) {
for word in wordlist.iter_mut() {
*word = format!("z{}", word);
}
}
b. Call This Function Before Pattern Analysis:
In your main function, after generating combinations and before pattern analysis, ensure all channel names have a 'z' prefix.
rust
// After generating combinations
let mut combinations = generate_combinations(&unique_wordlist);
// Prepend 'z' to each combination
augment_wordlist_with_z(&mut combinations);
// Proceed with HTTP checks and pattern analysis
Note: This approach depends on whether your channel names are supposed to have a 'z' prefix based on your application's logic.
Recommendation
Evaluate whether channel names inherently include a 'z' prefix. If not, remove the 'z' from your regex patterns to match the actual channel names. This is generally simpler and avoids unnecessary modifications to your data.
2. Enhancing Visual Output
Making your program's output more visually appealing can greatly enhance user experience. Below are several suggestions along with code snippets to implement these improvements.
a. Improved Colored Output
Currently, you're using the prettytable crate along with the colored crate for coloring text. Let's enhance this by adding more colors and utilizing table styles.
Install Additional Dependencies
Ensure you have the latest versions of the following crates in your Cargo.toml:
toml
[dependencies]
colored = "2.0"
prettytable = "0.11"
indicatif = "0.17"
itertools = "0.10"
rayon = "1.6"
rand = "0.8"
reqwest = { version = "0.11", features = ["blocking"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"
thiserror = "1.0"
clap = { version = "4.1", features = ["derive"] }
Enhancing print_channels Function
Let's make the channels table more colorful and stylistically appealing.
rust
use colored::*;
use prettytable::{Cell, Row, Table, format};
// Function to create a colored cell
fn colored_cell(content: &str, color: &str) -> Cell {
match color.to_lowercase().as_str() {
"green" => Cell::new(content).style_spec("Fg"),
"red" => Cell::new(content).style_spec("Fr"),
_ => Cell::new(content),
}
}
fn print_channels(results: &[ChannelInfo]) {
let mut table = Table::new();
// Define a prettier format
table.set_format(*format::consts::FORMAT_CLEAN);
// Add a header row with bold and underlined text
table.add_row(Row::new(vec![
Cell::new("Channel").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Roblox.exe").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("DeployHistory.txt").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Mac DeployHistory.txt").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("ClientSettings").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
]));
for channel in results {
table.add_row(Row::new(vec![
Cell::new(&channel.colored_channel.to_string()),
if channel.roblox_exe { "✅".green().to_string() } else { "❌".red().to_string() },
if channel.deploy_history { "✅".green().to_string() } else { "❌".red().to_string() },
if channel.mac_deploy_history { "✅".green().to_string() } else { "❌".red().to_string() },
if channel.client_settings { "✅".green().to_string() } else { "❌".red().to_string() },
]));
}
// Add some spacing
println!("{}", "=== Channels ===".bold().underline().blue());
table.printstd();
println!(); // Add an empty line for better readability
}
Enhancing print_patterns Function
Similarly, make the pattern analysis table more colorful.
rust
fn print_patterns(patterns: &[PatternGroup]) {
let mut table = Table::new();
table.set_format(*format::consts::FORMAT_CLEAN);
// Header with bold and underlined text
table.add_row(Row::new(vec![
Cell::new("Pattern").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Number of Channels").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Channels").style_spec("B").with_style(Attr::Bold).with_fmt(|s| s.underline()),
]));
for pattern in patterns {
table.add_row(Row::new(vec![
Cell::new(&pattern.pattern).cyan(),
Cell::new(&pattern.channels.len().to_string()).yellow(),
Cell::new(&pattern.channels.join(", ")).to_string().default(),
]));
}
// Add some spacing
println!("{}", "=== Pattern Analysis ===".bold().underline().blue());
table.printstd();
println!(); // Add an empty line for better readability
}
b. Enhanced Overview Section
Add colors and formatting to the overview section to make key metrics stand out.
rust
fn print_overview(results: &[ChannelInfo], patterns: &[PatternGroup]) {
println!("{}", "=== Overview ===".bold().underline().purple());
println!(
"Total Valid Channels: {}",
results.len().to_string().green()
);
let feature_channels = patterns
.iter()
.find(|p| p.pattern.to_lowercase().contains("feature"))
.map(|p| p.channels.len())
.unwrap_or(0);
println!(
"Channels with '{}' in their name: {}",
"feature".cyan(),
feature_channels.to_string().green()
);
println!(); // Add an empty line for better readability
}
c. Using indicatif for Progress Bars
You're already using indicatif for progress bars, but let's ensure it's styled to match the overall visual enhancements.
rust
let pb = ProgressBar::new(combinations.len() as u64);
pb.set_style(
ProgressStyle::default_bar()
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})")
.unwrap()
.progress_chars("#>-"),
);
d. Adding ASCII Art or Emojis for Visual Appeal
Incorporate some ASCII art or emojis at the start of the program to make the CLI experience more engaging.
Call this function at the very beginning of your main function:
rust
fn main() -> Result<(), AppError> {
// Print header
print_header();
// Initialize logging
tracing_subscriber::fmt()
// ... rest of your code
e. Interactive Menu or Selection (Optional)
For a more advanced UI, consider integrating an interactive menu using crates like dialoguer. However, this would change the program from purely CLI to interactive, which may or may not suit your use case.
3. Comprehensive Code Enhancement
Combining the above suggestions, here's how you can implement the enhancements:
Updated pattern.rs
Ensure your regex patterns match the actual channel names.
rust
use crate::models::PatternGroup;
use regex::Regex;
use std::collections::HashMap;
pub fn analyze_patterns(channels: &[String]) -> Vec<PatternGroup> {
// Define regex patterns to match without 'z' prefix
let patterns = vec![
regex_patterns("feature\\w+"),
regex_patterns("project\\w+"),
regex_patterns("bugfix\\w+"),
regex_patterns("canary\\w*"),
// Add more patterns as needed
];
let mut pattern_map: HashMap<String, Vec<String>> = HashMap::new();
for channel in channels {
let mut matched = false;
for (pattern_str, regex) in &patterns {
if regex.is_match(channel) {
pattern_map
.entry(pattern_str.clone())
.or_insert_with(Vec::new)
.push(channel.clone());
matched = true;
break;
}
}
if !matched {
pattern_map
.entry("Others".to_string())
.or_insert_with(Vec::new)
.push(channel.clone());
}
}
// Convert map to vector of PatternGroup
let mut grouped_patterns = Vec::new();
for (pattern, channels) in pattern_map {
grouped_patterns.push(PatternGroup { pattern, channels });
}
grouped_patterns
}
fn regex_patterns(pattern: &str) -> (String, Regex) {
(pattern.to_string(), Regex::new(&format!("(?i)^{}", pattern)).unwrap())
}
Updated main.rs
Incorporate the visual enhancements and ensure pattern matching is correct.
rust
Updated models.rs
To fully leverage colored output, ensure your ChannelInfo struct appropriately stores colored channel names.
When creating ChannelInfo instances, assign colored strings as needed. For example, you might color the channel name based on certain conditions.
Optional: Adding More Patterns
To ensure "Harmony" and similar channels are matched correctly, make sure your patterns cover all expected prefixes or naming conventions. If "Harmony" should match a specific pattern, add it accordingly.
rust
let patterns = vec![
regex_patterns("feature\\w+"),
regex_patterns("project\\w+"),
regex_patterns("bugfix\\w+"),
regex_patterns("canary\\w*"),
regex_patterns("harmony\\w+"), // Added harmony pattern
// Add more patterns as needed
];
Optional: Dynamic Pattern Loading
For scalability, consider loading regex patterns from a configuration file (e.g., JSON, YAML) instead of hardcoding them. This allows easy updates without modifying the codebase.
4. Final Output Example
With these enhancements, your program's output will be significantly more engaging. Here's an illustrative example based on your original output:
code
After adjustments to the regex patterns or appending 'z' prefixes, you should see channels categorized correctly. Additionally, the enhanced visual formatting makes the output more readable and user-friendly.
5. Additional Recommendations
Logging Levels: Implement different logging levels (e.g., INFO, DEBUG, ERROR) to control the verbosity of your application's output. This can be controlled via command-line arguments.
Configuration File: Use a configuration file to manage settings like regex patterns, colors, and other application parameters. This makes your application more flexible and easier to configure.
Error Handling: Enhance error messages with more context to aid in debugging. For instance, specify why a certain HTTP request failed.
Testing: Write unit tests for your pattern matching and wordlist augmentation functions to ensure they behave as expected.
Documentation: Provide comprehensive documentation or help messages detailing how to use your application, its features, and customization options.
By addressing the pattern matching bug and implementing these visual enhancements, your Rust program will not only function correctly but also provide an engaging and user-friendly experience.
use crate::checker::check_channel;
use crate::cli::parse_args;
use crate::errors::AppError;
use crate::models::ChannelInfo;
use crate::models::PatternGroup;
use crate::pattern::analyze_patterns;
pub mod checker;
pub mod cli;
pub mod errors;
pub mod models;
pub mod pattern;
use colored::{Colorize, ColoredString};
use indicatif::{ProgressBar, ProgressStyle};
use itertools::Itertools;
use prettytable::{cell, row, Attr, Cell, Row, Table, format};
use rayon::prelude::*;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use reqwest::blocking::Client;
use std::collections::HashSet;
use std::fs;
use std::io::{self, BufRead};
use std::path::Path;
use std::time::Duration;
use tracing::{error, info};
use tracing_subscriber::fmt::format::FmtSpan;
fn main() -> Result<(), AppError> {
// Print header
print_header();
// Initialize logging
tracing_subscriber::fmt()
.with_span_events(FmtSpan::CLOSE) // Log span end events
.with_max_level(tracing::Level::INFO)
.init();
// Parse command-line arguments
let matches = parse_args();
// Read wordlist from file or stdin
let wordlist = if let Some(input_path) = matches.get_one::<String>("input") {
read_wordlist_from_file(input_path)?
} else {
info!("Reading wordlist from stdin. Enter words followed by Enter. Press Ctrl+D (Unix) or Ctrl+Z (Windows) to finish:");
read_wordlist_from_stdin()?
};
// Deduplicate wordlist
let mut unique_wordlist: Vec<String> = wordlist.into_iter().unique().collect();
unique_wordlist.sort();
// Wordlist Augmentation
if let Some(prefixes_str) = matches.get_one::<String>("prefixes") {
let prefixes: Vec<&str> = prefixes_str.split(',').collect();
augment_wordlist_with_prefixes(&mut unique_wordlist, &prefixes);
info!("Augmented wordlist with prefixes.");
}
if let Some(suffixes_str) = matches.get_one::<String>("suffixes") {
let suffixes: Vec<&str> = suffixes_str.split(',').collect();
augment_wordlist_with_suffixes(&mut unique_wordlist, &suffixes);
info!("Augmented wordlist with suffixes.");
}
if let Some(num_random_str) = matches.get_one::<String>("random-strings") {
let num_random: usize = num_random_str.parse().unwrap_or(0);
augment_wordlist_with_random_strings(&mut unique_wordlist, num_random);
info!("Augmented wordlist with {} random strings.", num_random);
}
// Optionally, prepend 'z' to all words if required
/*
if matches.contains_id("prepend-z") {
augment_wordlist_with_z(&mut unique_wordlist);
info!("Prepended 'z' to all words in the wordlist.");
}
*/
if unique_wordlist.is_empty() {
error!("Wordlist is empty. Please provide at least one word.");
return Ok(());
}
info!("Generating combinations...");
let combinations = generate_combinations(&unique_wordlist);
info!("Total combinations generated: {}", combinations.len());
// Configure HTTP client
let timeout = matches
.get_one::<String>("timeout")
.unwrap()
.parse::<u64>()
.unwrap_or(10);
let client = Client::builder()
.timeout(Duration::from_secs(timeout))
.build()?;
// Setup progress bar
let pb = ProgressBar::new(combinations.len() as u64);
pb.set_style(
ProgressStyle::default_bar()
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})")
.unwrap()
.progress_chars("#>-"),
);
let concurrency = matches
.get_one::<String>("concurrency")
.unwrap()
.parse::<usize>()
.unwrap_or(8);
rayon::ThreadPoolBuilder::new()
.num_threads(concurrency)
.build_global()
.unwrap();
info!("Starting channel checks with concurrency level: {}", concurrency);
// Process combinations in parallel
let results: Vec<ChannelInfo> = combinations
.par_iter()
.map(|combination| {
let result = check_channel(&client, combination);
pb.inc(1);
result
})
.filter_map(|res| res)
.collect();
pb.finish_with_message("Channel checks completed.");
info!("Analyzing channel patterns...");
let patterns = analyze_patterns(
&results
.iter()
.map(|c| c.original_channel.clone())
.collect::<Vec<_>>(),
);
// Display results in CLI
print_overview(&results, &patterns);
print_channels(&results);
print_patterns(&patterns);
// Save results to file if output path is provided
if let Some(output_path) = matches.get_one::<String>("output") {
info!("Saving results to {}", output_path);
save_results_to_file(&results, output_path)?;
}
Ok(())
}
// Function to print header with ASCII art or emojis
fn print_header() {
println!("{}", "**********************************************".bold().cyan());
println!("{}", "* 🚀 Roblox Channel Checker v2.0 🚀 *".bold().yellow());
println!("{}", "**********************************************\n".bold().cyan());
}
// Reads wordlist from a file
fn read_wordlist_from_file<P: AsRef<Path>>(path: P) -> Result<Vec<String>, AppError> {
info!("Reading wordlist from file: {:?}", path.as_ref());
let file = fs::File::open(path)?;
let reader = io::BufReader::new(file);
let wordlist = reader
.lines()
.filter_map(Result::ok)
.filter(|line| !line.trim().is_empty())
.collect();
Ok(wordlist)
}
// Reads wordlist from standard input
fn read_wordlist_from_stdin() -> Result<Vec<String>, AppError> {
let stdin = io::stdin();
let wordlist = stdin
.lock()
.lines()
.filter_map(Result::ok)
.filter(|line| !line.trim().is_empty())
.collect();
Ok(wordlist)
}
// Generates combinations of words
fn generate_combinations(wordlist: &[String]) -> HashSet<String> {
let mut combinations = HashSet::new();
let max_combination_length = 3; // Adjust as needed
for length in 1..=max_combination_length {
for combo in wordlist.iter().permutations(length) {
let concatenated = combo.into_iter().join("");
combinations.insert(concatenated);
}
}
combinations
}
// Augments the wordlist with prefixes
fn augment_wordlist_with_prefixes(wordlist: &mut Vec<String>, prefixes: &[&str]) {
let mut new_words = Vec::new();
for prefix in prefixes {
for word in wordlist.iter() {
new_words.push(format!("{}{}", prefix, word));
}
}
wordlist.append(&mut new_words);
}
// Augments the wordlist with suffixes
fn augment_wordlist_with_suffixes(wordlist: &mut Vec<String>, suffixes: &[&str]) {
let mut new_words = Vec::new();
for suffix in suffixes {
for word in wordlist.iter() {
new_words.push(format!("{}{}", word, suffix));
}
}
wordlist.append(&mut new_words);
}
// Augments the wordlist with random strings
fn augment_wordlist_with_random_strings(wordlist: &mut Vec<String>, num_strings: usize) {
let mut rng = thread_rng();
for _ in 0..num_strings {
let random_string: String = rng
.sample_iter(&Alphanumeric)
.take(8) // Adjust the length of random strings as needed
.map(char::from)
.collect();
wordlist.push(random_string);
}
}
// Function to append 'z' to all words if necessary
fn augment_wordlist_with_z(wordlist: &mut Vec<String>) {
for word in wordlist.iter_mut() {
*word = format!("z{}", word);
}
}
// Saves results to a JSON file
fn save_results_to_file(results: &[ChannelInfo], path: &str) -> Result<(), AppError> {
let json = serde_json::to_string_pretty(results)?;
fs::write(path, json)?;
Ok(())
}
// Prints an overview of the results
fn print_overview(results: &[ChannelInfo], patterns: &[PatternGroup]) {
println!("{}", "=== Overview ===".bold().underline().purple());
println!(
"Total Valid Channels: {}",
results.len().to_string().green()
);
let feature_channels = patterns
.iter()
.find(|p| p.pattern.to_lowercase().contains("feature"))
.map(|p| p.channels.len())
.unwrap_or(0);
println!(
"Channels with '{}' in their name: {}",
"feature".cyan(),
feature_channels.to_string().green()
);
println!(); // Add an empty line for better readability
}
// Prints the details of each channel in a table
fn print_channels(results: &[ChannelInfo]) {
let mut table = Table::new();
// Define a prettier format
table.set_format(*format::consts::FORMAT_CLEAN);
// Add a header row with bold and underlined text
table.add_row(Row::new(vec![
Cell::new("Channel").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Roblox.exe").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("DeployHistory.txt").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Mac DeployHistory.txt").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("ClientSettings").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
]));
for channel in results {
table.add_row(Row::new(vec![
Cell::new(&channel.colored_channel.to_string()),
if channel.roblox_exe { "✅".green().to_string() } else { "❌".red().to_string() },
if channel.deploy_history { "✅".green().to_string() } else { "❌".red().to_string() },
if channel.mac_deploy_history { "✅".green().to_string() } else { "❌".red().to_string() },
if channel.client_settings { "✅".green().to_string() } else { "❌".red().to_string() },
]));
}
// Add some spacing
println!("{}", "=== Channels ===".bold().underline().blue());
table.printstd();
println!(); // Add an empty line for better readability
}
// Prints the pattern analysis in a table
fn print_patterns(patterns: &[PatternGroup]) {
let mut table = Table::new();
table.set_format(*format::consts::FORMAT_CLEAN);
// Header with bold and underlined text
table.add_row(Row::new(vec![
Cell::new("Pattern").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Number of Channels").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
Cell::new("Channels").style_spec("B").with_attr(Attr::Bold).with_fmt(|s| s.underline()),
]));
for pattern in patterns {
let color = if pattern.pattern.to_lowercase() == "others" {
"red"
} else {
"green"
};
table.add_row(Row::new(vec![
Cell::new(&pattern.pattern).color(color),
Cell::new(&pattern.channels.len().to_string()).color("yellow"),
Cell::new(&pattern.channels.join(", ")),
]));
}
// Add some spacing
println!("{}", "=== Pattern Analysis ===".bold().underline().blue());
table.printstd();
println!(); // Add an empty line for better readability
}