~/greynoise-cli

2a9ea282402dff1074e2b338619e1ad5ee4c5af6 — Arthur Melton 9ef163f6 2 years ago
works
5 files changed, 930 insertions(+), 2 deletions(-)

A Cargo.lock
M Cargo.toml
A src/args.rs
M src/get.rs
M src/main.rs
A Cargo.lock +669 -0
@@ 0,0 1,669 @@

# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"

[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"

[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"

[[package]]
name = "bumpalo"
version = "3.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"

[[package]]
name = "cc"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"

[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chunked_transfer"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e"

[[package]]
name = "clap"
version = "4.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39"
dependencies = [
 "bitflags",
 "clap_derive",
 "clap_lex",
 "is-terminal",
 "once_cell",
 "strsim",
 "termcolor",
]

[[package]]
name = "clap_derive"
version = "4.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
dependencies = [
 "heck",
 "proc-macro-error",
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "clap_lex"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
 "os_str_bytes",
]

[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
 "cfg-if",
]

[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
 "errno-dragonfly",
 "libc",
 "winapi",
]

[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
 "cc",
 "libc",
]

[[package]]
name = "flate2"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
dependencies = [
 "crc32fast",
 "miniz_oxide",
]

[[package]]
name = "form_urlencoded"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8"
dependencies = [
 "percent-encoding",
]

[[package]]
name = "gn"
version = "0.1.0"
dependencies = [
 "clap",
 "lazy_static",
 "serde",
 "serde_json",
 "ureq",
]

[[package]]
name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"

[[package]]
name = "hermit-abi"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
dependencies = [
 "libc",
]

[[package]]
name = "idna"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6"
dependencies = [
 "unicode-bidi",
 "unicode-normalization",
]

[[package]]
name = "io-lifetimes"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c"
dependencies = [
 "libc",
 "windows-sys",
]

[[package]]
name = "is-terminal"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
dependencies = [
 "hermit-abi",
 "io-lifetimes",
 "rustix",
 "windows-sys",
]

[[package]]
name = "itoa"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"

[[package]]
name = "js-sys"
version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
dependencies = [
 "wasm-bindgen",
]

[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

[[package]]
name = "libc"
version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"

[[package]]
name = "linux-raw-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"

[[package]]
name = "log"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
 "cfg-if",
]

[[package]]
name = "miniz_oxide"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
dependencies = [
 "adler",
]

[[package]]
name = "once_cell"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"

[[package]]
name = "os_str_bytes"
version = "6.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"

[[package]]
name = "percent-encoding"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"

[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
 "proc-macro-error-attr",
 "proc-macro2",
 "quote",
 "syn",
 "version_check",
]

[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
 "proc-macro2",
 "quote",
 "version_check",
]

[[package]]
name = "proc-macro2"
version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
dependencies = [
 "unicode-ident",
]

[[package]]
name = "quote"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
dependencies = [
 "proc-macro2",
]

[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
 "cc",
 "libc",
 "once_cell",
 "spin",
 "untrusted",
 "web-sys",
 "winapi",
]

[[package]]
name = "rustix"
version = "0.36.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588"
dependencies = [
 "bitflags",
 "errno",
 "io-lifetimes",
 "libc",
 "linux-raw-sys",
 "windows-sys",
]

[[package]]
name = "rustls"
version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c"
dependencies = [
 "log",
 "ring",
 "sct",
 "webpki",
]

[[package]]
name = "ryu"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"

[[package]]
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
 "ring",
 "untrusted",
]

[[package]]
name = "serde"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
dependencies = [
 "serde_derive",
]

[[package]]
name = "serde_derive"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "serde_json"
version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
dependencies = [
 "itoa",
 "ryu",
 "serde",
]

[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"

[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"

[[package]]
name = "syn"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
dependencies = [
 "proc-macro2",
 "quote",
 "unicode-ident",
]

[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
 "winapi-util",
]

[[package]]
name = "tinyvec"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
dependencies = [
 "tinyvec_macros",
]

[[package]]
name = "tinyvec_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"

[[package]]
name = "unicode-bidi"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"

[[package]]
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"

[[package]]
name = "unicode-normalization"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
dependencies = [
 "tinyvec",
]

[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"

[[package]]
name = "ureq"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97acb4c28a254fd7a4aeec976c46a7fa404eac4d7c134b30c75144846d7cb8f"
dependencies = [
 "base64",
 "chunked_transfer",
 "flate2",
 "log",
 "once_cell",
 "rustls",
 "serde",
 "serde_json",
 "url",
 "webpki",
 "webpki-roots",
]

[[package]]
name = "url"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
dependencies = [
 "form_urlencoded",
 "idna",
 "percent-encoding",
]

[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "wasm-bindgen"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
dependencies = [
 "cfg-if",
 "wasm-bindgen-macro",
]

[[package]]
name = "wasm-bindgen-backend"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
dependencies = [
 "bumpalo",
 "log",
 "once_cell",
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-shared",
]

[[package]]
name = "wasm-bindgen-macro"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
dependencies = [
 "quote",
 "wasm-bindgen-macro-support",
]

[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-backend",
 "wasm-bindgen-shared",
]

[[package]]
name = "wasm-bindgen-shared"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"

[[package]]
name = "web-sys"
version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
dependencies = [
 "js-sys",
 "wasm-bindgen",
]

[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
 "ring",
 "untrusted",
]

[[package]]
name = "webpki-roots"
version = "0.22.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
dependencies = [
 "webpki",
]

[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
 "winapi-i686-pc-windows-gnu",
 "winapi-x86_64-pc-windows-gnu",
]

[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"

[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
 "winapi",
]

[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
 "windows_aarch64_gnullvm",
 "windows_aarch64_msvc",
 "windows_i686_gnu",
 "windows_i686_msvc",
 "windows_x86_64_gnu",
 "windows_x86_64_gnullvm",
 "windows_x86_64_msvc",
]

[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"

[[package]]
name = "windows_aarch64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"

[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"

[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"

[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"

[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"

[[package]]
name = "windows_x86_64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"

M Cargo.toml => Cargo.toml +1 -0
@@ 7,6 7,7 @@ edition = "2021"


[dependencies]
clap = { version = "4.0.32", features = ["derive"] }
lazy_static = "1.4.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
ureq = { version = "2.5.0", features = ["json"] }

A src/args.rs +127 -0
@@ 0,0 1,127 @@

use clap::{Parser, Subcommand};

lazy_static! {
    pub static ref ARGS: Args = Args::parse(); 
}

/// A cli program to check ips
#[derive(Parser, Clone)]
#[command(author, version, about, long_about = None)]
pub struct Args {
    /// The ip that you want to check
    pub ip: String,
    
    /// The value you want to get
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand, Clone)]
pub enum Commands {
    /// How much noise do they make on the internet
    #[command(subcommand)]
    Noise(NoiseCommand),

    /// The person / company running the ip 
    #[command(subcommand)]
    Riot(RiotCommand),
}

#[derive(Subcommand, Clone)]
pub enum NoiseCommand {
    /// If they make noise on the internet
    Get,
    /// The first time they have been seen 
    FirstSeen,
    /// The last time they have been seen 
    LastSeen,
    /// Has greynoise seen the ip 
    Seen,
    /// What they are doing 
    Tags,
    /// If they finish the tcp handshake or if they use udp 
    Spoofable,
    /// What are they seen as 
    Classification,
    /// What CVEs do they try and exploit 
    Cve,
    /// If the ip is a bot 
    Bot,
    /// Is the ip a VPN 
    Vpn,
    /// What VPN service are they
    VpnService,
    /// Information about the ip
    #[command(subcommand)]
    Metadata(NoiseMetadata),
    /// Information about what they scan
    #[command(subcommand)]
    Scan(NoiseScan),
    /// Information about what they try and look for / get
    #[command(subcommand)]
    Web(NoiseWeb),
}

#[derive(Subcommand, Clone)]
pub enum NoiseMetadata {
    /// The ID of the matchine
    Asn,
    /// The city the IP lives in
    City,
    /// The country where the IP lives
    Country,
    /// The Country code that the IP lives in
    CountryCode,
    /// The organization that the ip is under
    Organization,
    /// The category for the ip or what it does
    Category,
    /// If the IP is involved with tor
    Tor,
    /// The reverse dns of the ip
    Rdns,
    /// The operating system the matchine is running
    Os,
    /// The countries that they target
    DestinationCountries,
    /// The countries that they target but the country codes
    DestinationCountryCodes,
}

#[derive(Subcommand, Clone)]
pub enum NoiseScan {
    /// Get all the ports that the ip scans
    GetPorts,
    /// Get all the protocols the ip uses
    GetProtocols,
    /// Get all the data
    GetAll,
}

#[derive(Subcommand, Clone)]
pub enum NoiseWeb {
    /// Get all the paths that the ip looks for
    GetPaths,
    /// Get all the useragents the ip uses
    GetUseragents,
}

#[derive(Subcommand, Clone)]
pub enum RiotCommand {
    /// Get what the ip is used for
    Category,
    /// The name of the company / person that operates the ip
    Name,
    /// The description of the company / person
    Description,
    /// The explanation of the category
    Explanation,
    /// The time that the Riot profile was last updated or varified
    LastUpdate,
    /// The url to there logo
    LogoUrl,
    /// The reference to where the information about the company was obtained
    Reference,
    /// How trustworthy is the company / person and if you can ignore there requests
    TrustLevel,
}

M src/get.rs => src/get.rs +1 -1
@@ 85,7 85,7 @@ pub struct NoiseRawData {

#[derive(Deserialize)]
pub struct ScanItem {
    pub port: u16,
    pub protocal: Option<String>,
    pub protocol: Option<String>,
}

#[derive(Deserialize)]

M src/main.rs => src/main.rs +132 -1
@@ 1,3 1,134 @@

#[macro_use]
extern crate lazy_static;

mod get;
mod args;

use args::*;

fn main() {
    println!("Hello, world!");
    let args = ARGS.clone();
    match get::get(args.ip) {
        Ok(data) => {
            match args.command {
                Commands::Noise(noise) => match noise {
                    NoiseCommand::Get => println!("{}", data.metadata.noise.found),
                    NoiseCommand::FirstSeen => print_value_maybe_none(data.noiseProfile.firstSeen, "noise"),
                    NoiseCommand::LastSeen => print_value_maybe_none(data.noiseProfile.lastSeen, "noise"),
                    NoiseCommand::Seen => println!("{}", data.noiseProfile.seen),
                    NoiseCommand::Tags => match data.noiseProfile.tags {
                        Some(tags) => match tags.len() {
                            0 => return_error("There are no tags for this ip"),
                            _ => println!("{}", tags.join("\n"))
                        },
                        None => return_error("There are no tags for this ip"),
                    },
                    NoiseCommand::Spoofable => println!("{}", data.noiseProfile.spoofable),
                    NoiseCommand::Classification => print_value_maybe_none(data.noiseProfile.classification, "noise"),
                    NoiseCommand::Cve => match data.noiseProfile.cve {
                        Some(cve) => match cve.len() {
                            0 => return_error("There are no CVEs for this ip"),
                            _ => println!("{}", cve.join("\n"))
                        },
                        None => return_error("There are no CVEs for this ip"),
                    },
                    NoiseCommand::Bot => println!("{}", data.noiseProfile.bot),
                    NoiseCommand::Vpn => println!("{}", data.noiseProfile.vpn),
                    NoiseCommand::VpnService => print_value_maybe_none(data.noiseProfile.vpnService, "noise"),
                    NoiseCommand::Metadata(metadata) => match metadata {
                        NoiseMetadata::Asn => print_value_maybe_none(data.noiseProfile.metadata.asn, "noise"),
                        NoiseMetadata::City => print_value_maybe_none(data.noiseProfile.metadata.city, "noise"),
                        NoiseMetadata::Country => print_value_maybe_none(data.noiseProfile.metadata.country, "noise"),
                        NoiseMetadata::CountryCode => print_value_maybe_none(data.noiseProfile.metadata.countryCode, "noise"),
                        NoiseMetadata::Organization => print_value_maybe_none(data.noiseProfile.metadata.organization, "noise"),
                        NoiseMetadata::Category => print_value_maybe_none(data.noiseProfile.metadata.category, "noise"),
                        NoiseMetadata::Tor => println!("{}", data.noiseProfile.metadata.tor),
                        NoiseMetadata::Rdns => print_value_maybe_none(data.noiseProfile.metadata.rdns, "noise"),
                        NoiseMetadata::Os => print_value_maybe_none(data.noiseProfile.metadata.os, "noise"),
                        NoiseMetadata::DestinationCountries => match data.noiseProfile.metadata.destinationCountries {
                            Some(countries) => match countries.len() {
                                0 => return_error("There are no destination countries for this ip"),
                                _ => println!("{}", countries.join("\n"))
                            },
                            None => return_error("There are no destination countries for this ip"),
                        },
                        NoiseMetadata::DestinationCountryCodes => match data.noiseProfile.metadata.destinationCountryCodes {
                            Some(countries) => match countries.len() {
                                0 => return_error("There are no destination countries for this ip"),
                                _ => println!("{}", countries.join("\n"))
                            },
                            None => return_error("There are no destination countries for this ip"),
                        },
                    },
                    NoiseCommand::Scan(scan) => match scan {
                        NoiseScan::GetPorts => match data.noiseProfile.rawData.scan {
                            Some(scan) => match scan.len() {
                                0 => return_error("There are no ports scanned for this ip"),
                                _ => println!("{}", scan.iter().map(|x| x.port.to_string() ).collect::<Vec<_>>().join("\n"))
                            }
                            None => return_error("There are no ports scanned for this ip")
                        },
                        NoiseScan::GetProtocols => match data.noiseProfile.rawData.scan {
                            Some(scan) => {
                                let mut protocols = scan.iter().filter_map(|x| x.protocol.clone() ).collect::<Vec<String>>();
                                protocols.sort();
                                protocols.dedup();
                                match protocols.len() {
                                    0 => return_error("There are no protocols for this ip"),
                                    _ => println!("{}", protocols.join("\n"))
                                }
                            }
                            None => return_error("There are no protocols for this ip")
                        },
                        NoiseScan::GetAll => match data.noiseProfile.rawData.scan {
                            Some(scan) => match scan.len() {
                                0 => return_error("There are no ports scanned for this ip"),
                                _ => println!("{}", scan.iter().map(|x| format!("{}, {}", x.port, x.protocol.clone().unwrap_or("None".to_string()))).collect::<Vec<String>>().join("\n"))
                            }
                            None => return_error("There are no ports scanned for this ip")
                        }
                    },
                    NoiseCommand::Web(web) => match web {
                        NoiseWeb::GetPaths => match data.noiseProfile.rawData.web.paths {
                            Some(paths) => match paths.len() {
                                0 => return_error("There are no paths scanned by ip"),
                                _ => println!("{}", paths.join("\n"))
                            }
                            None => return_error("There are no paths scanned by ip")
                        },
                        NoiseWeb::GetUseragents => match data.noiseProfile.rawData.web.useragents {
                            Some(useragents) => match useragents.len() {
                                0 => return_error("There are no paths scanned by ip"),
                                _ => println!("{}", useragents.join("\n"))
                            }
                            None => return_error("There are no paths scanned by ip")
                        }
                    },
                },
                Commands::Riot(riot) => match riot {
                    RiotCommand::Category => print_value_maybe_none(data.riotProfile.category, "riot"),
                    RiotCommand::Name => print_value_maybe_none(data.riotProfile.name, "riot"),
                    RiotCommand::Description => print_value_maybe_none(data.riotProfile.description, "riot"),
                    RiotCommand::Explanation => print_value_maybe_none(data.riotProfile.explanation, "riot"),
                    RiotCommand::LastUpdate => print_value_maybe_none(data.riotProfile.lastUpdated, "riot"),
                    RiotCommand::LogoUrl => print_value_maybe_none(data.riotProfile.logoUrl, "riot"),
                    RiotCommand::Reference => print_value_maybe_none(data.riotProfile.reference, "riot"),
                    RiotCommand::TrustLevel => print_value_maybe_none(data.riotProfile.trustLevel, "riot"),
                },
            }
        },
        Err(_) => return_error("Could not find information about this ip")
    }
}

fn return_error(message: &str) {
    eprintln!("{}", message);
    std::process::exit(1);
}

fn print_value_maybe_none(value: String, under: &str) {
    match &value as &str {
        "" => return_error(&format!("Could not find any data for this, make sure that {} was found.\ngn {} {} get", under, ARGS.clone().ip, under)),
        _ => println!("{}", value),
    }
}