-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservicescanner.src
More file actions
71 lines (68 loc) · 2.59 KB
/
Copy pathservicescanner.src
File metadata and controls
71 lines (68 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//--
//-- $$$$$$$$\ $$\
//-- \____$$ | $$ |
//-- $$ / $$$$$$\ $$ | $$$$$$\ $$\ $$\ $$\
//-- $$ / $$ __$$\ $$ |$$ __$$\ $$ | $$ | $$ |
//-- $$ / $$$$$$$$ |$$ |$$ / $$ |$$ | $$ | $$ |
//-- $$ / $$ ____|$$ |$$ | $$ |$$ | $$ | $$ |
//-- $$$$$$$$\\$$$$$$$\ $$ |\$$$$$$ |\$$$$$\$$$$ |
//-- \________|\_______|\__| \______/ \_____\____/
//--
//--For scanning ports usage: servicescanner [service?] service argument is optional. Default scans all.
//--Regardless of service choice all results are logged to a folder named by service.
if params.len > 1 or (params and params[0] == "-h") or (params and params[0] == "--help") then exit("<b>Usage: " + program_path.split("/")[-1] + " [service?]</b>")
log = ["PORT STATE SERVICE VERSION PUBLIC_IP LAN"]
p = null
if params then p = params[0]
foundips = []
genip = function()
while 1
ip = [ceil(rnd * 255), ceil(rnd * 255) ,ceil(rnd * 255), ceil(rnd * 255)].join(".")
if is_lan_ip(ip) then continue
if not is_valid_ip(ip) then continue
return ip
end while
end function
serveCheck = function(ipAddress)
for ip in foundips
if ip == ipAddress then return null
end for
if not is_lan_ip(ipAddress) then router = get_router(ipAddress)
if router == null then return null
if not is_lan_ip(ipAddress) then ports = router.used_ports
if ports.len == 0 then return null
for port in ports
service_info = router.port_info(port)
lan_ips = port.get_lan_ip
port_status = "open"
if port.is_closed and not is_lan_ip(ipAddress) then
port_status = "closed"
end if
x = port.port_number + " " + port_status + " " + service_info + " " + ipAddress + " " + lan_ips
foundips.push(ipAddress)
filelog(x)
if p and service_info != p then continue
log.push(x)
if oldlog.len != log.len then
print("Started service scanning..." + char(10) + format_columns(log.join(char(10))) + char(10) + "Press ctrl + C to stop service scanning...", true)
oldlog = log
end if
end for
end function
filelog = function(x)
logfilename = x.split(" ")[2] + ".txt"
comp = get_shell.host_computer
comp.create_folder(home_dir, "servlogs")
touched = comp.touch(home_dir + "/servlogs", logfilename)
file = comp.File(home_dir + "/servlogs/" + logfilename)
if touched == 1 then file.set_content("PORT STATE SERVICE VERSION PUBLIC_IP LAN")
if not file or file.get_content.split(char(10)).len == 0 then return
for line in file.get_content.split(char(10))
if line == x then return
end for
file.set_content(file.get_content + char(10) + x)
end function
oldlog = []
while 1
serveCheck(genip())
end while