This commit is contained in:
spv00 2023-11-29 18:39:18 +01:00
commit fd98e5f3fd
5 changed files with 1433 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1346
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

13
Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "discord_bruter"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.75"
getset = "0.1.2"
headless_chrome = {git = "https://github.com/atroche/rust-headless-chrome", features = ["fetch"]}
strum = { version = "0.25.0", features = ["strum_macros", "derive"] }
strum_macros = "0.25.3"

54
src/invite.rs Normal file
View File

@ -0,0 +1,54 @@
use getset::{Getters, Setters};
use headless_chrome::Browser;
use strum::Display;
#[derive(Getters, Setters, Debug)]
#[getset(get = "pub")]
pub struct DiscordInvite {
code: String,
}
impl DiscordInvite {
pub fn new(code: String) -> Self {
Self { code }
}
pub fn resolve(&self, browser: &Browser) -> Result<(), DiscordInviteError> {
let mut tab = browser
.new_tab()
.map_err(|e| DiscordInviteError::Unknown(format!("Failed to create new tab: {}", e)))?;
tab.navigate_to(&format!("https://discord.com/invite/{}", self.code))
.map_err(|e| {
DiscordInviteError::Unknown(format!("Failed to navigate to url: {}", e))
})?;
//std::thread::sleep(std::time::Duration::from_secs(4));
tab.wait_until_navigated().map_err(|e| {
DiscordInviteError::Unknown(format!("Failed to wait until navigated: {}", e))
})?;
let content = tab.get_content().unwrap();
return match content.contains("Invite Invalid") {
true => Err(DiscordInviteError::InvalidInvite),
false => Ok(()),
};
}
}
impl From<String> for DiscordInvite {
fn from(code: String) -> Self {
Self::new(code)
}
}
impl From<&str> for DiscordInvite {
fn from(code: &str) -> Self {
Self::new(code.to_string())
}
}
#[derive(Debug, Display)]
pub enum DiscordInviteError {
InvalidInvite,
RateLimit,
Timeout,
Unknown(String),
}

19
src/main.rs Normal file
View File

@ -0,0 +1,19 @@
use headless_chrome::protocol::cdp::Page;
use headless_chrome::Browser;
use invite::DiscordInvite;
use std::time::Duration;
pub mod invite;
fn main() -> anyhow::Result<()> {
let mut browser = Browser::default()?;
let mut invite = DiscordInvite::from("incestcentral");
let result = invite.resolve(&mut browser);
match result {
Ok(_) => println!("Invite is valid!"),
Err(e) => println!("Invite is invalid: {:?}", e),
}
Ok(())
}