diff --git a/README.md b/README.md index 5dccd4c..0e6cb47 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,9 @@ fn main() { // Attempt to identify an unknown string mercy_extra("identify", "UCrlEbqe4ppk5dVIHzdxtC7g"); + + // Attempt to crack an encrypted string + mercy_extra("crack", "YXphemVsbTNkajNk"); } ``` @@ -91,6 +94,17 @@ You can also use the following parameters, replacing the "all" keyword under `sy - os_release - proc +There's also an experimental method, which means the code may be a bit broken or it's created differently from the other methods in some way: + +```rust +use mercy::mercy_experimental; + +fn main() { + // Shuffle a provided string to construct a domain name + mercy_experimental("domain_gen", "example.com"); +} +``` + ### More Info If ever in doubt, feel free to run this special function to display more information about the crate. @@ -154,7 +168,7 @@ mercy -m ip -p internal_ip ``` Quickly check if a domain is malicious. -``` +```bash mercy -m mal -p status -i "azazelm3dj3d.com" ``` diff --git a/src/lib.rs b/src/lib.rs index cc074e0..ab44b24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,16 +19,25 @@ License: BSD 2-Clause */ -use std::{io::Write, net::TcpStream, str::from_utf8}; -use serde_json::Value; - use std::{ path::Path, - fs::{self, File}, - io::Read, - net::UdpSocket + str::from_utf8, + fs::{ + self, + File + }, + io::{ + Read, + Write + }, + net::{ + UdpSocket, + TcpStream + } }; +use serde_json::Value; + use base64; use md5; use sha2::{Sha256, Digest}; @@ -44,8 +53,10 @@ use sys_info::{ use lemmeknow::Identifier; -use ares::perform_cracking; -use ares::config::Config; +use ares::{ + perform_cracking, + config::Config +}; /// Learn more about the crate pub fn mercy_source() -> String { @@ -122,7 +133,7 @@ pub fn mercy_malicious(mercy_call: &str, mercy_domain: &str) -> String { /// /// `whois` - Returns WHOIS lookup information /// -/// `identify` - Attempt to identify an unknown string +/// `identify` - Attempt to identify an unknown string (requires a "." followed by an extension) /// /// `crack` - Attempt to crack an encrypted string pub fn mercy_extra(mercy_call: &str, mercy_choose: &str) -> String { @@ -137,6 +148,18 @@ pub fn mercy_extra(mercy_call: &str, mercy_choose: &str) -> String { } } +/* Experimental methods that still require some improvements and may only `prinln!` instead of a traditional `return` */ + +/// Information about various data points +/// ### Methods +/// `domain_gen` - Shuffle a provided string to construct a domain name +pub fn mercy_experimental(mercy_call: &str, mercy_choose: &str) { + match mercy_call { + "domain_gen" => domain_gen(mercy_choose), + _ => println!("Unable to provide the information you requested") + } +} + /* Decoding methods */ // Base64 decode @@ -304,6 +327,53 @@ fn crack_str(data: &str) -> String { } } +// Domain generation +fn domain_gen(url: &str) { + + let common_exts = [".com", ".io", ".co", ".ai", ".moe", ".org", ".edu", ".net", ".biz", ".ru", ".uk", ".au", ".de", ".in"]; + + for i in 0..url.len() { + let char_val = url.as_bytes()[i]; + + for bit_switch in 0..8 { + // Shuffles the character position + let shuffle: u8 = char_val ^ 1 << bit_switch; + + if shuffle.is_ascii_alphanumeric() + || shuffle as char == '-' + && shuffle.to_ascii_lowercase() + != char_val.to_ascii_lowercase() { + + let mut payload = url.as_bytes()[..i].to_vec(); + payload.push(shuffle); + + // Appends onto the Vec for parsing + payload.append(&mut url.as_bytes()[i + 1..].to_vec()); + + if let Ok(d) = String::from_utf8(payload) { + + // Iterates over the preset extensions + for e in common_exts.iter() { + + // Only returns if one of the extensions is present + if d.ends_with(e) { + println!("{}", d); + } + } + + // Handles cases where an extension is not present + if !d.contains(".") { + // Apparently, this way it doesn't return something like examplecom (when providing "example.com") + if d.contains(".") { + println!("{}", d); + } + } + } + } + } + } +} + fn unknown_msg(custom_msg: &str) -> String { return format!("{}", custom_msg); } diff --git a/src/main.rs b/src/main.rs index d15d070..12a7af5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,7 @@ fn main() { // Extended help section for new users if args.extended { println!("\n=== Mercy CLI ==="); - pretty_output("encode\ndecode\nhash\nhex\nsys\nip\nmal\nd\nwho\nid\nc", "base64, rot13\nbase64, rot13\nmd5, sha2_256\nhex_dump\nsystem_info\ninternal_ip\nstatus\ndefang\nwhois\nidentify\ncrack", "Method(s)", "Protocol(s)"); + pretty_output("encode\ndecode\nhash\nhex\nsys\nip\nmal\nd\nwho\nid\nc\ndg", "base64, rot13\nbase64, rot13\nmd5, sha2_256\nhex_dump\nsystem_info\ninternal_ip\nstatus\ndefang\nwhois\nidentify\ncrack\ndomain_gen", "Method(s)", "Protocol(s)"); println!("\n=== Mercy CLI Extended ==="); pretty_output("system_info", "hostname\ncpu_cores\ncpu_speed\nos_release\nproc\nall", "Protocol(s)", "Input(s)"); @@ -85,6 +85,9 @@ fn main() { println!("Identify an unknown string"); println!("mercy -m id -p identify -i 'UCrlEbqe4ppk5dVIHzdxtC7g'\n"); + + println!("Shuffle a provided string to construct a domain name"); + println!("mercy -m dg -p domain_gen -i 'example.com'\n"); } else { match args.method.as_str() { @@ -99,6 +102,7 @@ fn main() { "who" => println!("{}", mercy::mercy_extra(&args.protocol, &args.input)), "id" => println!("{}", mercy::mercy_extra(&args.protocol, &args.input)), "c" => println!("{}", mercy::mercy_extra(&args.protocol, &args.input)), + "dg" => mercy::mercy_experimental(&args.protocol, &args.input), "mal" => println!("{}", mercy::mercy_malicious(&args.protocol, &args.input)), _ => println!("Unable to parse provided arguments") }