Skip to content

Commit

Permalink
wip: tilde module cli args
Browse files Browse the repository at this point in the history
  • Loading branch information
phra committed Jun 28, 2019
1 parent 16a47f1 commit 4b15e4d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 43 deletions.
64 changes: 47 additions & 17 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ use clap::{App, Arg};
use terminal_size::{terminal_size, Height, Width};

pub struct CommonArgs {
pub wordlist_paths: Vec<String>,
pub no_banner: bool,
pub no_progress_bar: bool,
pub exit_on_connection_errors: bool,
pub n_threads: usize,
pub output: String,
}

pub struct WordlistArgs {
pub wordlist_paths: Vec<String>,
}

pub struct DNSArgs {
pub domain: String,
}
Expand Down Expand Up @@ -58,16 +61,6 @@ pub fn set_common_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
.long("no-banner")
.help("Skips initial banner"),
)
.arg(
Arg::with_name("wordlist")
.long("wordlist")
.help("Sets the wordlist")
.short("w")
.takes_value(true)
.multiple(true)
.use_delimiter(true)
.required(true),
)
.arg(
Arg::with_name("threads")
.long("threads")
Expand Down Expand Up @@ -202,6 +195,19 @@ pub fn set_dir_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
)
}

pub fn set_wordlist_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
app.arg(
Arg::with_name("wordlist")
.long("wordlist")
.help("Sets the wordlist")
.short("w")
.takes_value(true)
.multiple(true)
.use_delimiter(true)
.required(true),
)
}

pub fn set_tilde_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
app.arg(
Arg::with_name("extension")
Expand Down Expand Up @@ -269,11 +275,6 @@ pub fn set_fuzz_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
}

pub fn extract_common_args<'a>(submatches: &clap::ArgMatches<'a>) -> CommonArgs {
let wordlist_paths = submatches
.values_of("wordlist")
.unwrap()
.map(|w| w.to_owned())
.collect::<Vec<String>>();
let mut no_banner = submatches.is_present("no-banner");
let mut no_progress_bar = submatches.is_present("no-progress-bar");
let exit_on_connection_errors = submatches.is_present("exit-on-error");
Expand Down Expand Up @@ -302,7 +303,6 @@ pub fn extract_common_args<'a>(submatches: &clap::ArgMatches<'a>) -> CommonArgs
}

CommonArgs {
wordlist_paths,
no_banner,
no_progress_bar,
exit_on_connection_errors,
Expand Down Expand Up @@ -472,3 +472,33 @@ pub fn extract_tilde_args<'a>(submatches: &clap::ArgMatches<'a>) -> TildeArgs {
extension,
}
}

pub fn extract_wordlist_args<'a>(submatches: &clap::ArgMatches<'a>) -> Result<WordlistArgs, ()> {
let wordlist_paths = submatches
.values_of("wordlist")
.unwrap()
.map(|w| w.to_owned())
.collect::<Vec<String>>();

let all_wordlists_exist = wordlist_paths
.iter()
.map(|wordlist_path| {
if std::fs::metadata(wordlist_path).is_err() {
error!("Specified wordlist does not exist: {}", wordlist_path);
return false;
} else {
return true;
}
})
.fold(true, |acc, e| acc && e);

if !all_wordlists_exist {
return Err(());
}

Ok(
WordlistArgs {
wordlist_paths,
}
)
}
53 changes: 28 additions & 25 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ fn main() {
--csrf-url \"http://localhost:3000/csrf\" \\
--csrf-regex '\\{\"csrf\":\"(\\w+)\"\\}'
")
.subcommand(set_dir_args(set_http_args(set_common_args(SubCommand::with_name("dir"))))
.subcommand(set_wordlist_args(set_dir_args(set_http_args(set_common_args(SubCommand::with_name("dir")))))
.about("Directories and files enumeration mode")
.after_help("EXAMPLE:
rustbuster dir -u http://localhost:3000/ -w examples/wordlist -e php"))
.subcommand(set_dns_args(set_common_args(SubCommand::with_name("dns")))
.subcommand(set_wordlist_args(set_dns_args(set_common_args(SubCommand::with_name("dns"))))
.about("A/AAAA entries enumeration mode")
.after_help("EXAMPLE:
rustbuster dns -u google.com -w examples/wordlist"))
.subcommand(set_vhost_args(set_http_args(set_common_args(SubCommand::with_name("vhost"))))
.subcommand(set_wordlist_args(set_vhost_args(set_http_args(set_common_args(SubCommand::with_name("vhost")))))
.about("Virtual hosts enumeration mode")
.after_help("EXAMPLE:
rustbuster vhost -u http://localhost:3000/ -w examples/wordlist -d test.local -x \"Hello\""))
.subcommand(set_tilde_args(set_http_args(set_common_args(SubCommand::with_name("tilde"))))
.about("IIS 8.3 shortname enumeration mode")
.after_help("EXAMPLE:
rustbuster tilde -u http://localhost:3000/ -e aspx"))
.subcommand(set_fuzz_args(set_body_args(set_http_args(set_common_args(SubCommand::with_name("fuzz")))))
.subcommand(set_wordlist_args(set_fuzz_args(set_body_args(set_http_args(set_common_args(SubCommand::with_name("fuzz"))))))
.about("Custom fuzzing enumeration mode")
.after_help("EXAMPLE:
rustbuster fuzz -u http://localhost:3000/login \\
Expand All @@ -109,23 +109,6 @@ fn main() {

let common_args = extract_common_args(submatches);

let all_wordlists_exist = common_args
.wordlist_paths
.iter()
.map(|wordlist_path| {
if std::fs::metadata(wordlist_path).is_err() {
error!("Specified wordlist does not exist: {}", wordlist_path);
return false;
} else {
return true;
}
})
.fold(true, |acc, e| acc && e);

if !all_wordlists_exist {
return;
}

match submatches.occurrences_of("verbose") {
0 => trace!("No verbose info"),
1 => trace!("Some verbose info"),
Expand All @@ -146,14 +129,19 @@ fn main() {

match mode {
"dir" => {
let wordlist_args = match extract_wordlist_args(submatches) {
Err(_) => return,
Ok(v) => v,
};

let http_args = extract_http_args(submatches);
if !url_is_valid(&http_args.url) {
return;
}

let dir_args = extract_dir_args(submatches);
let urls = build_urls(
&common_args.wordlist_paths[0],
&wordlist_args.wordlist_paths[0],
&http_args.url,
dir_args.extensions,
dir_args.append_slash,
Expand Down Expand Up @@ -264,8 +252,13 @@ fn main() {
}
}
"dns" => {
let wordlist_args = match extract_wordlist_args(submatches) {
Err(_) => return,
Ok(v) => v,
};

let dns_args = extract_dns_args(submatches);
let domains = build_domains(&common_args.wordlist_paths[0], &dns_args.domain);
let domains = build_domains(&wordlist_args.wordlist_paths[0], &dns_args.domain);
let total_numbers_of_request = domains.len();
let (tx, rx) = channel::<SingleDnsScanResult>();
let config = DnsConfig {
Expand Down Expand Up @@ -360,7 +353,12 @@ fn main() {
return;
}

let vhosts = build_vhosts(&common_args.wordlist_paths[0], &dns_args.domain);
let wordlist_args = match extract_wordlist_args(submatches) {
Err(_) => return,
Ok(v) => v,
};

let vhosts = build_vhosts(&wordlist_args.wordlist_paths[0], &dns_args.domain);
let total_numbers_of_request = vhosts.len();
let (tx, rx) = channel::<SingleVhostScanResult>();
let config = VhostConfig {
Expand Down Expand Up @@ -460,6 +458,11 @@ fn main() {
return;
}

let wordlist_args = match extract_wordlist_args(submatches) {
Err(_) => return,
Ok(v) => v,
};

let body_args = extract_body_args(submatches);
let fuzz_args = extract_fuzz_args(submatches);

Expand All @@ -470,7 +473,7 @@ fn main() {
http_body: http_args.http_body.to_owned(),
user_agent: http_args.user_agent.to_owned(),
http_headers: http_args.http_headers,
wordlist_paths: common_args.wordlist_paths,
wordlist_paths: wordlist_args.wordlist_paths,
url: http_args.url.to_owned(),
ignore_status_codes: http_args.ignore_status_codes,
include_status_codes: http_args.include_status_codes,
Expand Down
2 changes: 1 addition & 1 deletion src/tildebuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl TildeBuster {
Ok(())
});

let _ = thread::spawn(move || rt::run(fut));
let _ = thread::spawn(move || rt::run(fut)).join();
}

fn _brute_extension(
Expand Down

0 comments on commit 4b15e4d

Please sign in to comment.