Add randomwifi & formatting tag test

This commit is contained in:
Tristan D. 2024-05-26 00:08:53 +02:00
parent 829f5b9b91
commit fc4cf8928b
Signed by: tristan
SSH key fingerprint: SHA256:3RU4RLOoM8oAjFU19f1W6t8uouZbA7GWkaSW6rjp1k8
2 changed files with 64 additions and 0 deletions

1
src/echotest.src Normal file
View file

@ -0,0 +1 @@
print "<size=100%>Echo <size=80%>Echo <size=60%>Echo <size=40%>Echo <size=20%>Echo"

63
src/randomwifi.src Normal file
View file

@ -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