diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-05-07 22:40:47 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-05-07 22:40:47 +0200 |
commit | 268df91e3ced5ca92e21c83021d6b431190656a6 (patch) | |
tree | 1995ee7aaf7e9ad7eff81f8774b8b6e810943080 /src | |
download | phisher-268df91e3ced5ca92e21c83021d6b431190656a6.tar.gz phisher-268df91e3ced5ca92e21c83021d6b431190656a6.tar.bz2 phisher-268df91e3ced5ca92e21c83021d6b431190656a6.zip |
Initial commit.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 54 | ||||
-rw-r--r-- | src/main.rs | 39 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..45add28 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,54 @@ +// A program to scan emails for phishing links. +// Copyright (C) 2019 Harald Eilertsen +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. + +use chrono::{ DateTime, Utc }; +use serde::Deserialize; +use serde_json; +use std::io::{ BufRead, Result }; +use std::net::IpAddr; + +#[derive(Deserialize)] +pub struct PhishTank { + pub phishes: Vec<Phish>, +} + +#[derive(Deserialize)] +pub struct Phish { + pub phish_id: String, + pub url: String, + pub phish_detail_url: String, + pub submission_time: DateTime<Utc>, + pub verified: String, + pub verified_time: Option<DateTime<Utc>>, + pub online: String, + pub target: String, + pub details: Vec<PhishDetails>, +} + +#[derive(Deserialize)] +pub struct PhishDetails { + pub ip_address: IpAddr, + pub cidr_block: String, + pub announcing_network: String, + pub rir: String, + pub country: String, + pub detail_time: DateTime<Utc>, +} + +pub fn load_phistank<R: BufRead>(input: R) -> Result<PhishTank> { + let phishes = serde_json::from_reader(input)?; + Ok(PhishTank { phishes }) +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4e3076b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,39 @@ +// A program to scan emails for phishing links. +// Copyright (C) 2019 Harald Eilertsen +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. + +use phisher; +use clap::{clap_app, crate_name, crate_authors, crate_version, crate_description}; +use std::fs::File; +use std::io::BufReader; +use std::time::SystemTime; + +fn main() { + let args = clap_app!(app => + (name: crate_name!()) + (version: crate_version!()) + (author: crate_authors!()) + (about: crate_description!()) + (@arg PHISHTANK: --phishtank +required +takes_value "The phishtank json data file to use.") + ).get_matches(); + + let start_time = SystemTime::now(); + let r = BufReader::new(File::open(args.value_of("PHISHTANK").unwrap()).unwrap()); + let tank = phisher::load_phistank(r).unwrap(); + + println!("Loaded {} phishes in {} seconds!", + tank.phishes.len(), + start_time.elapsed().unwrap().as_secs()); +} |