Location: PHPKode > projects > Cancerbero - The watchdog of the ports > cancerbero-0.6/site/include/cancerbero.php
<?php

# Script to change a cancerbero's database version 3 to version 4

include_once("dbconnect.php");

$database_ver = 4;

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `configuration` (
			`database_ver` int(3) NOT NULL default '1',
			`check_alive` int(6) unsigned default '30',
			`gui_debug` int(1) NOT NULL default '-1',
			`num_rows` int(3) NOT NULL default '10',
			`num_links` int(3) NOT NULL default '7',
			PRIMARY KEY  (`database_ver`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());
$query = mysql_query ("INSERT INTO `configuration` (`database_ver`) VALUES ($database_ver)") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `hosts` (
			`ip` varchar(16) NOT NULL,
			`hostname` varchar(64) NOT NULL,
			`ping` int(5) unsigned NOT NULL default '0',
			`priority` int(1) NOT NULL default '6',
			`comment` varchar(255) default NULL,
			`host_id` int(10) unsigned NOT NULL auto_increment,
			`d_last_scan` int(10) unsigned default '0',
			`range_id` int(3) NOT NULL default '0',
			PRIMARY KEY  (`host_id`),
			UNIQUE KEY `idx_ip` (`ip`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `logs` (
			`logs_id` int(21) NOT NULL auto_increment,
			`range_id` int(3) default NULL,
			`sensor_id` int(3) default NULL,
			`name_proc` varchar(32) NOT NULL,
			`facility` varchar(32) NOT NULL,
			`priority` varchar(32) NOT NULL,
			`date` int(10) default NULL,
			`message` varchar(255) NOT NULL,
			PRIMARY KEY  (`logs_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `nmap_cfg` (
			`nmap_cfg_id` int(2) NOT NULL auto_increment,
			`nmap_type_cfg` enum('Sweep','Scan') NOT NULL default 'Sweep',
			`nmap_option_name` varchar(32) NOT NULL,
			`nmap_cmd_cfg` varchar(255) NOT NULL,
			PRIMARY KEY  (`nmap_cfg_id`),
			UNIQUE KEY `nmap_type_cfg` (`nmap_type_cfg`,`nmap_option_name`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("INSERT INTO `nmap_cfg` (`nmap_type_cfg`,`nmap_option_name`,`nmap_cmd_cfg`) VALUES ('Scan','Polite','-A -T4 -PA445,22 -PS445,22 --host_timeout 900000 -p -')") or die (mysql_error());
$query = mysql_query ("INSERT INTO `nmap_cfg` (`nmap_type_cfg`,`nmap_option_name`,`nmap_cmd_cfg`) VALUES ('Scan','Normal','-A -r -T5 -PA445,22 -PS445,22 -PE --host_timeout 900000 -p -')") or die (mysql_error());
$query = mysql_query ("INSERT INTO `nmap_cfg` (`nmap_type_cfg`,`nmap_option_name`,`nmap_cmd_cfg`) VALUES ('Scan','Aggressive','-A -r -PA445,22 -PS445,22 -PE -p - --max_rtt_timeout 100 --min_rtt_timeout 10 --host_timeout 900000 --initial_rtt_timeout 50 --max_scan_delay 5')") or die (mysql_error());
$query = mysql_query ("INSERT INTO `nmap_cfg` (`nmap_type_cfg`,`nmap_option_name`,`nmap_cmd_cfg`) VALUES ('Sweep','Polite','-sP -PA445,22 -PS445,22')") or die (mysql_error());
$query = mysql_query ("INSERT INTO `nmap_cfg` (`nmap_type_cfg`,`nmap_option_name`,`nmap_cmd_cfg`) VALUES ('Sweep','Normal','-sP -T5 -PA445,22 -PS445,22')") or die (mysql_error());
$query = mysql_query ("INSERT INTO `nmap_cfg` (`nmap_type_cfg`,`nmap_option_name`,`nmap_cmd_cfg`) VALUES ('Sweep','Aggressive','-sP -PA445,22 -PS445,22 -PE --min_parallelism 100 --max_rtt_timeout 100 --min_rtt_timeout 10 --initial_rtt_timeout 50')") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `ports` (
			`port` int(6) unsigned default NULL,
			`protocol` varchar(10) default NULL,
			`service` varchar(20) default NULL,
			`scan_rec_id` int(10) unsigned NOT NULL default '0',
			`range_id` int(3) NOT NULL default '1',
			`port_rec_id` int(10) unsigned NOT NULL auto_increment,
			`fingerprint` varchar(255) default NULL,
			`product` varchar(255) default NULL,
			`extra_info` varchar(255) default NULL,
			`port_version` varchar(255) default NULL,
			`service_confidence` varchar(255) default NULL,
			PRIMARY KEY  (`port_rec_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `program_values` (
			`date_next` int(10) unsigned default NULL,
			`date_prev` int(10) unsigned default NULL,
			`num_sub_nmaps` int(6) unsigned default NULL,
			`saw_alive` int(20) unsigned default NULL,
			`status_sweep` varchar(25) default NULL,
			`sensor_id` int(3) NOT NULL default '0',
			PRIMARY KEY  (`sensor_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `ranges` (
			`range_id` int(3) NOT NULL auto_increment,
			`sensor_id` int(3) NOT NULL default '0',
			`range` varchar(18) NOT NULL default '',
			`range_name` varchar(100) default NULL,
			`range_delay_scan` int(6) unsigned NOT NULL default '15',
			`range_nmap_opts` int(3) default NULL,
			`comment` varchar (254) default NULL,
			PRIMARY KEY  (`range_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `scans` (
			`host_id` int(6) unsigned NOT NULL default '0',
			`range_id` int(3) NOT NULL default '1',
			`open_ports` int(6) unsigned default NULL,
			`ports_scanned` int(6) unsigned default NULL,
			`os_guessed` varchar(100) default NULL,
			`os_gen` varchar(100) default NULL,
			`host_fingerprint` varchar(254) default NULL,
			`scan_rec_id` int(10) unsigned NOT NULL auto_increment,
			`d_scan` int(10) unsigned default '0',
			`number_of_alerts` INT( 3 ) DEFAULT '0' NOT NULL,
			PRIMARY KEY  (`scan_rec_id`),
			KEY `range_id` (`range_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `sensors` (
			`sensor_id` int(3) NOT NULL auto_increment,
			`sensor_name` varchar(40) NOT NULL default '',
			`cancerbero_sensor_ver` varchar(8) NOT NULL default '0',
			`sensor_loop` int(1) unsigned default '1',
			`sensor_delay_scan` int(6) unsigned default '15',
			`sensor_sweep_time` int(6) unsigned default '3600',
			`sensor_max_num_scan` int(6) unsigned default '5',
			`sensor_stored_scans` int(6) unsigned NOT NULL default '10',
			`sensor_debug` int(1) default '-1',
			`sensor_nmap_sweep_opts` int(3) default '6',
			`sensor_nmap_opts` int(3) default '2',
			`comment` varchar (254) default NULL,
			PRIMARY KEY  (`sensor_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `users` (
			`host_id` int(6) unsigned NOT NULL default '0',
			`range_id` int(3) NOT NULL default '1',
			`email` varchar(100) NOT NULL default '',
			`date_mail` int(10) NOT NULL default '0',
			`mail_rec_id` int(21) unsigned NOT NULL auto_increment,
			PRIMARY KEY  (`mail_rec_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `white_list` (
			`white_list_id` int(3) NOT NULL auto_increment,
			`range_id` int(3) NOT NULL default '0',
			`white_list` varchar(18) NOT NULL default '',
			`comment` varchar(255) default NULL,
			`white_list_name` varchar(100) default NULL,
			PRIMARY KEY  (`white_list_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `alerts` (
			`alert_id` int(21) NOT NULL auto_increment,
			`last_scan_id` int(10) NOT NULL default '0',
			`old_scan_id` int(10) NOT NULL default '0',
			`alert_name` varchar (100) NOT NULL,
			`alert_checked` ENUM( 'unchecked', 'checked' ) NOT NULL,
			`message` varchar(254) default NULL,
			
			PRIMARY KEY  (`alert_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `alert_type` (
			`alert_name` varchar(100) NOT NULL, 
			`status` ENUM( 'on', 'off' ) NOT NULL,
			`alert_level` ENUM( 'Soft', 'Medium', 'Critical', 'Doom' ) NOT NULL,
			`description` varchar(254) default NULL,
			`plugin_name` varchar(100) NOT NULL,
			
			PRIMARY KEY  (`alert_name`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `plugins` (
			`plugin_name` varchar(100) NOT NULL, 
			`status` ENUM( 'on', 'off' ) NOT NULL,
			`description` varchar(255) default NULL,
			`version` varchar(10) default NULL,
			
			PRIMARY KEY  (`plugin_name`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `owners` (
			`owner_id` int(21) NOT NULL auto_increment,
			`name` varchar(100) NOT NULL,
			`email` varchar(100) NOT NULL,
			`telephone` varchar(15) DEFAULT NULL,
			`section` varchar(20) DEFAULT NULL,
			
			PRIMARY KEY  (`owner_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `send_alerts` (
			`owner_id` int(21) NOT NULL auto_increment,
			`alert_name` varchar(100) default NULL,
			`object` ENUM( 'Host', 'Range','Sensor', 'God', 'Other' ) NOT NULL,
			`object_index` int(21) NOT NULL,
			
			PRIMARY KEY  (`owner_id`, `alert_name`, `object`, `object_index`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

$query = mysql_query ("CREATE TABLE IF NOT EXISTS `ownership` (
			`object` ENUM( 'Host', 'Range','Sensor', 'God' ) NOT NULL,
			`object_index` int(21) NOT NULL,
			`owner_id` int(21) NOT NULL,
			
			PRIMARY KEY  (`object`, `object_index`, `owner_id`)
			) ENGINE=MyISAM DEFAULT CHARSET=utf8
		      ") or die (mysql_error());

?>
Return current item: Cancerbero - The watchdog of the ports