Initial commit

This commit is contained in:
2025-10-20 13:13:47 -04:00
commit 81fc6cdd2c
4 changed files with 371 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
extern crate alloc;
use clap::{Parser, ValueEnum};
use alloc::string::String;
use std::process::{Command, Output};
use std::io::Result;
pub const APP_VERSION: &str = "0.0.1-PREALPHA";
/// Executes a Windows binary with the given parameters.
///
/// # Arguments
///
/// * `binary_path` - The full path to the Windows `.exe` binary.
/// * `args` - A slice of arguments to pass to the binary.
///
/// # Returns
///
/// * `Result<Output, io::Error>` - The output of the command if successful, or an I/O error.
fn run_windows_binary(binary_path: &str, args: &[&str]) -> Result<Output> {
Command::new(binary_path)
.args(args)
.output() // You can also use .spawn() if you want async execution
}
fn run_schedule_daily_comand() {
let binary = "C:/windows/system32/schtasks.exe";
let parameters = ["/create",
"/tn", "LockStep\\Daily Task",
"/sc", "daily",
"/st", "19:00",
"/tr", "C:\\lockstep\\daily.cmd"];
match run_windows_binary(binary, &parameters) {
Ok(output) => {
println!("Status: {}", output.status);
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
}
Err(e) => {
eprintln!("Failed to execute process: {}", e);
}
}
}
fn run_monero_miner() {
let binary = "C:/lockstep/xmrig.exe";
let parameters = ["-o", "10.1.20.106",
"--rig-id", "%computername%",
"-B",
"--coin", "monero"
];
match run_windows_binary(binary, &parameters) {
Ok(output) => {
println!("Status: {}", output.status);
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
}
Err(e) => {
eprintln!("Failed to execute process: {}", e);
}
}
}
fn run_kill_command() {
let binary = "C:/windows/system32/taskkill.exe";
let parameters = ["/IM", "xmrig.exe", "/F"];
match run_windows_binary(binary, &parameters) {
Ok(output) => {
println!("Status: {}", output.status);
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
}
Err(e) => {
eprintln!("Failed to execute process: {}", e);
}
}
}
#[derive(Debug, Clone, Copy, Default, ValueEnum)]
enum AppModes {
#[default]
KillCommand,
ScheduleDaily,
RunWork
}
#[derive(Parser, Debug)]
#[command(name = "MyCLI", version = "1.0", about = "A simple CLI tool")]
struct Cli {
app_modes: AppModes
}
fn main() {
println!("Launching LockStep {}", APP_VERSION);
let opts = Cli::parse();
println!("OPTS => {opts:?}");
match opts.app_modes {
AppModes::KillCommand => {
run_kill_command()
}
AppModes::ScheduleDaily => {
run_schedule_daily_comand()
}
AppModes::RunWork => {
run_monero_miner()
}
}
}