diff --git a/src/main.rs b/src/main.rs index f0c703b..5dd26ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,22 +7,13 @@ use transpiler::{Args, micro_ducky_transpiler::transpile, parser::parse_payload} mod errors; use errors::DuckyError; - fn main() -> Result<(), DuckyError> { let args: Args = Args::new(); - if !args.transpile && !args.compile { - println!("[ERROR] Must provide a compilation type.\nRun rusty_ducky with the -h flag to see more info.\nEx: ./rusty_ducky -h"); - return Ok(()); - } - - let report_buf = match parse_payload(&args) { - Ok(r) => r, - Err(e) => {println!("{:?}", e); vec![[0, 0, 0, 0, 0, 0, 0, 0]]} - }; + let report_buf = parse_payload(&args)?; if args.transpile { transpile(&args, &report_buf)? } - if args.compile { todo!() } + //if args.compile { todo!() } Ok(()) diff --git a/src/transpiler/mod.rs b/src/transpiler/mod.rs index 1fa0380..02913f9 100644 --- a/src/transpiler/mod.rs +++ b/src/transpiler/mod.rs @@ -39,14 +39,14 @@ impl Args { { let app = App::new("rusty_ducky") .version("0.4") - .about("A Rust transpiler and compiler for keystroke injections on imbedded devices.") + .about("rusty_ducky is a DuckyScript keystroke injection toolkit for microcontrollers that support Circuit Python.") .author("Carter Vavra"); let payload_file_option = Arg::new("payload") .long("payload") .short('p') .takes_value(true) - .help("Points rusty ducky to a payload file to transpile.\nDefault is payload.txt") + .help("Points rusty ducky to a payload file to transpile.") .default_value("payload.txt") .required(false); let app = app.arg(payload_file_option); @@ -63,7 +63,7 @@ impl Args { .long("output") .short('o') .takes_value(true) - .help("Specify a name for the transpiled cuircut python file.") + .help("Specify a name for the transpiled circuit python file.") .default_value("Code.py") .required(false); let app = app.arg(output_file_option); @@ -77,21 +77,21 @@ impl Args { .required(false); let app = app.arg(keyboard_language_option); - let compile_option = Arg::new("compile") - .long("compile") - .short('c') - .takes_value(false) - .help("Tells rusty ducky to compile the payload file. [NOT IMPLEMENTED YET!]") - .required(false); - let app = app.arg(compile_option); - - let transpile_option = Arg::new("transpile") - .long("transpile") - .short('t') - .takes_value(false) - .help("Tells rusty ducky to transpile the payload file to cuircut python.") - .required(false); - let app = app.arg(transpile_option); + // let compile_option = Arg::new("compile") + // .long("compile") + // .short('c') + // .takes_value(false) + // .help("Tells rusty ducky to compile the payload file. [NOT IMPLEMENTED YET!]") + // .required(false); + // let app = app.arg(compile_option); + + // let transpile_option = Arg::new("transpile") + // .long("transpile") + // .short('t') + // .takes_value(false) + // .help("Tells rusty ducky to transpile the payload file to cuircut python.") + // .required(false); + // let app = app.arg(transpile_option); let verbose_option = Arg::new("verbose") .long("verbose") @@ -113,8 +113,8 @@ impl Args { .value_of("language") .unwrap(); let verbose = matches.is_present("verbose"); - let compiled = matches.is_present("compile"); - let transpiled = matches.is_present("transpile"); + //let compiled = matches.is_present("compile"); + //let transpiled = matches.is_present("transpile"); let mut template: Option = None; if matches.is_present("template") { template = Some(matches.value_of("template").unwrap().to_string())} @@ -124,8 +124,9 @@ impl Args { output_file: output_file.to_string(), template_file: template, keyboard_language: keyboard_language.to_string(), - compile: compiled, - transpile: transpiled, + // change when compile is implemented + compile: false, + transpile: true, verbose: verbose } ) } diff --git a/src/transpiler/parser.rs b/src/transpiler/parser.rs index 19b1549..068fffa 100644 --- a/src/transpiler/parser.rs +++ b/src/transpiler/parser.rs @@ -9,8 +9,7 @@ use crate::DuckyError; use super::{KeyCode, KeyReport, RELEASE, Args}; fn load_layout(args: &Args) -> Result { - let file_location: String = format!("keyboard_layouts/{}.json", &args.keyboard_language.to_uppercase()); - let layout_file = match File::open(file_location) { + let layout_file = match File::open(&args.keyboard_language) { Ok(f) => Ok(f), Err(e) => { let verbose_error = format!("{}", e);