-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet.cpp
270 lines (195 loc) · 6.76 KB
/
net.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#include<QProcess>
#include<QDebug>
#include<QObject>
#include<QWidget>
#include<QString>
#include<iostream>
#include<QApplication>
#include<process.h>
#include<QFile>
#include<fstream>
#include<QDebug>
#include<QtNetwork/QHttp>
#include<QtNetwork/QNetworkAccessManager>
#include<QtNetwork/QUrlInfo>
#include<QDataStream>
#include<QEventLoop>
#include<QtNetwork/QNetworkReply>
#include<net.h>
#include<QCoreApplication>
#include<QtNetwork/QNetworkRequest>
#include<QtNetwork/QNetworkCookieJar>
#include<QTime>
#include<QTextStream>
#include<QFile>
#include<QMainWindow>
using namespace std;
int static j=90;
int static t=1;
net::net(QWidget *parent):QMainWindow(parent)
{
QWidget *widget = new QWidget;
QMenu *menu;
menu = menuBar()->addMenu( tr("&About") );
newaction = new QAction("Developer",this);
menu->addAction(newaction);
connect(newaction,SIGNAL(triggered()),this,SLOT(developer()));
lab = new QLabel;
lab->setText("<font color= red>See Status Here </font>");
but = new QPushButton("Terminate");
but1 = new QPushButton("Start");
but->setFixedSize(80,30);
but1->setFixedSize(80,30);
QHBoxLayout *lay = new QHBoxLayout;
lay->addWidget(but1);
lay->addWidget(but);
lay->addWidget(lab);
widget->setLayout(lay);
this->setWindowTitle("Ion Trolled 7th Block"); //setWindowIconText("Rajat");
//widget->setWindowTitle("Rajat Trolled Ion");
this->setCentralWidget(widget);
this->setStyleSheet("*{background-color:rgb(202,200, 200)}");
this->setWindowOpacity(.9);
this->show();
connect(but, SIGNAL(clicked()),this,SLOT(stop()));
connect(but1, SIGNAL(clicked()),this,SLOT(preprocess()));
}
void net::preprocess()
{
but1->setEnabled(0);
allprocess(0,0);
}
void net::allprocess(int u,int v)
{
QString path = QCoreApplication::applicationDirPath();
if(v==0)
{
lab->setText("<font color = green>Please Wait . . .</font>");
ofstream foot,fvbs0;
foot.open("k.bat");
QString str1 = "@echo off\n netsh interface ip set dns \"Wireless Network Connection\" static 10.49.0.45";
char *ch1= str1.toLocal8Bit().data();
foot.write(ch1,str1.length());
foot.close();
fvbs0.open("k.vbs");
QString strvbs0 = "Set WshShell = CreateObject(\"WScript.Shell\")\nWshShell.Run chr(34) & \""+path+"/k.bat\" & Chr(34), 0\nSet WshShell = Nothing";
char *chvbs0= strvbs0.toLocal8Bit().data();
fvbs0.write(chvbs0,strvbs0.length());
qDebug()<<chvbs0;
fvbs0.close();
QProcess myprocess1;
QString script1 = "cscript";
QStringList args1;
args1<<QString(QDir::currentPath()+ "/k.vbs");
myprocess1.start(script1,args1);
delay();
myprocess1.start(script1,args1);
}
ofstream fout,fvbs,fping,fvbsping;
QString str,strvbs,strping,strvbsping;
qDebug()<<u;
if(j<255)
{ if(u==1)
exit(0);
else
{
++j;
fout.open("l.bat");
str = "@echo off\nnetsh interface ip set address name=\"Wireless Network Connection\" static 10.67.0."+ QString::number(j)+ " 255.255.255.0 10.67.0.1\n";
char *ch= str.toLocal8Bit().data();
fout.write(ch,str.length());
qDebug()<<ch;
fout.close();
fvbs.open("l.vbs");
strvbs = "Set WshShell = CreateObject(\"WScript.Shell\")\nWshShell.Run chr(34) & \""+path+"/l.bat\" & Chr(34), 0\nSet WshShell = Nothing";
char *chvbs= strvbs.toLocal8Bit().data();
fvbs.write(chvbs,strvbs.length());
qDebug()<<chvbs;
fvbs.close();
fping.open("p.bat");
strping = "@echo off\nping google.com>ion.txt";
char *chping= strping.toLocal8Bit().data();
fping.write(chping,strping.length());
fping.close();
qDebug()<<chping;
fvbsping.open("p.vbs");
strvbsping = "Set WshShell = CreateObject(\"WScript.Shell\")\nWshShell.Run chr(34) & \""+path+"/p.bat\" & Chr(34), 0\nSet WshShell = Nothing";
char *chvbsping= strvbsping.toLocal8Bit().data();
fvbsping.write(chvbsping,strvbsping.length());
fvbsping.close();
qDebug()<<chvbsping;
QProcess myprocess;
QString script = "cscript";
QStringList args;
args<<QString(QDir::currentPath()+ "/l.vbs");
myprocess.start(script,args);
delay();
lab->setText("<b><font color = blue>Attempt No. : </font></b>"+ QString::number(t));
++t;
QProcess process2;
QString sscript = "cscript";
QStringList argss;
argss<<QString(QDir::currentPath()+ "/p.vbs");
process2.start(sscript,argss);
delay();
qDebug()<<"system call made";
requestFinished();
}
}
}
void net::delay()
{
QTime dieTime= QTime::currentTime().addSecs(4);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
void net::requestFinished()
{
qDebug()<<"in RequestFInished";
QFile file("ion.txt");
file.open(QIODevice::ReadWrite | QIODevice::Text);
QTextStream in(&file);
QString line = in.readAll();
qDebug()<<line;
if(line.contains("Reply"))
{
lab->setText("<b>CONNECTED !!</b><br><b>Here it is</b></br><br><b>Enjoy The World Of INTERNET</b> ");
for(;;)
delay();
file.close();
qDebug()<<"yes";
replystat(1);
}
else
{lab->setText("<b><font color = green>Checking For Connectivity . . . .</font></b>");
file.close();
delay();
replystat(0);
}
}
int net::replystat(int x)
{
qDebug()<<"in return";
allprocess(x,1) ;
return 0;
}
void net::stop()
{
exit(0);
}
void net::developer()
{
QWidget *devel = new QWidget;
QLabel *lab = new QLabel;
lab->setText("<p><b>Developed By:</b><br><b> RAJAT GUPTA</b><br><b>MIT Manipal</b><br>""<br><b>[email protected]</b><br><b><font color=\"white\">www.facebook.com/LUGManipal</font></b></p>");
QVBoxLayout lay;
lay.addWidget(lab);
devel->setLayout(&lay);
devel->setStyleSheet("*{background-color:rgb(10,125, 200 )}");
devel->setWindowTitle("LUG Manipal");
devel->show();
}
void net::closeEvent(QCloseEvent *e)
{
exit(0) ;
}