Re: [Plugins-writers] Writing a plugin to detect a service on any port

From: George A. Theall (theall@private)
Date: Wed Jul 19 2006 - 12:45:27 PDT


On Wed, Jul 19, 2006 at 02:29:57PM -0400, Shawn Duffy wrote:

> I need to write a plugin that will detect a proprietary service that
> may be listening on any port.  I can write the code that I need in
> order to check if the service is listening on a given port but I'm not
> sure of the best way to write it so that it checks any open port for
> that service.

For a TCP-based service, I tend to declare a script dependency on
find_service.nes and then do something like :

  include("global_settings.inc");

  if (thorough_tests)
  {
    port = get_kb_item("Services/unknown");
    if (!port) port = 123;
  }
  else port = 123;
  if (!get_tcp_port_state(port)) exit(0);


Essentially, this causes the plugin to iterate over ports with unknown
services if thorough_tests is enabled or the default port (123 in this
case) otherwise. Since get_kb_item() spawns a new instance of the plugin
for each port returned, you don't have to worry about explicitly
iterating over each port.

If the service doesn't have a well-known port, then just do something like :

  port = get_kb_item("Services/unknown");
  if (!get_tcp_port_state(port)) exit(0);


George
-- 
theall@private
_______________________________________________
Plugins-writers mailing list
Plugins-writers@private
http://mail.nessus.org/mailman/listinfo/plugins-writers



This archive was generated by hypermail 2.1.3 : Wed Jul 19 2006 - 12:45:50 PDT