From 5d3cb90d4a9e273975b1c92e6242a2dabee5d336 Mon Sep 17 00:00:00 2001 From: starrysky <2152773194@qq.com> Date: Sun, 26 Jan 2025 16:01:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A9=E4=BB=A3=E7=A0=81=E5=8F=98=E5=BE=97?= =?UTF-8?q?=E5=A5=BD=E7=9C=8B=EF=BC=8C=E5=85=81=E8=AE=B8=E7=8E=A9=E5=AE=B6?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E7=94=9F=E6=88=90=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E9=95=BF=E5=BA=A6=EF=BC=88=E9=9A=8F=E6=9C=BA=E5=AD=97?= =?UTF-8?q?=E6=AF=8D=E9=83=A8=E5=88=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot_socks5.rs | 22 +--------------------- src/configuration.rs | 21 +++------------------ src/main.rs | 33 --------------------------------- src/utils.rs | 2 +- 4 files changed, 5 insertions(+), 73 deletions(-) diff --git a/src/bot_socks5.rs b/src/bot_socks5.rs index 69ae0d5..fb4f1e6 100644 --- a/src/bot_socks5.rs +++ b/src/bot_socks5.rs @@ -20,31 +20,11 @@ pub struct BotMessage { pub last_keepalive_sec: u64, } -// impl Clone for BotVariable { -// fn clone(&self) -> Self { -// Self { spam_file: self.spam_file.clone() } -// } -// } - // 定义一个StreamType的特性,要求实现Read和Write,且含有connect函数 pub trait StreamType: Read + Write { fn connect(server_addr: &str,proxy_addr: &str) -> Result where Self: Sized; } -// *由于下面的Stream已经实现过connect了,所以这里没必要重复一遍 -// // 然后让Socks5Stream实现StreamType -// impl StreamType for Socks5Stream{ -// fn connect(server_addr: &str,proxy_addr: &str) -> Result where Self: Sized { -// return Socks5Stream::connect(proxy_addr, server_addr); -// } -// } -// // 再让TcpStream实现StreamType -// impl StreamType for TcpStream { -// fn connect(server_addr: &str,_: &str) -> Result where Self: Sized { -// return TcpStream::connect(server_addr); -// } -// } - // Bot泛型版 pub struct Bot { pub username: String, @@ -307,7 +287,7 @@ impl Bot { && !login_command_flag { // 登录3s后且未执行过登录命令 let commands = self.config.login_commands().clone(); for i in commands{ - self.send_command(i.to_string()).await.unwrap(); + self.send_command(i.to_string()).await.unwrap_or(()); thread::sleep(Duration::from_secs(1)); } info!("[{}/WORKER] Login commands executed!",self.username); diff --git a/src/configuration.rs b/src/configuration.rs index 61906ce..2580b6e 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -8,6 +8,7 @@ pub struct Configuration { server_ip: String, server_port: String, username_prefix: String, + pub name_len_limit: Vec, count: i32, proxy_url: String, reco_words: Vec, @@ -58,6 +59,7 @@ impl Configuration { server_ip: "m.earthvillage.top".to_string(), server_port: "33009".to_string(), username_prefix: "".to_string(), + name_len_limit: vec![4,8], count: 300, proxy_url: "http://uu-proxy.com/api/get_proxies?id=RZ7GS5ZYTA&size=1&schemes=socks5&support_https=false&format=json".to_string(), reco_words: vec!["AntiAttack".to_string()], @@ -102,21 +104,4 @@ impl Configuration { pub fn random_prefix(&self) -> bool { self.random_prefix } -} - -// impl Clone for Configuration { -// fn clone(&self) -> Self { -// Configuration { -// server_ip: self.server_ip.clone(), -// server_port: self.server_port.clone(), -// username_prefix: self.username_prefix.clone(), -// count: self.count, -// proxy_url: self.proxy_url.clone(), -// reco_words: self.reco_words.clone(), -// login_commands:self.login_commands.clone(), -// random_prefix: self.random_prefix, -// spam_file: self.spam_file.clone(), -// spam_delay_ms: self.spam_delay_ms, -// } -// } -// } \ No newline at end of file +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4a3f160..56e29fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,26 +16,10 @@ use tokio::sync::Mutex; use crate::utils::generate_username; use crate::configuration::Configuration; -// 暂且保留一下 -// // 目标的ip地址(暂时不能解析dns) -// // 理论上你可以把它改成任何支持1.20.1的服务器 -// const SERVER_ADDR: &str = "49.70.3.146:33009"; -// // uu代理的api(用来实时获取代理) -// const UU_URL: &str = "http://uu-proxy.com/api/get_proxies?id=RZ7GS5ZYTA&size=1&schemes=socks5&support_https=false&format=json"; -// // 用户名的开头 -// // 这很不错了 -// const USERNAME_PREFIX: &str = "Nikke_"; // 2 3 3 -// // 假人数量 -// const COUNT :i32 = 300; - #[tokio::main] async fn main() { let mut logger_builder = env_logger::Builder::from_default_env(); logger_builder.filter_level(log::LevelFilter::Info); - // logger_builder.format(|buf,record| { - // buf.write(format!("[{}/{}] {}\n", record.target(),record.level(),record.args()).as_bytes()).unwrap(); - // Ok(()) - // }); logger_builder.init(); // 一个互斥锁,防止有多个线程同时请求uuproxy let thread_lock = Arc::new(Mutex::new(())); @@ -44,10 +28,6 @@ async fn main() { let configuration = Configuration::new("config.json"); let configuration_rc = Arc::new(configuration); let mut spam_file = None; - if configuration_rc.username_prefix().len() > 14 { - error!("Error: Username prefix should not longer than 14"); - return; - } if !configuration_rc.clone().spam_file().is_empty() { spam_file = Some(tokio::fs::File::open(configuration_rc.clone().spam_file()).await.unwrap()); } @@ -75,13 +55,6 @@ async fn main() { let configuration_rc_clone = configuration_rc.clone(); let variables_clone = variables.clone(); let rt_update_clone = rt_update.clone(); - // let handle = tokio::spawn(async move { - // attack_thread(lock_clone).await; - // println!("[MAIN] Thread {} created", i); - // }); - // 生成一个线程 - // let handle = tokio::task::spawn(attack_thread(lock_clone,configuration_rc_clone,variables_clone)); - // let handle; if configuration_rc.use_thread_pool { rt.spawn(attack_thread(lock_clone,configuration_rc_clone,variables_clone,rt_update_clone)); }else{ @@ -97,13 +70,7 @@ async fn main() { }); }); } - // handles.push(handle); - // println!("[MAIN] Thread {} created", i) // 这个太吵了( } - - // 等待所有任务完成(虽然大概也许可能这辈子都等不到) - // for _ in handles { - // } let lock_clone = thread_lock.clone(); let configuration_rc_clone = configuration_rc.clone(); let variables_clone = variables.clone(); diff --git a/src/utils.rs b/src/utils.rs index 0037cd0..7a1a2b1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -57,6 +57,6 @@ pub fn generate_string(len_min: i64, len_max: i64) -> String { pub fn generate_username(config: &Arc) -> String { config.username_prefix().to_string() + generate_string( - 2,16-config.username_prefix().len() as i64 + config.name_len_limit[0], config.name_len_limit[1] ).to_string().as_str() } \ No newline at end of file