コード例 #1
0
ファイル: main.py プロジェクト: LemonCANDY42/Wifi-detection
 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
コード例 #2
0
ファイル: WIFI_tool完美版.py プロジェクト: NFWcap/learngit
def connect_open(iface, bss):
    '''连接开放AP'''

    iface_name = iface.name()
    command_start = "dhclient " + iface_name
    iface.disconnect()
    time.sleep(3)
    '''添加配置文件'''

    profile_info = Profile()
    profile_info.ssid = bss.ssid
    profile_info.akm.append(const.AKM_TYPE_NONE)
    '''删除其他的配置'''

    iface.remove_all_network_profiles()
    tmp_profile = iface.add_network_profile(profile_info)
    iface.connect(tmp_profile)
    print("%s 正在连接开放网络 %s(%s)..." % (iface.name(), bss.ssid, bss.bssid))
    time.sleep(5)
    if iface.status() == const.IFACE_CONNECTED:
        print("wifi:%s(%s) 连接成功!" % (bss.ssid, bss.bssid))
        print("正在分配ip地址...")
        subprocess.call(command_release, shell=True)
        subprocess.call(command_start, shell=True)
        print("分配完成!")
    else:
        print("wifi:%s(%s) 连接失败!" % (bss.ssid, bss.bssid))
コード例 #3
0
    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
コード例 #4
0
ファイル: wifi1.py プロジェクト: badboy-wq/movie3mu8
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)
コード例 #5
0
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
コード例 #6
0
ファイル: main.py プロジェクト: hensir/LANTT
 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)
コード例 #7
0
    def connect_open(self, interface, bss):

        self.notify_Label.emit('Disconnecting from the current network...')
        interface.disconnect()
        time.sleep(2)
        profile_info = Profile()
        profile_info.ssid = bss.ssid
        profile_info.bssid = bss.bssid
        profile_info.akm.append(const.AKM_TYPE_NONE)
        interface.remove_all_network_profiles()
        tmp_profile = interface.add_network_profile(profile_info)
        self.notify_Label.emit("Begin to connect the AP:%s(%s)..." %
                               (bss.ssid, bss.bssid))
        interface.connect(tmp_profile)
コード例 #8
0
 def wifi_connect(self, iface):
     '''连接WIFI,网络连通返回真'''
     known_wifi = self.wifi_name.split(';')
     profile = Profile()  # 配置文件
     for wifi in known_wifi:
         iface.disconnect()
         time.sleep(1)
         profile.ssid = wifi  # wifi名称
         iface.connect(iface.add_network_profile(profile))
         time.sleep(5)
         network_ok = self.network_status()
         time.sleep(1)
         if network_ok:
             return True
     return False
コード例 #9
0
    def connect_encrypt(self, interface, bss, wifi_password):

        self.notify_Label.emit('Disconnecting from the current network...')
        interface.disconnect()
        time.sleep(2)
        profile_info = Profile()
        profile_info.ssid = bss.ssid
        profile_info.bssid = bss.bssid
        profile_info.akm.append(bss.akm[-1])
        profile_info.key = wifi_password
        interface.remove_all_network_profiles()
        tmp_profile = interface.add_network_profile(profile_info)
        self.notify_Label.emit("Begin to connect the AP:%s(%s)..." %
                               (bss.ssid, bss.bssid))
        interface.connect(tmp_profile)
コード例 #10
0
def wifi_connect(iface):
    '''连接WIFI,网络连通返回真'''
    known_wifi = ['NBLXZ_5G', 'HBNU']
    profile = Profile()  # 配置文件
    for wifi in known_wifi:
        iface.disconnect()
        time.sleep(1)
        profile.ssid = wifi  # wifi名称
        iface.connect(iface.add_network_profile(profile))
        print('正在尝试连接到%s...' % wifi)
        time.sleep(5)
        network_ok = network_status()
        time.sleep(1)
        if network_ok:
            return True
    return False
コード例 #11
0
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)
コード例 #12
0
ファイル: Mylib.py プロジェクト: bjjdyx345/PowerBankTest
    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
コード例 #13
0
ファイル: wifi1.py プロジェクト: badboy-wq/movie3mu8
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('失败')
コード例 #14
0
    def connect_open(self, interface, bss):

        iface_name = interface.name()
        interface.disconnect()
        time.sleep(2)
        profile_info = Profile()
        profile_info.ssid = bss.ssid
        profile_info.bssid = bss.bssid
        profile_info.akm.append(const.AKM_TYPE_NONE)
        interface.remove_all_network_profiles()
        tmp_profile = interface.add_network_profile(profile_info)
        interface.connect(tmp_profile)
        time.sleep(3)
        if interface.status() == const.IFACE_CONNECTED:
            self.TextBrowser_text_signal.emit(
                '%s is connected to %s(%s)' %
                (iface_name, bss.ssid, bss.bssid))
        else:
            self.TextBrowser_text_signal.emit("AP:%s(%s) connect failed!" %
                                              (bss.ssid, bss.bssid))
            self.TextBrowser_text_signal.emit("%s disconnected..." %
                                              iface_name)
コード例 #15
0
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))
コード例 #16
0
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)
コード例 #17
0
ファイル: wifiConnect.py プロジェクト: panghaibin/shuClient
    def run(self):
        try:
            wifi = PyWiFi()  # 创建一个wifi对象
            iface = wifi.interfaces()[0]  # 取第一个无限网卡

            iface.disconnect()  # 断开网卡连接
            profile = Profile()  # 配置文件
            profile.ssid = "Shu(ForAll)"  # wifi名称

            iface.remove_all_network_profiles()  # 删除其他配置文件
            tmp_profile = iface.add_network_profile(profile)  # 加载配置文件

            iface.connect(tmp_profile)  # 连接
            sleep(1)  # 不延时,wifi反应不过来

            s0 = "Shu(ForAll) 连接成功\n"
            shu = shuConnect(self.user, self.passwd, chose=2)
            s = s0 + shu.start_connect()

        except:
            s = 'macError'

        self.signalCon.emit(s)
コード例 #18
0
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!")
コード例 #19
0
ファイル: button.py プロジェクト: wuyoutiandi/lushigongju
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("提示", "连接失败,请重新设置用户名和密码")
コード例 #20
0
ファイル: WIFI_tool完美版.py プロジェクト: NFWcap/learngit
def connect_encrypt(iface, bss, wifi_password):
    '''连接有密码的AP'''

    iface_name = iface.name()
    command_start = "dhclient " + iface_name
    iface.disconnect()
    time.sleep(3)
    profile_info = Profile()
    profile_info.ssid = bss.ssid
    profile_info.akm.append(bss.akm[-1])  #akm的list的最新添加的一项
    profile_info.key = wifi_password
    iface.remove_all_network_profiles()
    tmp_profile = iface.add_network_profile(profile_info)
    iface.connect(tmp_profile)
    print("正在连接...")
    time.sleep(5)
    if iface.status() == const.IFACE_CONNECTED:
        print("wifi:%s(%s) 连接成功!" % (bss.ssid, bss.bssid))
        print("正在分配ip地址...")
        subprocess.call(command_release, shell=True)
        subprocess.call(command_start, shell=True)
        print('分配完成!')
    else:
        print("wifi:%s(%s) 连接失败!" % (bss.ssid, bss.bssid))
コード例 #21
0
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))
コード例 #22
0
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
コード例 #23
0
 def connect(self):
     profile = Profile()
     profile.ssid = 'BNUZ-Student'
     self.wifi.interfaces()[0].connect(profile)