#! /usr/bin/perl # # Purpose: # FlowGrapher.cgi creates the FlowGrapher web page for inputting # selection criteria. # # Description: # # FlowGrapher.cgi will create a form for accepting parameters to control # the filtering and selection of Netflow data in the generation of a # flow graph. # # Input arguments: # Name Description # ----------------------------------------------------------------------- # none # # Modification history: # Author Date Vers. Description # ----------------------------------------------------------------------- # J. Loiacono 01/01/2006 2.0 Original distributed version. # J. Loiacono 01/26/2006 2.2 Added flow_select option # J. Loiacono 07/04/2006 3.0 Replaces create_FG_webpage # J. Loiacono 12/25/2006 3.1 New 300 second sample time # J. Loiacono 02/14/2007 3.2 [No Change to this module] # #$Author$ #$Date$ #$Header$ # ########################################################################### # # BEGIN EXECUTABLE STATEMENTS # use FlowViewer_Configuration; use FlowViewer_Utilities; if ($debug_grapher eq "Y") { open (DEBUG,">$work_directory/DEBUG_GRAPHER"); } # Create the header portion of the FlowGrapher webpage print "Content-type:text/html\n\n"; print "\n"; print "\n"; print "\n"; print "FlowGrapher $version\n"; print "\n"; print "\n"; print ""; print "
"; print "
";

# Copy image into Graphs directory 
      
if (!-e $graphs_directory) {

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

        $copy_command = "cp $cgi_bin_directory/FlowGrapher.png $graphs_directory";
        system($copy_command);

        print "
";
        print "      The directory for storing FlowGrapher files has been created:\n\n";
        print "      $graphs_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/FlowGrapher.png $graphs_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"; } $detail_lines = 20; print " Start Date: (mm/dd/yyyy) Start Time: (hh:mm:ss) TOS Field: (e.g., -0x0b/0x0F)\n"; print "\n"; print " End Date: (mm/dd/yyyy) End Time: (hh:mm:ss) TCP Flag: Protocol: \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 "Graphing Parameters:\n\n"; print " Detail Lines: "; print " Sample Time: "; print " Graph Width: "; print " Resolve Addresses: "; print "\n\n"; print " Include Flow if: "; print "\n\n"; print "
"; print "\n\n"; print "
"; print " \;\n"; print "
"; print "
"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n";