Skip to content

Commit

Permalink
New domain_gen method
Browse files Browse the repository at this point in the history
- Updated REAMDE with new additions
- Added a new `mercy_experimental` public function to the API
- New method allows for domain generation based on a provided domain (shuffles the characters to output a similar string)
- CLI was updated with the new method
  • Loading branch information
battleoverflow committed Mar 8, 2023
1 parent 199bad9 commit fe9580a
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 11 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
```

Expand All @@ -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.

Expand Down Expand Up @@ -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"
```

Expand Down
88 changes: 79 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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<u8> 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);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand All @@ -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() {

Expand All @@ -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")
}
Expand Down

0 comments on commit fe9580a

Please sign in to comment.