-
Notifications
You must be signed in to change notification settings - Fork 0
/
aireplayarpreplay.cpp
executable file
·168 lines (133 loc) · 4.82 KB
/
aireplayarpreplay.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
#include "aireplayarpreplay.h"
#include "ui_aireplayarpreplay.h"
aireplayArpReplay::aireplayArpReplay(QWidget *parent) :
QWidget(parent),
ui(new Ui::aireplayArpReplay)
{
logThread::addLog("Constructor of ARP replay GUI", logInfo::MAIN);
attack = new attackArpReplay();
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->setStatus(STOPPED);
}
aireplayArpReplay::~aireplayArpReplay()
{
logThread::addLog("Destructor of ARP replay GUI", logInfo::MAIN);
delete ui;
delete attack;
}
QString aireplayArpReplay::getStatusQString()
{
switch (status) {
case STOPPED:
return "STOPPED";
break;
case READING:
return "READING";
break;
case SENDING:
return "SENDING";
break;
default:
return "UNKNOWN";
break;
}
}
void aireplayArpReplay::resetValues(){
this->ui->spinBoxReading->setValue(0);
this->ui->spinBoxSended->setValue(0);
this->ui->spinBoxSending->setValue(0);
this->ui->spinBoxArpRequests->setValue(0);
}
void aireplayArpReplay::clearLog(){
utils::customClearLog(this->ui->textEdit, "Aireplay ARP Replay Log");
}
void aireplayArpReplay::toThisLog(const QString &com){
this->ui->textEdit->append(com);
}
void aireplayArpReplay::setStatus(STATUS s){
{status = s;}
switch (s) {
case STOPPED:
this->ui->lineEditStatus->setText("STOPPED");
utils::setBackgroundColor(this->ui->lineEditStatus, utils::RED);
break;
case READING:
this->ui->lineEditStatus->setText("READING PACKETS...");
utils::setBackgroundColor(this->ui->lineEditStatus, utils::YELLOW);
break;
case SENDING:
utils::setBackgroundColor(this->ui->lineEditStatus, utils::GREEN);
this->ui->lineEditStatus->setText("REINJECTING ARP PACKETS...");
emit succesfull("ARP REPLAY ATTACK SUCCESFULL! RE-INYECTING!");
break;
}
logThread::addLog("ARP Replay: Status changes to " + getStatusQString(), logInfo::MAIN);
emit statusChanged(getStatusQString());
}
bool aireplayArpReplay::start(const QString &BSSID, QString MAC, QString cap){
logThread::addLog(QString("ARP Replay: Starting attack with BSSID=%1, MAC=%2, cap=%3")
.arg(BSSID).arg(MAC).arg(cap), logInfo::MAIN);
//checking if the folder BSSID exists. If not, we create it to store there caps
if (!QFile::exists(ARP_FOLDER + BSSID))
QDir::current().mkdir(ARP_FOLDER + BSSID);
//set working directory
attack->getProcess()->setWorkingDirectory(ARP_FOLDER + BSSID);
const bool ok = attack->start(BSSID, MAC, cap);
if (ok)
this->setStatus(READING);
return ok;
}
void aireplayArpReplay::stop(){
logThread::addLog("ARP Replay: Stopping", logInfo::MAIN);
if (attack->isRunning()) {
attack->stop();
toThisLog("Process stopped");
}
this->setStatus(STOPPED);
}
void aireplayArpReplay::update(QString info){
static int arpAux;
info.remove("\n");
info.remove("\r");
if (!info.isEmpty()) {
//cheking errors
if (info.contains("failed") || info.contains("select failed") || info.contains("but the AP uses")){
toThisLog(utils::htmlRojo(info));
this->ui->pushButtonStop->click();
return;
}
//ckecking succesful.
//where we store the arp cap
else if (info.contains("Saving"))
toThisLog(utils::htmlVerde(info + " (" + ARP_FOLDER + ")"));
//skipping 'You should also start airodump-ng to capture replies.'
else if (info.contains("You should"))
;
//Read 1 packets (got 0 ARP requests and 0 ACKs), sent 0 packets...(0 pps)
else if (info.contains("Read")){
//drop to reading
this->ui->spinBoxReading->setValue(utils::dropNumber(info));
//drop ACKS
this->ui->spinBoxACK->setValue(utils::dropNumber(info.split("ARP").at(1)));
//drop ARP
arpAux = utils::dropNumber(info.split('(').at(1));
//WE GOT ANY ARP???
if (arpAux != 0){
if (this->getStatus() != SENDING) {
this->setStatus(SENDING);
//drop pps (one time)
this->ui->spinBoxSending->setValue(GLOBALS::SEND_RATE);
}
this->ui->spinBoxArpRequests->setValue(arpAux);
//drop sent
this->ui->spinBoxSended->setValue(utils::dropNumber(info.split(',').at(1)));
}
}
//normal information
else
toThisLog(info);
}
}