Grey Hack

Grey Hack

Not enough ratings
Wifi cracking and automatic switching
By Redit0
This is two utilities that are meant to be compiled and run in grey hack. The first is called xwifi. It automatically cracks the password for all wifi networks available, skipping low signal strength networks and networks that have already been cracked. The results are output to a file. This utility can be run any time, and it will update the list with new networks, and clear out networks that are no longer available.

The second is one i call nomad. It reads the file generated by xwifi and randomly switches which network you're connected to on an interval (in seconds) that you specify at the time that you run it. It reads the file every time, so you can run xwifi while nomad is running and it will take newly cracked networks into account when selecting one to switch to. It also ensures that it doesn't randomly switch to the same network you're already connected to.

These can run from anywhere, but they are designed to both run from the same location. Meaning, xwifi will create the file and write to it in whatever directory it's been run from, and nomad will expect to find that same file in whatever directory it's been run from.
   
Award
Favorite
Favorited
Unfavorite
xwifi
vars = {} vars.green = "<color=#81eb00><b>" vars.darkgreen = "<color=#007700><b>" vars.cyan = "<color=#0cddf2><b>" vars.blue = "<color=#3366ff><b>" vars.yellow = "<color=#dbd700><b>" vars.orange = "<color=#ffa500><b>" vars.magenta = "<color=#b0509e><b>" vars.red = "<color=#c30000><b>" vars.white = "<color=#eeeeee><b>" vars.lightgray = "<color=#b3b3b3><b>" vars.endcolor = "</b></color>" cryptools = include_lib("/lib/crypto.so") if not cryptools then cryptools = include_lib(current_path + "/crypto.so") end if if not cryptools then exit(vars.red + "[Error] Could not find crypto.so" + vars.endcolor) airmonResult = airmon(cryptools, "start", "wlan0") if typeof(airmonResult) == "string" then exit(vars.red + "[Error] Could not start monitor mode: " + airmonResult + vars.endcolor) else print(vars.darkgreen + "Monitoring mode started successfully" + vars.endcolor) end if //// FUNCTIONS alreadyCracked = function(results, network) for result in results networkName = result.split(" ")[1] if networkName == network then return 1 end for return 0 end function formatResults = function(results, colors = 0) list = [] for line in results parsed = line.split(" ") item = {} item.str = parsed[0] item.net = parsed[1] item.pass = parsed[2] list.push(item) end for list.sort("net") results = [] for item in list newLine = item.str + " " + item.net + " " + item.pass results.push(newLine) end for if colors then temp = vars.yellow + "Strength Network Password" + vars.endcolor for line in results temp = temp + char(10) + vars.green + line + vars.endcolor end for else temp = "Strength Network Password" for line in results temp = temp + char(10) + line end for end if return format_columns(temp) end function writeResults = function(results, file) text = formatResults(results) file.set_content(text) end function cleanResults = function(results) if results.len > 0 then print(vars.blue + "Cleaning Results..." + vars.endcolor) for index in range(results.len - 1) results[index] = replace_regex(results[index], "\s+", " ") end for end if end function removeStaleNetworks = function(results, networks) print(vars.blue + "Removing stale networks..." + vars.endcolor) for result in results essid = result.split(" ")[1] current = 0 for network in networks networkName = network.split(" ")[2] if essid == networkName then current = 1 break end if end for if not current then print(vars.red + "Removing: " + essid + vars.endcolor) index = results.indexOf(result) results.remove(index) end if end for end function //// END FUNCTIONS outputFile = "wifi.txt" comp = get_shell.host_computer file = comp.File(current_path + "/" + outputFile) networks = comp.wifi_networks("wlan0") results = [] if file and file.has_permission("r") then content = file.get_content if content then print(vars.blue + "Loading previous results..." + vars.endcolor) results = content.split(char(10))[1:] end if else print(vars.orange + "Could not load previous results, starting over..." + vars.endcolor) comp.touch(current_path, outputFile) file = comp.File(current_path + "/" + outputFile) end if cleanResults(results) removeStaleNetworks(results, networks) for network in networks parsed = network.split(" ") bssid = parsed[0] pwr = parsed[1][:-1].to_int essid = parsed[2] acks = floor(300000 / pwr) if alreadyCracked(results, essid) then print(vars.darkgreen + "Skipping " + essid + ", already cracked." + vars.endcolor) continue end if if pwr < 15 then print(vars.orange + "Skipping " + essid + ", strength " + pwr + "%." + vars.endcolor) continue end if print(vars.yellow + "Cracking " + essid + ", " + acks + " acks." + vars.endcolor) aireplayResult = cryptools.aireplay(bssid, essid, acks) if typeof(aireplayResult) == "string" then print(vars.red + "[Error] " + aireplayResult + vars.endcolor) continue end if pwd = cryptools.aircrack(current_path + "/file.cap") results.push(pwr + " " + essid + " " + pwd) writeResults(results, file) print(vars.green + pwr + " " + essid + " " + pwd + vars.endcolor) end for print(formatResults(results, 1))
nomad
green = function(str) return "<color=#81eb00><b>"+str+"</b></color>" end function magenta = function(str) return "<color=#b0509e><b>"+str+"</b></color>" end function red = function(str) return "<color=#c30000><b>"+str+"</b></color>" end function //// Functions getLines = function() file = get_shell.host_computer.File(current_path + "/wifi.txt") if not file then print(red("[Error] Could not find wifi.txt")) if not file.has_permission("r") then print(red("[Error] Could not read wifi.txt")) lines = file.get_content.split("\n")[1:] if lines.len == 0 then exit(red("[Error] The wifi.txt file is empty")) end if for index in range(lines.len - 1) lines[index] = replace_regex(lines[index], "\s+", " ") end for return lines end function getBssid = function(name) networks = get_shell.host_computer.wifi_networks("wlan0") for network in networks parsed = network.split(" ") bssid = parsed[0] essid = parsed[2] if essid == name then return bssid end for return null end function getRandom = function(max) return floor(rnd * max) end function getNetwork = function() lines = getLines max = lines.len index = getRandom(max) parsed = lines[index].split(" ") network = {} network["name"] = parsed[1] network["pass"] = parsed[2] return network end function //// End Functions if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(magenta("<b>Usage: nomad [interval in seconds]</b>")) end if interval = params[0].to_int count = 0 lastNetwork = null print(magenta("Nomad running...")) while true network = getNetwork() while network["name"] == lastNetwork network = getNetwork() end while print(green("Connecting to " + network["name"] + "...")) lastNetwork = network["name"] bssid = getBssid(network["name"]) get_shell.host_computer.connect_wifi("wlan0", bssid, network["name"], network["pass"]) wait(interval) end while