z3r0wifi.src
Code
Copy
001// When copying this script you agree to these terms:
002// You are not allowed to modify or/and share it as long as you didn't change the author.
003// There is no warranty, use it on your own risk.
004// You will not ask me for support.
005// If you break the terms, I will find you and ruin you life. Promised.
006// Changelog
007// * Fixed file.cap path
008
009author = "unz3r0"
010
011banner = function(bg,fg)
012
013	print(char(10))
014	lines = ["'########::'#######::'########::::'#####:::'##:::::'##:'####:'########:'####:","..... ##::'##.... ##: ##.... ##::'##.. ##:: ##:'##: ##:. ##:: ##.....::. ##::",":::: ##:::..::::: ##: ##:::: ##:'##:::: ##: ##: ##: ##:: ##:: ##:::::::: ##::","::: ##:::::'#######:: ########:: ##:::: ##: ##: ##: ##:: ##:: ######:::: ##::",":: ##::::::...... ##: ##.. ##::: ##:::: ##: ##: ##: ##:: ##:: ##...::::: ##::",": ##::::::'##:::: ##: ##::. ##::. ##:: ##:: ##: ##: ##:: ##:: ##:::::::: ##::"," ########:. #######:: ##:::. ##::. #####:::. ###. ###::'####: ##:::::::'####:","........:::.......:::..:::::..::::.....:::::...::...:::....::..::::::::....::"]
015	
016	for line in lines
017		print(char(32)*5+line.replace("#","<color="+fg+">#</color>").replace(":","<color="+bg+">:</color>").replace(".","<color="+bg+">.</color>").replace("'","<color="+bg+">'</color>") )
018		wait(0.1)
019	end for
020
021	print(char(32)*62+"<color=#FC766AFF>v1.0.1 - ©"+author+"</color>")
022	print(char(10) * 1.5)
023
024end function
025
026tocolor = function(color)
027return "<color="+color+">"+self.str+"</color>"
028end function
029	
030convert = function(text)
031obj = {}
032obj.str = str(text)
033obj.tocolor = @tocolor
034return obj
035end function
036
037debug = function(msg)
038
039	if params.len == 1 and params[0] == "-d" then
040		date = current_date.split(" ")[0]
041		time = current_date.split(" ")[2]
042		print( convert("[DEBUG] "+date+"+"+time+" - "+msg).tocolor("purple") )
043	end if
044
045end function
046
047libs = function(dirs,names)
048	obj = {}
049	for name in names
050		for dir in dirs
051			file = get_shell.host_computer.File(dir+"/"+name)
052			if typeof(file) != "null" then
053				if file.has_permission("r") then 
054					if file.is_binary then 
055						debug("Loaded "+file.path)
056						obj.push( typeof( include_lib(file.path) ) )
057						obj[typeof( include_lib(file.path) )] = include_lib(file.path) 
058						break
059					end if
060					if not file.is_binary then 
061						debug(file.path+" is not a binary.")
062					end if
063				end if
064				if not file.has_permission("r") then 
065					debug(file.path+" has no read permissions.")
066				end if
067			end if
068			if typeof(file) == "null" then
069				debug(dir+"/"+name+" does not exist.")
070			end if
071		end for
072	end for
073	return obj
074end function
075
076initdb = function(filepath) 
077
078	// get wifi device name
079	netdev = get_shell.host_computer.network_devices.split(" ")[0]
080	globals.netdev = netdev
081	// scan networks
082	networks = {}
083	for network in get_shell.host_computer.wifi_networks(netdev)
084	networks[network.split(" ")[2]] = {}
085	networks[network.split(" ")[2]].bssid = {}
086	networks[network.split(" ")[2]].power = {}
087	networks[network.split(" ")[2]].bssid = network.split(" ")[0] 
088	networks[network.split(" ")[2]].power = network.split(" ")[1] 
089	end for
090	globals.networks = networks
091	debug("netdev => "+netdev)
092	for m in networks.indexes
093		debug(m+" "+networks[m].bssid+" "+networks[m].power)
094	end for
095	debug("DB => "+filepath)	
096	// create database file if not exist
097	filepath = filepath.split("/")
098	file = get_shell.host_computer.File(filepath.join("/"))
099	if typeof(file) == "null"  then
100		filename = filepath.pop
101		dir = []
102		for folder in filepath
103			dir.push(folder)
104			get_shell.host_computer.create_folder(dir.join("/").remove(dir[-1]),dir[-1])
105		end for
106		get_shell.host_computer.touch(dir.join("/"),filename)
107		file = get_shell.host_computer.File(dir.join("/")+"/"+filename)
108		// init database content
109		for essid in networks.indexes
110			if file.get_content == "" then
111				file.set_content(essid+":")
112			else if file.get_content != "" then
113				getfile = file.get_content
114				file.set_content(getfile+char(10)+essid+":")
115			end if
116		end for
117	end if
118end function
119
120ckdb = function(filepath,essid)
121	file = get_shell.host_computer.File(filepath)
122	db = file.get_content.split(char(10))
123	for line in db
124		if line.split(":")[0] == essid and line.split(":")[1] == "" then 
125			print("<color=yellow>[INFO] Password for "+line.split(":")[0]+"</color>")
126			return 0
127			break
128		end if
129		if line.split(":")[0] == essid and line.split(":")[1] != "" then 
130			print("<color=yellow>[INFO] Password for "+line.split(":")[0]+" is known: </color>"+"<color=red>["+line.split(":")[1]+"]</color>")
131			return 1
132			break
133		end if
134	end for
135end function
136
137upddb = function(filepath)
138	file = get_shell.host_computer.File(filepath)
139	db = file.get_content.split(char(10))
140	
141	obj = {}
142	for line in db
143		obj[line.split(":")[0]] = {}
144		// check password is there
145		if line.split(":")[1] != "" then
146		obj[line.split(":")[0]] = line.split(":")[1]
147		end if
148		// if not there check essid and include
149		if line.split(":")[1] == ""  and line.split(":")[0] == essid then
150		obj[line.split(":")[0]] = password
151		end if
152	end for
153	
154	newdb = []
155	for index in obj.indexes
156		if not obj[index] then
157			newdb.push(index+":")
158			debug("not "+newdb)
159		end if
160		if obj[index] then
161			newdb.push(index+":"+obj[index])
162			debug("has "+newdb)
163		end if
164	end for
165
166	file.set_content(newdb.join(char(10)))
167
168end function
169
170ShuffleConnect = function()
171	file = get_shell.host_computer.File(filepath)
172	db = file.get_content.split(char(10))
173	
174	obj = {}
175	for line in db
176		obj[line.split(":")[0]] = {}
177		obj[line.split(":")[0]] = line.split(":")[1]
178	end for
179	
180	list = []
181	for x in obj.indexes
182		list.push(x)
183	end for
184	list.shuffle
185	
186	print("Connecting to <color=yellow>"+list[0]+"</color>")
187	get_shell.host_computer.connect_wifi(netdev,networks[list[0]].bssid,list[0],obj[list[0]])
188
189end function
190
191banner("#00A4CCFF","#F95700FF")
192libraries = libs([current_path,parent_path(launch_path),"/lib"],["crypto.so"])
193CrypTools = libraries["cryptoLib"]
194filepath = home_dir+"/"+"Config"+"/"+"Wifi.txt"
195initdb(filepath)
196
197for essid in networks.indexes
198	if ckdb(filepath,essid) then continue
199	print("<color=yellow>[INFO] Hacking "+essid+"</color>")
200	acks = round(300000/networks[essid].power.remove("%").to_int,0)+1
201	print("<color=yellow>[INFO] "+essid+" needs at least "+acks+" ACKs</color>")
202	CrypTools.airmon("start",netdev)
203	CrypTools.aireplay(networks[essid].bssid,essid,acks)
204	CrypTools.airmon("stop",netdev)
205	filecap = get_shell.host_computer.File(home_dir+"/"+"file.cap")
206	password = CrypTools.aircrack(filecap.path)
207	upddb(filepath)
208	print("<color=yellow>[INFO] "+essid+":"+password+"</color>")
209end for
210
211ShuffleConnect()
212