This file is indexed.

/usr/lib/cgi-bin/graphdefang.cgi is in graphdefang 2.73-2build1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/perl -w
#
# GraphDefang -- a set of tools to create graphs of your mimedefang
#                spam and virus logs.
#
# Written by:    John Kirkland
#                jpk@bl.org
#
# Copyright (c) 2002-2003, John Kirkland
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#=============================================================================

use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Fcntl;
use Data::Dumper;

use vars qw($SHAREDIR $OUTPUT_DIR $SUMMARYDB $QUIET $NODB $NOFILE $DATAFILE @GRAPHS %TZ);

# CONFIGURE HERE
#my $GRAPHDEFANGDIR = '/home/jpk/graphdefang';
$SUMMARYDB = "/var/cache/graphdefang/SummaryDB.db";
$SHAREDIR = "/usr/share/graphdefang";
# THE REST SHOULD BE OKAY

# Require the graphdefang library file
require ("$SHAREDIR/graphdefanglib.pl");

# Don't output messages for the web app
$QUIET = 1;

# Open the SummaryDB file
my %data = ();;
read_summarydb(\%data, O_RDONLY);

# Get the cmd from the parameter list:
my $cmd = '';
if (param('cmd')) {
	$cmd = param('cmd');
} else {
	$cmd = 'null';
}

# Check for errors
my $error = '';
my $submit = param('submit');
if ($submit && !param('data_types')) {
	$error = "<font color=red>No Data Types Selected.  Please Try Again!</font>\n";
}

# Create image
if ($cmd eq 'get-image') {

	my $grouping_time = param('grouping_time');
	my $grouping = param('grouping');
	my $graph_type = param('graph_type');
	my @data_types = param('data_types');
	my $top_n = param('top_n');
	my %settings = ();

	push @{$settings{grouping_times}}, $grouping_time;
	$settings{grouping} = $grouping;
	$settings{graph_type} = $graph_type;
	$settings{data_types} = ();
	push @{$settings{data_types}}, @data_types;
	$settings{top_n} = $top_n;

	$settings{num_hourly_values} = 48;
	$settings{num_hourly_values} = param('num_hourly_values') if param('num_hourly_values');
	$settings{num_daily_values} = 60;
	$settings{num_daily_values} = param('num_daily_values') if param('num_daily_values');
	$settings{num_monthly_values} = 24;
	$settings{num_monthly_values} = param('num_monthly_values') if param('num_monthly_values');

	$settings{x_graph_size} = 700;
	$settings{x_graph_size} = param('x_graph_size') if param('x_graph_size');
	$settings{y_graph_size} = 300;
	$settings{y_graph_size} = param('y_graph_size') if param('y_graph_size');

	$OUTPUT_DIR="/tmp";
	graph(\%settings, \%data);

	my $filename = $settings{chart_filename};

	open IMG, "< $OUTPUT_DIR/$filename.png" or die $!;
	binmode IMG;

	print header(-type=>'image/png', -expires=>'now');
	print while <IMG>;
	close IMG;

	unlink ("$OUTPUT_DIR/$filename.png");

} elsif ($cmd eq 'null') {

	my @all_data_types = get_all_data_types(\%data);
	
	print header(-type=>'text/html',
		     -expires=>'now');
	print start_html(-title=>'GraphDefang CGI Interface');
	print h2('Select graph attributes and click the Submit button');
	print startform();
	print "<table border=1 cellspacing=0 cellpadding=5>\n";
	print "  <tr>\n";
	print "    <th>Data Types</th>\n";
	print "    <th>Grouping Time</th>\n";
	print "    <th>Grouping</th>\n";
	print "    <th>Graph Type</th>\n";
	print "  </tr>\n";
	print "  <tr valign=top>\n";
	print "    <td>\n";
	print        checkbox_group(-name=>'data_types',
					-values=>\@all_data_types,
					-linebreak=>'true');
	print "    </td>\n";
	print "    <td>\n";
  	print "      <table>\n";
	print "        <tr>\n";
	print "          <td>\n";
	print              radio_group(-name=>'grouping_time',
					-values=>['hourly'],
					-default=>'hourly');
	print "          </td>\n";
	print "          <td>\n";
	print              textfield(-name=>'num_hourly_values',
					-default=>48,
					-size=>2,
					-maxlength=>3);
	print "          </td>\n";
	print "        </tr>\n";
	print "        <tr>\n";
	print "          <td>\n";
	print              radio_group(-name=>'grouping_time',
					-values=>['daily'],
					-default=>'hourly');
	print "          </td>\n";
	print "          <td>\n";
	print              textfield(-name=>'num_daily_values',
					-default=>60,
					-size=>2,
					-maxlength=>3);
	print "          </td>\n";
	print "        </tr>\n";
	print "        <tr>\n";
	print "          <td>\n";
	print              radio_group(-name=>'grouping_time',
					-values=>['monthly'],
					-default=>'hourly');
	print "          </td>\n";
	print "          <td>\n";
	print              textfield(-name=>'num_monthly_values',
					-default=>24,
					-size=>2,
					-maxlength=>3);
	print "          </td>\n";
	print "        </tr>\n";
	print "      </table>\n";
	print "    </td>\n";
	print "    <td>\n";
	print        radio_group(-name=>'grouping',
				-values=>['summary','sender','recipient','subject','value1','value2'],
				-linebreak=>'true',
				-default=>'summary');
	print        "<br>Top N:&nbsp;";
	print        textfield(-name=>'top_n',
				-default=>10,
				-size=>2,
				-maxlength=>2);
	print "    </td>\n";
	print "    <td>\n";
	print        radio_group(-name=>'graph_type',
				-values=>['line','stacked_bar'],
				-linebreak=>'true',
				-default=>'line');
	print "    </td>\n";
	print "  </tr>\n";
	print "</table>\n";
	print "<br>\n";
	print "X Graph Size: ";  
	print textfield(-name=>'x_graph_size', -default=>700, -size=>3, -maxlength=>4);
	print "&nbsp;&nbsp;\n";
	print "Y Graph Size: ";
	print textfield(-name=>'y_graph_size', -default=>300, -size=>3, -maxlength=>4);
	print "<p>\n";
	print submit(-value=>'Submit');
	print hidden(-name=>'submit', 'default'=>['1']);
	print endform();
	print "<img src=./graphdefang.cgi?cmd=get-image;" . query_string() . ">\n" if (param('submit') && !$error);
	if ($error) {
		print "$error";
	}
	print end_html();
}