-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path7ports.src
42 lines (37 loc) · 2.35 KB
/
7ports.src
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
// 7ports (search for open ports for given service and version)
if params.len != 2 then exit("<b>Usage: 7ports [serviceName] [serviceVersion]</b>\nExample: '7ports ssh x' will show all open ssh ports\nServiceNames: http / ssh / ftp / smtp / bank_account / repository")
serviceName = params[0] // service you want to search for. example "ssh"
serviceVersion = params[1] // version of the service your are searching for. example "1.0.0"
if serviceName == "x" and serviceVersion == "x" then verbose = true else verbose = false
PrintYellow=function(string); print("<color=yellow>" + string + "</color>"); end function
PrintWhite=function(string); print("<color=white>" + string + "</color>"); end function
CreateIp=function()
n=function();return floor((rnd * 255) + 0);end function
a=function();return floor((rnd * 255) + 1);end function
ipv4=[a,n,n,n].join(".")
if not is_valid_ip(ipv4) then return CreateIp()
router=get_router(ipv4)
if typeof(router) != "router" then return CreateIp()
if router == null then return CreateIp()
if typeof(router.used_ports) != "list" then return CreateIp()
return ipv4
end function
OpenPorts=function(ipAddr)
router = get_router(ipAddr)
ports = router.used_ports
if ports == null then return false
for port in ports
service_info = router.port_info(port).split(" ")
if (service_info[0] == serviceName) and (service_info[1] == serviceVersion) and (not port.is_closed) then print("<color=yellow>" + ipAddr + " " + service_info[0] + " (" + service_info[1] + ") " + port.port_number + "</color>")
if (service_info[0] == serviceName) and (serviceVersion == "x") and (not port.is_closed) then print(ipAddr + " <color=yellow>" + service_info[0] + "</color> (" + service_info[1] + ") " + port.port_number + "</color>")
if (serviceName == "x") and (service_info[1] == serviceVersion) and (not port.is_closed) then print(ipAddr + " " + service_info[0] + " (<color=yellow>" + service_info[1] + "</color>) " + port.port_number + "</color>")
if (verbose == true) and (not port.is_closed) then print(ipAddr + ": " + service_info[0] + " (" + service_info[1] + ") " + port.port_number)
end for
end function
clear_screen
PrintYellow("running /bin/7ports")
PrintWhite("start searching for service: " + serviceName + " with version: " + serviceVersion + " ...")
while true
ipAddress = CreateIp
OpenPorts(ipAddress)
end while