Сканер портов на PL/SQL


CREATE OR REPLACE PROCEDURE PORT_SCAN(sHOST VARCHAR2,
nPORT_START NUMBER,
nPORT_END NUMBER) AS
sSTATUS varchar2(20);
FUNCTION CHECK_PORT(sHOST VARCHAR2, nPORT NUMBER) RETURN VARCHAR2 IS
conn utl_tcp.connection;
sRET varchar2(20);
begin
conn := utl_tcp.open_connection(remote_host => sHOST,
remote_port => nPORT);
IF (utl_tcp.available(conn) > 0) THEN
sRET := 'CLOSE';
ELSE
sRET := 'OPEN';
END IF;
utl_tcp.close_connection(conn);
return sRET;
end;

BEGIN
for i in nPORT_START .. nPORT_END loop
sSTATUS := CHECK_PORT(sHOST, i);
dbms_output.put_line(i||': ' || sSTATUS);
sSTATUS := NULL;
end loop;
END PORT_SCAN;

begin
port_scan(‘192.168.56.102‘, 130, 140);
end;
130: CLOSE
131: CLOSE
132: CLOSE
133: CLOSE
134: CLOSE
135: OPEN
136: CLOSE
137: CLOSE
138: CLOSE
139: OPEN
140: CLOSE