Skip to content
Extraits de code Groupes Projets
airbreaker.src 3,86 ko
Newer Older
  • Learn to ignore specific revisions
  • // Automates as most as possible the wifi cracking process
    // Requirements : crypto.so
    // On current version, aireplay must be installed and another Terminal is required
    
    
    imports = {}
    
    imports.utils = {}
    
    imports.utils.IncludeLib = function(libName, mandatory)
    	lib = include_lib("/lib/" + libName)
    	if not lib then
    		currentPath = get_shell.host_computer.current_path
    		lib = include_lib(currentPath + "/" + libName)
    	end if
    	if mandatory and not lib then exit("Error: Can't find " + libName + " library in the /lib path or the current folder")
    	return lib
    end function
    
    imports.utils.Exit = function(reason)
    	exit(reason)
    end function
    
    imports.utils.Choice = function(choices, reason)
    	len = choices.len
    	if len < 2 then return len-1
    	if not reason then print("Please choose "+reason)
    	while true
    		for index in range(0,len-1)
    			print(index+1 + ":" + choices[index])
    		end for
    		input = user_input("Enter the number to select then press ENTER: ")
    		input = input.trim().to_int - 1
    		if input >= 0 and input < len then return input
    		print("Not a recognized selection")
    	end while
    	return -1 // Should never happen
    end function
    
    imports.network = {}
    
    // Is it REALLY useful to call network_devices() for that one?
    imports.network.getNetDevices = function()
    	return ["eth0"]
    end function
    
    imports.network.getWifi = function(device)
    	result = []
    	for network in get_shell.host_computer.wifi_networks(device)
    		data = network.split(" ")
    		data[1] = imports.network.airpower(data[1])
    		result.push(data)
    	end for
    	return result
    end function
    
    // Formula is provided by GHTools, sorry!
    imports.network.airpower = function(strength)
    	return -1
    end function
    
    // command: airbreaker
    cryptools = imports.utils.IncludeLib("crypto.so")
    comp = get_shell.host_computer
    
    name = "aireplay"
    path = "/bin/"+name
    if not comp.File(path) then
    	path = get_shell.host_computer.current_path+"/"+name
    	if not comp.File(path) then imports.utils.Exit(name+" command is required")
    end if
    
    devices = imports.network.getNetDevices()
    if devices.len == 0 then imports.utils.Exit("No devices found")
    device = devices[imports.utils.Choice(devices)]
    
    if not cryptools.airmon("start", device) then imports.utils.Exit("Can't activate monitor mode on "+device)
    
    networks = imports.network.getWifi(device)
    
    choice = []
    for item in networks
    	choice.push(item[2])
    end for
    network = networks[imports.utils.Choice(choice, "a wifi network")]
    
    bssid = network[0]
    required = network[1]
    essid = network[2]
    
    
    // Nightly support
    if cryptools.hasIndex("aireplay") then
    
    	if required < 0 then
    		print("Please enter the number of ACKs you want to generate")
    		required = user_prompt().to_int
    		if typeof(required) == "string" or required < 0 then exit("Error: invalid number")
    	end if
        print("Generating <color=white>"+required+"</color> ACKs, please wait")
    	cryptools.aireplay(bssid,essid,required)
    
        if required < 0 then required ="*UNKNOWN*"
        print("Once <color=white>"+required+"</color> ACKs have been generated, do Ctrl+C")
    
    	args = "-b "+bssid+" -e "+essid
    	result = get_shell.launch(path, args)
    	if not result then
    		QUOTE = """"
    		print("It seems that 'get_shell.launch("+QUOTE+path+QUOTE+", "+QUOTE+args+QUOTE+")' doesn't work, so...")
    		print("1) Open another Terminal")
    		print("2) Paste '"+path+" "+args+"'")
    		print("3) When the ACKs are obtained, do Ctrl+C IN THE OTHER TERMINAL")
    		print("4) Once you're done, press Enter in THIS terminal\"+"n")
    		print("PS: I blame Albyton for the wasted 15 minutes writing this text!")
    		print("Press ENTER to continue")
    		user_input()
    	end if
    
    end if
    
    cryptools.airmon("stop", device)
    
    path = home_dir+"/file.cap"
    file = comp.File(path)
    
    if not file then imports.utils.Exit("Couldn't find file, expected "+path)
    
    
    password = cryptools.aircrack(home_dir+"/file.cap")
    if not comp.connect_wifi(device, bssid, essid, password) then imports.utils.Exit("Couldn't connect !?")
    
    print("Connected to " + essid + ", password : "+password)
    file.delete()