-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaireplayfragmentation.cpp
executable file
·217 lines (165 loc) · 6.3 KB
/
aireplayfragmentation.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
#include "aireplayfragmentation.h"
#include "ui_fragmentation.h"
#include <QDebug>
aireplayFragmentation::aireplayFragmentation(QWidget *parent) :
QWidget(parent),
ui(new Ui::fragmentation)
{
logThread::addLog("Constructor of fragmentation attack GUI", logInfo::MAIN);
attack = new attackFragmentation();
ui->setupUi(this);
connect(attack, SIGNAL(processOutput(QString)), this, SLOT(update(QString)));
connect(this->ui->pushButtonStop, SIGNAL(clicked()), this, SLOT(stop()));
connect(this->ui->pushButtonLog, SIGNAL(clicked()), this, SLOT(clearLog()));
this->arpReplay = NULL;
this->setStatus(STOPPED);
}
aireplayFragmentation::~aireplayFragmentation()
{
logThread::addLog("Destructor of fragmentation attack GUI", logInfo::MAIN);
delete ui;
delete attack;
if (arpReplay)
delete arpReplay;
}
void aireplayFragmentation::resetValues(){
this->ui->spinBoxReading->setValue(0);
}
void aireplayFragmentation::clearLog(){
utils::customClearLog(this->ui->textEdit, "Fragmentation Attack Log");
}
void aireplayFragmentation::toThisLog(QString com){
this->ui->textEdit->append(com);
}
QString aireplayFragmentation::getStatusQString()
{
switch (status) {
case STOPPED:
return "STOPPED";
break;
case ATTACKING:
return "ATTACKING";
break;
case OBTAINED:
return "OBTAINED";
break;
default:
return "UNKNOWN";
break;
}
}
void aireplayFragmentation::setStatus(STATUS s){
{status = s;}
switch (s) {
case STOPPED:
this->ui->lineEditStatus->setText("STOPPED");
utils::setBackgroundColor(this->ui->lineEditStatus, utils::RED);
break;
case ATTACKING:
this->ui->lineEditStatus->setText("ATTACKING...");
utils::setBackgroundColor(this->ui->lineEditStatus, utils::YELLOW);
break;
case OBTAINED:
this->ui->lineEditStatus->setText("OBTAINED");
utils::setBackgroundColor(this->ui->lineEditStatus, utils::GREEN);
break;
}
logThread::addLog("Fragmentation: Status changes to " + getStatusQString(), logInfo::MAIN);
emit statusChanged(getStatusQString());
}
void aireplayFragmentation::injectPaquet(){
logThread::addLog("Fragmentation: Injecting packet", logInfo::MAIN);
//If previuos arp is open, we delete
if (arpReplay)
delete arpReplay;
//inserting window arp replay
arpReplay = new aireplayArpReplay();
//connect to log
connect(this->arpReplay, SIGNAL(toLog(QString)), this, SLOT(toThisLog(QString)));
this->ui->tabWidget->addTab(arpReplay, "Step 2: Inject ARP Forged");
this->ui->tabWidget->setCurrentWidget(arpReplay);
arpReplay->showMaximized();
//We have not any decrypted packet so we cannot find ipdest, so using broadcast
//************************************************************************
//by this method, we obtain 1 IV per each ARP Paquet reinjected
//************************************************************************
const QString arpForged = utils::forgeARP(lastXor, lastBSSID, lastMAC,
"255.255.255.255",
"255.255.255.255");
if (arpForged.isEmpty()) {
toThisLog(utils::htmlRojo("arpForged Error File"));
return;
}
toThisLog(utils::htmlVerde(QString("arpForged and stored in " + arpForged)));
//start injecting
arpReplay->start(lastBSSID, lastMAC, arpForged);
toThisLog(utils::htmlVerde("INJECTING!!"));
emit succesfull("FRAGMENTATION ATTACK SUCCESFULL! RE-INYECTING!");
}
bool aireplayFragmentation::start(QString BSSID, QString MAC){
logThread::addLog(QString("Fragmentation: Starting attack with BSSID=%1, MAC=%2").arg(BSSID).arg(MAC), logInfo::MAIN);
//checking if the folder BSSID exists. If not, we create it to store there caps
if (!QFile::exists(FRAG_FOLDER + BSSID))
QDir::current().mkdir(FRAG_FOLDER + BSSID);
//set working directory
attack->getProcess()->setWorkingDirectory(FRAG_FOLDER + BSSID);
const bool ok = attack->start(BSSID, MAC);
if (ok) {
//storing BSSID & MAC
this->lastBSSID = BSSID;
this->lastMAC = MAC;
this->setStatus(ATTACKING);
}
return ok;
}
void aireplayFragmentation::stop(){
logThread::addLog("Fragmentation: Stopping", logInfo::MAIN);
if (attack->isRunning()) {
attack->stop();
toThisLog("Process stopped");
}
//stopping arpreplay step 2 also
if (arpReplay)
if (arpReplay->getStatus() != aireplayArpReplay::STOPPED)
arpReplay->stop();
this->setStatus(STOPPED);
}
void aireplayFragmentation::update(QString info){
info.remove("\n");
info.remove("\r");
if (!info.isEmpty()) {
if (info.contains("Read"))
this->ui->spinBoxReading->setValue(utils::dropNumber(info));
//arrive a packet
else if (info.contains("Size: ")){
toThisLog(utils::htmlVerde("We found a packet!!!"));
toThisLog(info);
}
//normal error
else if (info.contains("No answer") || info.contains("Not enough acks") ||
info.contains("trying another"))
toThisLog(utils::htmlRojo(info));
//good news
else if (info.contains("RELAYED"))
toThisLog(utils::htmlVerde(info));
//Saving keystream in fragment-0511-221818.xor
else if(info.contains("Saving keystream")) {
toThisLog(utils::htmlVerde(info));
//getting xor file
lastXor = FRAG_FOLDER + lastBSSID + "/" + info.split(' ').at(3);
//absolute path
lastXor = QFileInfo(lastXor).absoluteFilePath();
logThread::addLog("Fragmentation: Saving keystream to " + lastXor, logInfo::MAIN);
}
//obtained
else if (info.contains("Now you can build")) {
toThisLog(utils::htmlVerde("Building and preparing arp request to be injected..."));
this->setStatus(OBTAINED);
logThread::addLog("Fragmentation: ATTACK SUCCESFULL. Injecting in 1 second", logInfo::MAIN);
//LAUNCH INJECT!
QTimer::singleShot(1000, this, SLOT(injectPaquet()));
}
else
toThisLog(info);
}
}