home *** CD-ROM | disk | FTP | other *** search
- /*
- A "not so good" macro to scan tcp ports.
-
- Usage: pst <host> <fromPort/N> <toPort/N>"
- */
-
- parse arg host low hi .
-
- if ~show("L","rxsocket.library") then
- if ~addLib("rxsocket.library",0,-30) then do
- say "can't find rxsocket.library"
- exit
- end
-
- if host=="" | host== "?" | low=="" | hi=="" then do
- say "Usage: pst <host> <fromPort/N> <toPort/N>"
- exit
- end
-
- if ~DataType(low,NUM) then do
- say "pst: bad number fromPort"
- exit
- end
-
- if ~DataType(hi,NUM) then do
- say "pst: bad number toPort"
- exit
- end
-
- if hi<low then do
- say "pst: fromPort must be less than toPort"
- exit
- end
-
- sin.ADDRADDR = resolve(host)
- if sin.ADDRADDR==-1 then do
- say "pst: no host <" || host || ">"
- exit
- end
-
- sin.ADDRFAMILY = "INET"
-
- do sin.ADDRPORT = low to hi
-
- sock = socket("INET","STREAM","IP")
- if sock<0 then do
- say "pst: no socket (" "" errno() || ")"
- exit
- end
-
- if connect(sock,"SIN")>=0 then
- if GetServByPort("SERV",sin.ADDRPORT,"tcp") then
- say "pst: servizio" serv.servname "(" || sin.ADDRPORT ||")" "aperto"
- else say "pst: porta" sin.ADDRPORT "aperta"
-
- call CloseSocket(sock)
-
- end
-