-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b82d08
commit 9d2c27c
Showing
7 changed files
with
203 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "abrute" | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
authors = ["Daniel P. Clark <[email protected]>"] | ||
description = "AESCrypt Brute force attempter." | ||
documentation = "http:https://danielpclark.github.io/abrute/index.html" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,79 @@ | ||
use std::process::{Command,Stdio}; | ||
use super::result::Error; | ||
use std::path::Path; | ||
use digits::Digits; | ||
use clap; | ||
|
||
pub fn validate_adjacent_input(v: String) -> Result<(), Error> { | ||
if v.parse::<u8>().is_ok() { return Ok(()); } | ||
Err(Error::InvalidAdjacentNumber) | ||
} | ||
|
||
pub fn validate_string_length(v: &str, max: usize) -> Result<(), Error> { | ||
if v.len() <= max { return Ok(()); } | ||
Err(Error::InvalidStringLength) | ||
pub fn validate_start_string(matches: &clap::ArgMatches, max: usize) -> Result<(), Error> { | ||
if let Some(s) = matches.value_of("start") { | ||
if s.len() > max { return Err(Error::InvalidStringLength); } | ||
|
||
let chrctrs: Vec<char> = matches.value_of("CHARACTERS").unwrap().chars().collect(); | ||
let mut itr = s.chars(); | ||
loop { | ||
match itr.next() { | ||
Some(ref c) => { | ||
if !chrctrs.contains(c) { return Err(Error::InvalidCharacterSet); } | ||
}, | ||
_ => break, | ||
} | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn validate_and_prep_sequencer_adjacent<'a>( | ||
sequencer: &mut Digits<'a>, | ||
adjacent: Option<&str> | ||
) -> Result<(), Error> { | ||
|
||
let seq_base = sequencer.base(); | ||
|
||
if let &Some(num) = &adjacent { | ||
validate_adjacent_input(num.to_string())?; | ||
if seq_base > 3 { | ||
sequencer.prep_non_adjacent(num.parse::<usize>().unwrap()); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn validate_file_exists(target: &str) -> Result<(), Error> { | ||
if !Path::new(target).exists() { | ||
return Err(Error::FileMissing) | ||
} | ||
|
||
Ok(()) | ||
|
||
} | ||
|
||
pub fn validate_aescrpyt_executable() -> Result<(), Error> { | ||
if Command::new("aescrypt"). | ||
stdout(Stdio::null()). | ||
stderr(Stdio::null()). | ||
spawn(). | ||
is_err() { | ||
return Err(Error::AescryptMissing); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn validate_unzip_executable() -> Result<(), Error> { | ||
if Command::new("unzip"). | ||
stdout(Stdio::null()). | ||
stderr(Stdio::null()). | ||
spawn(). | ||
is_err() { | ||
return Err(Error::UnzipMissing); | ||
} | ||
|
||
Ok(()) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
# Note: This is not directly executable. | ||
# This is for VIM syntax highlighting. | ||
|
||
describe "* abrute decrypts zip files" | ||
it "A) decrypts file" | ||
folder="$(pwd)" | ||
cd test/data/ | ||
../../target/debug/abrute 4 1234 -z -a 0 -- example.zip >/dev/null | ||
assert equal $? 0 | ||
cd $folder | ||
assert file_present test/data/zipped.file | ||
end | ||
|
||
it "B) clean up" | ||
rm test/data/zipped.file | ||
assert file_absent test/data/zipped.file | ||
end | ||
|
||
end |