dos-attacks

git clone git://git.codymlewis.com/dos-attacks.git
Log | Files | Refs | README | LICENSE

main.rs (1427B)


      1 // Copyright (C) 2020 Cody Lewis
      2 //
      3 // This program is free software: you can redistribute it and/or modify
      4 // it under the terms of the GNU General Public License as published by
      5 // the Free Software Foundation, either version 3 of the License, or
      6 // (at your option) any later version.
      7 //
      8 // This program is distributed in the hope that it will be useful,
      9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 // GNU General Public License for more details.
     12 //
     13 // You should have received a copy of the GNU General Public License
     14 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
     15 
     16 extern crate pnet;
     17 
     18 use std::env;
     19 
     20 mod icmp_flood;
     21 
     22 fn main() {
     23     println!("dos-attacks  Copyright (C) 2020  Cody Lewis");
     24     println!("This program comes with ABSOLUTELY NO WARRANTY.");
     25     println!("This is free software, and you are welcome to redistribute it under certain conditions.");
     26     println!();
     27     let args: Vec<String> = env::args().collect();
     28     if args.len() < 3 {
     29         panic!("Not enough arguments");
     30     }
     31     let attack_name = &args[1];
     32     let addr = &args[2];
     33     run_attack(attack_name)(addr);
     34 }
     35 
     36 fn run_attack(attack: &String) -> Box<dyn Fn(&String)> {
     37     match attack.as_str() {
     38         "ping-flood" => Box::new(icmp_flood::run),
     39         _ => return Box::new(move |a| panic!("No attack named {}", a)),
     40     }
     41 }