// public delegate Boolean isSuccess(); //声明委托 // public void AsyncCallbackImpl(IAsyncResult ar) // { // isSuccess iss = ar.AsyncState as isSuccess; // isConnection= iss.EndInvoke(ar); // } private void AutoConnect_button_Click(object sender, EventArgs e) { if (AutoConnect_button.Text == "自动重连") { AutoConnect_button.Text = "取消重连"; this.Refresh(); if (!WifiName_comboBox.Text.Equals("")) //合法输入判断 { foreach (WIFISSID SSID in wifiName) { if (SSID.SSID.Equals(WifiName_comboBox.Text.ToString())) { targetSSID = SSID; break; } } State state = new State(targetSSID, WifiPswd_textBox.Text.Trim().ToString(), authen, encry, time); // isSuccess iss=new isSuccess(state.AutoConThread); // AsyncCallback callback = new AsyncCallback(this.AsyncCallbackImpl); // iss.BeginInvoke(callback, iss); autoConnect = new Thread(state.AutoConThread); autoConnect.IsBackground = true; //设置线程为后台进程 //System.Environment.Exit(0); 也可以起到退出后程序完全关闭的效果 autoConnect.Start(); Thread.Sleep(3000); if (state.connectResult == false) { MessageBox.Show("连接失败!小提示:密码正确和设置正确才能连得上哦!"); } monitor = new Thread(state.monitorThread); monitor.IsBackground = true; monitor.Start(); isThread = true; // wifi.ConnectToSSID(targetSSID); } else { if (WifiName_comboBox.Text.Equals("")) { MessageBox.Show("请选择wifi!"); AutoConnect_button.Enabled = true; } } } else { AutoConnect_button.Text = "自动重连"; this.Refresh(); if (isThread) { AutoConnect_button.Enabled = true; // monitor.Abort(); autoConnect.Abort(); monitor.Abort(); // shutDown.Abort(); isThread = false; } } }
public List <WIFISSID> ScanSSID() { List <WIFISSID> wifiName = new List <WIFISSID>(); // WIFISSID SSID = new WIFISSID(); WlanClient client = new WlanClient(); foreach (WlanClient.WlanInterface wlanIface in client.Interfaces) { // Lists all networks with WEP security Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0); foreach (Wlan.WlanAvailableNetwork network in networks) { WIFISSID targetSSID = new WIFISSID(); targetSSID.wlanInterface = wlanIface; targetSSID.wlanSignalQuality = (int)network.wlanSignalQuality; targetSSID.SSID = GetStringForSSID(network.dot11Ssid); //targetSSID.SSID = Encoding.Default.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength); targetSSID.dot11DefaultAuthAlgorithm = network.dot11DefaultAuthAlgorithm.ToString(); targetSSID.dot11DefaultCipherAlgorithm = network.dot11DefaultCipherAlgorithm.ToString(); // Console.WriteLine(targetSSID.SSID); //if (targetSSID.SSID == "Tenda_4B8660") //{ // return targetSSID; //} wifiName.Add(targetSSID); } } return(wifiName); }
public Wifi(WIFISSID SSID, String pswd, String authen, String encry) { targetSSID = SSID; this.pswd = pswd; this.authen = authen; this.encry = encry; }
public State(WIFISSID SSID, String pswd, String authen, String encry, int time) { targetSSID = SSID; this.pswd = pswd; wifi = new Wifi(SSID, pswd, authen, encry); sw = new Stopwatch(); this.time = time * 60000; }
public CrackPassword(WIFISSID SSID, String authen, String encry, int passwordNumber) { this.passwordNumber = passwordNumber; this.SSID = SSID; this.authen = authen; this.encry = encry; allComboNumber = Math.Pow(10, this.passwordNumber); }
// private Boolean isConnection = true; // private XmlDocument doc = null; // private XmlNode node = null; // private XmlElement elem = null; public AutoConnect() { InitializeComponent(); wifi = new Wifi(); wifiName = new List <WIFISSID>(); targetSSID = new WIFISSID(); // doc = new XmlDocument(); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; }
public Crack(WIFISSID SSID, String authen, String encry) { InitializeComponent(); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; targetSSID = SSID; this.authen = authen; this.encry = encry; cp = new CrackPassword(targetSSID, authen, encry, passwordNumber); }
private void Crack_button_Click(object sender, EventArgs e) { if (WifiName_comboBox.Text.Equals("")) { MessageBox.Show("请先选择要破解的wifi名"); return; } foreach (WIFISSID SSID in wifiName) { if (SSID.SSID.Equals(WifiName_comboBox.Text.ToString())) { targetSSID = SSID; break; } } Crack crack = new Crack(targetSSID, authen, encry); crack.ShowDialog(); }