#! /usr/bin/perl # # Purpose: # FlowViewer.cgi creates the FlowViewer web page for inputting # selection criteria. # # Description: # # FlowViewer.cgi will create an form for accepting parameters # to control the filtering and selection of Netflow data. # # Input arguments: # Name Description # ----------------------------------------------------------------------- # none # # Modification history: # Author Date Vers. Description # ----------------------------------------------------------------------- # J. Loiacono 07/04/2005 1.0 Original version. # J. Loiacono 01/01/2006 2.0 New filter parameters # J. Loiacono 01/26/2006 2.2 Added flow_select option # J. Loiacono 07/04/2006 3.0 Replaces create_FlowViewer_webpage # J. Loiacono 12/25/2006 3.1 [No Change to this module] # J. Loiacono 02/14/2007 3.2 [No Change to this module] # #$Author$ #$Date$ #$Header$ # ########################################################################### # # BEGIN EXECUTABLE STATEMENTS # use FlowViewer_Configuration; use FlowViewer_Utilities; # Create the header portion of the FlowViewer webpage print "Content-type:text/html\n\n"; print "\n"; print "\n"; print "\n"; print "FlowViewer $version\n"; print "\n"; print "\n"; print ""; print "
"; print "
";

# Copy image into Reports directory

if (!-e $reports_directory) { 

        mkdir($reports_directory,$html_dir_perms) || die "cannot mkdir $reports_directory: $!";   
        chmod $html_dir_perms, $reports_directory;

	$copy_command = "cp $cgi_bin_directory/FlowViewer.png $reports_directory";
	system($copy_command);

	print "
";
        print "      The directory for storing FlowViewer files has been created:\n\n"; 
        print "      $reports_directory\n\n"; 
        print "      Please ensure this directory has adequate permissions for your\n"; 
        print "      web server process owner (e.g., 'apache') to write into it.\n\n"; 
	print "\n";
        print "      RETURN\n"; 
        print "
"; exit; } $copy_command = "cp $cgi_bin_directory/FlowViewer.png $reports_directory"; system($copy_command); # Set up start and end times according to configurable start and end offsets ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$start_offset); $mnth += 1; $yr += 1900; $min_delta = $min % 5; $min = $min - $min_delta; if (length $min < 2) { $min = "0" . $min; } $start_date = $mnth ."/". $date ."/". $yr; if ($use_even_hours eq "Y") { $start_time = $hr .":00:00"; } else { $start_time = $hr .":". $min .":00"; } ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$end_offset); $mnth += 1; $yr += 1900; $min_delta = $min % 5; $min = $min - $min_delta; if (length $min < 2) { $min = "0" . $min; } $end_date = $mnth ."/". $date ."/". $yr; if ($use_even_hours eq "Y") { $end_time = $hr .":00:00"; } else { $end_time = $hr .":". $min .":00"; } # If a user has called this program from another FlowViewer tool, pre-fill the input fields $query_string = $ENV{'QUERY_STRING'}; if ($query_string ne "") { $query_string =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ; chop $query_string; @fields = split(/&/,$query_string); foreach $input_field (@fields) { ($field,$field_value) = split(/=/,$input_field); if ($field eq "device_name") { $selected_device_name = $field_value; } if ($field eq "start_date") { $start_date = $field_value; } if ($field eq "start_time") { $start_time = $field_value; } if ($field eq "end_date") { $end_date = $field_value; } if ($field eq "end_time") { $end_time = $field_value; } if ($field eq "source_addresses") { $source_address = $field_value; } if ($field eq "source_ports") { $source_port = $field_value; } if ($field eq "source_ifs") { $source_if = $field_value; } if ($field eq "source_ases") { $source_as = $field_value; } if ($field eq "dest_addresses") { $dest_address = $field_value; } if ($field eq "dest_ports") { $dest_port = $field_value; } if ($field eq "dest_ifs") { $dest_if = $field_value; } if ($field eq "dest_ases") { $dest_as = $field_value; } if ($field eq "protocols") { $protocols = $field_value; } if ($field eq "tos_fields") { $tos_fields = $field_value; } if ($field eq "tcp_flags") { $tcp_flags = $field_value; } if ($field eq "tracking_label") { $tracking_label = $field_value; } if ($field eq "general_comment") { $general_comment = $field_value; } } } print "Filter Criteria:\n\n"; print "
"; if ($devices[0] ne "") { print " Device: "; print "\n\n"; } $cutoff_lines = 100; $sort_field = 4; print " Start Date: (mm/dd/yyyy) Start Time: (hh:mm:ss) TOS Fields: (e.g., -0x0b/0x0F)\n"; print "\n"; print " End Date: (mm/dd/yyyy) End Time: (hh:mm:ss) TCP Flags: Protocols: \n"; print "\n"; print " Source IP: (e.g., 192.168.16.0/22) Source Port: Source Interface: Source AS: \n"; print "\n"; print " Dest IP: (or, e.g., www.abc.com) Dest Port: Dest Interface: Dest AS: \n"; print "\n"; print "
Note: Multiple field entries, separated by commas, are permitted in the fields above.\n A minus sign (-) will negate an entry (e.g. -1776 for AS, would mean any AS but 1776)
"; print "
"; print "Reporting Parameters:\n\n"; print " Statistics: "; print " Printed: "; print " Include Flow if: "; print "\n\n"; print " Sort Field: "; print " Cutoff Lines: "; print " Cutoff Octets: "; print " Resolve Addresses: "; print "\n\n"; print "
"; print "\n"; print "
"; print " \;\n"; print "
"; print "
"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n";