-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkNet.cpp
More file actions
114 lines (110 loc) · 2.26 KB
/
Copy pathWorkNet.cpp
File metadata and controls
114 lines (110 loc) · 2.26 KB
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
#include<iostream>
#include<windows.h>
#include<string>
#include<fstream>
#include<vector>
#include <conio.h>
using namespace std;
void SetLang()
{
setlocale(LC_ALL, "rus");
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
}
void ClearFile(string name = "file.txt")
{
char path[MAX_PATH];
GetCurrentDirectory(sizeof(path), path);
string pp = path;
pp += "\\" + name;
ofstream outt(pp.c_str());
outt << "";
outt.close();
}
int main()
{
SetLang();
char path[MAX_PATH];
GetCurrentDirectory(sizeof(path), path);
string pp = path;
ClearFile();
pp = "netsh wlan show profiles >> " + pp + "\\file.txt";
system(pp.c_str());
pp = path;
ifstream inp(pp + "\\file.txt");
vector <string> sett;
while(inp.peek() != EOF)
{
string noww;
getline(inp, noww);
size_t pos = noww.find(" : ");
if (pos != string::npos)
sett.push_back(noww.substr(pos + 3, noww.size() - 1));
}
inp.close();
int pos = 0;
char ch;
do
{
string outstr;
for(int i = 0; i < sett.size(); i++)
{
if(pos == i)
{
outstr.append("> ");
}
else
{
outstr.append(" ");
}
outstr.append(sett[i] + '\n');
cout << outstr;
outstr = "";
}
ch = _getch();
system("cls");
if((ch == 80) && (pos < (sett.size() - 1)))
{
pos++;
}
else if((ch == 80) && (pos == (sett.size() - 1)))
{
pos = 0;
}
if(ch == 72 && pos > 0)
{
pos--;
}
else if(ch == 72 && pos == 0)
{
pos = sett.size() - 1;
}
}
while(ch != 13);
ClearFile();
pp = "netsh wlan show profiles name=\"" + sett[pos] + "\" key=clear >> " + static_cast<string>(path) + "\\file.txt";
system(pp.c_str());
pp = path;
inp.open(pp + "\\file.txt");
bool WifiIsOpen = true;
while(inp.peek() != EOF)
{
string noww;
getline(inp, noww);
size_t po = noww.find(" Ñîäåðæèìîå êëþ÷à : ");
if (po != string::npos)
{
cout << "Wifi: " << sett[pos] << "\tPassword: "<< noww.substr(34, noww.size() - 1) << "\n\n\n";
WifiIsOpen = false;
}
}
inp.close();
if(WifiIsOpen)
{
cout << "Ñåòü îòêðûòàÿ\nÍó èëè ïðîèçîøëà êàêàÿ-òî îøèáêà. Áûâàåò...\n\n\n";
}
ClearFile();
pp = "erase " + pp + "\\file.txt";
system(pp.c_str());
system("pause");
}