diff --git a/src/echotest.src b/src/echotest.src new file mode 100644 index 0000000..be27254 --- /dev/null +++ b/src/echotest.src @@ -0,0 +1 @@ +print "Echo Echo Echo Echo Echo" diff --git a/src/randomwifi.src b/src/randomwifi.src new file mode 100644 index 0000000..445ee41 --- /dev/null +++ b/src/randomwifi.src @@ -0,0 +1,63 @@ + +crypto = include_lib("/lib/crypto.so") + +if not crypto then + exit("Can't find crypto.so in /lib") +end if + +max = function(max, num) + if num > max then return max + return num +end function + +get_random_good_wifi = function() + hostComputer = get_shell.host_computer + networks = hostComputer.wifi_networks("wlan0") + result = [] + for network in networks + parsedItem = network.split(" ") + item = {} + item.BSSID = parsedItem[0] + item.PWR = parsedItem[1][:-1].to_int() + item.ESSID = parsedItem[2] + result.push(item) + end for + sort(result, "PWR") + len = result.len() + slice(result, len/2, -(max(10, len/4))) + result.shuffle() + return result.pop() +end function + +selectedWifi = get_random_good_wifi() +potentialAcks = 300000 / selectedWifi.PWR + +print("Will need " + potentialAcks + " to get into " + selectedWifi) + +res = crypto.airmon("start", "wlan0") +if not res == true then + exit("Can't put wifi in monitor mode:"+ res) +end if + +res = crypto.aireplay(selectedWifi.BSSID, selectedWifi.ESSID, potentialAcks) + +if res then + exit("Can't capture wifi" + res) +end if + +res = crypto.airmon("stop", "wlan0") +if not res == true then + exit("Can't put wifi in monitor mode:"+ res) +end if + +wifiPassword = crypto.aircrack(home_dir() + "/file.cap") + +print("Wifi password for " + selectedWifi.ESSID + ":" + wifiPassword) + +connectionResult = get_shell().host_computer().connect_wifi("wlan0", selectedWifi.BSSID, selectedWifi.ESSID, wifiPassword) + +if typeof(connectionResult) == "string" then + print("There was an error while connecting to new Wifi: " + connectionResult) +else + print("Connected to new Wifi successfully.") +end if