16 close(soc);
17 }
18 }
Lines 3 and 4 set the variables that will be used to declare the start and end ports for
scanning. Note that these numbers represent the entire set of ports for any given system
(minus the zero port, which is frequently utilized for attacks or information gathering).
Lines 8 and 9 open a socket connection and then determine if the opened socket
connection was successful. After grabbing the banner with the inline initialization banner
(line 11) and using the recv_line function, a regular expression is used on line 13 to
determine if Apache is found within the received banner. Lastly, the script indicates that
Apache version 1.0 was found on the corresponding port that returned the banner.
Although this example script is reasonably ...