-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCLI.cpp
169 lines (154 loc) · 4.06 KB
/
CLI.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
#include "CLI.h"
CLI::CLI()
{
state = LISTHOSTS;
}
CLI::~CLI()
{
// dtor
}
void
CLI::mainLoop()
{
while (true) {
showMenu();
usleep(100000);
}
}
void
CLI::showHeader()
{
std::cout << "--------------ShockWave----------------" << std::endl;
std::cout << "-----------By Transpalette-------------" << std::endl;
std::cout << "--Kick 'em out of your personal space--" << std::endl;
std::cout << "***************************************" << std::endl
<< std::endl;
}
void
CLI::listConnectedHosts()
{
std::string iprange;
std::cout << "Enter the IP range to scan (<base_address>/<int_mask>), or leave empty to use the DHCP config: ";
getline(std::cin, iprange);
// TODO: Validate with a regex
int devices = network.getConnectedDevices(iprange);
std::cout << "[*] Done! ";
if (devices > 0) {
do {
std::cout << "Press enter to proceed...";
} while (std::cin.get() != '\n');
} else {
std::cout << "[*] No devices found on the network. Exiting..." << std::endl;
exit(0);
}
}
void
CLI::listInterfaces()
{
interfaces = network.getInterfaces();
int i = 0;
for (const std::wstring& iface : interfaces) {
std::wcout << ++i << ". " << iface << std::endl;
}
}
void
CLI::listAccessPoints()
{
std::cout << "[*] Scanning access points..." << std::endl;
aps = network.getAccessPoints();
std::cout << std::endl << std::endl;
int i = 0;
for (const std::pair<std::string, std::set<address_type>>& pair : aps) {
if (pair.first == "") {
aps.erase(pair.first);
continue;
}
std::cout << ++i << ". " << pair.first << " -> [";
for (std::set<address_type>::iterator it = pair.second.begin();
it != pair.second.end();
it++) {
std::cout << (*it).to_string();
if ((it != pair.second.end()) && (next(it) != pair.second.end()))
std::cout << ", ";
}
std::cout << "]" << std::endl;
}
}
void
CLI::chooseInterface(int no)
{
std::wstring w_iface = interfaces.at(no - 1);
// setup converter
using convert_type = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_type, wchar_t> converter;
// use converter (.to_bytes: wstr->str, .from_bytes: str->wstr)
std::string iface = converter.to_bytes(w_iface);
network.setSpoofingInterface(iface);
}
void
CLI::chooseAccessPoint(int no)
{
int i = 1;
for (std::map<std::string, std::set<address_type>>::iterator iterator =
aps.begin();
iterator != aps.end();
iterator++, i++) {
if (i == no) {
network.setBssid(*iterator->second.begin());
break;
}
}
}
void
CLI::showAction()
{
switch (state) {
case CHOOSEIF:
listInterfaces();
int interfaceNo;
std::cout << std::endl << std::endl << "[*] Choose the spoofing interface: ";
std::cin >> interfaceNo;
chooseInterface(interfaceNo);
state = LISTAPS;
break;
case LISTAPS:
listAccessPoints();
int ap;
std::cout << std::endl << std::endl << "[*] Choose the access point: ";
std::cin >> ap;
chooseAccessPoint(ap);
state = ATTACK;
break;
case LISTHOSTS:
listConnectedHosts();
state = WHITELIST;
break;
case WHITELIST:
state = CHOOSEIF;
break;
case ATTACK:
attack();
break;
}
}
void
CLI::showMenu()
{
if (state != WHITELIST)
system("clear");
showHeader();
showAction();
}
void
CLI::attack()
{
std::cout << "-> BSSID: " << network.getBssid() << std::endl;
//std::cout << "-> Target: 40:b4:cd:6e:de:d5" << std::endl << std::endl;
std::cout << "[*] Deauthenticating..." << std::endl;
network.startDeauth();
do
{
std::cout << "[*] Press enter to stop...";
} while (std::cin.get() != '\n');
network.stopDeauth();
}