###############################################################################
# OpenVAS Vulnerability Test
# $Id: support_incident_tracker_detect.nasl 7589 2010-05-07 14:33:00Z chandra $
#
# SiT! Support Incident Tracker Detection
#
# Authors:
# Michael Meyer
#
# Copyright:
# Copyright (c) 2010 Greenbone Networks GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# (or any later version), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
###############################################################################

# need desc here to modify it later in script.
desc = "Overview:
This host is running SiT! Support Incident Tracker, a web based
application which uses PHP and MySQL for tracking technical support
calls/emails.

See also:
http://sitracker.org/wiki/Main_Page
Risk factor : None";

if (description)
{
 script_id(100466);
 script_version ("1.0-$Revision: 7589 $");
 script_tag(name:"risk_factor", value:"None");

 script_name("SiT! Support Incident Tracker Detection");
 script_description(desc);
 script_summary("Checks for the presence of SiT! Support Incident Tracker");
 script_category(ACT_GATHER_INFO);
 script_family("Service detection");
 script_copyright("This script is Copyright (C) 2010 Greenbone Networks GmbH");
 script_dependencies("find_service.nes", "http_version.nasl");
 script_require_ports("Services/www", 80);
 script_exclude_keys("Settings/disable_cgi_scanning");
 exit(0);
}

include("http_func.inc");
include("http_keepalive.inc");
include("global_settings.inc");

port = get_http_port(default:80);

if(!get_port_state(port))exit(0);
if(!can_host_php(port:port))exit(0);

dirs = make_list("/tracker","/support",cgi_dirs());

foreach dir (dirs) {

 url = string(dir, "/index.php");
 req = http_get(item:url, port:port);
 buf = http_keepalive_send_recv(port:port, data:req, bodyonly:FALSE);
 if( buf == NULL )continue;

 if(egrep(pattern: '< buf )
 {
     if(strlen(dir)>0) {
        install=dir;
     } else {
        install=string("/");
     }

    vers = string("unknown");
    ### try to get version 
    version = eregmatch(string: buf, pattern: "Support Incident Tracker v([0-9.]+)",icase:TRUE);

    if ( !isnull(version[1]) ) {
       vers=chomp(version[1]);
       set_kb_item(name: string("cpe:/a:salford_software:support_incident_tracker:", vers), value: TRUE);
    } else {
       set_kb_item(name: string("cpe:/a:salford_software:support_incident_tracker"), value: TRUE);
    }  

    set_kb_item(name: string("www/", port, "/support_incident_tracker"), value: string(vers," under ",install));

    info = string("None\n\nSiT! Support Incident Tracker Version '");
    info += string(vers);
    info += string("' was detected on the remote host in the following directory(s):\n\n");
    info += string(install, "\n");

    desc = ereg_replace(
        string:desc,
        pattern:"None$",
        replace:info
    );

       if(report_verbosity > 0) {
         security_note(port:port,data:desc);
       }
       exit(0);

 }
}
exit(0);

