def connect(wifi_name, wifi_password, auth_type): '''Connect WiFi''' wifi = PyWiFi() iface = wifi.interfaces()[0] iface.disconnect() time.sleep(1) profile_info = Profile() profile_info.ssid = wifi_name profile_info.auth = const.AUTH_ALG_OPEN if auth_type == "OPEN": profile_info.akm.append(const.AKM_TYPE_NONE) profile_info.cipher = const.CIPHER_TYPE_NONE else: profile_info.akm.append(const.AKM_TYPE_WPA2PSK) profile_info.cipher = const.CIPHER_TYPE_CCMP profile_info.key = wifi_password iface.remove_all_network_profiles() tmp_profile = iface.add_network_profile(profile_info) iface.connect(tmp_profile) time.sleep(1) if iface.status() == const.IFACE_CONNECTED: print("WiFi: %s 连接成功" % wifi_name) return True else: print("WiFi: %s 连接失败" % wifi_name) return False
def connect_wifi(self, wifi_name, wifi_password): self.iface.disconnect() #断开无线网卡连接 time.sleep(1) #缓冲1秒 profile_info = Profile() #wifi配置文件 profile_info.ssid = wifi_name #wifi名称 profile_info.auth = const.AUTH_ALG_OPEN #需要密码 profile_info.akm.append(const.AKM_TYPE_WPA2PSK) #加密类型 profile_info.cipher = const.CIPHER_TYPE_CCMP #加密单元 profile_info.key = wifi_password #wifi密码 self.iface.remove_all_network_profiles() #删除其他配置文件 tmp_profile = self.iface.add_network_profile(profile_info) #加载配置文件 self.iface.connect(tmp_profile) #连接 #尝试5秒是否能成功连接(时间过短可能会导致正确密码尚未连接成功) time.sleep(5) if self.iface.status() == const.IFACE_CONNECTED: print( '\n==========================================================================' ) print('wifi:{0}连接成功,密码:{1}'.format(wifi_name, wifi_password), end='') print( '==========================================================================\n' ) return True else: print('密码错误:{0}'.format(wifi_password), end='') return False
def pass2(): with open("D:/2.txt", "r") as f: for wifi_password in f: wifi = PyWiFi() iface = wifi.interfaces()[0] iface.disconnect() time.sleep(1) info = Profile() info.ssid = 'ChinaNet-FMNS' info.auth = const.AUTH_ALG_OPEN info.akm.append(const.AKM_TYPE_WPA2PSK) info.cipher = const.CIPHER_TYPE_CCMP info.key = wifi_password iface.remove_all_network_profiles() tmp = iface.add_network_profile(info) iface.connect(tmp) time.sleep(3) if iface.status() == const.IFACE_CONNECTED: print('成功') print(wifi_password) break else: print('失败') print(wifi_password)
def connect_wifi(self, wifi_name, wifi_key=None, akm='WPA2', check_connected=True): assert akm in ['None', 'WPA', 'WPA2'] profile = Profile() # The ssid of the AP(Authentication Profile). profile.ssid = wifi_name # The authentication algorithm of the AP. For normal case, almost all the APs use open algorithm. profile.auth = const.AUTH_ALG_OPEN # The cipher type of the AP. The cipher type should be set to the Profile if the akm is not AKM_TYPE_NONE. cipher = const.CIPHER_TYPE_CCMP if wifi_key == None: akm = 'None' cipher = const.CIPHER_TYPE_NONE else: profile.key = wifi_key profile.cipher = cipher # The key management type of the AP. profile.akm.append(self.akm[akm]) profile = self.iface.add_network_profile(profile) self.iface.connect(profile) if check_connected: return self.check_wifi_connected() else: return True
def on_StB5_clicked(self): wifi = PyWiFi() iface = wifi.interfaces()[0] self.ui.StE.append("网卡接口为\n" + iface.name()) profile = Profile() profile.ssid = "LANTT" profile.auth = const.AUTH_ALG_OPEN profile.akm.append(const.AKM_TYPE_WPA2PSK) profile.cipher = const.CIPHER_TYPE_CCMP profile.key = "5607893124" tep_profile = iface.add_network_profile(profile) iface.connect(tep_profile)
def test_connect(wifi_name,wifi_password): wifi = PyWiFi() iface = wifi.interfaces()[0] test_disconnect() time.sleep(3) profile_info = Profile() profile_info.ssid = wifi_name profile_info.auth = const.AUTH_ALG_OPEN profile_info.akm.append(const.AKM_TYPE_NONE) profile_info.cipher = const.CIPHER_TYPE_CCMP iface.remove_all_network_profiles() tmp_profile = iface.add_network_profile(profile_info) iface.connect(tmp_profile) time.sleep(5) if iface.status() == const.IFACE_CONNECTED: print("wifi: %s 连接成功"% wifi_name) else: print("wifi: %s 连接失败" % wifi_name)
def connect_wifi(self, wifi_ssid, password): profile = Profile() # 配置文件 profile.ssid = wifi_ssid # wifi名称 profile.auth = const.AUTH_ALG_OPEN # 需要密码 profile.akm.append(const.AKM_TYPE_WPA2PSK) # 加密类型 profile.cipher = const.CIPHER_TYPE_CCMP # 加密单元 profile.key = password # wifi密码 self.iface.remove_all_network_profiles() # 删除其他配置 tmp_profile = self.iface.add_network_profile(profile) # 加载配置 self.iface.connect(tmp_profile) # link start time.sleep(10) # 尝试10s是否成功 isok = True if self.iface.status() == const.IFACE_CONNECTED: return isok # 连接成功 else: isok = False # 连接失败设置isok = False self.iface.disconnect() # 避免超时后连接成功手动断开一下,因为在一定时间内连接失败用户会继续重试连接 time.sleep(1) return isok
def test1(wifi_name, wifi_password): wifi = PyWiFi() iface = wifi.interfaces()[0] iface.disconnect() time.sleep(1) info = Profile() info.ssid = wifi_name info.auth = const.AUTH_ALG_OPEN info.akm.append(const.AKM_TYPE_WPA2PSK) info.cipher = const.CIPHER_TYPE_CCMP info.key = wifi_password iface.remove_all_network_profiles() tmp = iface.add_network_profile(info) iface.connect(tmp) time.sleep(3) if iface.status() == const.IFACE_CONNECTED: print('成功') print(wifi_password) else: print('失败')
def main(ssid, password, number): profile = Profile() profile.ssid = ssid profile.auth = const.AUTH_ALG_OPEN profile.akm.append(const.AKM_TYPE_WPA2PSK) profile.cipher = const.CIPHER_TYPE_CCMP profile.key = password iface.remove_all_network_profiles() tmp_profile = iface.add_network_profile(profile) time.sleep(0.1) # if script not working change time to 1 !!!!!! iface.connect(tmp_profile) # trying to Connect time.sleep(0.35) # 1s if ifaces.status() == const.IFACE_CONNECTED: # checker time.sleep(1) print(BOLD, GREEN, '[*] Crack success!', RESET) print(BOLD, GREEN, '[*] password is ' + password, RESET) time.sleep(1) exit() else: print(RED, '[{}] Crack Failed using {}'.format(number, password))
def main(ssid, password): profile = Profile() profile.ssid = ssid profile.auth = const.AUTH_ALG_OPEN profile.akm.append(const.AKM_TYPE_WPA2PSK) profile.cipher = const.CIPHER_TYPE_CCMP profile.key = password iface.remove_all_network_profiles() tmp_profile = iface.add_network_profile(profile) time.sleep(0.5) iface.connect(tmp_profile) # trying to Connect time.sleep(0.35) if ifaces.status() == const.IFACE_CONNECTED: # checker time.sleep(1) print("[+] Password Found!") print("[+] Password is: " + password) time.sleep(1) return "Success" else: print('[-] Password Not Found! : ' + password)
def connect_wifi(ssid, password): # function to connect to Wi-Fi with Password wifi = PyWiFi() iface = wifi.interfaces()[0] iface.disconnect() # disconnects from the current Wi-Fi if any time.sleep(2) profile = Profile() # adding new Profile for given Wi-Fi profile.ssid = ssid profile.auth = const.AUTH_ALG_OPEN profile.akm.append(const.AKM_TYPE_WPA2PSK) profile.cipher = const.CIPHER_TYPE_CCMP profile.key = password print("\nConnecting to WiFi....") iface.connect(iface.add_network_profile(profile)) time.sleep(5) if iface.status() == const.IFACE_CONNECTED: print("\t>> Connected Successfully!") else: print("\t>> Failed to Connect!")
def main(ssid, password, number): profile = Profile() # create profile instance profile.ssid = ssid #name of client profile.auth = const.AUTH_ALG_OPEN # auth algo profile.akm.append(const.AKM_TYPE_WPA2PSK) # key management profile.cipher = const.CIPHER_TYPE_CCMP #type of cipher profile.key = password # use generated password iface.remove_all_network_profiles( ) # remove all the profiles which are previously connected to device tmp_profile = iface.add_network_profile(profile) # add new profile time.sleep(0.1) # if script not working change time to 1 !!!!!! iface.connect(tmp_profile) # trying to Connect time.sleep(0.35) # 1s if ifaces.status() == const.IFACE_CONNECTED: # checker time.sleep(1) print(BOLD, GREEN, '[*] Crack success!', RESET) print(BOLD, GREEN, '[*] password is ' + password, RESET) time.sleep(1) exit() else: print(RED, '[{}] Crack Failed using {}'.format(number, password))
def connect_wifi(): wifi = pywifi.PyWiFi() iface = wifi.interfaces()[0] profile = Profile() wifiUn = wifiDict["wifiName"] wifiPw = wifiDict["wifiPw"] if not wifiUn or not wifiPw: messagebox.showinfo("提示", "用户名和密码为空") return profile.ssid = wifiUn #用户名 profile.auth = const.AUTH_ALG_OPEN profile.akm.append(const.AKM_TYPE_WPA2PSK) #加密类型 profile.cipher = const.CIPHER_TYPE_CCMP decription = EncryptData(getEntrypyKey()) profile.key = decription.decrypt(wifiPw) iface.remove_all_network_profiles() #清除其他配置文件 tmp_profile = iface.add_network_profile(profile) #加载配置文件 iface.connect(tmp_profile) time.sleep(1) if iface.status() == const.IFACE_CONNECTED: logger.info('重新连接成功') else: logger.error('连接失败,重新连接') messagebox.showinfo("提示", "连接失败,请重新设置用户名和密码")
def connect_wifi(wifi_name, wifi_password): wifi = PyWiFi() # 创建一个无限对象 ifaces = wifi.interfaces()[0] # 取一个无限网卡 # print(ifaces.name()) # 输出无线网卡名称 ifaces.disconnect() # 断开网卡连接 # time.sleep(1) # 缓冲3秒 profile_info = Profile() # 配置文件 profile_info.ssid = wifi_name # wifi名称 profile_info.auth = const.AUTH_ALG_OPEN # 需要密码 profile_info.akm.append(const.AKM_TYPE_WPA2PSK) # 加密类型 profile_info.cipher = const.CIPHER_TYPE_CCMP # 加密单元 profile_info.key = wifi_password ifaces.remove_all_network_profiles() # 删除其他配置文件 tmp_profile = ifaces.add_network_profile(profile_info) # 加载配置文件 ifaces.connect(tmp_profile) # 连接 time.sleep(2) # (必不可少)尝试2秒能否成功连接 isok = True if ifaces.status() == const.IFACE_CONNECTED: print("成功切换连接为wifi: %s" % wifi_name) else: print("wifi: %s 连接失败" % wifi_name) # time.sleep(2) return isok