From 199bad901b813379c5508c17e5c1c038f3fb5b90 Mon Sep 17 00:00:00 2001
From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com>
Date: Mon, 6 Mar 2023 16:39:03 -0600
Subject: [PATCH 1/6] Now attempts to crack hashes using ares
- Includes the `project_ares` crate to crack a hash and/or string
---
Cargo.toml | 3 ++-
README.md | 2 +-
src/lib.rs | 28 ++++++++++++++++++++++++++++
src/main.rs | 3 ++-
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index c89eebb..6bd5fc3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,4 +21,5 @@ reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
clap = { version = "4.0.18", features = ["derive"] }
prettytable-rs = "0.10.0"
-lemmeknow = "0.7"
\ No newline at end of file
+lemmeknow = "0.7"
+project_ares = "0.9.0"
\ No newline at end of file
diff --git a/README.md b/README.md
index 0b64992..5dccd4c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
+
📚 [Documentation](https://docs.rs/mercy/latest/mercy/)
diff --git a/src/lib.rs b/src/lib.rs
index a589aa9..cc074e0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -44,6 +44,9 @@ use sys_info::{
use lemmeknow::Identifier;
+use ares::perform_cracking;
+use ares::config::Config;
+
/// Learn more about the crate
pub fn mercy_source() -> String {
const VERSION: &str = "1.2.21";
@@ -118,6 +121,10 @@ pub fn mercy_malicious(mercy_call: &str, mercy_domain: &str) -> String {
/// `defang` - Returns a defanged url and/or ip address
///
/// `whois` - Returns WHOIS lookup information
+///
+/// `identify` - Attempt to identify an unknown string
+///
+/// `crack` - Attempt to crack an encrypted string
pub fn mercy_extra(mercy_call: &str, mercy_choose: &str) -> String {
match mercy_call {
"internal_ip" => internal_ip(),
@@ -125,6 +132,7 @@ pub fn mercy_extra(mercy_call: &str, mercy_choose: &str) -> String {
"defang" => defang(mercy_choose),
"whois" => whois_lookup(mercy_choose),
"identify" => identify_str(mercy_choose),
+ "crack" => crack_str(mercy_choose),
_ => unknown_msg("Unable to provide the information you requested")
}
}
@@ -276,6 +284,26 @@ fn identify_str(data: &str) -> String {
return Identifier::to_json(&Identifier::default().identify(data));
}
+// Attempt to crack an encrypted string
+fn crack_str(data: &str) -> String {
+ let mut config = Config::default();
+ // TODO: Allow user to specify timeout
+ // Attempts to crack the string within 10 seconds
+ config.timeout = 10;
+ config.human_checker_on = false;
+
+ let result = perform_cracking(data, config);
+
+ if !result.is_none() {
+ match result {
+ Some(result) => return format!("{:?}", result.text),
+ _ => return "Unable to crack string".to_string()
+ }
+ } else {
+ return "Result is None".to_string()
+ }
+}
+
fn unknown_msg(custom_msg: &str) -> String {
return format!("{}", custom_msg);
}
diff --git a/src/main.rs b/src/main.rs
index c4fb04c..d15d070 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", "base64, rot13\nbase64, rot13\nmd5, sha2_256\nhex_dump\nsystem_info\ninternal_ip\nstatus\ndefang\nwhois\nidentify", "Method(s)", "Protocol(s)");
+ 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)");
println!("\n=== Mercy CLI Extended ===");
pretty_output("system_info", "hostname\ncpu_cores\ncpu_speed\nos_release\nproc\nall", "Protocol(s)", "Input(s)");
@@ -98,6 +98,7 @@ fn main() {
"d" => println!("{}", mercy::mercy_extra(&args.protocol, &args.input)),
"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)),
"mal" => println!("{}", mercy::mercy_malicious(&args.protocol, &args.input)),
_ => println!("Unable to parse provided arguments")
}
From fe9580a78d525ce84f1cc27dd4443aedc863a4af Mon Sep 17 00:00:00 2001
From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com>
Date: Tue, 7 Mar 2023 22:04:03 -0600
Subject: [PATCH 2/6] New domain_gen method
- 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
---
README.md | 16 +++++++++-
src/lib.rs | 88 +++++++++++++++++++++++++++++++++++++++++++++++------
src/main.rs | 6 +++-
3 files changed, 99 insertions(+), 11 deletions(-)
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")
}
From 9065bc8b218d2f729b4e78995bb3ba85df672446 Mon Sep 17 00:00:00 2001
From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com>
Date: Tue, 7 Mar 2023 22:09:05 -0600
Subject: [PATCH 3/6] Small changes
---
.github/workflows/dev.yml | 5 +----
README.md | 3 +--
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index 4293110..05e6786 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -1,10 +1,7 @@
name: Mercy Status (Dev)
on:
- push:
- branches: ["dev"]
- pull_request:
- branches: ["dev"]
+ push: [push]
env:
CARGO_TERM_COLOR: always
diff --git a/README.md b/README.md
index 0e6cb47..183949e 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,9 @@
📚 [Documentation](https://docs.rs/mercy/latest/mercy/)
-![Mercy Status (Dev)](https://github.com/azazelm3dj3d/mercy/actions/workflows/dev.yml/badge.svg?branch=dev)
![Mercy Status (Main)](https://github.com/azazelm3dj3d/mercy/actions/workflows/main.yml/badge.svg?branch=main)
-Mercy is an open-source Rust crate and CLI for building cybersecurity tools, assessment projects, and testing infrastructure. The goal is to create a sustainable project to make creating security tools in Rust a little easier.
+Mercy is a Rust crate and CLI for building cybersecurity tools, assessment projects, and testing infrastructure. The goal is to create a sustainable project to make creating security tools in Rust a little easier.
## Usage
Since Mercy is a standard crate, it can easily be used in any project already initialized with Cargo. Simply add the following line to your `Cargo.toml` file:
From a994b8c81561b23bb9d46fb9b2ec70d953752d98 Mon Sep 17 00:00:00 2001
From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com>
Date: Thu, 9 Mar 2023 22:52:32 -0600
Subject: [PATCH 4/6] Now includes zip file extraction
---
.gitignore | 5 +++-
Cargo.toml | 3 ++-
README.md | 17 ++++++++++++-
src/lib.rs | 71 +++++++++++++++++++++++++++++++++++++++++++++++++----
src/main.rs | 8 ++++--
5 files changed, 94 insertions(+), 10 deletions(-)
diff --git a/.gitignore b/.gitignore
index 50c8301..bf94c11 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,7 @@
Cargo.lock
# These are backup files generated by rustfmt
-**/*.rs.bk
\ No newline at end of file
+**/*.rs.bk
+
+# macOS
+.DS_Store
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 6bd5fc3..c1f6ba4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,4 +22,5 @@ tokio = { version = "1", features = ["full"] }
clap = { version = "4.0.18", features = ["derive"] }
prettytable-rs = "0.10.0"
lemmeknow = "0.7"
-project_ares = "0.9.0"
\ No newline at end of file
+project_ares = "0.9.0"
+zip = "0.6.4"
\ No newline at end of file
diff --git a/README.md b/README.md
index 183949e..5677759 100644
--- a/README.md
+++ b/README.md
@@ -93,7 +93,7 @@ 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:
+There's also an experimental method, which means you'll receive everything through stdout without a `println!()`:
```rust
use mercy::mercy_experimental;
@@ -104,6 +104,16 @@ fn main() {
}
```
+You can now also extract zip files within your script or via the CLI. This is another method that only prints to stdout:
+
+```rust
+use mercy::mercy_experimental;
+
+fn main() {
+ mercy_experimental("zip", "/Users/name/Downloads/archive.zip");
+}
+```
+
### More Info
If ever in doubt, feel free to run this special function to display more information about the crate.
@@ -171,6 +181,11 @@ Quickly check if a domain is malicious.
mercy -m mal -p status -i "azazelm3dj3d.com"
```
+Extract a zip file.
+```bash
+mercy -m zip_e -p zip -i "/Users/name/Downloads/archive.zip"
+```
+
If you're stuck, you can use this option to learn every command at your disposal from [Mercy](https://github.com/azazelm3dj3d/mercy):
```bash
mercy -e
diff --git a/src/lib.rs b/src/lib.rs
index ab44b24..f1214ee 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,7 +7,7 @@
//! | `mercy_source` | Learn more about the crate |
//! | `mercy_decode` | Supports: base64, rot13 |
//! | `mercy_encode` | Supports: base64 |
-//! | `mercy_hash` | Supports: sha2_256, md5 |
+//! | `mercy_hash` | Supports: sha256, md5 |
//! | `mercy_hex` | Dump hexadecimal values of a file |
//! | `mercy_malicious` | Malware detection or malicious intent |
//! | `mercy_extra` | Information about various data points |
@@ -27,6 +27,7 @@ use std::{
File
},
io::{
+ self,
Read,
Write
},
@@ -88,10 +89,10 @@ pub fn mercy_encode(mercy_call: &str, mercy_string: &str) -> String {
/* Public hashing methods provided by Mercy */
-/// Supports: sha2_256, md5
+/// Supports: sha256, md5
pub fn mercy_hash(mercy_call: &str, mercy_string: &str) -> String {
match mercy_call {
- "sha2_256" => sha2_256_hash(mercy_string.to_string()),
+ "sha256" => sha256_hash(mercy_string.to_string()),
"md5" => md5_hash(mercy_string.to_string()),
_ => unknown_msg("Unable to hash message")
}
@@ -148,14 +149,17 @@ 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` */
+/* 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
+///
+/// `zip` - Extract a zip file
pub fn mercy_experimental(mercy_call: &str, mercy_choose: &str) {
match mercy_call {
"domain_gen" => domain_gen(mercy_choose),
+ "zip" => zip_extract(mercy_choose),
_ => println!("Unable to provide the information you requested")
}
}
@@ -211,7 +215,7 @@ fn base64_encode(plaintext_msg: String) -> String {
/* Hashing methods */
// SHA256 hash
-fn sha2_256_hash(plaintext_msg: String) -> String {
+fn sha256_hash(plaintext_msg: String) -> String {
let mut run_hash = Sha256::new();
run_hash.update(plaintext_msg.as_bytes());
@@ -225,6 +229,63 @@ fn md5_hash(plaintext_msg: String) -> String {
return format!("{:x}", hash);
}
+/* Extraction methods */
+
+// Zip file extraction
+fn zip_extract(filename: &str) {
+
+ // Locate zip file
+ let collect_file = File::open(Path::new(&*filename)).expect("Unable to locate file");
+
+ // Begin zip file read
+ let mut zip_archive = zip::ZipArchive::new(collect_file).expect("Failed to generate zip archive");
+
+ // Iterate over zip file data
+ for file in 0..zip_archive.len() {
+ let mut file_idx = zip_archive.by_index(file).expect("Unable to build zip index");
+
+ let out_path = match file_idx.enclosed_name() {
+ Some(path) => path.to_owned(),
+ None => continue
+ };
+
+ {
+ let comment = file_idx.comment();
+
+ if !comment.is_empty() {
+ println!("Comment located for file: {file}");
+ println!("Comment: \n{comment}");
+ }
+ }
+
+ if (*file_idx.name()).ends_with('/') {
+ println!("[{}] File path: \"{}\"", file, out_path.display());
+ fs::create_dir_all(&out_path).expect("Unable to create zip directories");
+ } else {
+ println!("[{}] File path: \"{}\" [{} bytes]", file, out_path.display(), file_idx.size());
+
+ if let Some(zip_path) = out_path.parent() {
+ if !zip_path.exists() {
+ fs::create_dir_all(zip_path).unwrap();
+ }
+ }
+
+ let mut out = File::create(&out_path).unwrap();
+ io::copy(&mut file_idx, &mut out).unwrap();
+ }
+
+ // Get and Set permissions
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+
+ if let Some(mode) = file_idx.unix_mode() {
+ fs::set_permissions(&out_path, fs::Permissions::from_mode(mode)).unwrap();
+ }
+ }
+ }
+}
+
/* Hexadecimal manipulation */
// Converts file/bytes to a readable vector
diff --git a/src/main.rs b/src/main.rs
index 12a7af5..ac2ca40 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\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)");
+ pretty_output("encode\ndecode\nhash\nhex\nsys\nip\nmal\nd\nwho\nid\nc\ndg\nzip_e", "base64, rot13\nbase64, rot13\nmd5, sha2_256\nhex_dump\nsystem_info\ninternal_ip\nstatus\ndefang\nwhois\nidentify\ncrack\ndomain_gen\nzip", "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)");
@@ -88,6 +88,9 @@ fn main() {
println!("Shuffle a provided string to construct a domain name");
println!("mercy -m dg -p domain_gen -i 'example.com'\n");
+
+ println!("Extract a zip file");
+ println!("mercy -m zip_e -p zip -i '/Users/name/Downloads/archive.zip'\n");
} else {
match args.method.as_str() {
@@ -102,7 +105,8 @@ 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),
+ "dg" => mercy::mercy_experimental(&args.protocol, &args.input),
+ "zip_e" => mercy::mercy_experimental(&args.protocol, &args.input),
"mal" => println!("{}", mercy::mercy_malicious(&args.protocol, &args.input)),
_ => println!("Unable to parse provided arguments")
}
From 2ea242f5058e0b46c6662ba1f4db32f92c2b3d47 Mon Sep 17 00:00:00 2001
From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com>
Date: Thu, 9 Mar 2023 23:02:46 -0600
Subject: [PATCH 5/6] Added better comments and improved readability
---
src/lib.rs | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
index f1214ee..6a5f949 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -250,6 +250,7 @@ fn zip_extract(filename: &str) {
};
{
+ // Checks the status of comments
let comment = file_idx.comment();
if !comment.is_empty() {
@@ -258,29 +259,33 @@ fn zip_extract(filename: &str) {
}
}
+ // Validates if the extracted data is a file or directory
if (*file_idx.name()).ends_with('/') {
- println!("[{}] File path: \"{}\"", file, out_path.display());
+ println!("[{}] Directory path: \"{}\"", file, out_path.display());
+
+ // Creates internal zip directories
fs::create_dir_all(&out_path).expect("Unable to create zip directories");
} else {
- println!("[{}] File path: \"{}\" [{} bytes]", file, out_path.display(), file_idx.size());
+ println!("[{}] File path: \"{}\" ({} bytes)", file, out_path.display(), file_idx.size());
if let Some(zip_path) = out_path.parent() {
if !zip_path.exists() {
- fs::create_dir_all(zip_path).unwrap();
+ fs::create_dir_all(zip_path).expect("Unable to create directories");
}
}
- let mut out = File::create(&out_path).unwrap();
- io::copy(&mut file_idx, &mut out).unwrap();
+ // Builds the output path
+ let mut out = File::create(&out_path).expect("Unable to create out_path");
+ io::copy(&mut file_idx, &mut out).expect("Unable to copy contents");
}
- // Get and Set permissions
+ // Handles permissions for Unix systems
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
if let Some(mode) = file_idx.unix_mode() {
- fs::set_permissions(&out_path, fs::Permissions::from_mode(mode)).unwrap();
+ fs::set_permissions(&out_path, fs::Permissions::from_mode(mode)).expect("Failure to update permissions");
}
}
}
From e07cde7b7c800f2d015f1dffb2fab8133567f576 Mon Sep 17 00:00:00 2001
From: azazelm3dj3d <56496067+azazelm3dj3d@users.noreply.github.com>
Date: Tue, 14 Mar 2023 02:44:56 -0500
Subject: [PATCH 6/6] v1.2.22
New version should now be ready for release
---
.github/workflows/dev.yml | 6 ++++++
.github/workflows/main.yml | 6 ++++++
Cargo.toml | 2 +-
README.md | 4 ++--
src/lib.rs | 30 ++++++++++++++++--------------
src/main.rs | 6 +++---
6 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index 05e6786..eb73aed 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -1,3 +1,9 @@
+# This workflow is for PRs, development builds, etc.
+
+# Project: Mercy (https://github.com/azazelm3dj3d/mercy)
+# Author(s): azazelm3dj3d (https://github.com/azazelm3dj3d)
+# License: BSD 2-Clause
+
name: Mercy Status (Dev)
on:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 7a208a6..5bc8610 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,3 +1,9 @@
+# This workflow is for production builds, main branch builds, etc.
+
+# Project: Mercy (https://github.com/azazelm3dj3d/mercy)
+# Author(s): azazelm3dj3d (https://github.com/azazelm3dj3d)
+# License: BSD 2-Clause
+
name: Mercy Status (Main)
on:
diff --git a/Cargo.toml b/Cargo.toml
index c1f6ba4..561dd1c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "mercy"
description = "Mercy is an open-source Rust crate and CLI for building cybersecurity tools, assessment projects, and testing infrastructure."
-version = "1.2.21"
+version = "1.2.22"
edition = "2021"
author = "azazelm3dj3d"
license = "BSD-2-Clause"
diff --git a/README.md b/README.md
index 5677759..0ad52ec 100644
--- a/README.md
+++ b/README.md
@@ -6,13 +6,13 @@
![Mercy Status (Main)](https://github.com/azazelm3dj3d/mercy/actions/workflows/main.yml/badge.svg?branch=main)
-Mercy is a Rust crate and CLI for building cybersecurity tools, assessment projects, and testing infrastructure. The goal is to create a sustainable project to make creating security tools in Rust a little easier.
+Mercy is an open source Rust crate and CLI designed for building cybersecurity tools, assessment projects, and immediate testing. The goal of the project is to make creating security tools in Rust more accessible and sustainable.
## Usage
Since Mercy is a standard crate, it can easily be used in any project already initialized with Cargo. Simply add the following line to your `Cargo.toml` file:
```toml
-mercy = "1.2.21"
+mercy = "1.2.22"
```
Once the `Cargo.toml` file is updated, you can import the crate and use the provided methods by running `cargo run`. There are lots of different examples available below.
diff --git a/src/lib.rs b/src/lib.rs
index 6a5f949..4a6d210 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,21 +1,22 @@
//! # Mercy
//!
-//! Mercy is an open-source Rust crate and CLI for building cybersecurity tools, assessment projects, and testing infrastructure. The goal is to create a sustainable project to make creating security tools in Rust a little easier.
+//! Mercy is an open source Rust crate and CLI designed for building cybersecurity tools, assessment projects, and immediate testing. The goal of the project is to make creating security tools in Rust more accessible and sustainable.
//!
-//! | Function | More Info |
-//! | ----------------------- | -------------------------------------- |
-//! | `mercy_source` | Learn more about the crate |
-//! | `mercy_decode` | Supports: base64, rot13 |
-//! | `mercy_encode` | Supports: base64 |
-//! | `mercy_hash` | Supports: sha256, md5 |
-//! | `mercy_hex` | Dump hexadecimal values of a file |
-//! | `mercy_malicious` | Malware detection or malicious intent |
-//! | `mercy_extra` | Information about various data points |
+//! | Function | More Info |
+//! | ----------------------- | --------------------------------------- |
+//! | `mercy_source` | Learn more about the crate |
+//! | `mercy_decode` | Supports: base64, rot13 |
+//! | `mercy_encode` | Supports: base64 |
+//! | `mercy_hash` | Supports: sha256, md5 |
+//! | `mercy_hex` | Dump hexadecimal values of a file |
+//! | `mercy_malicious` | Malware detection or malicious intent |
+//! | `mercy_extra` | Information about various data points |
+//! | `mercy_experimental` | Experimental functions for data control |
//!
/*
Project: Mercy (https://github.com/azazelm3dj3d/mercy)
- Author: azazelm3dj3d (https://github.com/azazelm3dj3d)
+ Author(s): azazelm3dj3d (https://github.com/azazelm3dj3d)
License: BSD 2-Clause
*/
@@ -61,7 +62,7 @@ use ares::{
/// Learn more about the crate
pub fn mercy_source() -> String {
- const VERSION: &str = "1.2.21";
+ const VERSION: &str = "1.2.22";
const AUTHOR: &str = "azazelm3dj3d (https://github.com/azazelm3dj3d)";
return format!("Author: {}\nVersion: {}\nDocumentation: https://docs.rs/crate/mercy/latest", AUTHOR, VERSION);
}
@@ -149,9 +150,10 @@ 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` */
+/* Experimental methods that do not require a `prinln!()`. Instead, you just call the method within the code for stdout. */
+// Example: mercy_experimental("zip", "/Users/name/Downloads/archive.zip");
-/// Information about various data points
+/// Experimental functions that only accept stdout
/// ### Methods
/// `domain_gen` - Shuffle a provided string to construct a domain name
///
diff --git a/src/main.rs b/src/main.rs
index ac2ca40..b26a001 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,11 @@
-//! # Mercy
+//! # Mercy CLI
//!
-//! Mercy is an open-source Rust crate and CLI for building cybersecurity tools, assessment projects, and testing infrastructure. The goal is to create a sustainable project to make creating security tools in Rust a little easier.
+//! Mercy is an open source Rust crate and CLI designed for building cybersecurity tools, assessment projects, and immediate testing. The goal of the project is to make creating security tools in Rust more accessible and sustainable.
//!
/*
Project: Mercy (https://github.com/azazelm3dj3d/mercy)
- Author: azazelm3dj3d (https://github.com/azazelm3dj3d)
+ Author(s): azazelm3dj3d (https://github.com/azazelm3dj3d)
License: BSD 2-Clause
*/