Hi Chapin, I wrote this resolver for the VirusTotal API which I am looking to integrate into Chickadee
use reqwest::Client;
use serde_json::Value;
//hardcoded api key; implement alternative
const VIRUS_TOTAL_API_KEY: &str = "YOUR API KEY HERE";
async fn lookup_ip(ip: &str) -> Result<(), reqwest::Error> {
let client = Client::new();
let url = format!("https://www.virustotal.com/api/v3/ip_addresses/{}", ip);
//create request headers from API key
let mut headers = HeaderMap::new();
headers.insert(
"x-apikey",
HeaderValue::from_str(VIRUS_TOTAL_API_KEY).expect("Invalid API key"),
);
//send async request
let mut response = client
.get(&url)
.headers(headers)
.send()
.await?;
//parse response body as json
let response_body: Value = response.json().await?;
println!("Response: {:?}", response_body);
Ok(())
}
#[tokio::main]
async fn main() {
//implement cli arg here
let ip_address = "204.77.151.204";
if let Err(err) = lookup_ip(ip_address).await {
eprintln!("Error: {}", err);
}
}
/*to do:
parse output
impl arg for choosing resolver
*/